aboutsummaryrefslogtreecommitdiff
path: root/lobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'lobject.c')
-rw-r--r--lobject.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/lobject.c b/lobject.c
index 86b3097e..11be7ad9 100644
--- a/lobject.c
+++ b/lobject.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.c,v 2.54 2011/11/30 12:44:26 roberto Exp roberto $ 2** $Id: lobject.c,v 2.55 2011/11/30 19:30:16 roberto Exp roberto $
3** Some generic functions over Lua objects 3** Some generic functions over Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -171,8 +171,7 @@ int luaO_str2d (const char *s, size_t len, lua_Number *result) {
171 171
172 172
173static void pushstr (lua_State *L, const char *str, size_t l) { 173static void pushstr (lua_State *L, const char *str, size_t l) {
174 setsvalue2s(L, L->top, luaS_newlstr(L, str, l)); 174 setsvalue2s(L, L->top++, luaS_newlstr(L, str, l));
175 incr_top(L);
176} 175}
177 176
178 177
@@ -182,8 +181,8 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
182 for (;;) { 181 for (;;) {
183 const char *e = strchr(fmt, '%'); 182 const char *e = strchr(fmt, '%');
184 if (e == NULL) break; 183 if (e == NULL) break;
185 setsvalue2s(L, L->top, luaS_newlstr(L, fmt, e-fmt)); 184 luaD_checkstack(L, 2); /* fmt + item */
186 incr_top(L); 185 pushstr(L, fmt, e - fmt);
187 switch (*(e+1)) { 186 switch (*(e+1)) {
188 case 's': { 187 case 's': {
189 const char *s = va_arg(argp, char *); 188 const char *s = va_arg(argp, char *);
@@ -198,13 +197,11 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
198 break; 197 break;
199 } 198 }
200 case 'd': { 199 case 'd': {
201 setnvalue(L->top, cast_num(va_arg(argp, int))); 200 setnvalue(L->top++, cast_num(va_arg(argp, int)));
202 incr_top(L);
203 break; 201 break;
204 } 202 }
205 case 'f': { 203 case 'f': {
206 setnvalue(L->top, cast_num(va_arg(argp, l_uacNumber))); 204 setnvalue(L->top++, cast_num(va_arg(argp, l_uacNumber)));
207 incr_top(L);
208 break; 205 break;
209 } 206 }
210 case 'p': { 207 case 'p': {
@@ -226,6 +223,7 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
226 n += 2; 223 n += 2;
227 fmt = e+2; 224 fmt = e+2;
228 } 225 }
226 luaD_checkstack(L, 1);
229 pushstr(L, fmt, strlen(fmt)); 227 pushstr(L, fmt, strlen(fmt));
230 if (n > 0) luaV_concat(L, n + 1); 228 if (n > 0) luaV_concat(L, n + 1);
231 return svalue(L->top - 1); 229 return svalue(L->top - 1);