summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2016-04-16 12:14:44 +0000
committerjilles <jilles@FreeBSD.org>2016-04-16 12:14:44 +0000
commitf576b52aa0a921be7895766367552479f621b662 (patch)
tree29cbe2bb5b808c640935834b820337cc9f7f7f49 /bin
parentaee34abee1c7761f573d75689c2526a93c7d8908 (diff)
downloadFreeBSD-src-f576b52aa0a921be7895766367552479f621b662.zip
FreeBSD-src-f576b52aa0a921be7895766367552479f621b662.tar.gz
sh: Write LINENO value to stack string directly.
Diffstat (limited to 'bin')
-rw-r--r--bin/sh/parser.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/bin/sh/parser.c b/bin/sh/parser.c
index e72a6f1..26c1362 100644
--- a/bin/sh/parser.c
+++ b/bin/sh/parser.c
@@ -1610,7 +1610,6 @@ endword:
*/
parsesub: {
- char buf[10];
int subtype;
int typeloc;
int flags;
@@ -1654,12 +1653,15 @@ varname:
strncmp(out - length, "LINENO", length) == 0) {
/* Replace the variable name with the
* current line number. */
+ STADJUST(-6, out);
+ CHECKSTRSPACE(11, out);
linno = plinno;
if (funclinno != 0)
linno -= funclinno - 1;
- snprintf(buf, sizeof(buf), "%d", linno);
- STADJUST(-6, out);
- STPUTS(buf, out);
+ length = snprintf(out, 11, "%d", linno);
+ if (length > 10)
+ length = 10;
+ out += length;
flags |= VSLINENO;
}
} else if (is_digit(c)) {
OpenPOWER on IntegriCloud