some shellology; also, make ctlwords.c into a srcfile of its own
authormirabilos <t.glaser@tarent.de>
Thu, 25 Jul 2019 17:10:29 +0000 (19:10 +0200)
committermirabilos <mirabilos@evolvis.org>
Thu, 25 Jul 2019 17:10:29 +0000 (19:10 +0200)
TODO
ctlwords.sh
globals.c

diff --git a/TODO b/TODO
index 7678f4a..14c00bb 100644 (file)
--- a/TODO
+++ b/TODO
@@ -99,6 +99,7 @@ xwintoppm: -I$S/contrib/xwintoppm -lXmu -lXt -lX11
        $(pkg-config --libs imlib2) $(pkg-config --libs xft) -lm \
        ?:iconv_open:-liconv
 libmgpcommon.a: -I$S/image #common
+ ↑ ctlwords.c
  - image/dither.c
  - image/imagetypes.c
  - image/imlib_loader.c
index a0a76c0..fac4729 100644 (file)
@@ -40,7 +40,18 @@ upper() {
        echo :"$@" | sed 's/^://' | tr $alll $allu
 }
 
-rm -f ctlwords.pl
+rm -f ctlwords.c ctlwords.h ctlwords.pl
+
+cat >ctlwords.c~ <<\EOF
+/* this was generated by ctlwords.sh, do not edit */
+#include "mgp.h"
+const struct ctl_words ctl_words[] = {
+EOF
+
+cat >ctlwords.h~ <<\EOF
+/* this was generated by ctlwords.sh, do not edit */
+EOF
+
 cat >ctlwords.pl~ <<\EOF
 
 # this keyword list was generated by ctlwords.sh, do not edit
@@ -55,8 +66,11 @@ while read control ctype clabel; do
                clabel=$control
        elif test x"$clabel" = x"*"; then
                clabel='*'$control'*'
+       else
+               :
        fi
-       clbsz=${#clabel}
+       clbsz=`expr "X$clabel" : '.*'`
+       clbsz=`expr $clbsz - 1` # the X
        cat >&4 <<EOF
        { "$clabel", $clbsz, $ctlup, $ctyup },
 EOF
@@ -67,7 +81,7 @@ EOF
 "$control",
 EOF
        lfd=`expr $lfd + 1`
-done 4>ctlwords.c 5>ctlwords.h 6>>ctlwords.pl~ <<\EOF
+done 4>>ctlwords.c~ 5>>ctlwords.h~ 6>>ctlwords.pl~ <<\EOF
 noop           void
 default                int
 tab            sp
@@ -127,10 +141,22 @@ setsup            int
 title          str
 EOF
 
-cat >ctlwords.pl~ <<\EOF
+cat >>ctlwords.c~ <<\EOF
+       { NULL, 0, 0, 0 }
+};
+/* end of generated list */
+EOF
+
+cat >>ctlwords.h~ <<\EOF
+/* end of generated file */
+EOF
+
+cat >>ctlwords.pl~ <<\EOF
 );
 # end of generated keyword list
 
 EOF
 
 mv ctlwords.pl~ ctlwords.pl
+mv ctlwords.h~ ctlwords.h
+mv ctlwords.c~ ctlwords.c
index e951dc6..d4abf30 100644 (file)
--- a/globals.c
+++ b/globals.c
@@ -91,11 +91,6 @@ struct alloc_color image_clr = { NULL, 0 };
 struct alloc_color back_clr = { NULL, 0 };
 struct alloc_color font_clr = { NULL, 0 };
 
-const struct ctl_words ctl_words[] = {
-#include "ctlwords.c"
-       { NULL, 0, 0, 0 }
-};
-
 const struct ctl_words icon_words[] = {
        { "box",    3, 1, T_SP },
        { "arc",    3, 2, T_SP },