diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-02-07 10:23:15 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-02-07 10:23:15 -0200 |
commit | 5d3cc5def8d2566fdd1741732ad207d4beed1230 (patch) | |
tree | c41eaf47221798ef7735bbeb84d1d78f2d331f2f /lbaselib.c | |
parent | 53db607963177fb91e566f4790f15e3fbcbdad61 (diff) | |
download | lua-5d3cc5def8d2566fdd1741732ad207d4beed1230.tar.gz lua-5d3cc5def8d2566fdd1741732ad207d4beed1230.tar.bz2 lua-5d3cc5def8d2566fdd1741732ad207d4beed1230.zip |
'writestring' changed into a configurable macro
Diffstat (limited to 'lbaselib.c')
-rw-r--r-- | lbaselib.c | 21 |
1 files changed, 4 insertions, 17 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.208 2008/07/11 17:51:01 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.209 2009/02/06 18:38:47 roberto Exp roberto $ |
3 | ** Basic library | 3 | ** Basic library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -19,19 +19,6 @@ | |||
19 | #include "lualib.h" | 19 | #include "lualib.h" |
20 | 20 | ||
21 | 21 | ||
22 | |||
23 | |||
24 | /* | ||
25 | ** If your system does not support `stdout', you can just remove this function. | ||
26 | ** If you need, you can define your own `print' function, following this | ||
27 | ** model but changing `writestring' to put the strings at a proper place | ||
28 | ** (a console window or a log file, for instance). | ||
29 | */ | ||
30 | static void writestring (const char *s, size_t l) { | ||
31 | fwrite(s, sizeof(char), l, stdout); | ||
32 | } | ||
33 | |||
34 | |||
35 | static int luaB_print (lua_State *L) { | 22 | static int luaB_print (lua_State *L) { |
36 | int n = lua_gettop(L); /* number of arguments */ | 23 | int n = lua_gettop(L); /* number of arguments */ |
37 | int i; | 24 | int i; |
@@ -46,11 +33,11 @@ static int luaB_print (lua_State *L) { | |||
46 | if (s == NULL) | 33 | if (s == NULL) |
47 | return luaL_error(L, LUA_QL("tostring") " must return a string to " | 34 | return luaL_error(L, LUA_QL("tostring") " must return a string to " |
48 | LUA_QL("print")); | 35 | LUA_QL("print")); |
49 | if (i>1) writestring("\t", 1); | 36 | if (i>1) luai_writestring("\t", 1); |
50 | writestring(s, l); | 37 | luai_writestring(s, l); |
51 | lua_pop(L, 1); /* pop result */ | 38 | lua_pop(L, 1); /* pop result */ |
52 | } | 39 | } |
53 | writestring("\n", 1); | 40 | luai_writestring("\n", 1); |
54 | return 0; | 41 | return 0; |
55 | } | 42 | } |
56 | 43 | ||