diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-10-26 10:47:05 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-10-26 10:47:05 -0200 |
commit | b892f0a8774f573d7ec9b02617428871b8d3a2b3 (patch) | |
tree | 4aab88443264d84d314ca663cf3c30b48c7e9107 /lvm.c | |
parent | aadc35449ec2752c298a7a8fa6359a3a12c538ee (diff) | |
download | lua-b892f0a8774f573d7ec9b02617428871b8d3a2b3.tar.gz lua-b892f0a8774f573d7ec9b02617428871b8d3a2b3.tar.bz2 lua-b892f0a8774f573d7ec9b02617428871b8d3a2b3.zip |
new API function `createuserdata'
Diffstat (limited to 'lvm.c')
-rw-r--r-- | lvm.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -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 | ||
250 | static int luaV_strcomp (const TString *ls, const TString *rs) { | 250 | static 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 | } |