summary refs log tree commit diff
path: root/src/parser.c
diff options
context:
space:
mode:
authorRocky Bernstein <rocky.bernstein@gmail.com>2009-08-11 15:59:33 +1000
committerHerbert Xu <herbert@gondor.apana.org.au>2009-08-11 15:59:33 +1000
commit0df96793ef6aa103df228d7dfe56099b7d721a15 (patch)
treef45936f681b1a54cef2c12958597c427fcec5aa8 /src/parser.c
parent[BUILTIN] Honor tab as IFS whitespace when splitting fields in readcmd (diff)
downloaddash-0df96793ef6aa103df228d7dfe56099b7d721a15.tar.gz
dash-0df96793ef6aa103df228d7dfe56099b7d721a15.zip
[SHELL] Add preliminary LINENO support
Looks like in contrast to what the dash.1 manual page says, expansion
of PS{1,2,4} does work.

Here is a little patch to set LINENO. The ways in that it is less than
ideal mirror the ways that the line number error reporting is also
less than ideal.

For example if you run this:

(
    x=$((1/0))
    # Just to add another line
    # And another
) # error reports this line

The error reported will be  the closing parenthesis even though I
think most people would prefer the error to be the one where x was
set.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to '')
-rw-r--r--src/parser.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/parser.c b/src/parser.c
index 28a46c0..be20ff7 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -776,7 +776,7 @@ xxreadtoken(void)
 			continue;
 		case '\\':
 			if (pgetc() == '\n') {
-				startlinno = ++plinno;
+				startlinno = lineno_inc();
 				if (doprompt)
 					setprompt(2);
 				continue;
@@ -784,7 +784,7 @@ xxreadtoken(void)
 			pungetc();
 			goto breakloop;
 		case '\n':
-			plinno++;
+			lineno_inc();
 			needprompt = doprompt;
 			RETURN(TNL);
 		case PEOF:
@@ -886,7 +886,7 @@ readtoken1(int firstc, char const *syntax, char *eofmark, int striptabs)
 				if (syntax == BASESYNTAX)
 					goto endword;	/* exit outer loop */
 				USTPUTC(c, out);
-				plinno++;
+				lineno_inc();
 				if (doprompt)
 					setprompt(2);
 				c = pgetc();
@@ -1065,7 +1065,7 @@ checkend: {
 
 		if (c == '\n' || c == PEOF) {
 			c = PEOF;
-			plinno++;
+			lineno_inc();
 			needprompt = doprompt;
 		} else {
 			int len;
@@ -1315,7 +1315,7 @@ parsebackq: {
 
 			case '\\':
                                 if ((pc = pgetc()) == '\n') {
-					plinno++;
+					lineno_inc();
 					if (doprompt)
 						setprompt(2);
 					/*
@@ -1340,7 +1340,7 @@ parsebackq: {
 				synerror("EOF in backquote substitution");
 
 			case '\n':
-				plinno++;
+				lineno_inc();
 				needprompt = doprompt;
 				break;
 
Lighten dark whiteJune McEnroe 2019-07-25Add png.3 man pageJune McEnroe 2019-07-25Use scheme to style HTMLsJune McEnroe 2019-07-25Don't match comments in strings in makeJune McEnroe 2019-07-25Generate index.html with links from bin.7June McEnroe 2019-07-24Warn when date has changedJune McEnroe 2019-07-24Add whenJune McEnroe When? Now. 2019-07-24Remove histedit from bitJune McEnroe