Renaming two new functions
'lua_numbertostrbuff' -> 'lua_numbertocstring' 'lua_pushextlstring' -> 'lua_pushexternalstring'
This commit is contained in:
4
lapi.c
4
lapi.c
@@ -366,7 +366,7 @@ LUA_API int lua_compare (lua_State *L, int index1, int index2, int op) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API unsigned (lua_numbertostrbuff) (lua_State *L, int idx, char *buff) {
|
LUA_API unsigned (lua_numbertocstring) (lua_State *L, int idx, char *buff) {
|
||||||
const TValue *o = index2value(L, idx);
|
const TValue *o = index2value(L, idx);
|
||||||
if (ttisnumber(o)) {
|
if (ttisnumber(o)) {
|
||||||
unsigned len = luaO_tostringbuff(o, buff);
|
unsigned len = luaO_tostringbuff(o, buff);
|
||||||
@@ -546,7 +546,7 @@ LUA_API const char *lua_pushlstring (lua_State *L, const char *s, size_t len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API const char *lua_pushextlstring (lua_State *L,
|
LUA_API const char *lua_pushexternalstring (lua_State *L,
|
||||||
const char *s, size_t len, lua_Alloc falloc, void *ud) {
|
const char *s, size_t len, lua_Alloc falloc, void *ud) {
|
||||||
TString *ts;
|
TString *ts;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
|
|||||||
@@ -622,9 +622,9 @@ LUALIB_API void luaL_pushresult (luaL_Buffer *B) {
|
|||||||
resizebox(L, -1, len + 1); /* adjust box size to content size */
|
resizebox(L, -1, len + 1); /* adjust box size to content size */
|
||||||
s = (char*)box->box; /* final buffer address */
|
s = (char*)box->box; /* final buffer address */
|
||||||
s[len] = '\0'; /* add ending zero */
|
s[len] = '\0'; /* add ending zero */
|
||||||
/* clear box, as 'lua_pushextlstring' will take control over buffer */
|
/* clear box, as Lua will take control of the buffer */
|
||||||
box->bsize = 0; box->box = NULL;
|
box->bsize = 0; box->box = NULL;
|
||||||
lua_pushextlstring(L, s, len, allocf, ud);
|
lua_pushexternalstring(L, s, len, allocf, ud);
|
||||||
lua_closeslot(L, -2); /* close the box */
|
lua_closeslot(L, -2); /* close the box */
|
||||||
lua_gc(L, LUA_GCSTEP, len);
|
lua_gc(L, LUA_GCSTEP, len);
|
||||||
}
|
}
|
||||||
@@ -929,7 +929,7 @@ LUALIB_API const char *luaL_tolstring (lua_State *L, int idx, size_t *len) {
|
|||||||
switch (lua_type(L, idx)) {
|
switch (lua_type(L, idx)) {
|
||||||
case LUA_TNUMBER: {
|
case LUA_TNUMBER: {
|
||||||
char buff[LUA_N2SBUFFSZ];
|
char buff[LUA_N2SBUFFSZ];
|
||||||
lua_numbertostrbuff(L, idx, buff);
|
lua_numbertocstring(L, idx, buff);
|
||||||
lua_pushstring(L, buff);
|
lua_pushstring(L, buff);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
2
liolib.c
2
liolib.c
@@ -667,7 +667,7 @@ static int g_write (lua_State *L, FILE *f, int arg) {
|
|||||||
for (; nargs--; arg++) {
|
for (; nargs--; arg++) {
|
||||||
char buff[LUA_N2SBUFFSZ];
|
char buff[LUA_N2SBUFFSZ];
|
||||||
const char *s;
|
const char *s;
|
||||||
size_t len = lua_numbertostrbuff(L, arg, buff); /* try as a number */
|
size_t len = lua_numbertocstring(L, arg, buff); /* try as a number */
|
||||||
if (len > 0) { /* did conversion work (value was a number)? */
|
if (len > 0) { /* did conversion work (value was a number)? */
|
||||||
s = buff;
|
s = buff;
|
||||||
len--;
|
len--;
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ static void setpath (lua_State *L, const char *fieldname,
|
|||||||
if (path == NULL) /* no versioned environment variable? */
|
if (path == NULL) /* no versioned environment variable? */
|
||||||
path = getenv(envname); /* try unversioned name */
|
path = getenv(envname); /* try unversioned name */
|
||||||
if (path == NULL || noenv(L)) /* no environment variable? */
|
if (path == NULL || noenv(L)) /* no environment variable? */
|
||||||
lua_pushextlstring(L, dft, strlen(dft), NULL, NULL); /* use default */
|
lua_pushexternalstring(L, dft, strlen(dft), NULL, NULL); /* use default */
|
||||||
else if ((dftmark = strstr(path, LUA_PATH_SEP LUA_PATH_SEP)) == NULL)
|
else if ((dftmark = strstr(path, LUA_PATH_SEP LUA_PATH_SEP)) == NULL)
|
||||||
lua_pushstring(L, path); /* nothing to change */
|
lua_pushstring(L, path); /* nothing to change */
|
||||||
else { /* path contains a ";;": insert default path in its place */
|
else { /* path contains a ";;": insert default path in its place */
|
||||||
|
|||||||
4
ltests.c
4
ltests.c
@@ -1389,7 +1389,7 @@ static int checkpanic (lua_State *L) {
|
|||||||
static int externKstr (lua_State *L) {
|
static int externKstr (lua_State *L) {
|
||||||
size_t len;
|
size_t len;
|
||||||
const char *s = luaL_checklstring(L, 1, &len);
|
const char *s = luaL_checklstring(L, 1, &len);
|
||||||
lua_pushextlstring(L, s, len, NULL, NULL);
|
lua_pushexternalstring(L, s, len, NULL, NULL);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1413,7 +1413,7 @@ static int externstr (lua_State *L) {
|
|||||||
/* copy string content to buffer, including ending 0 */
|
/* copy string content to buffer, including ending 0 */
|
||||||
memcpy(buff, s, (len + 1) * sizeof(char));
|
memcpy(buff, s, (len + 1) * sizeof(char));
|
||||||
/* create external string */
|
/* create external string */
|
||||||
lua_pushextlstring(L, buff, len, allocf, ud);
|
lua_pushexternalstring(L, buff, len, allocf, ud);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
4
lua.h
4
lua.h
@@ -244,7 +244,7 @@ LUA_API void (lua_pushnil) (lua_State *L);
|
|||||||
LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n);
|
LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n);
|
||||||
LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n);
|
LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n);
|
||||||
LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t len);
|
LUA_API const char *(lua_pushlstring) (lua_State *L, const char *s, size_t len);
|
||||||
LUA_API const char *(lua_pushextlstring) (lua_State *L,
|
LUA_API const char *(lua_pushexternalstring) (lua_State *L,
|
||||||
const char *s, size_t len, lua_Alloc falloc, void *ud);
|
const char *s, size_t len, lua_Alloc falloc, void *ud);
|
||||||
LUA_API const char *(lua_pushstring) (lua_State *L, const char *s);
|
LUA_API const char *(lua_pushstring) (lua_State *L, const char *s);
|
||||||
LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt,
|
LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt,
|
||||||
@@ -372,7 +372,7 @@ LUA_API void (lua_concat) (lua_State *L, int n);
|
|||||||
LUA_API void (lua_len) (lua_State *L, int idx);
|
LUA_API void (lua_len) (lua_State *L, int idx);
|
||||||
|
|
||||||
#define LUA_N2SBUFFSZ 64
|
#define LUA_N2SBUFFSZ 64
|
||||||
LUA_API unsigned (lua_numbertostrbuff) (lua_State *L, int idx, char *buff);
|
LUA_API unsigned (lua_numbertocstring) (lua_State *L, int idx, char *buff);
|
||||||
LUA_API size_t (lua_stringtonumber) (lua_State *L, const char *s);
|
LUA_API size_t (lua_stringtonumber) (lua_State *L, const char *s);
|
||||||
|
|
||||||
LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud);
|
LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud);
|
||||||
|
|||||||
@@ -3829,7 +3829,7 @@ This macro may evaluate its arguments more than once.
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@APIEntry{unsigned (lua_numbertostrbuff) (lua_State *L, int idx,
|
@APIEntry{unsigned (lua_numbertocstring) (lua_State *L, int idx,
|
||||||
char *buff);|
|
char *buff);|
|
||||||
@apii{0,0,-}
|
@apii{0,0,-}
|
||||||
|
|
||||||
@@ -3955,7 +3955,7 @@ This function is equivalent to @Lid{lua_pushcclosure} with no upvalues.
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@APIEntry{const char *(lua_pushextlstring) (lua_State *L,
|
@APIEntry{const char *(lua_pushexternalstring) (lua_State *L,
|
||||||
const char *s, size_t len, lua_Alloc falloc, void *ud);|
|
const char *s, size_t len, lua_Alloc falloc, void *ud);|
|
||||||
@apii{0,1,m}
|
@apii{0,1,m}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user