summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2007-10-20 18:49:31 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2007-10-20 18:49:31 +0800
commitd39c8628b8594c29d234427ba07a12538ab36f41 (patch)
tree6438d14d319a352929319f0b59ee587fc9ac3605 /src
parent[EXPAND] Added configure --enable-glob and --enable-fnmatch options (diff)
downloaddash-d39c8628b8594c29d234427ba07a12538ab36f41.tar.gz
dash-d39c8628b8594c29d234427ba07a12538ab36f41.zip
[PARSER] Fix here-doc corruption
The change

	[PARSER] Recognise here-doc delimiters terminated by EOF

introduced a regerssion whereby lines starting with eofmark but are not equal
to eofmark would be corrupted.  This patch fixes it.

Test case:

	cat << _ACEOF
	_ASBOX
	_ACEOF

Old result:

	SASBOX

New result:

	_ASBOX
Diffstat (limited to '')
-rw-r--r--src/parser.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/parser.c b/src/parser.c
index 4b8a5fe..3832f0b 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -1047,16 +1047,17 @@ checkend: {
 		if (c == *eofmark) {
 			if (pfgets(line, sizeof line) != NULL) {
 				char *p, *q;
+				int cc;
 
 				p = line;
 				for (q = eofmark + 1;; p++, q++) {
-					c = *p;
-					if (c == '\n')
-						c = 0;
-					if (!*q || c != *q)
+					cc = *p;
+					if (cc == '\n')
+						cc = 0;
+					if (!*q || cc != *q)
 						break;
 				}
-				if (c == *q) {
+				if (cc == *q) {
 					c = PEOF;
 					plinno++;
 					needprompt = doprompt;