aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-05-16 15:39:46 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-05-16 15:39:46 -0300
commit955def034814e96f5f8e42def2e47ca6817ef103 (patch)
treed8eea96980860d1d1e5005ee6ecedb47fa64d594
parent9c3b3f82fe1b0942183ddeef2e16d60bab4f4c06 (diff)
downloadlua-955def034814e96f5f8e42def2e47ca6817ef103.tar.gz
lua-955def034814e96f5f8e42def2e47ca6817ef103.tar.bz2
lua-955def034814e96f5f8e42def2e47ca6817ef103.zip
new names for string formating functions
-rw-r--r--lapi.c48
-rw-r--r--lauxlib.c21
-rw-r--r--lauxlib.h3
-rw-r--r--lbaselib.c25
-rw-r--r--ldblib.c17
-rw-r--r--ldebug.c6
-rw-r--r--ldo.c4
-rw-r--r--llex.c16
-rw-r--r--lobject.c8
-rw-r--r--lobject.h6
-rw-r--r--lparser.c6
-rw-r--r--lua.h18
12 files changed, 78 insertions, 100 deletions
diff --git a/lapi.c b/lapi.c
index eae26308..5421cdf4 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 1.190 2002/05/07 17:36:56 roberto Exp roberto $ 2** $Id: lapi.c,v 1.191 2002/05/15 18:57:44 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -355,10 +355,23 @@ LUA_API void lua_pushstring (lua_State *L, const char *s) {
355} 355}
356 356
357 357
358LUA_API void lua_vpushstr (lua_State *L, const char *fmt, va_list argp) { 358LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt,
359 va_list argp) {
360 const char *ret;
359 lua_lock(L); 361 lua_lock(L);
360 luaO_vpushstr(L, fmt, argp); 362 ret = luaO_pushvfstring(L, fmt, argp);
361 lua_unlock(L); 363 lua_unlock(L);
364 return ret;
365}
366
367
368LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) {
369 const char *ret;
370 va_list argp;
371 va_start(argp, fmt);
372 ret = lua_pushvfstring(L, fmt, argp);
373 va_end(argp);
374 return ret;
362} 375}
363 376
364 377
@@ -556,21 +569,16 @@ LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errf) {
556 569
557static int errfile (lua_State *L, const char *filename) { 570static int errfile (lua_State *L, const char *filename) {
558 if (filename == NULL) filename = "stdin"; 571 if (filename == NULL) filename = "stdin";
559 lua_pushliteral(L, "cannot read "); 572 lua_pushfstring(L, "cannot read %s: %s", filename, lua_fileerror);
560 lua_pushstring(L, filename);
561 lua_pushliteral(L, ": ");
562 lua_pushstring(L, lua_fileerror);
563 lua_concat(L, 4);
564 return LUA_ERRFILE; 573 return LUA_ERRFILE;
565} 574}
566 575
567 576
568LUA_API int lua_loadfile (lua_State *L, const char *filename) { 577LUA_API int lua_loadfile (lua_State *L, const char *filename) {
569 ZIO z; 578 ZIO z;
570 const char *luafname; /* name used by lua */ 579 int fnindex;
571 int status; 580 int status;
572 int bin; /* flag for file mode */ 581 int bin; /* flag for file mode */
573 int nlevel; /* level on the stack of filename */
574 FILE *f = (filename == NULL) ? stdin : fopen(filename, "r"); 582 FILE *f = (filename == NULL) ? stdin : fopen(filename, "r");
575 if (f == NULL) return errfile(L, filename); /* unable to open file */ 583 if (f == NULL) return errfile(L, filename); /* unable to open file */
576 bin = (ungetc(getc(f), f) == LUA_SIGNATURE[0]); 584 bin = (ungetc(getc(f), f) == LUA_SIGNATURE[0]);
@@ -580,19 +588,17 @@ LUA_API int lua_loadfile (lua_State *L, const char *filename) {
580 if (f == NULL) return errfile(L, filename); /* unable to reopen file */ 588 if (f == NULL) return errfile(L, filename); /* unable to reopen file */
581 } 589 }
582 if (filename == NULL) 590 if (filename == NULL)
583 lua_pushstring(L, "=stdin"); 591 lua_pushliteral(L, "=stdin");
584 else { 592 else
585 lua_pushliteral(L, "@"); 593 lua_pushfstring(L, "@%s", filename);
586 lua_pushstring(L, filename); 594 fnindex = lua_gettop(L); /* stack index of file name */
587 lua_concat(L, 2); 595 luaZ_Fopen(&z, f, lua_tostring(L, fnindex));
588 }
589 nlevel = lua_gettop(L);
590 luafname = lua_tostring(L, -1); /* luafname = `@'..filename */
591 luaZ_Fopen(&z, f, luafname);
592 status = luaD_protectedparser(L, &z, bin); 596 status = luaD_protectedparser(L, &z, bin);
593 if (ferror(f)) 597 lua_remove(L, fnindex);
598 if (ferror(f)) {
599 if (status == 0) lua_pop(L, 1); /* remove chunk */
594 return errfile(L, filename); 600 return errfile(L, filename);
595 lua_remove(L, nlevel); /* remove filename */ 601 }
596 if (f != stdin) 602 if (f != stdin)
597 fclose(f); 603 fclose(f);
598 return status; 604 return status;
diff --git a/lauxlib.c b/lauxlib.c
index ecaa6c8f..b7b82661 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.c,v 1.69 2002/05/07 17:36:56 roberto Exp roberto $ 2** $Id: lauxlib.c,v 1.70 2002/05/15 18:57:44 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*/
@@ -43,8 +43,9 @@ LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) {
43 43
44 44
45LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) { 45LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) {
46 luaL_vstr(L, "%s expected, got %s", tname, lua_typename(L, lua_type(L,narg))); 46 const char *msg = lua_pushfstring(L, "%s expected, got %s",
47 return luaL_argerror(L, narg, lua_tostring(L, -1)); 47 tname, lua_typename(L, lua_type(L,narg)));
48 return luaL_argerror(L, narg, msg);
48} 49}
49 50
50 51
@@ -142,25 +143,17 @@ LUALIB_API void luaL_opennamedlib (lua_State *L, const char *libname,
142} 143}
143 144
144 145
145LUALIB_API void luaL_vstr (lua_State *L, const char *fmt, ...) {
146 va_list argp;
147 va_start(argp, fmt);
148 lua_vpushstr(L, fmt, argp);
149 va_end(argp);
150}
151
152
153LUALIB_API int luaL_verror (lua_State *L, const char *fmt, ...) { 146LUALIB_API int luaL_verror (lua_State *L, const char *fmt, ...) {
154 lua_Debug ar; 147 lua_Debug ar;
148 const char *msg;
155 va_list argp; 149 va_list argp;
156 va_start(argp, fmt); 150 va_start(argp, fmt);
157 lua_vpushstr(L, fmt, argp); 151 msg = lua_pushvfstring(L, fmt, argp);
158 va_end(argp); 152 va_end(argp);
159 if (lua_getstack(L, 1, &ar)) { /* check calling function */ 153 if (lua_getstack(L, 1, &ar)) { /* check calling function */
160 lua_getinfo(L, "Snl", &ar); 154 lua_getinfo(L, "Snl", &ar);
161 if (ar.currentline > 0) 155 if (ar.currentline > 0)
162 luaL_vstr(L, "%s:%d: %s", 156 lua_pushfstring(L, "%s:%d: %s", ar.short_src, ar.currentline, msg);
163 ar.short_src, ar.currentline, lua_tostring(L, -1));
164 } 157 }
165 return lua_errorobj(L); 158 return lua_errorobj(L);
166} 159}
diff --git a/lauxlib.h b/lauxlib.h
index 93282517..f8c0235e 100644
--- a/lauxlib.h
+++ b/lauxlib.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.h,v 1.45 2002/05/01 20:40:42 roberto Exp roberto $ 2** $Id: lauxlib.h,v 1.46 2002/05/06 19:05:10 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*/
@@ -45,7 +45,6 @@ LUALIB_API void luaL_check_type (lua_State *L, int narg, int t);
45LUALIB_API void luaL_check_any (lua_State *L, int narg); 45LUALIB_API void luaL_check_any (lua_State *L, int narg);
46 46
47LUALIB_API int luaL_verror (lua_State *L, const char *fmt, ...); 47LUALIB_API int luaL_verror (lua_State *L, const char *fmt, ...);
48LUALIB_API void luaL_vstr (lua_State *L, const char *fmt, ...);
49LUALIB_API int luaL_findstring (const char *name, 48LUALIB_API int luaL_findstring (const char *name,
50 const char *const list[]); 49 const char *const list[]);
51 50
diff --git a/lbaselib.c b/lbaselib.c
index cdfa3d33..e29480bd 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.72 2002/05/06 19:05:10 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.73 2002/05/13 13:10:58 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*/
@@ -32,28 +32,6 @@ static int luaB__ALERT (lua_State *L) {
32 32
33 33
34/* 34/*
35** Basic implementation of _ERRORMESSAGE.
36** The library `liolib' redefines _ERRORMESSAGE for better error information.
37*/
38static int luaB__ERRORMESSAGE (lua_State *L) {
39 lua_Debug ar;
40 luaL_check_type(L, 1, LUA_TSTRING);
41 lua_pushliteral(L, "error: ");
42 lua_pushvalue(L, 1);
43 if (lua_getstack(L, 1, &ar)) {
44 lua_getinfo(L, "Sl", &ar);
45 if (ar.source && ar.currentline > 0) {
46 luaL_vstr(L, "\n <%s: line %d>", ar.short_src, ar.currentline);
47 lua_concat(L, 2);
48 }
49 }
50 lua_pushliteral(L, "\n");
51 lua_concat(L, 3);
52 return 1;
53}
54
55
56/*
57** If your system does not support `stdout', you can just remove this function. 35** If your system does not support `stdout', you can just remove this function.
58** If you need, you can define your own `print' function, following this 36** If you need, you can define your own `print' function, following this
59** model but changing `fputs' to put the strings at a proper place 37** model but changing `fputs' to put the strings at a proper place
@@ -408,7 +386,6 @@ static int luaB_require (lua_State *L) {
408 386
409static const luaL_reg base_funcs[] = { 387static const luaL_reg base_funcs[] = {
410 {LUA_ALERT, luaB__ALERT}, 388 {LUA_ALERT, luaB__ALERT},
411 {"_ERRORMESSAGE", luaB__ERRORMESSAGE},
412 {"error", luaB_error}, 389 {"error", luaB_error},
413 {"metatable", luaB_metatable}, 390 {"metatable", luaB_metatable},
414 {"globals", luaB_globals}, 391 {"globals", luaB_globals},
diff --git a/ldblib.c b/ldblib.c
index da0a90f5..5ef7d428 100644
--- a/ldblib.c
+++ b/ldblib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldblib.c,v 1.51 2002/05/07 17:36:56 roberto Exp roberto $ 2** $Id: ldblib.c,v 1.52 2002/05/15 18:57:44 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*/
@@ -41,7 +41,7 @@ static int getinfo (lua_State *L) {
41 } 41 }
42 } 42 }
43 else if (lua_isfunction(L, 1)) { 43 else if (lua_isfunction(L, 1)) {
44 luaL_vstr(L, ">%s", options); 44 lua_pushfstring(L, ">%s", options);
45 options = lua_tostring(L, -1); 45 options = lua_tostring(L, -1);
46 lua_pushvalue(L, 1); 46 lua_pushvalue(L, 1);
47 } 47 }
@@ -207,23 +207,24 @@ static int errorfb (lua_State *L) {
207 sprintf(buff, "%4d- ", level-1); 207 sprintf(buff, "%4d- ", level-1);
208 lua_pushstring(L, buff); 208 lua_pushstring(L, buff);
209 lua_getinfo(L, "Snl", &ar); 209 lua_getinfo(L, "Snl", &ar);
210 luaL_vstr(L, "%s:", ar.short_src); 210 lua_pushfstring(L, "%s:", ar.short_src);
211 if (ar.currentline > 0) 211 if (ar.currentline > 0)
212 luaL_vstr(L, "%d:", ar.currentline); 212 lua_pushfstring(L, "%d:", ar.currentline);
213 switch (*ar.namewhat) { 213 switch (*ar.namewhat) {
214 case 'g': /* global */ 214 case 'g': /* global */
215 case 'l': /* local */ 215 case 'l': /* local */
216 case 'f': /* field */ 216 case 'f': /* field */
217 case 'm': /* method */ 217 case 'm': /* method */
218 luaL_vstr(L, " in function `%s'", ar.name); 218 lua_pushfstring(L, " in function `%s'", ar.name);
219 break; 219 break;
220 default: { 220 default: {
221 if (*ar.what == 'm') /* main? */ 221 if (*ar.what == 'm') /* main? */
222 luaL_vstr(L, " in main chunk"); 222 lua_pushfstring(L, " in main chunk");
223 else if (*ar.what == 'C') /* C function? */ 223 else if (*ar.what == 'C') /* C function? */
224 luaL_vstr(L, "%s", ar.short_src); 224 lua_pushfstring(L, "%s", ar.short_src);
225 else 225 else
226 luaL_vstr(L, " in function <%s:%d>", ar.short_src, ar.linedefined); 226 lua_pushfstring(L, " in function <%s:%d>",
227 ar.short_src, ar.linedefined);
227 } 228 }
228 } 229 }
229 lua_pushliteral(L, "\n"); 230 lua_pushliteral(L, "\n");
diff --git a/ldebug.c b/ldebug.c
index eb2aa527..2a94dc09 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldebug.c,v 1.115 2002/05/14 17:52:22 roberto Exp roberto $ 2** $Id: ldebug.c,v 1.116 2002/05/15 18:57:44 roberto Exp roberto $
3** Debug Interface 3** Debug Interface
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -517,13 +517,13 @@ void luaG_runerror (lua_State *L, const char *fmt, ...) {
517 const char *msg; 517 const char *msg;
518 va_list argp; 518 va_list argp;
519 va_start(argp, fmt); 519 va_start(argp, fmt);
520 msg = luaO_vpushstr(L, fmt, argp); 520 msg = luaO_pushvfstring(L, fmt, argp);
521 va_end(argp); 521 va_end(argp);
522 if (isLmark(L->ci)) { 522 if (isLmark(L->ci)) {
523 char buff[LUA_IDSIZE]; 523 char buff[LUA_IDSIZE];
524 int line = currentline(L, L->ci); 524 int line = currentline(L, L->ci);
525 luaO_chunkid(buff, getstr(getluaproto(L->ci)->source), LUA_IDSIZE); 525 luaO_chunkid(buff, getstr(getluaproto(L->ci)->source), LUA_IDSIZE);
526 msg = luaO_pushstr(L, "%s:%d: %s", buff, line, msg); 526 msg = luaO_pushfstring(L, "%s:%d: %s", buff, line, msg);
527 } 527 }
528 luaD_error(L, msg, LUA_ERRRUN); 528 luaD_error(L, msg, LUA_ERRRUN);
529} 529}
diff --git a/ldo.c b/ldo.c
index 5b5bad8d..34914923 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 1.174 2002/05/07 17:36:56 roberto Exp roberto $ 2** $Id: ldo.c,v 1.175 2002/05/15 18:57:44 roberto Exp roberto $
3** Stack and Call structure of Lua 3** Stack and Call structure of Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -424,7 +424,7 @@ int luaD_protectedparser (lua_State *L, ZIO *z, int bin) {
424 lua_lock(L); 424 lua_lock(L);
425 p.z = z; p.bin = bin; 425 p.z = z; p.bin = bin;
426 /* before parsing, give a (good) chance to GC */ 426 /* before parsing, give a (good) chance to GC */
427 if (G(L)->nblocks/8 >= G(L)->GCthreshold/10) 427 if (G(L)->nblocks + G(L)->nblocks/4 >= G(L)->GCthreshold)
428 luaC_collectgarbage(L); 428 luaC_collectgarbage(L);
429 old_blocks = G(L)->nblocks; 429 old_blocks = G(L)->nblocks;
430 setnilvalue(&p.err); 430 setnilvalue(&p.err);
diff --git a/llex.c b/llex.c
index 90e6698b..08beda35 100644
--- a/llex.c
+++ b/llex.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llex.c,v 1.100 2002/05/07 17:36:56 roberto Exp roberto $ 2** $Id: llex.c,v 1.101 2002/05/15 18:57:44 roberto Exp roberto $
3** Lexical Analyzer 3** Lexical Analyzer
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -51,7 +51,7 @@ void luaX_init (lua_State *L) {
51 51
52void luaX_checklimit (LexState *ls, int val, int limit, const char *msg) { 52void luaX_checklimit (LexState *ls, int val, int limit, const char *msg) {
53 if (val > limit) { 53 if (val > limit) {
54 msg = luaO_pushstr(ls->L, "too many %s (limit=%d)", msg, limit); 54 msg = luaO_pushfstring(ls->L, "too many %s (limit=%d)", msg, limit);
55 luaX_syntaxerror(ls, msg); 55 luaX_syntaxerror(ls, msg);
56 } 56 }
57} 57}
@@ -61,7 +61,7 @@ static void luaX_error (LexState *ls, const char *s, const char *token) {
61 lua_State *L = ls->L; 61 lua_State *L = ls->L;
62 char buff[MAXSRC]; 62 char buff[MAXSRC];
63 luaO_chunkid(buff, getstr(ls->source), MAXSRC); 63 luaO_chunkid(buff, getstr(ls->source), MAXSRC);
64 luaO_pushstr(L, "%s:%d: %s near `%s'", buff, ls->linenumber, s, token); 64 luaO_pushfstring(L, "%s:%d: %s near `%s'", buff, ls->linenumber, s, token);
65 luaD_errorobj(L, L->top - 1, LUA_ERRSYNTAX); 65 luaD_errorobj(L, L->top - 1, LUA_ERRSYNTAX);
66} 66}
67 67
@@ -70,13 +70,13 @@ void luaX_syntaxerror (LexState *ls, const char *msg) {
70 const char *lasttoken; 70 const char *lasttoken;
71 switch (ls->t.token) { 71 switch (ls->t.token) {
72 case TK_NAME: 72 case TK_NAME:
73 lasttoken = luaO_pushstr(ls->L, "%s", getstr(ls->t.seminfo.ts)); 73 lasttoken = luaO_pushfstring(ls->L, "%s", getstr(ls->t.seminfo.ts));
74 break; 74 break;
75 case TK_STRING: 75 case TK_STRING:
76 lasttoken = luaO_pushstr(ls->L, "\"%s\"", getstr(ls->t.seminfo.ts)); 76 lasttoken = luaO_pushfstring(ls->L, "\"%s\"", getstr(ls->t.seminfo.ts));
77 break; 77 break;
78 case TK_NUMBER: 78 case TK_NUMBER:
79 lasttoken = luaO_pushstr(ls->L, "%f", ls->t.seminfo.r); 79 lasttoken = luaO_pushfstring(ls->L, "%f", ls->t.seminfo.r);
80 break; 80 break;
81 default: 81 default:
82 lasttoken = luaX_token2str(ls, ls->t.token); 82 lasttoken = luaX_token2str(ls, ls->t.token);
@@ -89,7 +89,7 @@ void luaX_syntaxerror (LexState *ls, const char *msg) {
89const char *luaX_token2str (LexState *ls, int token) { 89const char *luaX_token2str (LexState *ls, int token) {
90 if (token < FIRST_RESERVED) { 90 if (token < FIRST_RESERVED) {
91 lua_assert(token == (char)token); 91 lua_assert(token == (char)token);
92 return luaO_pushstr(ls->L, "%c", token); 92 return luaO_pushfstring(ls->L, "%c", token);
93 } 93 }
94 else 94 else
95 return token2string[token-FIRST_RESERVED]; 95 return token2string[token-FIRST_RESERVED];
@@ -397,7 +397,7 @@ int luaX_lex (LexState *LS, SemInfo *seminfo) {
397 int c = LS->current; 397 int c = LS->current;
398 if (iscntrl(c)) 398 if (iscntrl(c))
399 luaX_error(LS, "invalid control char", 399 luaX_error(LS, "invalid control char",
400 luaO_pushstr(LS->L, "char(%d)", c)); 400 luaO_pushfstring(LS->L, "char(%d)", c));
401 next(LS); 401 next(LS);
402 return c; /* single-char tokens (+ - / ...) */ 402 return c; /* single-char tokens (+ - / ...) */
403 } 403 }
diff --git a/lobject.c b/lobject.c
index 52e81205..a57db0c3 100644
--- a/lobject.c
+++ b/lobject.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.c,v 1.79 2002/05/07 17:36:56 roberto Exp roberto $ 2** $Id: lobject.c,v 1.80 2002/05/15 18:57:44 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*/
@@ -99,7 +99,7 @@ static void pushstr (lua_State *L, const char *str) {
99 99
100 100
101/* this function handles only `%d', `%c', %f, and `%s' formats */ 101/* this function handles only `%d', `%c', %f, and `%s' formats */
102const char *luaO_vpushstr (lua_State *L, const char *fmt, va_list argp) { 102const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
103 int n = 1; 103 int n = 1;
104 pushstr(L, ""); 104 pushstr(L, "");
105 for (;;) { 105 for (;;) {
@@ -141,11 +141,11 @@ const char *luaO_vpushstr (lua_State *L, const char *fmt, va_list argp) {
141} 141}
142 142
143 143
144const char *luaO_pushstr (lua_State *L, const char *fmt, ...) { 144const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) {
145 const char *msg; 145 const char *msg;
146 va_list argp; 146 va_list argp;
147 va_start(argp, fmt); 147 va_start(argp, fmt);
148 msg = luaO_vpushstr(L, fmt, argp); 148 msg = luaO_pushvfstring(L, fmt, argp);
149 va_end(argp); 149 va_end(argp);
150 return msg; 150 return msg;
151} 151}
diff --git a/lobject.h b/lobject.h
index fbf57adc..76855319 100644
--- a/lobject.h
+++ b/lobject.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.h,v 1.131 2002/05/07 17:36:56 roberto Exp roberto $ 2** $Id: lobject.h,v 1.132 2002/05/15 18:57:44 roberto Exp roberto $
3** Type definitions for Lua objects 3** Type definitions for Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -250,8 +250,8 @@ void *luaO_openspaceaux (lua_State *L, size_t n);
250int luaO_equalObj (const TObject *t1, const TObject *t2); 250int luaO_equalObj (const TObject *t1, const TObject *t2);
251int luaO_str2d (const char *s, lua_Number *result); 251int luaO_str2d (const char *s, lua_Number *result);
252 252
253const char *luaO_vpushstr (lua_State *L, const char *fmt, va_list argp); 253const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp);
254const char *luaO_pushstr (lua_State *L, const char *fmt, ...); 254const char *luaO_pushfstring (lua_State *L, const char *fmt, ...);
255void luaO_chunkid (char *out, const char *source, int len); 255void luaO_chunkid (char *out, const char *source, int len);
256 256
257 257
diff --git a/lparser.c b/lparser.c
index af9d0f6e..3afe5945 100644
--- a/lparser.c
+++ b/lparser.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.c,v 1.182 2002/05/13 13:09:00 roberto Exp roberto $ 2** $Id: lparser.c,v 1.183 2002/05/14 17:52:22 roberto Exp roberto $
3** Lua Parser 3** Lua Parser
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -70,7 +70,7 @@ static void lookahead (LexState *ls) {
70 70
71static void error_expected (LexState *ls, int token) { 71static void error_expected (LexState *ls, int token) {
72 luaX_syntaxerror(ls, 72 luaX_syntaxerror(ls,
73 luaO_pushstr(ls->L, "`%s' expected", luaX_token2str(ls, token))); 73 luaO_pushfstring(ls->L, "`%s' expected", luaX_token2str(ls, token)));
74} 74}
75 75
76 76
@@ -98,7 +98,7 @@ static void check_match (LexState *ls, int what, int who, int where) {
98 if (where == ls->linenumber) 98 if (where == ls->linenumber)
99 error_expected(ls, what); 99 error_expected(ls, what);
100 else { 100 else {
101 luaX_syntaxerror(ls, luaO_pushstr(ls->L, 101 luaX_syntaxerror(ls, luaO_pushfstring(ls->L,
102 "`%s' expected (to close `%s' at line %d)", 102 "`%s' expected (to close `%s' at line %d)",
103 luaX_token2str(ls, what), luaX_token2str(ls, who), where)); 103 luaX_token2str(ls, what), luaX_token2str(ls, who), where));
104 } 104 }
diff --git a/lua.h b/lua.h
index ba2069e7..58af7a92 100644
--- a/lua.h
+++ b/lua.h
@@ -1,7 +1,7 @@
1/* 1/*
2** $Id: lua.h,v 1.131 2002/05/06 19:05:10 roberto Exp roberto $ 2** $Id: lua.h,v 1.132 2002/05/07 17:36:56 roberto Exp roberto $
3** Lua - An Extensible Extension Language 3** Lua - An Extensible Extension Language
4** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil 4** Tecgraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil
5** e-mail: info@lua.org 5** e-mail: info@lua.org
6** www: http://www.lua.org 6** www: http://www.lua.org
7** See Copyright Notice at the end of this file 7** See Copyright Notice at the end of this file
@@ -21,7 +21,7 @@
21 21
22 22
23#define LUA_VERSION "Lua 5.0 (alpha)" 23#define LUA_VERSION "Lua 5.0 (alpha)"
24#define LUA_COPYRIGHT "Copyright (C) 1994-2002 TeCGraf, PUC-Rio" 24#define LUA_COPYRIGHT "Copyright (C) 1994-2002 Tecgraf, PUC-Rio"
25#define LUA_AUTHORS "W. Celes, R. Ierusalimschy & L. H. de Figueiredo" 25#define LUA_AUTHORS "W. Celes, R. Ierusalimschy & L. H. de Figueiredo"
26 26
27 27
@@ -130,7 +130,7 @@ LUA_API int lua_lessthan (lua_State *L, int index1, int index2);
130 130
131LUA_API lua_Number lua_tonumber (lua_State *L, int index); 131LUA_API lua_Number lua_tonumber (lua_State *L, int index);
132LUA_API int lua_toboolean (lua_State *L, int index); 132LUA_API int lua_toboolean (lua_State *L, int index);
133LUA_API const char *lua_tostring (lua_State *L, int index); 133LUA_API const char *lua_tostring (lua_State *L, int index);
134LUA_API size_t lua_strlen (lua_State *L, int index); 134LUA_API size_t lua_strlen (lua_State *L, int index);
135LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index); 135LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index);
136LUA_API void *lua_touserdata (lua_State *L, int index); 136LUA_API void *lua_touserdata (lua_State *L, int index);
@@ -144,7 +144,9 @@ LUA_API void lua_pushnil (lua_State *L);
144LUA_API void lua_pushnumber (lua_State *L, lua_Number n); 144LUA_API void lua_pushnumber (lua_State *L, lua_Number n);
145LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len); 145LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len);
146LUA_API void lua_pushstring (lua_State *L, const char *s); 146LUA_API void lua_pushstring (lua_State *L, const char *s);
147LUA_API void lua_vpushstr (lua_State *L, const char *fmt, va_list argp); 147LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt,
148 va_list argp);
149LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...);
148LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n); 150LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n);
149LUA_API void lua_pushboolean (lua_State *L, int b); 151LUA_API void lua_pushboolean (lua_State *L, int b);
150LUA_API void lua_pushudataval (lua_State *L, void *p); 152LUA_API void lua_pushudataval (lua_State *L, void *p);
@@ -319,7 +321,7 @@ LUA_API int lua_pushupvalues (lua_State *L);
319 321
320 322
321/****************************************************************************** 323/******************************************************************************
322* Copyright (C) 1994-2001 TeCGraf, PUC-Rio. All rights reserved. 324* Copyright (C) 1994-2001 Tecgraf, PUC-Rio. All rights reserved.
323* 325*
324* Permission is hereby granted, without written agreement and without license 326* Permission is hereby granted, without written agreement and without license
325* or royalty fees, to use, copy, modify, and distribute this software and its 327* or royalty fees, to use, copy, modify, and distribute this software and its
@@ -341,14 +343,14 @@ LUA_API int lua_pushupvalues (lua_State *L);
341* to, the implied warranties of merchantability and fitness for a particular 343* to, the implied warranties of merchantability and fitness for a particular
342* purpose. The software provided hereunder is on an "as is" basis, and the 344* purpose. The software provided hereunder is on an "as is" basis, and the
343* authors have no obligation to provide maintenance, support, updates, 345* authors have no obligation to provide maintenance, support, updates,
344* enhancements, or modifications. In no event shall TeCGraf, PUC-Rio, or the 346* enhancements, or modifications. In no event shall Tecgraf, PUC-Rio, or the
345* authors be held liable to any party for direct, indirect, special, 347* authors be held liable to any party for direct, indirect, special,
346* incidental, or consequential damages arising out of the use of this software 348* incidental, or consequential damages arising out of the use of this software
347* and its documentation. 349* and its documentation.
348* 350*
349* The Lua language and this implementation have been entirely designed and 351* The Lua language and this implementation have been entirely designed and
350* written by Waldemar Celes Filho, Roberto Ierusalimschy and 352* written by Waldemar Celes Filho, Roberto Ierusalimschy and
351* Luiz Henrique de Figueiredo at TeCGraf, PUC-Rio. 353* Luiz Henrique de Figueiredo at Tecgraf, PUC-Rio.
352* 354*
353* This implementation contains no third-party code. 355* This implementation contains no third-party code.
354******************************************************************************/ 356******************************************************************************/