diff options
| author | Russ Cox <rsc@swtch.com> | 2020-05-04 22:52:27 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@swtch.com> | 2020-05-04 23:41:15 -0400 |
| commit | 3caf5c238a886d06b438ec6d42f2609b8625463f (patch) | |
| tree | b72b8b652b2a465eaf8aa1b5940e5192d669a337 /src/cmd/rc/lex.c | |
| parent | 47d4646eebac34c0b94951cfcf1b81ed2ca513e1 (diff) | |
| download | plan9port-3caf5c238a886d06b438ec6d42f2609b8625463f.tar.gz plan9port-3caf5c238a886d06b438ec6d42f2609b8625463f.zip | |
rc: move newline handling into parser
Diffstat (limited to 'src/cmd/rc/lex.c')
| -rw-r--r-- | src/cmd/rc/lex.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/cmd/rc/lex.c b/src/cmd/rc/lex.c index 0bdbbb4b..58338479 100644 --- a/src/cmd/rc/lex.c +++ b/src/cmd/rc/lex.c @@ -102,15 +102,17 @@ pprompt(void) doprompt = 0; } -void +int skipwhite(void) { - int c; + int c, skipped; + skipped = 0; for(;;){ c = nextc(); /* Why did this used to be if(!inquote && c=='#') ?? */ if(c=='#'){ incomm = 1; + skipped = 1; for(;;){ c = nextc(); if(c=='\n' || c==EOF) { @@ -120,9 +122,12 @@ skipwhite(void) advance(); } } - if(c==' ' || c=='\t') + if(c==' ' || c=='\t') { + skipped = 1; advance(); - else return; + } + else + return skipped; } } @@ -210,7 +215,8 @@ yylex(void) } } inquote = 0; - skipwhite(); + if(skipwhite() && flag['Z']) + return SP; switch(c = advance()){ case EOF: lastdol = 0; @@ -231,7 +237,8 @@ yylex(void) case '&': lastdol = 0; if(nextis('&')){ - skipnl(); + if(flag['Y']) + skipnl(); strcpy(tok, "&&"); return ANDAND; } @@ -240,7 +247,8 @@ yylex(void) case '|': lastdol = 0; if(nextis(c)){ - skipnl(); + if(flag['Y']) + skipnl(); strcpy(tok, "||"); return OROR; } @@ -329,7 +337,7 @@ yylex(void) } *w='\0'; yylval.tree = t; - if(t->type==PIPE) + if(t->type==PIPE && flag['Y']) skipnl(); if(t->type==REDIR) { skipwhite(); |
