Port support for comment-to-end-of-line via '#' from heirloom-sh: while
authornealcrook <neal@pippaluk.org.uk>
Tue, 22 Nov 2016 09:15:47 +0000 (09:15 +0000)
committernealcrook <neal@pippaluk.org.uk>
Tue, 22 Nov 2016 09:15:47 +0000 (09:15 +0000)
loop added to the start of word() in word.c

Applications/V7/cmd/sh/sym.h
Applications/V7/cmd/sh/word.c

index ac0d78b..5bea387 100644 (file)
@@ -46,3 +46,4 @@
 #define DOLLAR '$'
 #define ESCAPE '\\'
 #define BRACE  '{'
+#define COMCHAR '#'
index 31b7886..5139ca0 100644 (file)
@@ -28,7 +28,21 @@ int word(void)
        wdnum = 0;
        wdset = 0;
 
-       while ((c = nextc(0), space(c)));
+       while (1)
+       {
+               while (c = nextc(0), space(c))          /* skipc() */
+                       ;
+
+               if (c == COMCHAR)
+               {
+                       while ((c = readc()) != NL && c != EOF);
+                       peekc = c;
+               }
+               else
+               {
+                       break;  /* out of comment - white space loop */
+               }
+       }
 
        if (!eofmeta(c)) {
                do {