Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 16 Apr 2016 12:14:45 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r298109 - head/bin/sh
Message-ID:  <201604161214.u3GCEjgc064924@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Sat Apr 16 12:14:44 2016
New Revision: 298109
URL: https://svnweb.freebsd.org/changeset/base/298109

Log:
  sh: Write LINENO value to stack string directly.

Modified:
  head/bin/sh/parser.c

Modified: head/bin/sh/parser.c
==============================================================================
--- head/bin/sh/parser.c	Sat Apr 16 07:50:50 2016	(r298108)
+++ head/bin/sh/parser.c	Sat Apr 16 12:14:44 2016	(r298109)
@@ -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)) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201604161214.u3GCEjgc064924>