Fix a system performance issue created by ata_sort_queue(). This function
[dragonfly.git] / contrib / ncurses-5.4 / misc / cmpdef.cmd
blob7cc9c95cc47596f25df4eee823e02cdca5d9260e
1 /*
2 * $Id: cmpdef.cmd,v 1.2 1998/08/29 21:44:47 tom Exp $
4 * Author: Juan Jose Garcia Ripoll <worm@arrakis.es>.
5 * Webpage: http://www.arrakis.es/~worm/
7 * cmpdef.cmd - compares two .def files, checking whether they have
8 * the same entries with the same export codes.
10 * returns 0 if there are no conflicts between the files -- that is,
11 * the newer one can replace the older one.
13 * returns 1 when either of the files is not properly formatted and
14 * when there are conflicts: two symbols having the same export code.
16 * the standard output shows a list with newly added symbols, plus
17 * replaced symbols and conflicts.
19 parse arg def_file1 def_file2
21 def_file1 = translate(def_file1,'\','/')
22 def_file2 = translate(def_file2,'\','/')
24 call CleanQueue
27 * `cmp' is zero when the last file is valid and upward compatible
28 * `numbers' is the stem where symbols are stored
30 cmp = 0
31 names. = ''
32 numbers. = 0
35 * This sed expression cleans empty lines, comments and special .DEF
36 * commands, such as LIBRARY..., EXPORTS..., etc
38 tidy_up = '"s/[ ][ ]*/ /g;s/;.*//g;/^[ ]*$/d;/^[a-zA-Z]/d;"'
41 * First we find all public symbols from the original DLL. All this
42 * information is pushed into a REXX private list with the RXQUEUE
43 * utility program.
45 '@echo off'
46 'type' def_file1 '| sed' tidy_up '| sort | rxqueue'
48 do while queued() > 0
50 * We retrieve the symbol name (NAME) and its number (NUMBER)
52 parse pull '"' name '"' '@'number rest
53 if number = '' || name = '' then
55 say 'Corrupted file' def_file1
56 say 'Symbol' name 'has no number'
57 exit 1
58 end
59 else
61 numbers.name = number
62 names.number = name
63 end
64 end
67 * Now we find all public symbols from the new DLL, and compare.
69 'type' def_file2 '| sed' tidy_up '| sort | rxqueue'
71 do while queued() > 0
72 parse pull '"' name '"' '@'number rest
73 if name = '' | number = '' then
75 say 'Corrupted file' def_file2
76 say 'Symbol' name 'has no number'
77 exit 1
78 end
79 if numbers.name = 0 then
81 cmp = 1
82 if names.number = '' then
83 say 'New symbol' name 'with code @'number
84 else
85 say 'Conflict old =' names.number ', new =' name 'at @'number
86 end
87 else if numbers.name \= number then
89 cmp = 1
90 say name 'Symbol' name 'changed from @'numbers.name 'to @'number
91 end
92 end /* do */
94 exit cmp
97 * Cleans the REXX queue by pulling and forgetting every line.
98 * This is needed, at least, when `cmpdef.cmd' starts, because an aborted
99 * REXX program might have left some rubbish in.
101 CleanQueue: procedure
102 do while queued() > 0
103 parse pull foo
105 return