diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-05-16 16:21:11 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-05-16 16:21:11 -0300 |
commit | da32450c3d4c8abd3fd6709692859a12a8886511 (patch) | |
tree | a75289cd092dd6cbd9e454c9689de3b9c4d5de33 /lbaselib.c | |
parent | a2b78aad49388c1fd5286773085ef8a35545faa6 (diff) | |
download | lua-da32450c3d4c8abd3fd6709692859a12a8886511.tar.gz lua-da32450c3d4c8abd3fd6709692859a12a8886511.tar.bz2 lua-da32450c3d4c8abd3fd6709692859a12a8886511.zip |
new API function `lua_tolstring'
Diffstat (limited to 'lbaselib.c')
-rw-r--r-- | lbaselib.c | 7 |
1 files changed, 2 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.172 2005/03/22 16:04:29 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.173 2005/03/28 17:17:53 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 | */ |
@@ -294,11 +294,8 @@ static const char *generic_reader (lua_State *L, void *ud, size_t *size) { | |||
294 | return NULL; | 294 | return NULL; |
295 | } | 295 | } |
296 | else if (lua_isstring(L, -1)) { | 296 | else if (lua_isstring(L, -1)) { |
297 | const char *res; | ||
298 | lua_replace(L, 3); /* save string in a reserved stack slot */ | 297 | lua_replace(L, 3); /* save string in a reserved stack slot */ |
299 | res = lua_tostring(L, 3); | 298 | return lua_tolstring(L, 3, size); |
300 | *size = lua_strlen(L, 3); | ||
301 | return res; | ||
302 | } | 299 | } |
303 | else luaL_error(L, "reader function must return a string"); | 300 | else luaL_error(L, "reader function must return a string"); |
304 | return NULL; /* to avoid warnings */ | 301 | return NULL; /* to avoid warnings */ |