From 4f30f2993f73eb3ec18ed10985aec984d9e7cdc5 Mon Sep 17 00:00:00 2001 From: Stefan Farfeleder Date: Wed, 28 May 2008 21:44:32 +0000 Subject: [PATCH] Fix checking if a variable name is LINENO. As STPUTC changes the pointer if it needs to enlarge the buffer, we must not keep a pointer to the beginning. PR: ports/123879 --- bin/sh/parser.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/sh/parser.c b/bin/sh/parser.c index 75b4cac74ba..86f50fc7b84 100644 --- a/bin/sh/parser.c +++ b/bin/sh/parser.c @@ -1188,6 +1188,7 @@ parsesub: { int bracketed_name = 0; /* used to handle ${[0-9]*} variables */ int i; int linno; + int length; c = pgetc(); if (c != '(' && c != '{' && (is_eof(c) || !is_name(c)) && @@ -1220,12 +1221,14 @@ parsesub: { subtype = 0; } if (!is_eof(c) && is_name(c)) { - p = out; + length = 0; do { STPUTC(c, out); c = pgetc(); + length++; } while (!is_eof(c) && is_in_name(c)); - if (out - p == 6 && strncmp(p, "LINENO", 6) == 0) { + if (length == 6 && + strncmp(out - length, "LINENO", length) == 0) { /* Replace the variable name with the * current line number. */ linno = plinno;