aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-09-11 17:29:27 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-09-11 17:29:27 -0300
commit8060193702b21a06af3541555db4cd317c733ce9 (patch)
treed1cfa3a4ac41dc6766188680659c1bd1311e22a8
parent2779e81fbbdebf8b7cac97c167ff109bad537c4b (diff)
downloadlua-8060193702b21a06af3541555db4cd317c733ce9.tar.gz
lua-8060193702b21a06af3541555db4cd317c733ce9.tar.bz2
lua-8060193702b21a06af3541555db4cd317c733ce9.zip
`lauxlib' is now part of the libraries (not used by core Lua)
-rw-r--r--lapi.c7
-rw-r--r--lauxlib.c24
-rw-r--r--lauxlib.h3
-rw-r--r--ldebug.c28
-rw-r--r--ldo.c3
-rw-r--r--liolib.c18
-rw-r--r--llex.c7
-rw-r--r--lobject.c36
-rw-r--r--lobject.h5
-rw-r--r--ltable.c3
-rw-r--r--ltm.c26
-rw-r--r--luadebug.h10
-rw-r--r--lundump.c19
-rw-r--r--makefile67
14 files changed, 134 insertions, 122 deletions
diff --git a/lapi.c b/lapi.c
index dc103bc4..8d5555e4 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 1.94 2000/09/05 19:33:32 roberto Exp roberto $ 2** $Id: lapi.c,v 1.95 2000/09/11 19:45:27 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*/
@@ -10,7 +10,6 @@
10#include "lua.h" 10#include "lua.h"
11 11
12#include "lapi.h" 12#include "lapi.h"
13#include "lauxlib.h"
14#include "ldo.h" 13#include "ldo.h"
15#include "lfunc.h" 14#include "lfunc.h"
16#include "lgc.h" 15#include "lgc.h"
@@ -234,7 +233,7 @@ void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
234void lua_pushusertag (lua_State *L, void *u, int tag) { /* ORDER LUA_T */ 233void lua_pushusertag (lua_State *L, void *u, int tag) { /* ORDER LUA_T */
235 luaC_checkGC(L); 234 luaC_checkGC(L);
236 if (tag != LUA_ANYTAG && tag != TAG_USERDATA && tag < NUM_TAGS) 235 if (tag != LUA_ANYTAG && tag != TAG_USERDATA && tag < NUM_TAGS)
237 luaL_verror(L, "invalid tag for a userdata (%d)", tag); 236 luaO_verror(L, "invalid tag for a userdata (%d)", tag);
238 tsvalue(L->top) = luaS_createudata(L, u, tag); 237 tsvalue(L->top) = luaS_createudata(L, u, tag);
239 ttype(L->top) = TAG_USERDATA; 238 ttype(L->top) = TAG_USERDATA;
240 api_incr_top(L); 239 api_incr_top(L);
@@ -387,7 +386,7 @@ void lua_settag (lua_State *L, int tag) {
387 tsvalue(L->top-1)->u.d.tag = tag; 386 tsvalue(L->top-1)->u.d.tag = tag;
388 break; 387 break;
389 default: 388 default:
390 luaL_verror(L, "cannot change the tag of a %.20s", 389 luaO_verror(L, "cannot change the tag of a %.20s",
391 luaO_typename(L->top-1)); 390 luaO_typename(L->top-1));
392 } 391 }
393 L->top--; 392 L->top--;
diff --git a/lauxlib.c b/lauxlib.c
index 84ccb3b9..ee715ab5 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.c,v 1.33 2000/08/29 20:43:28 roberto Exp roberto $ 2** $Id: lauxlib.c,v 1.34 2000/09/11 17:38:42 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*/
@@ -118,28 +118,6 @@ void luaL_verror (lua_State *L, const char *fmt, ...) {
118} 118}
119 119
120 120
121#define EXTRALEN sizeof("string \"...\"0")
122
123void luaL_chunkid (char *out, const char *source, int len) {
124 if (*source == '(') {
125 strncpy(out, source+1, len-1); /* remove first char */
126 out[len-1] = '\0'; /* make sure `out' has an end */
127 out[strlen(out)-1] = '\0'; /* remove last char */
128 }
129 else {
130 len -= EXTRALEN;
131 if (*source == '@')
132 sprintf(out, "file `%.*s'", len, source+1);
133 else {
134 const char *b = strchr(source , '\n'); /* stop at first new line */
135 int lim = (b && (b-source)<len) ? b-source : len;
136 sprintf(out, "string \"%.*s\"", lim, source);
137 strcpy(out+lim+(EXTRALEN-sizeof("...\"0")), "...\"");
138 }
139 }
140}
141
142
143/* 121/*
144** {====================================================== 122** {======================================================
145** Generic Buffer manipulation 123** Generic Buffer manipulation
diff --git a/lauxlib.h b/lauxlib.h
index de717da5..723ad84a 100644
--- a/lauxlib.h
+++ b/lauxlib.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.h,v 1.22 2000/09/04 18:27:32 roberto Exp roberto $ 2** $Id: lauxlib.h,v 1.23 2000/09/11 17:38:42 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*/
@@ -34,7 +34,6 @@ void luaL_checktype (lua_State *L, int narg, const char *tname);
34 34
35void luaL_verror (lua_State *L, const char *fmt, ...); 35void luaL_verror (lua_State *L, const char *fmt, ...);
36int luaL_findstring (const char *name, const char *const list[]); 36int luaL_findstring (const char *name, const char *const list[]);
37void luaL_chunkid (char *out, const char *source, int len);
38 37
39 38
40 39
diff --git a/ldebug.c b/ldebug.c
index 93a35ff2..59053ed0 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldebug.c,v 1.38 2000/08/28 20:22:21 roberto Exp roberto $ 2** $Id: ldebug.c,v 1.39 2000/08/31 13:29:12 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*/
@@ -10,7 +10,6 @@
10#include "lua.h" 10#include "lua.h"
11 11
12#include "lapi.h" 12#include "lapi.h"
13#include "lauxlib.h"
14#include "lcode.h" 13#include "lcode.h"
15#include "ldebug.h" 14#include "ldebug.h"
16#include "ldo.h" 15#include "ldo.h"
@@ -18,6 +17,7 @@
18#include "lobject.h" 17#include "lobject.h"
19#include "lopcodes.h" 18#include "lopcodes.h"
20#include "lstate.h" 19#include "lstate.h"
20#include "lstring.h"
21#include "ltable.h" 21#include "ltable.h"
22#include "ltm.h" 22#include "ltm.h"
23#include "luadebug.h" 23#include "luadebug.h"
@@ -172,17 +172,20 @@ const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int localnum) {
172} 172}
173 173
174 174
175static void infoLproto (lua_Debug *ar, Proto *f) {
176 ar->source = f->source->str;
177 ar->linedefined = f->lineDefined;
178 ar->what = "Lua";
179}
180
181
175static void lua_funcinfo (lua_Debug *ar, StkId func) { 182static void lua_funcinfo (lua_Debug *ar, StkId func) {
176 switch (ttype(func)) { 183 switch (ttype(func)) {
177 case TAG_LCLOSURE: 184 case TAG_LCLOSURE:
178 ar->source = clvalue(func)->f.l->source->str; 185 infoLproto(ar, clvalue(func)->f.l);
179 ar->linedefined = clvalue(func)->f.l->lineDefined;
180 ar->what = "Lua";
181 break; 186 break;
182 case TAG_LMARK: 187 case TAG_LMARK:
183 ar->source = infovalue(func)->func->f.l->source->str; 188 infoLproto(ar, infovalue(func)->func->f.l);
184 ar->linedefined = infovalue(func)->func->f.l->lineDefined;
185 ar->what = "Lua";
186 break; 189 break;
187 case TAG_CCLOSURE: case TAG_CMARK: 190 case TAG_CCLOSURE: case TAG_CMARK:
188 ar->source = "(C)"; 191 ar->source = "(C)";
@@ -192,6 +195,7 @@ static void lua_funcinfo (lua_Debug *ar, StkId func) {
192 default: 195 default:
193 LUA_INTERNALERROR("invalid `func' value"); 196 LUA_INTERNALERROR("invalid `func' value");
194 } 197 }
198 luaO_chunkid(ar->source_id, ar->source, sizeof(ar->source_id));
195 if (ar->linedefined == 0) 199 if (ar->linedefined == 0)
196 ar->what = "main"; 200 ar->what = "main";
197} 201}
@@ -431,10 +435,10 @@ void luaG_typeerror (lua_State *L, StkId o, const char *op) {
431 const char *kind = getobjname(L, o, &name); 435 const char *kind = getobjname(L, o, &name);
432 const char *t = luaO_typename(o); 436 const char *t = luaO_typename(o);
433 if (kind) 437 if (kind)
434 luaL_verror(L, "attempt to %.30s %.20s `%.40s' (a %.10s value)", 438 luaO_verror(L, "attempt to %.30s %.20s `%.40s' (a %.10s value)",
435 op, kind, name, t); 439 op, kind, name, t);
436 else 440 else
437 luaL_verror(L, "attempt to %.30s a %.10s value", op, t); 441 luaO_verror(L, "attempt to %.30s a %.10s value", op, t);
438} 442}
439 443
440 444
@@ -449,8 +453,8 @@ void luaG_ordererror (lua_State *L, StkId top) {
449 const char *t1 = luaO_typename(top-2); 453 const char *t1 = luaO_typename(top-2);
450 const char *t2 = luaO_typename(top-1); 454 const char *t2 = luaO_typename(top-1);
451 if (t1[2] == t2[2]) 455 if (t1[2] == t2[2])
452 luaL_verror(L, "attempt to compare two %.10s values", t1); 456 luaO_verror(L, "attempt to compare two %.10s values", t1);
453 else 457 else
454 luaL_verror(L, "attempt to compare %.10s with %.10s", t1, t2); 458 luaO_verror(L, "attempt to compare %.10s with %.10s", t1, t2);
455} 459}
456 460
diff --git a/ldo.c b/ldo.c
index 1fd993c7..220be2f9 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 1.93 2000/09/04 18:52:51 roberto Exp roberto $ 2** $Id: ldo.c,v 1.94 2000/09/11 17:38:42 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*/
@@ -12,7 +12,6 @@
12 12
13#include "lua.h" 13#include "lua.h"
14 14
15#include "lauxlib.h"
16#include "ldebug.h" 15#include "ldebug.h"
17#include "ldo.h" 16#include "ldo.h"
18#include "lgc.h" 17#include "lgc.h"
diff --git a/liolib.c b/liolib.c
index db9f36d6..055508c5 100644
--- a/liolib.c
+++ b/liolib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: liolib.c,v 1.77 2000/09/05 19:33:32 roberto Exp $ 2** $Id: liolib.c,v 1.78 2000/09/11 17:38:42 roberto Exp roberto $
3** Standard I/O (and system) library 3** Standard I/O (and system) library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -393,8 +393,8 @@ static int io_read (lua_State *L) {
393 firstarg = lastarg = 1; /* correct indices */ 393 firstarg = lastarg = 1; /* correct indices */
394 lua_pushstring(L, "*l"); /* push default argument */ 394 lua_pushstring(L, "*l"); /* push default argument */
395 } 395 }
396 else 396 else /* ensure stack space for all results and for auxlib's buffer */
397 luaL_checkstack(L, lastarg-firstarg+1, "too many arguments"); 397 luaL_checkstack(L, lastarg-firstarg+1+LUA_MINSTACK, "too many arguments");
398 for (n = firstarg; n<=lastarg; n++) { 398 for (n = firstarg; n<=lastarg; n++) {
399 int success; 399 int success;
400 if (lua_isnumber(L, n)) 400 if (lua_isnumber(L, n))
@@ -598,7 +598,6 @@ static int errorfb (lua_State *L) {
598 lua_concat(L, 3); 598 lua_concat(L, 3);
599 while (lua_getstack(L, level++, &ar)) { 599 while (lua_getstack(L, level++, &ar)) {
600 char buff[120]; /* enough to fit following `sprintf's */ 600 char buff[120]; /* enough to fit following `sprintf's */
601 char buffchunk[60];
602 int toconcat = 1; /* number of strings in the stack to concat */ 601 int toconcat = 1; /* number of strings in the stack to concat */
603 if (level > LEVELS1 && firstpart) { 602 if (level > LEVELS1 && firstpart) {
604 /* no more than `LEVELS2' more levels? */ 603 /* no more than `LEVELS2' more levels? */
@@ -607,7 +606,7 @@ static int errorfb (lua_State *L) {
607 else { 606 else {
608 lua_pushstring(L, " ...\n"); /* too many levels */ 607 lua_pushstring(L, " ...\n"); /* too many levels */
609 lua_concat(L, 2); 608 lua_concat(L, 2);
610 while (lua_getstack(L, level+LEVELS2, &ar)) /* get last levels */ 609 while (lua_getstack(L, level+LEVELS2, &ar)) /* find last levels */
611 level++; 610 level++;
612 } 611 }
613 firstpart = 0; 612 firstpart = 0;
@@ -616,7 +615,6 @@ static int errorfb (lua_State *L) {
616 sprintf(buff, "%4d: ", level-1); 615 sprintf(buff, "%4d: ", level-1);
617 lua_pushstring(L, buff); toconcat++; 616 lua_pushstring(L, buff); toconcat++;
618 lua_getinfo(L, "Snl", &ar); 617 lua_getinfo(L, "Snl", &ar);
619 luaL_chunkid(buffchunk, ar.source, sizeof(buffchunk));
620 switch (*ar.namewhat) { 618 switch (*ar.namewhat) {
621 case 'g': case 'l': /* global, local */ 619 case 'g': case 'l': /* global, local */
622 sprintf(buff, "function `%.50s'", ar.name); 620 sprintf(buff, "function `%.50s'", ar.name);
@@ -629,11 +627,11 @@ static int errorfb (lua_State *L) {
629 break; 627 break;
630 default: { 628 default: {
631 if (*ar.what == 'm') /* main? */ 629 if (*ar.what == 'm') /* main? */
632 sprintf(buff, "main of %.70s", buffchunk); 630 sprintf(buff, "main of %.70s", ar.source_id);
633 else if (*ar.what == 'C') /* C function? */ 631 else if (*ar.what == 'C') /* C function? */
634 sprintf(buff, "%.70s", buffchunk); 632 sprintf(buff, "%.70s", ar.source_id);
635 else 633 else
636 sprintf(buff, "function <%d:%.70s>", ar.linedefined, buffchunk); 634 sprintf(buff, "function <%d:%.70s>", ar.linedefined, ar.source_id);
637 ar.source = NULL; 635 ar.source = NULL;
638 } 636 }
639 } 637 }
@@ -643,7 +641,7 @@ static int errorfb (lua_State *L) {
643 lua_pushstring(L, buff); toconcat++; 641 lua_pushstring(L, buff); toconcat++;
644 } 642 }
645 if (ar.source) { 643 if (ar.source) {
646 sprintf(buff, " [%.70s]", buffchunk); 644 sprintf(buff, " [%.70s]", ar.source_id);
647 lua_pushstring(L, buff); toconcat++; 645 lua_pushstring(L, buff); toconcat++;
648 } 646 }
649 lua_pushstring(L, "\n"); toconcat++; 647 lua_pushstring(L, "\n"); toconcat++;
diff --git a/llex.c b/llex.c
index d16cb99f..e4c4936a 100644
--- a/llex.c
+++ b/llex.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llex.c,v 1.68 2000/08/22 20:07:56 roberto Exp $ 2** $Id: llex.c,v 1.69 2000/09/11 17:38:42 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*/
@@ -11,7 +11,6 @@
11 11
12#include "lua.h" 12#include "lua.h"
13 13
14#include "lauxlib.h"
15#include "llex.h" 14#include "llex.h"
16#include "lmem.h" 15#include "lmem.h"
17#include "lobject.h" 16#include "lobject.h"
@@ -58,8 +57,8 @@ void luaX_checklimit (LexState *ls, int val, int limit, const char *msg) {
58 57
59void luaX_syntaxerror (LexState *ls, const char *s, const char *token) { 58void luaX_syntaxerror (LexState *ls, const char *s, const char *token) {
60 char buff[MAXSRC]; 59 char buff[MAXSRC];
61 luaL_chunkid(buff, ls->source->str, sizeof(buff)); 60 luaO_chunkid(buff, ls->source->str, sizeof(buff));
62 luaL_verror(ls->L, "%.100s;\n last token read: `%.50s' at line %d in %.80s", 61 luaO_verror(ls->L, "%.100s;\n last token read: `%.50s' at line %d in %.80s",
63 s, token, ls->linenumber, buff); 62 s, token, ls->linenumber, buff);
64} 63}
65 64
diff --git a/lobject.c b/lobject.c
index 7f3d71fc..c4f45d8b 100644
--- a/lobject.c
+++ b/lobject.c
@@ -1,11 +1,14 @@
1/* 1/*
2** $Id: lobject.c,v 1.45 2000/08/11 16:17:28 roberto Exp roberto $ 2** $Id: lobject.c,v 1.46 2000/09/11 17:38:42 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*/
6 6
7#include <ctype.h> 7#include <ctype.h>
8#include <stdarg.h>
9#include <stdio.h>
8#include <stdlib.h> 10#include <stdlib.h>
11#include <string.h>
9 12
10#include "lua.h" 13#include "lua.h"
11 14
@@ -123,3 +126,34 @@ int luaO_str2d (const char *s, Number *result) { /* LUA_NUMBER */
123 return 1; 126 return 1;
124} 127}
125 128
129
130void luaO_verror (lua_State *L, const char *fmt, ...) {
131 char buff[500];
132 va_list argp;
133 va_start(argp, fmt);
134 vsprintf(buff, fmt, argp);
135 va_end(argp);
136 lua_error(L, buff);
137}
138
139
140#define EXTRALEN sizeof("string \"...\"0")
141
142void luaO_chunkid (char *out, const char *source, int len) {
143 if (*source == '(') {
144 strncpy(out, source+1, len-1); /* remove first char */
145 out[len-1] = '\0'; /* make sure `out' has an end */
146 out[strlen(out)-1] = '\0'; /* remove last char */
147 }
148 else {
149 len -= EXTRALEN;
150 if (*source == '@')
151 sprintf(out, "file `%.*s'", len, source+1);
152 else {
153 const char *b = strchr(source , '\n'); /* stop at first new line */
154 int lim = (b && (b-source)<len) ? b-source : len;
155 sprintf(out, "string \"%.*s\"", lim, source);
156 strcpy(out+lim+(EXTRALEN-sizeof("...\"0")), "...\"");
157 }
158 }
159}
diff --git a/lobject.h b/lobject.h
index d36391a6..c455bc3d 100644
--- a/lobject.h
+++ b/lobject.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.h,v 1.74 2000/08/22 17:44:17 roberto Exp roberto $ 2** $Id: lobject.h,v 1.75 2000/09/11 17:38:42 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*/
@@ -198,5 +198,8 @@ char *luaO_openspace (lua_State *L, size_t n);
198int luaO_equalObj (const TObject *t1, const TObject *t2); 198int luaO_equalObj (const TObject *t1, const TObject *t2);
199int luaO_str2d (const char *s, Number *result); 199int luaO_str2d (const char *s, Number *result);
200 200
201void luaO_verror (lua_State *L, const char *fmt, ...);
202void luaO_chunkid (char *out, const char *source, int len);
203
201 204
202#endif 205#endif
diff --git a/ltable.c b/ltable.c
index 3d2c4765..2f7ef3dc 100644
--- a/ltable.c
+++ b/ltable.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.c,v 1.53 2000/08/09 19:16:57 roberto Exp roberto $ 2** $Id: ltable.c,v 1.54 2000/08/31 14:08:27 roberto Exp roberto $
3** Lua tables (hash) 3** Lua tables (hash)
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -20,7 +20,6 @@
20 20
21#include "lua.h" 21#include "lua.h"
22 22
23#include "lauxlib.h"
24#include "lmem.h" 23#include "lmem.h"
25#include "lobject.h" 24#include "lobject.h"
26#include "lstate.h" 25#include "lstate.h"
diff --git a/ltm.c b/ltm.c
index a1ed11dc..ca4ea88d 100644
--- a/ltm.c
+++ b/ltm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltm.c,v 1.47 2000/09/05 19:33:32 roberto Exp roberto $ 2** $Id: ltm.c,v 1.48 2000/09/11 19:45:27 roberto Exp roberto $
3** Tag methods 3** Tag methods
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -10,7 +10,6 @@
10 10
11#include "lua.h" 11#include "lua.h"
12 12
13#include "lauxlib.h"
14#include "ldo.h" 13#include "ldo.h"
15#include "lmem.h" 14#include "lmem.h"
16#include "lobject.h" 15#include "lobject.h"
@@ -26,14 +25,23 @@ const char *const luaT_eventname[] = { /* ORDER IM */
26}; 25};
27 26
28 27
28static int findevent (const char *name) {
29 int i;
30 for (i=0; luaT_eventname[i]; i++)
31 if (strcmp(luaT_eventname[i], name) == 0)
32 return i;
33 return -1; /* name not found */
34}
35
36
29static int luaI_checkevent (lua_State *L, const char *name, int t) { 37static int luaI_checkevent (lua_State *L, const char *name, int t) {
30 int e = luaL_findstring(name, luaT_eventname); 38 int e = findevent(name);
31 if (e >= IM_N) 39 if (e >= IM_N)
32 luaL_verror(L, "event `%.50s' is deprecated", name); 40 luaO_verror(L, "event `%.50s' is deprecated", name);
33 if (e == IM_GC && t == TAG_TABLE) 41 if (e == IM_GC && t == TAG_TABLE)
34 luaL_verror(L, "event `gc' for tables is deprecated"); 42 luaO_verror(L, "event `gc' for tables is deprecated");
35 if (e < 0) 43 if (e < 0)
36 luaL_verror(L, "`%.50s' is not a valid event name", name); 44 luaO_verror(L, "`%.50s' is not a valid event name", name);
37 return e; 45 return e;
38} 46}
39 47
@@ -86,12 +94,12 @@ int lua_newtag (lua_State *L) {
86 94
87static void checktag (lua_State *L, int tag) { 95static void checktag (lua_State *L, int tag) {
88 if (!(0 <= tag && tag <= L->last_tag)) 96 if (!(0 <= tag && tag <= L->last_tag))
89 luaL_verror(L, "%d is not a valid tag", tag); 97 luaO_verror(L, "%d is not a valid tag", tag);
90} 98}
91 99
92void luaT_realtag (lua_State *L, int tag) { 100void luaT_realtag (lua_State *L, int tag) {
93 if (!(NUM_TAGS <= tag && tag <= L->last_tag)) 101 if (!(NUM_TAGS <= tag && tag <= L->last_tag))
94 luaL_verror(L, "tag %d was not created by `newtag'", tag); 102 luaO_verror(L, "tag %d was not created by `newtag'", tag);
95} 103}
96 104
97 105
@@ -140,7 +148,7 @@ void lua_settagmethod (lua_State *L, int t, const char *event) {
140 e = luaI_checkevent(L, event, t); 148 e = luaI_checkevent(L, event, t);
141 checktag(L, t); 149 checktag(L, t);
142 if (!luaT_validevent(t, e)) 150 if (!luaT_validevent(t, e))
143 luaL_verror(L, "cannot change `%.20s' tag method for type `%.20s'%.20s", 151 luaO_verror(L, "cannot change `%.20s' tag method for type `%.20s'%.20s",
144 luaT_eventname[e], luaO_typenames[t], 152 luaT_eventname[e], luaO_typenames[t],
145 (t == TAG_TABLE || t == TAG_USERDATA) ? " with default tag" 153 (t == TAG_TABLE || t == TAG_USERDATA) ? " with default tag"
146 : ""); 154 : "");
diff --git a/luadebug.h b/luadebug.h
index 67472ad9..f81496e1 100644
--- a/luadebug.h
+++ b/luadebug.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: luadebug.h,v 1.12 2000/08/11 16:17:28 roberto Exp roberto $ 2** $Id: luadebug.h,v 1.13 2000/08/28 17:57:04 roberto Exp roberto $
3** Debugging API 3** Debugging API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -26,16 +26,18 @@ lua_Hook lua_setcallhook (lua_State *L, lua_Hook func);
26lua_Hook lua_setlinehook (lua_State *L, lua_Hook func); 26lua_Hook lua_setlinehook (lua_State *L, lua_Hook func);
27 27
28 28
29#define LUA_IDSIZE 60
29 30
30struct lua_Debug { 31struct lua_Debug {
31 const char *event; /* `call', `return' */ 32 const char *event; /* `call', `return' */
32 const char *source; /* (S) */
33 int linedefined; /* (S) */
34 const char *what; /* (S) `Lua' function, `C' function, Lua `main' */
35 int currentline; /* (l) */ 33 int currentline; /* (l) */
36 const char *name; /* (n) */ 34 const char *name; /* (n) */
37 const char *namewhat; /* (n) `global', `tag method', `local', `field' */ 35 const char *namewhat; /* (n) `global', `tag method', `local', `field' */
38 int nups; /* (u) number of upvalues */ 36 int nups; /* (u) number of upvalues */
37 int linedefined; /* (S) */
38 const char *what; /* (S) `Lua' function, `C' function, Lua `main' */
39 const char *source; /* (S) */
40 char source_id[LUA_IDSIZE]; /* (S) */
39 /* private part */ 41 /* private part */
40 struct lua_TObject *_func; /* active function */ 42 struct lua_TObject *_func; /* active function */
41}; 43};
diff --git a/lundump.c b/lundump.c
index 95690033..d8f74758 100644
--- a/lundump.c
+++ b/lundump.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lundump.c,v 1.27 2000/09/04 18:53:41 roberto Exp roberto $ 2** $Id: lundump.c,v 1.28 2000/09/11 17:38:42 roberto Exp roberto $
3** load bytecodes from files 3** load bytecodes from files
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -7,7 +7,6 @@
7#include <stdio.h> 7#include <stdio.h>
8#include <string.h> 8#include <string.h>
9 9
10#include "lauxlib.h"
11#include "lfunc.h" 10#include "lfunc.h"
12#include "lmem.h" 11#include "lmem.h"
13#include "lopcodes.h" 12#include "lopcodes.h"
@@ -26,7 +25,7 @@ static const char* ZNAME(ZIO* Z)
26 25
27static void unexpectedEOZ (lua_State* L, ZIO* Z) 26static void unexpectedEOZ (lua_State* L, ZIO* Z)
28{ 27{
29 luaL_verror(L,"unexpected end of file in `%.255s'",ZNAME(Z)); 28 luaO_verror(L,"unexpected end of file in `%.255s'",ZNAME(Z));
30} 29}
31 30
32static int ezgetc (lua_State* L, ZIO* Z) 31static int ezgetc (lua_State* L, ZIO* Z)
@@ -100,7 +99,7 @@ static void LoadCode (lua_State* L, Proto* tf, ZIO* Z, int swap)
100#if 0 99#if 0
101 if (swap) SwapBytes(tf->code,sizeof(*tf->code),size); 100 if (swap) SwapBytes(tf->code,sizeof(*tf->code),size);
102#endif 101#endif
103 if (tf->code[size-1]!=OP_END) luaL_verror(L,"bad code in `%.255s'",ZNAME(Z)); 102 if (tf->code[size-1]!=OP_END) luaO_verror(L,"bad code in `%.255s'",ZNAME(Z));
104} 103}
105 104
106static void LoadLocals (lua_State* L, Proto* tf, ZIO* Z, int swap) 105static void LoadLocals (lua_State* L, Proto* tf, ZIO* Z, int swap)
@@ -167,14 +166,14 @@ static void LoadSignature (lua_State* L, ZIO* Z)
167 const char* s=SIGNATURE; 166 const char* s=SIGNATURE;
168 while (*s!=0 && ezgetc(L,Z)==*s) 167 while (*s!=0 && ezgetc(L,Z)==*s)
169 ++s; 168 ++s;
170 if (*s!=0) luaL_verror(L,"bad signature in `%.255s'",ZNAME(Z)); 169 if (*s!=0) luaO_verror(L,"bad signature in `%.255s'",ZNAME(Z));
171} 170}
172 171
173static void TestSize (lua_State* L, int s, const char* what, ZIO* Z) 172static void TestSize (lua_State* L, int s, const char* what, ZIO* Z)
174{ 173{
175 int r=ezgetc(L,Z); 174 int r=ezgetc(L,Z);
176 if (r!=s) 175 if (r!=s)
177 luaL_verror(L,"virtual machine mismatch in `%.255s':\n" 176 luaO_verror(L,"virtual machine mismatch in `%.255s':\n"
178 " %s is %d but read %d",ZNAME(Z),what,r,s); 177 " %s is %d but read %d",ZNAME(Z),what,r,s);
179} 178}
180 179
@@ -188,11 +187,11 @@ static int LoadHeader (lua_State* L, ZIO* Z)
188 LoadSignature(L,Z); 187 LoadSignature(L,Z);
189 version=ezgetc(L,Z); 188 version=ezgetc(L,Z);
190 if (version>VERSION) 189 if (version>VERSION)
191 luaL_verror(L,"`%.255s' too new:\n" 190 luaO_verror(L,"`%.255s' too new:\n"
192 " read version %d.%d; expected at most %d.%d", 191 " read version %d.%d; expected at most %d.%d",
193 ZNAME(Z),V(version),V(VERSION)); 192 ZNAME(Z),V(version),V(VERSION));
194 if (version<VERSION0) /* check last major change */ 193 if (version<VERSION0) /* check last major change */
195 luaL_verror(L,"`%.255s' too old:\n" 194 luaO_verror(L,"`%.255s' too old:\n"
196 " read version %d.%d; expected at least %d.%d", 195 " read version %d.%d; expected at least %d.%d",
197 ZNAME(Z),V(version),V(VERSION)); 196 ZNAME(Z),V(version),V(VERSION));
198 swap=(luaU_endianess()!=ezgetc(L,Z)); /* need to swap bytes? */ 197 swap=(luaU_endianess()!=ezgetc(L,Z)); /* need to swap bytes? */
@@ -205,7 +204,7 @@ static int LoadHeader (lua_State* L, ZIO* Z)
205 TESTSIZE(sizeof(Number)); 204 TESTSIZE(sizeof(Number));
206 f=LoadNumber(L,Z,swap); 205 f=LoadNumber(L,Z,swap);
207 if ((long)f!=(long)tf) /* disregard errors in last bit of fraction */ 206 if ((long)f!=(long)tf) /* disregard errors in last bit of fraction */
208 luaL_verror(L,"unknown number format in `%.255s':\n" 207 luaO_verror(L,"unknown number format in `%.255s':\n"
209 " read " NUMBER_FMT "; expected " NUMBER_FMT, 208 " read " NUMBER_FMT "; expected " NUMBER_FMT,
210 ZNAME(Z),f,tf); 209 ZNAME(Z),f,tf);
211 return swap; 210 return swap;
@@ -226,7 +225,7 @@ Proto* luaU_undump (lua_State* L, ZIO* Z)
226 if (c==ID_CHUNK) 225 if (c==ID_CHUNK)
227 return LoadChunk(L,Z); 226 return LoadChunk(L,Z);
228 else if (c!=EOZ) 227 else if (c!=EOZ)
229 luaL_verror(L,"`%.255s' is not a precompiled Lua chunk",ZNAME(Z)); 228 luaO_verror(L,"`%.255s' is not a precompiled Lua chunk",ZNAME(Z));
230 return NULL; 229 return NULL;
231} 230}
232 231
diff --git a/makefile b/makefile
index a4a7e10c..f9726874 100644
--- a/makefile
+++ b/makefile
@@ -1,5 +1,5 @@
1# 1#
2## $Id: makefile,v 1.25 2000/04/24 21:05:11 roberto Exp roberto $ 2## $Id: makefile,v 1.26 2000/08/09 19:16:57 roberto Exp roberto $
3## Makefile 3## Makefile
4## See Copyright Notice in lua.h 4## See Copyright Notice in lua.h
5# 5#
@@ -25,13 +25,13 @@
25# are passed as arguments 25# are passed as arguments
26# define LUA_DEPRECATETFUNCS to include obsolete functions 26# define LUA_DEPRECATETFUNCS to include obsolete functions
27 27
28CONFIG = -DPOPEN -D_POSIX_SOURCE -DDEBUG 28CONFIG = -DPOPEN -D_POSIX_SOURCE
29#CONFIG = -DOLD_ANSI -DDEBUG -DLUA_COMPAT_READPATTERN -DLUA_COMPAT_ARGRET 29#CONFIG = -DOLD_ANSI -DDEBUG -DLUA_COMPAT_READPATTERN -DLUA_COMPAT_ARGRET
30# -DLUA_DEPRECATETFUNCS 30# -DLUA_DEPRECATETFUNCS
31 31
32 32
33# Compilation parameters 33# Compilation parameters
34CC = g++ 34CC = gcc
35CWARNS = -Wall -W -pedantic \ 35CWARNS = -Wall -W -pedantic \
36 -Waggregate-return \ 36 -Waggregate-return \
37 -Wcast-align \ 37 -Wcast-align \
@@ -57,10 +57,7 @@ ARFLAGS = rvl
57# Aplication modules 57# Aplication modules
58LUAOBJS = \ 58LUAOBJS = \
59 lstate.o \ 59 lstate.o \
60 lref.o \
61 lapi.o \ 60 lapi.o \
62 lauxlib.o \
63 lbuiltin.o \
64 lmem.o \ 61 lmem.o \
65 lstring.o \ 62 lstring.o \
66 ltable.o \ 63 ltable.o \
@@ -68,7 +65,6 @@ LUAOBJS = \
68 lvm.o \ 65 lvm.o \
69 ldo.o \ 66 ldo.o \
70 lobject.o \ 67 lobject.o \
71 lbuffer.o \
72 lfunc.o \ 68 lfunc.o \
73 lgc.o \ 69 lgc.o \
74 lcode.o \ 70 lcode.o \
@@ -80,6 +76,8 @@ LUAOBJS = \
80 ltests.o 76 ltests.o
81 77
82LIBOBJS = \ 78LIBOBJS = \
79 lauxlib.o \
80 lbaselib.o \
83 liolib.o \ 81 liolib.o \
84 lmathlib.o \ 82 lmathlib.o \
85 lstrlib.o \ 83 lstrlib.o \
@@ -113,57 +111,50 @@ clear :
113 co $(CO_OPTIONS) $@ 111 co $(CO_OPTIONS) $@
114 112
115 113
116lapi.o: lapi.c lua.h lapi.h lobject.h llimits.h lauxlib.h ldo.h \ 114lapi.o: lapi.c lua.h lapi.h lobject.h llimits.h ldo.h lstate.h \
117 lstate.h luadebug.h lfunc.h lgc.h lmem.h lref.h lstring.h ltable.h \ 115 luadebug.h lfunc.h lgc.h lmem.h lstring.h ltable.h ltm.h lvm.h
118 ltm.h lvm.h
119lauxlib.o: lauxlib.c lua.h lauxlib.h luadebug.h 116lauxlib.o: lauxlib.c lua.h lauxlib.h luadebug.h
120lbuffer.o: lbuffer.c lua.h lauxlib.h lmem.h llimits.h lstate.h \ 117lbaselib.o: lbaselib.c lua.h lauxlib.h lualib.h
121 lobject.h luadebug.h
122lbuiltin.o: lbuiltin.c lua.h lapi.h lobject.h llimits.h lauxlib.h \
123 lbuiltin.h ldo.h lstate.h luadebug.h lfunc.h lmem.h lstring.h \
124 ltable.h ltm.h lundump.h lzio.h lvm.h
125lcode.o: lcode.c /usr/include/stdlib.h lua.h lcode.h llex.h lobject.h \ 118lcode.o: lcode.c /usr/include/stdlib.h lua.h lcode.h llex.h lobject.h \
126 llimits.h lzio.h lopcodes.h lparser.h ldo.h lstate.h luadebug.h \ 119 llimits.h lzio.h lopcodes.h lparser.h ldo.h lstate.h luadebug.h \
127 lmem.h 120 lmem.h
128ldblib.o: ldblib.c lua.h lauxlib.h luadebug.h lualib.h 121ldblib.o: ldblib.c lua.h lauxlib.h luadebug.h lualib.h
129ldebug.o: ldebug.c lua.h lapi.h lobject.h llimits.h lauxlib.h lcode.h \ 122ldebug.o: ldebug.c lua.h lapi.h lobject.h llimits.h lcode.h llex.h \
130 llex.h lzio.h lopcodes.h lparser.h ldebug.h lstate.h luadebug.h ldo.h \ 123 lzio.h lopcodes.h lparser.h ldebug.h lstate.h luadebug.h ldo.h \
131 lfunc.h ltable.h ltm.h 124 lfunc.h lstring.h ltable.h ltm.h
132ldo.o: ldo.c lua.h lauxlib.h ldebug.h lstate.h lobject.h llimits.h \ 125ldo.o: ldo.c lua.h ldebug.h lstate.h lobject.h llimits.h luadebug.h \
133 luadebug.h ldo.h lgc.h lmem.h lparser.h lzio.h lstring.h ltable.h \ 126 ldo.h lgc.h lmem.h lparser.h lzio.h lstring.h ltable.h ltm.h \
134 ltm.h lundump.h lvm.h 127 lundump.h lvm.h
135lfunc.o: lfunc.c lua.h lfunc.h lobject.h llimits.h lmem.h lstate.h \ 128lfunc.o: lfunc.c lua.h lfunc.h lobject.h llimits.h lmem.h lstate.h \
136 luadebug.h 129 luadebug.h
137lgc.o: lgc.c lua.h ldo.h lobject.h llimits.h lstate.h luadebug.h \ 130lgc.o: lgc.c lua.h ldo.h lobject.h llimits.h lstate.h luadebug.h \
138 lfunc.h lgc.h lmem.h lref.h lstring.h ltable.h ltm.h 131 lfunc.h lgc.h lmem.h lstring.h ltable.h ltm.h
139liolib.o: liolib.c lua.h lauxlib.h luadebug.h lualib.h 132liolib.o: liolib.c lua.h lauxlib.h luadebug.h lualib.h
140llex.o: llex.c lua.h lauxlib.h llex.h lobject.h llimits.h lzio.h \ 133llex.o: llex.c lua.h llex.h lobject.h llimits.h lzio.h lmem.h \
141 lmem.h lparser.h lstate.h luadebug.h lstring.h ltable.h 134 lparser.h lstate.h luadebug.h lstring.h ltable.h
142lmathlib.o: lmathlib.c lua.h lauxlib.h lualib.h 135lmathlib.o: lmathlib.c lua.h lauxlib.h lualib.h
143lmem.o: lmem.c lua.h ldo.h lobject.h llimits.h lstate.h luadebug.h \ 136lmem.o: lmem.c lua.h ldo.h lobject.h llimits.h lstate.h luadebug.h \
144 lmem.h 137 lmem.h
145lobject.o: lobject.c lua.h lobject.h llimits.h 138lobject.o: lobject.c lua.h lmem.h llimits.h lobject.h lstate.h \
139 luadebug.h
146lparser.o: lparser.c lua.h lcode.h llex.h lobject.h llimits.h lzio.h \ 140lparser.o: lparser.c lua.h lcode.h llex.h lobject.h llimits.h lzio.h \
147 lopcodes.h lparser.h lfunc.h lmem.h lstate.h luadebug.h lstring.h 141 lopcodes.h lparser.h lfunc.h lmem.h lstate.h luadebug.h lstring.h
148lref.o: lref.c lua.h lapi.h lobject.h llimits.h lmem.h lref.h lstate.h \ 142lstate.o: lstate.c lua.h ldo.h lobject.h llimits.h lstate.h luadebug.h \
149 luadebug.h 143 lgc.h llex.h lzio.h lmem.h lstring.h ltable.h ltm.h
150lstate.o: lstate.c lua.h lauxlib.h lbuiltin.h ldo.h lobject.h \
151 llimits.h lstate.h luadebug.h lgc.h llex.h lzio.h lmem.h lref.h \
152 lstring.h ltable.h ltm.h
153lstring.o: lstring.c lua.h lmem.h llimits.h lobject.h lstate.h \ 144lstring.o: lstring.c lua.h lmem.h llimits.h lobject.h lstate.h \
154 luadebug.h lstring.h 145 luadebug.h lstring.h
155lstrlib.o: lstrlib.c lua.h lauxlib.h lualib.h 146lstrlib.o: lstrlib.c lua.h lauxlib.h lualib.h
156ltable.o: ltable.c lua.h lauxlib.h lmem.h llimits.h lobject.h lstate.h \ 147ltable.o: ltable.c lua.h lmem.h llimits.h lobject.h lstate.h \
157 luadebug.h lstring.h ltable.h 148 luadebug.h lstring.h ltable.h
158ltests.o: ltests.c lua.h lapi.h lobject.h llimits.h lauxlib.h lcode.h \ 149ltests.o: ltests.c lua.h lapi.h lobject.h llimits.h lauxlib.h lcode.h \
159 llex.h lzio.h lopcodes.h lparser.h ldebug.h lstate.h luadebug.h ldo.h \ 150 llex.h lzio.h lopcodes.h lparser.h ldebug.h lstate.h luadebug.h ldo.h \
160 lfunc.h lmem.h lstring.h ltable.h 151 lfunc.h lmem.h lstring.h ltable.h
161ltm.o: ltm.c lua.h lauxlib.h lmem.h llimits.h lobject.h lstate.h \ 152ltm.o: ltm.c lua.h ldo.h lobject.h llimits.h lstate.h luadebug.h \
162 luadebug.h ltm.h 153 lmem.h ltm.h
163lua.o: lua.c lua.h luadebug.h lualib.h 154lua.o: lua.c lua.h luadebug.h lualib.h
164lundump.o: lundump.c lua.h lauxlib.h lfunc.h lobject.h llimits.h \ 155lundump.o: lundump.c lfunc.h lobject.h llimits.h lua.h lmem.h \
165 lmem.h lopcodes.h lstring.h lstate.h luadebug.h lundump.h lzio.h 156 lopcodes.h lstring.h lstate.h luadebug.h lundump.h lzio.h
166lvm.o: lvm.c lua.h lapi.h lobject.h llimits.h lauxlib.h ldebug.h \ 157lvm.o: lvm.c lua.h lapi.h lobject.h llimits.h ldebug.h lstate.h \
167 lstate.h luadebug.h ldo.h lfunc.h lgc.h lopcodes.h lstring.h ltable.h \ 158 luadebug.h ldo.h lfunc.h lgc.h lopcodes.h lstring.h ltable.h ltm.h \
168 ltm.h lvm.h 159 lvm.h
169lzio.o: lzio.c lua.h lzio.h 160lzio.o: lzio.c lua.h lzio.h