aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lapi.c13
-rw-r--r--lgc.c6
-rw-r--r--liolib.c30
-rw-r--r--llimits.h7
-rw-r--r--lmathlib.c10
-rw-r--r--lmem.c5
-rw-r--r--lobject.h5
-rw-r--r--lstate.c3
-rw-r--r--lstring.c35
-rw-r--r--lstring.h4
-rw-r--r--ltable.c4
-rw-r--r--ltests.c7
-rw-r--r--lua.h4
-rw-r--r--lvm.c16
14 files changed, 83 insertions, 66 deletions
diff --git a/lapi.c b/lapi.c
index f0c64191..adcd0ef1 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 1.107 2000/10/20 16:39:03 roberto Exp roberto $ 2** $Id: lapi.c,v 1.108 2000/10/24 19:19:15 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*/
@@ -173,7 +173,7 @@ LUA_API const char *lua_tostring (lua_State *L, int index) {
173LUA_API size_t lua_strlen (lua_State *L, int index) { 173LUA_API size_t lua_strlen (lua_State *L, int index) {
174 StkId o = luaA_indexAcceptable(L, index); 174 StkId o = luaA_indexAcceptable(L, index);
175 if (o == NULL || tostring(L, o)) return 0; 175 if (o == NULL || tostring(L, o)) return 0;
176 else return tsvalue(o)->u.s.len; 176 else return tsvalue(o)->len;
177} 177}
178 178
179LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index) { 179LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index) {
@@ -491,3 +491,12 @@ LUA_API void lua_concat (lua_State *L, int n) {
491 luaC_checkGC(L); 491 luaC_checkGC(L);
492} 492}
493 493
494
495LUA_API void *lua_newuserdata (lua_State *L, size_t size) {
496 TString *ts = luaS_newudata(L, size, NULL);
497 tsvalue(L->top) = ts;
498 ttype(L->top) = LUA_TUSERDATA;
499 api_incr_top(L);
500 return ts->u.d.value;
501}
502
diff --git a/lgc.c b/lgc.c
index 02ca2794..3ffc331d 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 1.70 2000/10/05 12:14:08 roberto Exp roberto $ 2** $Id: lgc.c,v 1.71 2000/10/05 13:00:17 roberto Exp roberto $
3** Garbage Collector 3** Garbage Collector
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -248,7 +248,7 @@ static void collectstrings (lua_State *L, int all) {
248 else { /* collect */ 248 else { /* collect */
249 *p = next->nexthash; 249 *p = next->nexthash;
250 L->strt.nuse--; 250 L->strt.nuse--;
251 L->nblocks -= sizestring(next->u.s.len); 251 L->nblocks -= sizestring(next->len);
252 luaM_free(L, next); 252 luaM_free(L, next);
253 } 253 }
254 } 254 }
@@ -273,7 +273,7 @@ static void collectudata (lua_State *L, int all) {
273 *p = next->nexthash; 273 *p = next->nexthash;
274 next->nexthash = L->TMtable[tag].collected; /* chain udata */ 274 next->nexthash = L->TMtable[tag].collected; /* chain udata */
275 L->TMtable[tag].collected = next; 275 L->TMtable[tag].collected = next;
276 L->nblocks -= gcsizeudata; 276 L->nblocks -= sizestring(next->len);
277 L->udt.nuse--; 277 L->udt.nuse--;
278 } 278 }
279 } 279 }
diff --git a/liolib.c b/liolib.c
index 0e58a942..b1fddebe 100644
--- a/liolib.c
+++ b/liolib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: liolib.c,v 1.86 2000/10/02 20:10:55 roberto Exp roberto $ 2** $Id: liolib.c,v 1.87 2000/10/20 16:39:03 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*/
@@ -159,18 +159,9 @@ static int io_close (lua_State *L) {
159 159
160static int file_collect (lua_State *L) { 160static int file_collect (lua_State *L) {
161 IOCtrl *ctrl = (IOCtrl *)lua_touserdata(L, -1); 161 IOCtrl *ctrl = (IOCtrl *)lua_touserdata(L, -1);
162 lua_pop(L, 1); /* remove upvalue */ 162 FILE *f = getnonullfile(L, ctrl, 1);
163 if (ctrl == (IOCtrl *)lua_touserdata(L, 1)) { 163 if (f != stdin && f != stdout && f != stderr)
164 /* collecting `ctrl' itself */ 164 CLOSEFILE(L, f);
165 lua_unref(L, ctrl->ref[INFILE]);
166 lua_unref(L, ctrl->ref[OUTFILE]);
167 free(ctrl);
168 }
169 else { /* collecting a file: Close it */
170 FILE *f = getnonullfile(L, ctrl, 1);
171 if (f != stdin && f != stdout && f != stderr)
172 CLOSEFILE(L, f);
173 }
174 return 0; 165 return 0;
175} 166}
176 167
@@ -690,14 +681,13 @@ static const struct luaL_reg iolibtag[] = {
690 681
691 682
692static void openwithcontrol (lua_State *L) { 683static void openwithcontrol (lua_State *L) {
693 IOCtrl *ctrl = (IOCtrl *)malloc(sizeof(IOCtrl)); 684 IOCtrl *ctrl = (IOCtrl *)lua_newuserdata(L, sizeof(IOCtrl));
694 unsigned int i; 685 unsigned int i;
695 int ctrltag = lua_newtag(L);
696 ctrl->iotag = lua_newtag(L); 686 ctrl->iotag = lua_newtag(L);
697 ctrl->closedtag = lua_newtag(L); 687 ctrl->closedtag = lua_newtag(L);
698 for (i=0; i<sizeof(iolibtag)/sizeof(iolibtag[0]); i++) { 688 for (i=0; i<sizeof(iolibtag)/sizeof(iolibtag[0]); i++) {
699 /* put `ctrl' as upvalue for these functions */ 689 /* put `ctrl' as upvalue for these functions */
700 lua_pushusertag(L, ctrl, ctrltag); 690 lua_pushvalue(L, -1);
701 lua_pushcclosure(L, iolibtag[i].func, 1); 691 lua_pushcclosure(L, iolibtag[i].func, 1);
702 lua_setglobal(L, iolibtag[i].name); 692 lua_setglobal(L, iolibtag[i].name);
703 } 693 }
@@ -712,12 +702,10 @@ static void openwithcontrol (lua_State *L) {
712 setfilebyname(L, ctrl, stdin, "_STDIN"); 702 setfilebyname(L, ctrl, stdin, "_STDIN");
713 setfilebyname(L, ctrl, stdout, "_STDOUT"); 703 setfilebyname(L, ctrl, stdout, "_STDOUT");
714 setfilebyname(L, ctrl, stderr, "_STDERR"); 704 setfilebyname(L, ctrl, stderr, "_STDERR");
715 /* delete `ctrl' when collected */
716 lua_pushusertag(L, ctrl, ctrltag);
717 lua_pushcclosure(L, file_collect, 1);
718 lua_settagmethod(L, ctrltag, "gc");
719 /* close files when collected */ 705 /* close files when collected */
720 lua_copytagmethods(L, ctrl->iotag, ctrltag); 706 lua_pushcclosure(L, file_collect, 1); /* pops `ctrl' from stack */
707 lua_settagmethod(L, ctrl->iotag, "gc");
708 lua_pop(L, 1); /* remove tag method returned by previous call */
721} 709}
722 710
723 711
diff --git a/llimits.h b/llimits.h
index 8c0c1b48..ca1619ba 100644
--- a/llimits.h
+++ b/llimits.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llimits.h,v 1.17 2000/10/06 19:28:38 roberto Exp roberto $ 2** $Id: llimits.h,v 1.18 2000/10/09 13:47:32 roberto Exp roberto $
3** Limits, basic types, and some other "installation-dependent" definitions 3** Limits, basic types, and some other "installation-dependent" definitions
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -76,6 +76,11 @@ typedef unsigned long lint32; /* unsigned int with at least 32 bits */
76 76
77 77
78 78
79/* type to ensure maximum alignment */
80union L_Umaxalign { double d; char *s; long l; };
81
82
83
79/* 84/*
80** type for virtual-machine instructions 85** type for virtual-machine instructions
81** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h) 86** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h)
diff --git a/lmathlib.c b/lmathlib.c
index 67ef899a..6551564a 100644
--- a/lmathlib.c
+++ b/lmathlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lmathlib.c,v 1.28 2000/08/31 20:23:40 roberto Exp roberto $ 2** $Id: lmathlib.c,v 1.29 2000/10/20 16:39:03 roberto Exp roberto $
3** Standard mathematical library 3** Standard mathematical library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -230,10 +230,10 @@ static const struct luaL_reg mathlib[] = {
230*/ 230*/
231LUA_API void lua_mathlibopen (lua_State *L) { 231LUA_API void lua_mathlibopen (lua_State *L) {
232 luaL_openl(L, mathlib); 232 luaL_openl(L, mathlib);
233 lua_pushnumber(L, 0); /* to get its tag */
234 lua_pushcfunction(L, math_pow); 233 lua_pushcfunction(L, math_pow);
235 lua_settagmethod(L, lua_tag(L, -2), "pow"); 234 lua_settagmethod(L, LUA_TNUMBER, "pow");
236 lua_pop(L, 1); /* remove number */ 235 lua_pop(L, 1); /* remove result from previous call */
237 lua_pushnumber(L, PI); lua_setglobal(L, "PI"); 236 lua_pushnumber(L, PI);
237 lua_setglobal(L, "PI");
238} 238}
239 239
diff --git a/lmem.c b/lmem.c
index bd6b58da..7bcc1a35 100644
--- a/lmem.c
+++ b/lmem.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lmem.c,v 1.36 2000/08/09 19:16:57 roberto Exp roberto $ 2** $Id: lmem.c,v 1.37 2000/10/11 16:47:50 roberto Exp roberto $
3** Interface to Memory Manager 3** Interface to Memory Manager
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -35,8 +35,7 @@
35 35
36 36
37/* ensures maximum alignment for HEADER */ 37/* ensures maximum alignment for HEADER */
38union L_U { double d; char *s; long l; }; 38#define HEADER (sizeof(union L_Umaxalign))
39#define HEADER (sizeof(union L_U))
40 39
41#define MARKSIZE 16 40#define MARKSIZE 16
42#define MARK 0x55 /* 01010101 (a nice pattern) */ 41#define MARK 0x55 /* 01010101 (a nice pattern) */
diff --git a/lobject.h b/lobject.h
index dd7adeda..a3638622 100644
--- a/lobject.h
+++ b/lobject.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.h,v 1.78 2000/10/02 20:10:55 roberto Exp roberto $ 2** $Id: lobject.h,v 1.79 2000/10/05 12:14:08 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*/
@@ -73,9 +73,9 @@ typedef struct lua_TObject {
73*/ 73*/
74typedef struct TString { 74typedef struct TString {
75 union { 75 union {
76 union L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */
76 struct { /* for strings */ 77 struct { /* for strings */
77 unsigned long hash; 78 unsigned long hash;
78 size_t len;
79 int constindex; /* hint to reuse constants */ 79 int constindex; /* hint to reuse constants */
80 } s; 80 } s;
81 struct { /* for userdata */ 81 struct { /* for userdata */
@@ -83,6 +83,7 @@ typedef struct TString {
83 void *value; 83 void *value;
84 } d; 84 } d;
85 } u; 85 } u;
86 size_t len;
86 struct TString *nexthash; /* chain for hash table */ 87 struct TString *nexthash; /* chain for hash table */
87 unsigned char marked; 88 unsigned char marked;
88 char str[1]; /* variable length string!! must be the last field! */ 89 char str[1]; /* variable length string!! must be the last field! */
diff --git a/lstate.c b/lstate.c
index ba7ed328..4593e5eb 100644
--- a/lstate.c
+++ b/lstate.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstate.c,v 1.45 2000/10/20 16:39:03 roberto Exp roberto $ 2** $Id: lstate.c,v 1.46 2000/10/24 19:12:06 roberto Exp roberto $
3** Global State 3** Global State
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -98,6 +98,7 @@ LUA_API lua_State *lua_open (int stacksize) {
98 98
99 99
100LUA_API void lua_close (lua_State *L) { 100LUA_API void lua_close (lua_State *L) {
101 LUA_ASSERT(L != lua_state || lua_gettop(L) == 0, "garbage in C stack");
101 luaC_collect(L, 1); /* collect all elements */ 102 luaC_collect(L, 1); /* collect all elements */
102 LUA_ASSERT(L->rootproto == NULL, "list should be empty"); 103 LUA_ASSERT(L->rootproto == NULL, "list should be empty");
103 LUA_ASSERT(L->rootcl == NULL, "list should be empty"); 104 LUA_ASSERT(L->rootcl == NULL, "list should be empty");
diff --git a/lstring.c b/lstring.c
index 02dd54c1..7990248c 100644
--- a/lstring.c
+++ b/lstring.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstring.c,v 1.42 2000/08/09 19:16:57 roberto Exp roberto $ 2** $Id: lstring.c,v 1.43 2000/09/29 12:42:13 roberto Exp roberto $
3** String table (keeps all strings handled by Lua) 3** String table (keeps all strings handled by Lua)
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -81,17 +81,17 @@ static void newentry (lua_State *L, stringtable *tb, TString *ts, int h) {
81 81
82TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { 82TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
83 unsigned long h = hash_s(str, l); 83 unsigned long h = hash_s(str, l);
84 int h1 = h&(L->strt.size-1); 84 int h1 = h & (L->strt.size-1);
85 TString *ts; 85 TString *ts;
86 for (ts = L->strt.hash[h1]; ts; ts = ts->nexthash) { 86 for (ts = L->strt.hash[h1]; ts; ts = ts->nexthash) {
87 if (ts->u.s.len == l && (memcmp(str, ts->str, l) == 0)) 87 if (ts->len == l && (memcmp(str, ts->str, l) == 0))
88 return ts; 88 return ts;
89 } 89 }
90 /* not found */ 90 /* not found */
91 ts = (TString *)luaM_malloc(L, sizestring(l)); 91 ts = (TString *)luaM_malloc(L, sizestring(l));
92 ts->marked = 0; 92 ts->marked = 0;
93 ts->nexthash = NULL; 93 ts->nexthash = NULL;
94 ts->u.s.len = l; 94 ts->len = l;
95 ts->u.s.hash = h; 95 ts->u.s.hash = h;
96 ts->u.s.constindex = 0; 96 ts->u.s.constindex = 0;
97 memcpy(ts->str, str, l); 97 memcpy(ts->str, str, l);
@@ -102,22 +102,31 @@ TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
102} 102}
103 103
104 104
105TString *luaS_newudata (lua_State *L, size_t s, void *udata) {
106 TString *ts = (TString *)luaM_malloc(L, (lint32)sizeof(TString)+s);
107 ts->marked = 0;
108 ts->nexthash = NULL;
109 ts->len = s;
110 ts->u.d.tag = 0;
111 ts->u.d.value = (udata == NULL) ? ts+1 : udata;
112 L->nblocks += sizestring(s);
113 /* insert it on table */
114 newentry(L, &L->udt, ts, IntPoint(ts->u.d.value) & (L->udt.size-1));
115 return ts;
116}
117
118
105TString *luaS_createudata (lua_State *L, void *udata, int tag) { 119TString *luaS_createudata (lua_State *L, void *udata, int tag) {
106 unsigned long h = IntPoint(udata); 120 int h1 = IntPoint(udata) & (L->udt.size-1);
107 int h1 = h&(L->udt.size-1);
108 TString *ts; 121 TString *ts;
109 for (ts = L->udt.hash[h1]; ts; ts = ts->nexthash) { 122 for (ts = L->udt.hash[h1]; ts; ts = ts->nexthash) {
110 if (udata == ts->u.d.value && (tag == ts->u.d.tag || tag == LUA_ANYTAG)) 123 if (udata == ts->u.d.value && (tag == ts->u.d.tag || tag == LUA_ANYTAG))
111 return ts; 124 return ts;
112 } 125 }
113 /* not found */ 126 /* not found */
114 ts = luaM_new(L, TString); 127 ts = luaS_newudata(L, 0, udata);
115 ts->marked = 0; 128 if (tag != LUA_ANYTAG)
116 ts->nexthash = NULL; 129 ts->u.d.tag = tag;
117 ts->u.d.value = udata;
118 ts->u.d.tag = (tag == LUA_ANYTAG) ? 0 : tag;
119 L->nblocks += gcsizeudata;
120 newentry(L, &L->udt, ts, h1); /* insert it on table */
121 return ts; 130 return ts;
122} 131}
123 132
diff --git a/lstring.h b/lstring.h
index c04ef12a..aa0157b5 100644
--- a/lstring.h
+++ b/lstring.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstring.h,v 1.21 2000/05/24 13:54:49 roberto Exp roberto $ 2** $Id: lstring.h,v 1.22 2000/09/29 12:42:13 roberto Exp roberto $
3** String table (keep all strings handled by Lua) 3** String table (keep all strings handled by Lua)
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -21,11 +21,11 @@
21 21
22 22
23#define sizestring(l) (sizeof(TString)+(lint32)(l)*sizeof(char)) 23#define sizestring(l) (sizeof(TString)+(lint32)(l)*sizeof(char))
24#define gcsizeudata (sizeof(TString))
25 24
26 25
27void luaS_init (lua_State *L); 26void luaS_init (lua_State *L);
28void luaS_resize (lua_State *L, stringtable *tb, int newsize); 27void luaS_resize (lua_State *L, stringtable *tb, int newsize);
28TString *luaS_newudata (lua_State *L, size_t s, void *udata);
29TString *luaS_createudata (lua_State *L, void *udata, int tag); 29TString *luaS_createudata (lua_State *L, void *udata, int tag);
30void luaS_freeall (lua_State *L); 30void luaS_freeall (lua_State *L);
31TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 31TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
diff --git a/ltable.c b/ltable.c
index 0e0fe772..4aef89c0 100644
--- a/ltable.c
+++ b/ltable.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.c,v 1.56 2000/09/29 12:42:13 roberto Exp roberto $ 2** $Id: ltable.c,v 1.57 2000/10/05 12:14:08 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*/
@@ -139,7 +139,7 @@ Node *luaH_next (lua_State *L, const Hash *t, const TObject *key) {
139*/ 139*/
140void luaH_remove (Hash *t, TObject *key) { 140void luaH_remove (Hash *t, TObject *key) {
141 if (ttype(key) == LUA_TNUMBER || 141 if (ttype(key) == LUA_TNUMBER ||
142 (ttype(key) == LUA_TSTRING && tsvalue(key)->u.s.len <= 30)) 142 (ttype(key) == LUA_TSTRING && tsvalue(key)->len <= 30))
143 return; /* do not remove numbers nor small strings */ 143 return; /* do not remove numbers nor small strings */
144 else { 144 else {
145 /* try to find a number `n' with the same hash as `key' */ 145 /* try to find a number `n' with the same hash as `key' */
diff --git a/ltests.c b/ltests.c
index 8470ab19..111c9f64 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltests.c,v 1.50 2000/10/06 19:29:26 roberto Exp roberto $ 2** $Id: ltests.c,v 1.51 2000/10/20 16:39:03 roberto Exp roberto $
3** Internal Module for Debugging of the Lua Implementation 3** Internal Module for Debugging of the Lua Implementation
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -260,7 +260,10 @@ static int unref (lua_State *L) {
260} 260}
261 261
262static int newuserdata (lua_State *L) { 262static int newuserdata (lua_State *L) {
263 lua_pushusertag(L, (void *)luaL_check_int(L, 1), luaL_check_int(L, 2)); 263 if (lua_isnumber(L, 2))
264 lua_pushusertag(L, (void *)luaL_check_int(L, 1), luaL_check_int(L, 2));
265 else
266 lua_newuserdata(L, luaL_check_int(L, 1));
264 return 1; 267 return 1;
265} 268}
266 269
diff --git a/lua.h b/lua.h
index c2c77a80..599dfafd 100644
--- a/lua.h
+++ b/lua.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lua.h,v 1.75 2000/10/20 16:39:03 roberto Exp roberto $ 2** $Id: lua.h,v 1.76 2000/10/24 19:12:06 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: lua@tecgraf.puc-rio.br 5** e-mail: lua@tecgraf.puc-rio.br
@@ -182,6 +182,8 @@ LUA_API int lua_getn (lua_State *L, int index);
182 182
183LUA_API void lua_concat (lua_State *L, int n); 183LUA_API void lua_concat (lua_State *L, int n);
184 184
185LUA_API void *lua_newuserdata (lua_State *L, size_t size);
186
185 187
186/* 188/*
187** =============================================================== 189** ===============================================================
diff --git a/lvm.c b/lvm.c
index 356dc4a1..71741cb5 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 1.144 2000/10/05 13:00:17 roberto Exp roberto $ 2** $Id: lvm.c,v 1.145 2000/10/06 12:45:25 roberto Exp roberto $
3** Lua virtual machine 3** Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -249,9 +249,9 @@ static void call_arith (lua_State *L, StkId top, TMS event) {
249 249
250static int luaV_strcomp (const TString *ls, const TString *rs) { 250static int luaV_strcomp (const TString *ls, const TString *rs) {
251 const char *l = ls->str; 251 const char *l = ls->str;
252 size_t ll = ls->u.s.len; 252 size_t ll = ls->len;
253 const char *r = rs->str; 253 const char *r = rs->str;
254 size_t lr = rs->u.s.len; 254 size_t lr = rs->len;
255 for (;;) { 255 for (;;) {
256 int temp = strcoll(l, r); 256 int temp = strcoll(l, r);
257 if (temp != 0) return temp; 257 if (temp != 0) return temp;
@@ -293,21 +293,21 @@ void luaV_strconc (lua_State *L, int total, StkId top) {
293 if (!call_binTM(L, top, TM_CONCAT)) 293 if (!call_binTM(L, top, TM_CONCAT))
294 luaG_binerror(L, top-2, LUA_TSTRING, "concat"); 294 luaG_binerror(L, top-2, LUA_TSTRING, "concat");
295 } 295 }
296 else if (tsvalue(top-1)->u.s.len > 0) { /* if len=0, do nothing */ 296 else if (tsvalue(top-1)->len > 0) { /* if len=0, do nothing */
297 /* at least two string values; get as many as possible */ 297 /* at least two string values; get as many as possible */
298 lint32 tl = (lint32)tsvalue(top-1)->u.s.len + 298 lint32 tl = (lint32)tsvalue(top-1)->len +
299 (lint32)tsvalue(top-2)->u.s.len; 299 (lint32)tsvalue(top-2)->len;
300 char *buffer; 300 char *buffer;
301 int i; 301 int i;
302 while (n < total && !tostring(L, top-n-1)) { /* collect total length */ 302 while (n < total && !tostring(L, top-n-1)) { /* collect total length */
303 tl += tsvalue(top-n-1)->u.s.len; 303 tl += tsvalue(top-n-1)->len;
304 n++; 304 n++;
305 } 305 }
306 if (tl > MAX_SIZET) lua_error(L, "string size overflow"); 306 if (tl > MAX_SIZET) lua_error(L, "string size overflow");
307 buffer = luaO_openspace(L, tl); 307 buffer = luaO_openspace(L, tl);
308 tl = 0; 308 tl = 0;
309 for (i=n; i>0; i--) { /* concat all strings */ 309 for (i=n; i>0; i--) { /* concat all strings */
310 size_t l = tsvalue(top-i)->u.s.len; 310 size_t l = tsvalue(top-i)->len;
311 memcpy(buffer+tl, tsvalue(top-i)->str, l); 311 memcpy(buffer+tl, tsvalue(top-i)->str, l);
312 tl += l; 312 tl += l;
313 } 313 }