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