diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-05-07 14:36:56 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-05-07 14:36:56 -0300 |
| commit | dea6b6da9422f34ad91c8f6ad9ad3ed650e95713 (patch) | |
| tree | 3016b2fbcd67d75c71ee1b190aff2c24ada9b168 /ldblib.c | |
| parent | 71144e3ff0cb81bd9b8bb56d94dc76074c638c64 (diff) | |
| download | lua-dea6b6da9422f34ad91c8f6ad9ad3ed650e95713.tar.gz lua-dea6b6da9422f34ad91c8f6ad9ad3ed650e95713.tar.bz2 lua-dea6b6da9422f34ad91c8f6ad9ad3ed650e95713.zip | |
new function `lua_vpushstr' to replace uses of `sprintf'
Diffstat (limited to 'ldblib.c')
| -rw-r--r-- | ldblib.c | 9 |
1 files changed, 4 insertions, 5 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldblib.c,v 1.49 2002/05/01 20:40:42 roberto Exp roberto $ | 2 | ** $Id: ldblib.c,v 1.50 2002/05/06 19:05:10 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 | */ |
| @@ -34,7 +34,6 @@ static void settabsi (lua_State *L, const char *i, int v) { | |||
| 34 | static int getinfo (lua_State *L) { | 34 | static int getinfo (lua_State *L) { |
| 35 | lua_Debug ar; | 35 | lua_Debug ar; |
| 36 | const char *options = luaL_opt_string(L, 2, "flnSu"); | 36 | const char *options = luaL_opt_string(L, 2, "flnSu"); |
| 37 | char buff[20]; | ||
| 38 | if (lua_isnumber(L, 1)) { | 37 | if (lua_isnumber(L, 1)) { |
| 39 | if (!lua_getstack(L, (int)(lua_tonumber(L, 1)), &ar)) { | 38 | if (!lua_getstack(L, (int)(lua_tonumber(L, 1)), &ar)) { |
| 40 | lua_pushnil(L); /* level out of range */ | 39 | lua_pushnil(L); /* level out of range */ |
| @@ -42,9 +41,9 @@ static int getinfo (lua_State *L) { | |||
| 42 | } | 41 | } |
| 43 | } | 42 | } |
| 44 | else if (lua_isfunction(L, 1)) { | 43 | else if (lua_isfunction(L, 1)) { |
| 44 | luaL_vstr(L, ">%s", options); | ||
| 45 | options = lua_tostring(L, -1); | ||
| 45 | lua_pushvalue(L, 1); | 46 | lua_pushvalue(L, 1); |
| 46 | sprintf(buff, ">%.10s", options); | ||
| 47 | options = buff; | ||
| 48 | } | 47 | } |
| 49 | else | 48 | else |
| 50 | return luaL_argerror(L, 1, "function or level expected"); | 49 | return luaL_argerror(L, 1, "function or level expected"); |
| @@ -170,7 +169,7 @@ static int setlinehook (lua_State *L) { | |||
| 170 | static int debug (lua_State *L) { | 169 | static int debug (lua_State *L) { |
| 171 | for (;;) { | 170 | for (;;) { |
| 172 | char buffer[250]; | 171 | char buffer[250]; |
| 173 | fprintf(stderr, "lua_debug> "); | 172 | fputs("lua_debug> ", stderr); |
| 174 | if (fgets(buffer, sizeof(buffer), stdin) == 0 || | 173 | if (fgets(buffer, sizeof(buffer), stdin) == 0 || |
| 175 | strcmp(buffer, "cont\n") == 0) | 174 | strcmp(buffer, "cont\n") == 0) |
| 176 | return 0; | 175 | return 0; |
