vendor/NCURSES: Remove version tag.
[dragonfly.git] / contrib / ncurses / misc / cmpdef.cmd
1 /*\r
2  * $Id: cmpdef.cmd,v 1.2 1998/08/29 21:44:47 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  * cmpdef.cmd - compares two .def files, checking whether they have\r
8  *              the same entries with the same export codes.\r
9  *\r
10  * returns 0 if there are no conflicts between the files -- that is,\r
11  * the newer one can replace the older one.\r
12  *\r
13  * returns 1 when either of the files is not properly formatted and\r
14  * when there are conflicts: two symbols having the same export code.\r
15  *\r
16  * the standard output shows a list with newly added symbols, plus\r
17  * replaced symbols and conflicts.\r
18  */\r
19 parse arg def_file1 def_file2\r
20 \r
21 def_file1 = translate(def_file1,'\','/')\r
22 def_file2 = translate(def_file2,'\','/')\r
23 \r
24 call CleanQueue\r
25 \r
26 /*\r
27  * `cmp' is zero when the last file is valid and upward compatible\r
28  * `numbers' is the stem where symbols are stored\r
29  */\r
30 cmp      = 0\r
31 names.   = ''\r
32 numbers. = 0\r
33 \r
34 /*\r
35  * This sed expression cleans empty lines, comments and special .DEF\r
36  * commands, such as LIBRARY..., EXPORTS..., etc\r
37  */\r
38 tidy_up  = '"s/[        ][      ]*/ /g;s/;.*//g;/^[ ]*$/d;/^[a-zA-Z]/d;"'\r
39 \r
40 /*\r
41  * First we find all public symbols from the original DLL. All this\r
42  * information is pushed into a REXX private list with the RXQUEUE\r
43  * utility program.\r
44  */\r
45 '@echo off'\r
46 'type' def_file1 '| sed' tidy_up '| sort | rxqueue'\r
47 \r
48 do while queued() > 0\r
49    /*\r
50     * We retrieve the symbol name (NAME) and its number (NUMBER)\r
51     */\r
52    parse pull '"' name '"' '@'number rest\r
53    if number = '' || name = '' then\r
54       do\r
55       say 'Corrupted file' def_file1\r
56       say 'Symbol' name 'has no number'\r
57       exit 1\r
58       end\r
59    else\r
60       do\r
61       numbers.name = number\r
62       names.number = name\r
63       end\r
64 end\r
65 \r
66 /*\r
67  * Now we find all public symbols from the new DLL, and compare.\r
68  */\r
69 'type' def_file2 '| sed' tidy_up '| sort | rxqueue'\r
70 \r
71 do while queued() > 0\r
72    parse pull '"' name '"' '@'number rest\r
73    if name = '' | number = '' then\r
74       do\r
75       say 'Corrupted file' def_file2\r
76       say 'Symbol' name 'has no number'\r
77       exit 1\r
78       end\r
79    if numbers.name = 0 then\r
80       do\r
81       cmp = 1\r
82       if names.number = '' then\r
83          say 'New symbol' name 'with code @'number\r
84       else\r
85          say 'Conflict old =' names.number ', new =' name 'at @'number\r
86       end\r
87    else if numbers.name \= number then\r
88       do\r
89       cmp = 1\r
90       say name 'Symbol' name 'changed from @'numbers.name 'to @'number\r
91       end\r
92 end /* do */\r
93 \r
94 exit cmp\r
95 \r
96 /*\r
97  * Cleans the REXX queue by pulling and forgetting every line.\r
98  * This is needed, at least, when `cmpdef.cmd' starts, because an aborted\r
99  * REXX program might have left some rubbish in.\r
100  */\r
101 CleanQueue: procedure\r
102    do while queued() > 0\r
103       parse pull foo\r
104    end\r
105 return\r
106 \r