]> ncurses.scripts.mit.edu Git - ncurses.git/blob - misc/chkdef.cmd
ncurses 5.1
[ncurses.git] / misc / chkdef.cmd
1 /*\r
2  * $Id: chkdef.cmd,v 1.2 1998/08/29 21:45:58 tom Exp $\r
3  *\r
4  * Author:  Juan Jose Garcia Ripoll <worm@arrakis.es>.\r
5  * Webpage: http://www.arrakis.es/~worm/\r
6  *\r
7  * chkdef.cmd - checks that a .def file has no conflicts and is properly\r
8  *              formatted.\r
9  *\r
10  * returns nonzero if two symbols have the same code or a line has a wrong\r
11  * format.\r
12  *\r
13  * returns 0 otherwise\r
14  *\r
15  * the standard output shows conflicts.\r
16  */\r
17 parse arg def_file\r
18 \r
19 def_file = translate(def_file,'\','/')\r
20 \r
21 call CleanQueue\r
22 \r
23 /*\r
24  * `cmp' is zero when the file is valid\r
25  * `codes' associates a name to a code\r
26  * `names' associates a code to a name\r
27  */\r
28 cmp    = 0\r
29 codes. = 0\r
30 names. = ''\r
31 \r
32 /*\r
33  * This sed expression cleans empty lines, comments and special .DEF\r
34  * commands, such as LIBRARY..., EXPORTS..., etc\r
35  */\r
36 tidy_up  = '"s/[        ][      ]*/ /g;s/;.*//g;/^[ ]*$/d;/^[a-zA-Z]/d;"'\r
37 \r
38 /*\r
39  * First we find all public symbols from the original DLL. All this\r
40  * information is pushed into a REXX private list with the RXQUEUE\r
41  * utility program.\r
42  */\r
43 '@echo off'\r
44 'type' def_file '| sed' tidy_up '| sort | rxqueue'\r
45 \r
46 do while queued() > 0\r
47    /*\r
48     * We retrieve the symbol name (NEW_NAME) and its code (NEW_CODE)\r
49     */\r
50    parse pull '"' new_name '"' '@'new_code rest\r
51    select\r
52       when (new_code = '') | (new_name = '') then\r
53          /* The input was not properly formatted */\r
54          do\r
55          say 'Error: symbol "'new_name'" has no export code or is empty'\r
56          cmp = 1\r
57          end\r
58       when codes.new_name \= 0 then\r
59          /* This symbol was already defined */\r
60          if codes.new_name \= new_code then\r
61             do\r
62             cmp = 2\r
63             say 'Symbol "'new_name'" multiply defined'\r
64             end\r
65       when names.new_code \= '' then\r
66          /* This code was already assigned to a symbol */\r
67          if names.new_code \= new_name then\r
68             do\r
69             cmp = 3\r
70             say 'Conflict with "'names.new_code'" & "'new_name'" being @'new_code\r
71             end\r
72       otherwise\r
73          do\r
74          codes.new_name = new_code\r
75          names.new_code = new_name\r
76          end\r
77    end  /* select */\r
78 end\r
79 \r
80 exit cmp\r
81 \r
82 CleanQueue: procedure\r
83         do while queued() > 0\r
84            parse pull foo\r
85         end\r
86 return\r