From f576b52aa0a921be7895766367552479f621b662 Mon Sep 17 00:00:00 2001 From: jilles Date: Sat, 16 Apr 2016 12:14:44 +0000 Subject: sh: Write LINENO value to stack string directly. --- bin/sh/parser.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'bin') 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)) { -- cgit v1.1