FIXUP: HAVE_VSNPRINTF
[mirror-ossqm-ncurses.git] / misc / chkdef.cmd
blobfa91dce54c229728505b9a44714b734afa856683
1 /****************************************************************************
2 * Copyright (c) 1998,2006 Free Software Foundation, Inc. *
3 * *
4 * Permission is hereby granted, free of charge, to any person obtaining a *
5 * copy of this software and associated documentation files (the *
6 * "Software"), to deal in the Software without restriction, including *
7 * without limitation the rights to use, copy, modify, merge, publish, *
8 * distribute, distribute with modifications, sublicense, and/or sell *
9 * copies of the Software, and to permit persons to whom the Software is *
10 * furnished to do so, subject to the following conditions: *
11 * *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
14 * *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
22 * *
23 * Except as contained in this notice, the name(s) of the above copyright *
24 * holders shall not be used in advertising or otherwise to promote the *
25 * sale, use or other dealings in this Software without prior written *
26 * authorization. *
27 ****************************************************************************/
30 * $Id: chkdef.cmd,v 1.3 2006/04/22 23:14:50 tom Exp $
32 * Author: Juan Jose Garcia Ripoll <worm@arrakis.es>.
33 * Webpage: http://www.arrakis.es/~worm/
35 * chkdef.cmd - checks that a .def file has no conflicts and is properly
36 * formatted.
38 * returns nonzero if two symbols have the same code or a line has a wrong
39 * format.
41 * returns 0 otherwise
43 * the standard output shows conflicts.
45 parse arg def_file
47 def_file = translate(def_file,'\','/')
49 call CleanQueue
52 * `cmp' is zero when the file is valid
53 * `codes' associates a name to a code
54 * `names' associates a code to a name
56 cmp = 0
57 codes. = 0
58 names. = ''
61 * This sed expression cleans empty lines, comments and special .DEF
62 * commands, such as LIBRARY..., EXPORTS..., etc
64 tidy_up = '"s/[ ][ ]*/ /g;s/;.*//g;/^[ ]*$/d;/^[a-zA-Z]/d;"'
67 * First we find all public symbols from the original DLL. All this
68 * information is pushed into a REXX private list with the RXQUEUE
69 * utility program.
71 '@echo off'
72 'type' def_file '| sed' tidy_up '| sort | rxqueue'
74 do while queued() > 0
76 * We retrieve the symbol name (NEW_NAME) and its code (NEW_CODE)
78 parse pull '"' new_name '"' '@'new_code rest
79 select
80 when (new_code = '') | (new_name = '') then
81 /* The input was not properly formatted */
83 say 'Error: symbol "'new_name'" has no export code or is empty'
84 cmp = 1
85 end
86 when codes.new_name \= 0 then
87 /* This symbol was already defined */
88 if codes.new_name \= new_code then
90 cmp = 2
91 say 'Symbol "'new_name'" multiply defined'
92 end
93 when names.new_code \= '' then
94 /* This code was already assigned to a symbol */
95 if names.new_code \= new_name then
97 cmp = 3
98 say 'Conflict with "'names.new_code'" & "'new_name'" being @'new_code
99 end
100 otherwise
102 codes.new_name = new_code
103 names.new_code = new_name
105 end /* select */
108 exit cmp
110 CleanQueue: procedure
111 do while queued() > 0
112 parse pull foo
114 return