aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2016-11-16 16:28:03 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2016-11-18 07:05:52 +0100
commitb44a4bae7d5c1098709dfaffd122263e0f4c5bc6 (patch)
tree2789f5ab99317bf1e399f82b173e7d2ba3b1ce1c /src
parentcb5e08b40d7444817c7eb6c1e4e8bf5208c2823c (diff)
downloadsciteco-b44a4bae7d5c1098709dfaffd122263e0f4c5bc6.tar.gz
standard lib: added getopt.tes for parsing command line options in scripts
* this uses an optstring compatible with getopt(3). * It does not use repeated getopt calls to iterate options, though but places the results in registers beginning with "getopt.". E.g. option "C" will result in "getopt.C" being set after the call to setopt. String arguments are supported and are placed in the string part of the getopt registers. * The grosciteco.tes and symbols-extract.tes scripts make use of getopt now, to simplify and clean up their command line handling.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am10
-rwxr-xr-xsrc/symbols-extract.tes30
2 files changed, 23 insertions, 17 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 72e9157..facf963 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -23,8 +23,10 @@ endif
BUILT_SOURCES =
-EXTRA_DIST = symbols-extract.tes \
- sciteco.html
+dist_noinst_SCRIPTS = symbols-extract.tes
+
+# Emscripten HTML page:
+EXTRA_DIST = sciteco.html
noinst_LTLIBRARIES = libsciteco-base.la
libsciteco_base_la_SOURCES = main.cpp sciteco.h \
@@ -77,12 +79,12 @@ CLEANFILES = $(BUILT_SOURCES) \
symbols-scintilla.cpp : @SCINTILLA_PATH@/include/Scintilla.h \
symbols-extract.tes
$(SCITECO_MINIMAL) -m -- @srcdir@/symbols-extract.tes \
- $< $@ "SCI_" scintilla
+ -p "SCI_" -n scintilla $@ $<
symbols-scilexer.cpp : @SCINTILLA_PATH@/include/SciLexer.h \
symbols-extract.tes
$(SCITECO_MINIMAL) -m -- @srcdir@/symbols-extract.tes \
- $< $@ "SCLEX_,SCE_" scilexer
+ -p "SCLEX_,SCE_" -n scilexer $@ $<
# This installs a wrapper script to libexecdir to be used as
# the SciTECO interpreter in Hash-Bang lines.
diff --git a/src/symbols-extract.tes b/src/symbols-extract.tes
index e81331a..a88731d 100755
--- a/src/symbols-extract.tes
+++ b/src/symbols-extract.tes
@@ -1,18 +1,24 @@
#!/usr/local/bin/sciteco -m
-! ./symbols-extract.tes <input file> <output file> <prefix pattern list> <array name> !
+!*
+ * ./symbols-extract.tes [-p <prefix pattern list>] -n <SymbolList object> [--] \
+ * <output file> <input header>
+ *!
+:EMQ[$SCITECOPATH]/getopt.tes
EMQ[$SCITECOPATH]/string.tes
-! read commandline arguments !
-LR 0X#in 2LR 0X#ou 2LR 0X#pa 2LR 0X#na HK
+!* read commandline arguments *!
+[getopt.p]
+[optstring]p:n: M[getopt]"F (0/0) '
+LR 0X#ou 2LR 0X#in HK
-! copy all defines in input file beginning with prefix !
-EBQ#in <S#defineS[Q#pa]; -SS :Xa> EF
+!* copy all defines in input file beginning with prefix *!
+EBN#in <S#defineS[Q[getopt.p]]; -SS :Xa> EF
-! sort all defines !
+!* sort all defines *!
Ga ZJB 0,.M[qsort] J
-! format as C/C++ array !
+!* format as C/C++ array *!
I/*
* AUTOGENERATED FROM Q#in
* DO NOT EDIT
@@ -29,20 +35,18 @@ I/*
namespace SciTECO {
-static const SymbolList::Entry entries[] = {
-
+static const SymbolList::Entry entries[] = {^J
<
.,W.Xa 0KK
I#ifdef Qa^J^I{"Qa", Qa},^J#endif^J
.-Z;>
I};
-SymbolList Symbols::Q#na(entries, G_N_ELEMENTS(entries));
+SymbolList Symbols::Q[getopt.n](entries, G_N_ELEMENTS(entries));
-} /* namespace SciTECO */
-
+} /* namespace SciTECO */^J
-! write output file !
+!* write output file *!
EWQ#ou
EX