Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Mar 2018 16:31:23 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r330284 - head/stand/liblua
Message-ID:  <201803021631.w22GVN0x083117@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Fri Mar  2 16:31:23 2018
New Revision: 330284
URL: https://svnweb.freebsd.org/changeset/base/330284

Log:
  liblua: Use putc instead of printf for printc
  
  printc does not need the features or the overhead of printf. It does not
  take formatting strings, and it pipes the single string argument through an
  "%s" format.
  
  Instead, use putc directly. This pipes the string through in its entirety as
  a series of 'unsigned char's, generally straight to the console emulator.
  
  Discussed with:	tsoome

Modified:
  head/stand/liblua/lutils.c

Modified: head/stand/liblua/lutils.c
==============================================================================
--- head/stand/liblua/lutils.c	Fri Mar  2 16:06:20 2018	(r330283)
+++ head/stand/liblua/lutils.c	Fri Mar  2 16:31:23 2018	(r330284)
@@ -153,13 +153,13 @@ lua_unsetenv(lua_State *L)
 static int
 lua_printc(lua_State *L)
 {
-	int status;
-	ssize_t l;
+	ssize_t cur, l;
 	const char *s = luaL_checklstring(L, 1, &l);
 
-	status = (printf("%s", s) == l);
+	for (cur = 0; cur < l; ++cur)
+		putchar((unsigned char)*(s++));
 
-	return status;
+	return 1;
 }
 
 static int



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