1 /****************************************************************************
\r
2 * Copyright 2020 Thomas E. Dickey *
\r
3 * Copyright 1998,2006 Free Software Foundation, Inc. *
\r
5 * Permission is hereby granted, free of charge, to any person obtaining a *
\r
6 * copy of this software and associated documentation files (the *
\r
7 * "Software"), to deal in the Software without restriction, including *
\r
8 * without limitation the rights to use, copy, modify, merge, publish, *
\r
9 * distribute, distribute with modifications, sublicense, and/or sell *
\r
10 * copies of the Software, and to permit persons to whom the Software is *
\r
11 * furnished to do so, subject to the following conditions: *
\r
13 * The above copyright notice and this permission notice shall be included *
\r
14 * in all copies or substantial portions of the Software. *
\r
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
\r
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
\r
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
\r
19 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
\r
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
\r
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
\r
22 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
\r
24 * Except as contained in this notice, the name(s) of the above copyright *
\r
25 * holders shall not be used in advertising or otherwise to promote the *
\r
26 * sale, use or other dealings in this Software without prior written *
\r
28 ****************************************************************************/
\r
31 * $Id: cmpdef.cmd,v 1.4 2020/02/02 23:34:34 tom Exp $
\r
33 * Author: Juan Jose Garcia Ripoll <worm@arrakis.es>.
\r
34 * Webpage: http://www.arrakis.es/~worm/
\r
36 * cmpdef.cmd - compares two .def files, checking whether they have
\r
37 * the same entries with the same export codes.
\r
39 * returns 0 if there are no conflicts between the files -- that is,
\r
40 * the newer one can replace the older one.
\r
42 * returns 1 when either of the files is not properly formatted and
\r
43 * when there are conflicts: two symbols having the same export code.
\r
45 * the standard output shows a list with newly added symbols, plus
\r
46 * replaced symbols and conflicts.
\r
48 parse arg def_file1 def_file2
\r
50 def_file1 = translate(def_file1,'\','/')
\r
51 def_file2 = translate(def_file2,'\','/')
\r
56 * `cmp' is zero when the last file is valid and upward compatible
\r
57 * `numbers' is the stem where symbols are stored
\r
64 * This sed expression cleans empty lines, comments and special .DEF
\r
65 * commands, such as LIBRARY..., EXPORTS..., etc
\r
67 tidy_up = '"s/[ ][ ]*/ /g;s/;.*//g;/^[ ]*$/d;/^[a-zA-Z]/d;"'
\r
70 * First we find all public symbols from the original DLL. All this
\r
71 * information is pushed into a REXX private list with the RXQUEUE
\r
75 'type' def_file1 '| sed' tidy_up '| sort | rxqueue'
\r
77 do while queued() > 0
\r
79 * We retrieve the symbol name (NAME) and its number (NUMBER)
\r
81 parse pull '"' name '"' '@'number rest
\r
82 if number = '' || name = '' then
\r
84 say 'Corrupted file' def_file1
\r
85 say 'Symbol' name 'has no number'
\r
90 numbers.name = number
\r
96 * Now we find all public symbols from the new DLL, and compare.
\r
98 'type' def_file2 '| sed' tidy_up '| sort | rxqueue'
\r
100 do while queued() > 0
\r
101 parse pull '"' name '"' '@'number rest
\r
102 if name = '' | number = '' then
\r
104 say 'Corrupted file' def_file2
\r
105 say 'Symbol' name 'has no number'
\r
108 if numbers.name = 0 then
\r
111 if names.number = '' then
\r
112 say 'New symbol' name 'with code @'number
\r
114 say 'Conflict old =' names.number ', new =' name 'at @'number
\r
116 else if numbers.name \= number then
\r
119 say name 'Symbol' name 'changed from @'numbers.name 'to @'number
\r
126 * Cleans the REXX queue by pulling and forgetting every line.
\r
127 * This is needed, at least, when `cmpdef.cmd' starts, because an aborted
\r
128 * REXX program might have left some rubbish in.
\r
130 CleanQueue: procedure
\r
131 do while queued() > 0
\r