]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - misc/chkdef.cmd
ncurses 5.0
[ncurses.git] / misc / chkdef.cmd
diff --git a/misc/chkdef.cmd b/misc/chkdef.cmd
new file mode 100644 (file)
index 0000000..c8d7433
--- /dev/null
@@ -0,0 +1,86 @@
+/*\r
+ * $Id: chkdef.cmd,v 1.2 1998/08/29 21:45:58 tom Exp $\r
+ *\r
+ * Author:  Juan Jose Garcia Ripoll <worm@arrakis.es>.\r
+ * Webpage: http://www.arrakis.es/~worm/\r
+ *\r
+ * chkdef.cmd - checks that a .def file has no conflicts and is properly\r
+ *             formatted.\r
+ *\r
+ * returns nonzero if two symbols have the same code or a line has a wrong\r
+ * format.\r
+ *\r
+ * returns 0 otherwise\r
+ *\r
+ * the standard output shows conflicts.\r
+ */\r
+parse arg def_file\r
+\r
+def_file = translate(def_file,'\','/')\r
+\r
+call CleanQueue\r
+\r
+/*\r
+ * `cmp' is zero when the file is valid\r
+ * `codes' associates a name to a code\r
+ * `names' associates a code to a name\r
+ */\r
+cmp    = 0\r
+codes. = 0\r
+names. = ''\r
+\r
+/*\r
+ * This sed expression cleans empty lines, comments and special .DEF\r
+ * commands, such as LIBRARY..., EXPORTS..., etc\r
+ */\r
+tidy_up  = '"s/[       ][      ]*/ /g;s/;.*//g;/^[ ]*$/d;/^[a-zA-Z]/d;"'\r
+\r
+/*\r
+ * First we find all public symbols from the original DLL. All this\r
+ * information is pushed into a REXX private list with the RXQUEUE\r
+ * utility program.\r
+ */\r
+'@echo off'\r
+'type' def_file '| sed' tidy_up '| sort | rxqueue'\r
+\r
+do while queued() > 0\r
+   /*\r
+    * We retrieve the symbol name (NEW_NAME) and its code (NEW_CODE)\r
+    */\r
+   parse pull '"' new_name '"' '@'new_code rest\r
+   select\r
+      when (new_code = '') | (new_name = '') then\r
+         /* The input was not properly formatted */\r
+         do\r
+         say 'Error: symbol "'new_name'" has no export code or is empty'\r
+         cmp = 1\r
+         end\r
+      when codes.new_name \= 0 then\r
+         /* This symbol was already defined */\r
+         if codes.new_name \= new_code then\r
+            do\r
+           cmp = 2\r
+           say 'Symbol "'new_name'" multiply defined'\r
+           end\r
+      when names.new_code \= '' then\r
+         /* This code was already assigned to a symbol */\r
+         if names.new_code \= new_name then\r
+            do\r
+            cmp = 3\r
+           say 'Conflict with "'names.new_code'" & "'new_name'" being @'new_code\r
+            end\r
+      otherwise\r
+         do\r
+         codes.new_name = new_code\r
+         names.new_code = new_name\r
+         end\r
+   end  /* select */\r
+end\r
+\r
+exit cmp\r
+\r
+CleanQueue: procedure\r
+       do while queued() > 0\r
+          parse pull foo\r
+       end\r
+return\r