diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-10-29 14:12:30 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-10-29 14:12:30 -0200 |
| commit | 05afee0f50f64b64dbb4c0614ccf737ffdc06ab6 (patch) | |
| tree | 76ddccce1152f3bb51ef80b801f6df4bf47c1525 | |
| parent | 351a446ec55d0e4a7520791cc4b6ff6097739e18 (diff) | |
| download | lua-05afee0f50f64b64dbb4c0614ccf737ffdc06ab6.tar.gz lua-05afee0f50f64b64dbb4c0614ccf737ffdc06ab6.tar.bz2 lua-05afee0f50f64b64dbb4c0614ccf737ffdc06ab6.zip | |
definitions for 'luai_writestring'/'luai_writeline'/'luai_writestringerror'
moved to 'lauxlib.h' (they do not need to be stable or configurable) +
prefixes changed from 'luai_' to 'lua_' (they are not part of the core)
| -rw-r--r-- | lauxlib.c | 6 | ||||
| -rw-r--r-- | lauxlib.h | 27 | ||||
| -rw-r--r-- | lbaselib.c | 8 | ||||
| -rw-r--r-- | ldblib.c | 6 | ||||
| -rw-r--r-- | lua.c | 20 |
5 files changed, 46 insertions, 21 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lauxlib.c,v 1.270 2014/10/22 11:44:20 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.271 2014/10/25 11:50:46 roberto Exp roberto $ |
| 3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -938,8 +938,8 @@ static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { | |||
| 938 | 938 | ||
| 939 | 939 | ||
| 940 | static int panic (lua_State *L) { | 940 | static int panic (lua_State *L) { |
| 941 | luai_writestringerror("PANIC: unprotected error in call to Lua API (%s)\n", | 941 | lua_writestringerror("PANIC: unprotected error in call to Lua API (%s)\n", |
| 942 | lua_tostring(L, -1)); | 942 | lua_tostring(L, -1)); |
| 943 | return 0; /* return to Lua to abort */ | 943 | return 0; /* return to Lua to abort */ |
| 944 | } | 944 | } |
| 945 | 945 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lauxlib.h,v 1.126 2014/10/01 11:54:56 roberto Exp roberto $ | 2 | ** $Id: lauxlib.h,v 1.127 2014/10/25 11:50:46 roberto Exp roberto $ |
| 3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -205,6 +205,31 @@ LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname, | |||
| 205 | 205 | ||
| 206 | 206 | ||
| 207 | /* | 207 | /* |
| 208 | ** {================================================================== | ||
| 209 | ** "Abstraction Layer" for basic report of messages and errors | ||
| 210 | ** =================================================================== | ||
| 211 | */ | ||
| 212 | |||
| 213 | /* print a string */ | ||
| 214 | #if !defined(lua_writestring) | ||
| 215 | #define lua_writestring(s,l) fwrite((s), sizeof(char), (l), stdout) | ||
| 216 | #endif | ||
| 217 | |||
| 218 | /* print a newline and flush the output */ | ||
| 219 | #if !defined(lua_writeline) | ||
| 220 | #define lua_writeline() (lua_writestring("\n", 1), fflush(stdout)) | ||
| 221 | #endif | ||
| 222 | |||
| 223 | /* print an error message */ | ||
| 224 | #if !defined(lua_writestringerror) | ||
| 225 | #define lua_writestringerror(s,p) \ | ||
| 226 | (fprintf(stderr, (s), (p)), fflush(stderr)) | ||
| 227 | #endif | ||
| 228 | |||
| 229 | /* }================================================================== */ | ||
| 230 | |||
| 231 | |||
| 232 | /* | ||
| 208 | ** {============================================================ | 233 | ** {============================================================ |
| 209 | ** Compatibility with deprecated conversions | 234 | ** Compatibility with deprecated conversions |
| 210 | ** ============================================================= | 235 | ** ============================================================= |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lbaselib.c,v 1.303 2014/10/17 19:17:55 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.304 2014/10/25 11:50:46 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 | */ |
| @@ -33,11 +33,11 @@ static int luaB_print (lua_State *L) { | |||
| 33 | s = lua_tolstring(L, -1, &l); /* get result */ | 33 | s = lua_tolstring(L, -1, &l); /* get result */ |
| 34 | if (s == NULL) | 34 | if (s == NULL) |
| 35 | return luaL_error(L, "'tostring' must return a string to 'print'"); | 35 | return luaL_error(L, "'tostring' must return a string to 'print'"); |
| 36 | if (i>1) luai_writestring("\t", 1); | 36 | if (i>1) lua_writestring("\t", 1); |
| 37 | luai_writestring(s, l); | 37 | lua_writestring(s, l); |
| 38 | lua_pop(L, 1); /* pop result */ | 38 | lua_pop(L, 1); /* pop result */ |
| 39 | } | 39 | } |
| 40 | luai_writeline(); | 40 | lua_writeline(); |
| 41 | return 0; | 41 | return 0; |
| 42 | } | 42 | } |
| 43 | 43 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldblib.c,v 1.142 2014/10/01 11:54:56 roberto Exp roberto $ | 2 | ** $Id: ldblib.c,v 1.143 2014/10/17 11:07:26 roberto Exp roberto $ |
| 3 | ** Interface from Lua to its debug API | 3 | ** Interface from Lua to its debug API |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -374,13 +374,13 @@ static int db_gethook (lua_State *L) { | |||
| 374 | static int db_debug (lua_State *L) { | 374 | static int db_debug (lua_State *L) { |
| 375 | for (;;) { | 375 | for (;;) { |
| 376 | char buffer[250]; | 376 | char buffer[250]; |
| 377 | luai_writestringerror("%s", "lua_debug> "); | 377 | lua_writestringerror("%s", "lua_debug> "); |
| 378 | if (fgets(buffer, sizeof(buffer), stdin) == 0 || | 378 | if (fgets(buffer, sizeof(buffer), stdin) == 0 || |
| 379 | strcmp(buffer, "cont\n") == 0) | 379 | strcmp(buffer, "cont\n") == 0) |
| 380 | return 0; | 380 | return 0; |
| 381 | if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") || | 381 | if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") || |
| 382 | lua_pcall(L, 0, 0, 0)) | 382 | lua_pcall(L, 0, 0, 0)) |
| 383 | luai_writestringerror("%s\n", lua_tostring(L, -1)); | 383 | lua_writestringerror("%s\n", lua_tostring(L, -1)); |
| 384 | lua_settop(L, 0); /* remove eventual returns */ | 384 | lua_settop(L, 0); /* remove eventual returns */ |
| 385 | } | 385 | } |
| 386 | } | 386 | } |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lua.c,v 1.216 2014/10/20 18:19:26 roberto Exp roberto $ | 2 | ** $Id: lua.c,v 1.217 2014/10/20 22:21:05 roberto Exp roberto $ |
| 3 | ** Lua stand-alone interpreter | 3 | ** Lua stand-alone interpreter |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -126,12 +126,12 @@ static void laction (int i) { | |||
| 126 | 126 | ||
| 127 | 127 | ||
| 128 | static void print_usage (const char *badoption) { | 128 | static void print_usage (const char *badoption) { |
| 129 | luai_writestringerror("%s: ", progname); | 129 | lua_writestringerror("%s: ", progname); |
| 130 | if (badoption[1] == 'e' || badoption[1] == 'l') | 130 | if (badoption[1] == 'e' || badoption[1] == 'l') |
| 131 | luai_writestringerror("'%s' needs argument\n", badoption); | 131 | lua_writestringerror("'%s' needs argument\n", badoption); |
| 132 | else | 132 | else |
| 133 | luai_writestringerror("unrecognized option '%s'\n", badoption); | 133 | lua_writestringerror("unrecognized option '%s'\n", badoption); |
| 134 | luai_writestringerror( | 134 | lua_writestringerror( |
| 135 | "usage: %s [options] [script [args]]\n" | 135 | "usage: %s [options] [script [args]]\n" |
| 136 | "Available options are:\n" | 136 | "Available options are:\n" |
| 137 | " -e stat execute string 'stat'\n" | 137 | " -e stat execute string 'stat'\n" |
| @@ -151,8 +151,8 @@ static void print_usage (const char *badoption) { | |||
| 151 | ** (if present) | 151 | ** (if present) |
| 152 | */ | 152 | */ |
| 153 | static void l_message (const char *pname, const char *msg) { | 153 | static void l_message (const char *pname, const char *msg) { |
| 154 | if (pname) luai_writestringerror("%s: ", pname); | 154 | if (pname) lua_writestringerror("%s: ", pname); |
| 155 | luai_writestringerror("%s\n", msg); | 155 | lua_writestringerror("%s\n", msg); |
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | 158 | ||
| @@ -208,8 +208,8 @@ static int docall (lua_State *L, int narg, int nres) { | |||
| 208 | 208 | ||
| 209 | 209 | ||
| 210 | static void print_version (void) { | 210 | static void print_version (void) { |
| 211 | luai_writestring(LUA_COPYRIGHT, strlen(LUA_COPYRIGHT)); | 211 | lua_writestring(LUA_COPYRIGHT, strlen(LUA_COPYRIGHT)); |
| 212 | luai_writeline(); | 212 | lua_writeline(); |
| 213 | } | 213 | } |
| 214 | 214 | ||
| 215 | 215 | ||
| @@ -410,7 +410,7 @@ static void doREPL (lua_State *L) { | |||
| 410 | else report(L, status); | 410 | else report(L, status); |
| 411 | } | 411 | } |
| 412 | lua_settop(L, 0); /* clear stack */ | 412 | lua_settop(L, 0); /* clear stack */ |
| 413 | luai_writeline(); | 413 | lua_writeline(); |
| 414 | progname = oldprogname; | 414 | progname = oldprogname; |
| 415 | } | 415 | } |
| 416 | 416 | ||
