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: chkdef.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 * chkdef.cmd - checks that a .def file has no conflicts and is properly
\r
38 * returns nonzero if two symbols have the same code or a line has a wrong
\r
41 * returns 0 otherwise
\r
43 * the standard output shows conflicts.
\r
47 def_file = translate(def_file,'\','/')
\r
52 * `cmp' is zero when the file is valid
\r
53 * `codes' associates a name to a code
\r
54 * `names' associates a code to a name
\r
61 * This sed expression cleans empty lines, comments and special .DEF
\r
62 * commands, such as LIBRARY..., EXPORTS..., etc
\r
64 tidy_up = '"s/[ ][ ]*/ /g;s/;.*//g;/^[ ]*$/d;/^[a-zA-Z]/d;"'
\r
67 * First we find all public symbols from the original DLL. All this
\r
68 * information is pushed into a REXX private list with the RXQUEUE
\r
72 'type' def_file '| sed' tidy_up '| sort | rxqueue'
\r
74 do while queued() > 0
\r
76 * We retrieve the symbol name (NEW_NAME) and its code (NEW_CODE)
\r
78 parse pull '"' new_name '"' '@'new_code rest
\r
80 when (new_code = '') | (new_name = '') then
\r
81 /* The input was not properly formatted */
\r
83 say 'Error: symbol "'new_name'" has no export code or is empty'
\r
86 when codes.new_name \= 0 then
\r
87 /* This symbol was already defined */
\r
88 if codes.new_name \= new_code then
\r
91 say 'Symbol "'new_name'" multiply defined'
\r
93 when names.new_code \= '' then
\r
94 /* This code was already assigned to a symbol */
\r
95 if names.new_code \= new_name then
\r
98 say 'Conflict with "'names.new_code'" & "'new_name'" being @'new_code
\r
102 codes.new_name = new_code
\r
103 names.new_code = new_name
\r
110 CleanQueue: procedure
\r
111 do while queued() > 0
\r