From 794dab68a4247d9978f7301f962781321bd940c4 Mon Sep 17 00:00:00 2001 From: nealcrook Date: Tue, 22 Nov 2016 09:15:47 +0000 Subject: [PATCH] Port support for comment-to-end-of-line via '#' from heirloom-sh: while loop added to the start of word() in word.c --- Applications/V7/cmd/sh/sym.h | 1 + Applications/V7/cmd/sh/word.c | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Applications/V7/cmd/sh/sym.h b/Applications/V7/cmd/sh/sym.h index ac0d78b8..5bea3872 100644 --- a/Applications/V7/cmd/sh/sym.h +++ b/Applications/V7/cmd/sh/sym.h @@ -46,3 +46,4 @@ #define DOLLAR '$' #define ESCAPE '\\' #define BRACE '{' +#define COMCHAR '#' diff --git a/Applications/V7/cmd/sh/word.c b/Applications/V7/cmd/sh/word.c index 31b78861..5139ca08 100644 --- a/Applications/V7/cmd/sh/word.c +++ b/Applications/V7/cmd/sh/word.c @@ -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 { -- 2.34.1