--- /dev/null
+/* 4allterm.cmd\r
+ This is an replacement for the unix shell script that makefiles normally\r
+ use to extract and sort terminal help from .trm files\r
+ It does only use cmd.exe as external tool and is much faster than\r
+ the previous approach.\r
+*/\r
+\r
+allterm = "..\docs\allterm.h"\r
+term_prefix = "..\term\"\r
+\r
+parse arg args\r
+sort_list = 1\r
+if args = "nosort" then do\r
+ sort_list = 0\r
+end\r
+else if args \= "sort" then do\r
+ say "4allterm creates ..\term\allterm.h"\r
+ say "Please specify `sort` or `nosort` options!"\r
+ return 0\r
+end\r
+\r
+\r
+/* extract all terminal files from makefile.all,\r
+ extract terminal names from terminal files, store result in terminal.\r
+ extract \r
+*/\r
+m = "makefile.all"\r
+i = 0\r
+lf = "0A"x\r
+start_help = lf || "START_HELP("\r
+end_help = lf || "END_HELP("\r
+call stream m, "c", "open read"\r
+do while lines(m) > 0\r
+ l = linein(m)\r
+ do while l \= '' \r
+ parse var l "$(T)" term l\r
+ if term \= '' then do\r
+\r
+ /* read complete .trm file */\r
+ term = term_prefix || term\r
+ size = stream(term, "c", "query size")\r
+ call stream term, "c", "open read"\r
+ data = charin(term, 1, size)\r
+ call stream term, "c", "close"\r
+\r
+ /* find help section */\r
+ p = pos( start_help, data )\r
+ do while p > 0\r
+ /* get terminal name, store it in terminal.i */\r
+ s = p + length(start_help)\r
+ q = pos(")", data, s)\r
+ i = i + 1\r
+ term_name = substr(data, s, q-p)\r
+ terminal.i = term_name\r
+\r
+ /* find end of help text */\r
+ q = pos(end_help, data, q+1)\r
+ q = pos(")", data, q)\r
+\r
+ /* save help text in help., use stem help. as hash table */\r
+ help.term_name = substr(data, p+1, q-p)\r
+\r
+ /* find next help section */\r
+ p = pos(start_help, data, q)\r
+ end\r
+ end\r
+ end\r
+end\r
+call stream m, "c", "close"\r
+terminal.0 = i\r
+drop q s p m l term_name term lf start_help end_help size data\r
+\r
+\r
+/* sort list of terminals \r
+*/\r
+/* simple bubble sort copied from \r
+ Bernd Schemmer's "Rexx Tips'N Tricks" v3.5 */\r
+if sort_list then do\r
+ do i = terminal.0 to 1 by -1 until flip_flop = 1\r
+ flip_flop = 1\r
+ do j = 2 to i\r
+ m = j - 1\r
+ if translate(terminal.m) >> translate(terminal.j) then\r
+ do\r
+ xchg = terminal.m\r
+ terminal.m = terminal.j\r
+ terminal.j = xchg\r
+ flip_flop = 0\r
+ end\r
+ end\r
+ end\r
+end\r
+\r
+\r
+/* create allterm.h \r
+*/\r
+address "cmd" "@del" allterm "2>out" /* remove old file */\r
+do i = 1 to terminal.0\r
+ term = terminal.i\r
+ call lineout allterm, help.term\r
+end\r
+\r
+return 0\r
+\r