macros 'getaddrstr' and 'getstr' unified (they do the same thing)

This commit is contained in:
Roberto Ierusalimschy 2015-09-17 12:51:05 -03:00
parent bda83e22c0
commit ee5edb6b68
4 changed files with 11 additions and 11 deletions

View File

@ -1,5 +1,5 @@
/*
** $Id: lobject.h,v 2.112 2015/09/08 15:49:25 roberto Exp roberto $
** $Id: lobject.h,v 2.113 2015/09/08 16:54:52 roberto Exp roberto $
** Type definitions for Lua objects
** See Copyright Notice in lua.h
*/
@ -325,9 +325,9 @@ typedef union UTString {
** Get the actual string (array of bytes) from a 'TString'.
** (Access to 'extra' ensures that value is really a 'TString'.)
*/
#define getaddrstr(ts) (cast(char *, (ts)) + sizeof(UTString))
#define getstr(ts) \
check_exp(sizeof((ts)->extra), cast(const char*, getaddrstr(ts)))
check_exp(sizeof((ts)->extra), cast(char *, (ts)) + sizeof(UTString))
/* get the actual string (array of bytes) from a Lua value */
#define svalue(o) getstr(tsvalue(o))

View File

@ -1,5 +1,5 @@
/*
** $Id: lstring.c,v 2.50 2015/06/18 14:20:32 roberto Exp roberto $
** $Id: lstring.c,v 2.51 2015/09/08 15:41:05 roberto Exp roberto $
** String table (keeps all strings handled by Lua)
** See Copyright Notice in lua.h
*/
@ -128,7 +128,7 @@ static TString *createstrobj (lua_State *L, size_t l, int tag, unsigned int h) {
ts = gco2ts(o);
ts->hash = h;
ts->extra = 0;
getaddrstr(ts)[l] = '\0'; /* ending 0 */
getstr(ts)[l] = '\0'; /* ending 0 */
return ts;
}
@ -172,7 +172,7 @@ static TString *internshrstr (lua_State *L, const char *str, size_t l) {
list = &g->strt.hash[lmod(h, g->strt.size)]; /* recompute with new size */
}
ts = createstrobj(L, l, LUA_TSHRSTR, h);
memcpy(getaddrstr(ts), str, l * sizeof(char));
memcpy(getstr(ts), str, l * sizeof(char));
ts->shrlen = cast_byte(l);
ts->u.hnext = *list;
*list = ts;
@ -192,7 +192,7 @@ TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
if (l >= (MAX_SIZE - sizeof(TString))/sizeof(char))
luaM_toobig(L);
ts = luaS_createlngstrobj(L, l);
memcpy(getaddrstr(ts), str, l * sizeof(char));
memcpy(getstr(ts), str, l * sizeof(char));
return ts;
}
}

View File

@ -1,5 +1,5 @@
/*
** $Id: lundump.c,v 2.41 2014/11/02 19:19:04 roberto Exp roberto $
** $Id: lundump.c,v 2.42 2015/09/08 15:41:05 roberto Exp roberto $
** load precompiled Lua chunks
** See Copyright Notice in lua.h
*/
@ -98,7 +98,7 @@ static TString *LoadString (LoadState *S) {
}
else { /* long string */
TString *ts = luaS_createlngstrobj(S->L, size);
LoadVector(S, getaddrstr(ts), size); /* load directly in final place */
LoadVector(S, getstr(ts), size); /* load directly in final place */
return ts;
}
}

4
lvm.c
View File

@ -1,5 +1,5 @@
/*
** $Id: lvm.c,v 2.251 2015/09/08 15:41:05 roberto Exp roberto $
** $Id: lvm.c,v 2.252 2015/09/09 13:44:07 roberto Exp roberto $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@ -487,7 +487,7 @@ void luaV_concat (lua_State *L, int total) {
}
else { /* long string; copy strings directly to final result */
ts = luaS_createlngstrobj(L, tl);
copy2buff(top, n, getaddrstr(ts));
copy2buff(top, n, getstr(ts));
}
setsvalue2s(L, top - n, ts); /* create result */
}