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: chkdef.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 * chkdef.cmd - checks that a .def file has no conflicts and is properly
\r
39 * returns nonzero if two symbols have the same code or a line has a wrong
\r
42 * returns 0 otherwise
\r
44 * the standard output shows conflicts.
\r
48 def_file = translate(def_file,'\','/')
\r
53 * `cmp' is zero when the file is valid
\r
54 * `codes' associates a name to a code
\r
55 * `names' associates a code to a name
\r
62 * This sed expression cleans empty lines, comments and special .DEF
\r
63 * commands, such as LIBRARY..., EXPORTS..., etc
\r
65 tidy_up = '"s/[ ][ ]*/ /g;s/;.*//g;/^[ ]*$/d;/^[a-zA-Z]/d;"'
\r
68 * First we find all public symbols from the original DLL. All this
\r
69 * information is pushed into a REXX private list with the RXQUEUE
\r
73 'type' def_file '| sed' tidy_up '| sort | rxqueue'
\r
75 do while queued() > 0
\r
77 * We retrieve the symbol name (NEW_NAME) and its code (NEW_CODE)
\r
79 parse pull '"' new_name '"' '@'new_code rest
\r
81 when (new_code = '') | (new_name = '') then
\r
82 /* The input was not properly formatted */
\r
84 say 'Error: symbol "'new_name'" has no export code or is empty'
\r
87 when codes.new_name \= 0 then
\r
88 /* This symbol was already defined */
\r
89 if codes.new_name \= new_code then
\r
92 say 'Symbol "'new_name'" multiply defined'
\r
94 when names.new_code \= '' then
\r
95 /* This code was already assigned to a symbol */
\r
96 if names.new_code \= new_name then
\r
99 say 'Conflict with "'names.new_code'" & "'new_name'" being @'new_code
\r
103 codes.new_name = new_code
\r
104 names.new_code = new_name
\r
111 CleanQueue: procedure
\r
112 do while queued() > 0
\r