Browse Source

'writestring' changed into a configurable macro

Roberto Ierusalimschy 16 years ago
parent
commit
5d3cc5def8
2 changed files with 12 additions and 18 deletions
  1. 4 17
      lbaselib.c
  2. 8 1
      luaconf.h

+ 4 - 17
lbaselib.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lbaselib.c,v 1.208 2008/07/11 17:51:01 roberto Exp roberto $
+** $Id: lbaselib.c,v 1.209 2009/02/06 18:38:47 roberto Exp roberto $
 ** Basic library
 ** See Copyright Notice in lua.h
 */
@@ -19,19 +19,6 @@
 #include "lualib.h"
 
 
-
-
-/*
-** If your system does not support `stdout', you can just remove this function.
-** If you need, you can define your own `print' function, following this
-** model but changing `writestring' to put the strings at a proper place
-** (a console window or a log file, for instance).
-*/
-static void writestring (const char *s, size_t l) {
-  fwrite(s, sizeof(char), l, stdout);
-}
-
-
 static int luaB_print (lua_State *L) {
   int n = lua_gettop(L);  /* number of arguments */
   int i;
@@ -46,11 +33,11 @@ static int luaB_print (lua_State *L) {
     if (s == NULL)
       return luaL_error(L, LUA_QL("tostring") " must return a string to "
                            LUA_QL("print"));
-    if (i>1) writestring("\t", 1);
-    writestring(s, l);
+    if (i>1) luai_writestring("\t", 1);
+    luai_writestring(s, l);
     lua_pop(L, 1);  /* pop result */
   }
-  writestring("\n", 1);
+  luai_writestring("\n", 1);
   return 0;
 }
 

+ 8 - 1
luaconf.h

@@ -1,5 +1,5 @@
 /*
-** $Id: luaconf.h,v 1.99 2008/07/11 17:50:31 roberto Exp roberto $
+** $Id: luaconf.h,v 1.100 2008/07/18 19:58:10 roberto Exp roberto $
 ** Configuration file for Lua
 ** See Copyright Notice in lua.h
 */
@@ -220,6 +220,13 @@
 #define LUA_IDSIZE	60
 
 
+/*
+@@ luai_writestring defines how 'print' prints its results. 
+** CHANGE it if your system does not have a useful stdout.
+*/ 
+#define luai_writestring(s,l)	fwrite((s), sizeof(char), (l), stdout)
+
+
 /*
 ** {==================================================================
 ** Stand-alone configuration