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