Details
Several small improvements (code style, warnings, comments, more tests),
in particular:
- 'lua_topointer' extended to handle strings
- raises an error in 'string.format("%10q")' ('%q' with modifiers)
- in the manual for 'string.format', the term "option" replaced by
"conversion specifier" (the term used by the C standard)
This commit is contained in:
@@ -181,7 +181,7 @@ static int str_byte (lua_State *L) {
|
||||
size_t pose = getendpos(L, 3, pi, l);
|
||||
int n, i;
|
||||
if (posi > pose) return 0; /* empty interval; return no values */
|
||||
if (pose - posi >= INT_MAX) /* arithmetic overflow? */
|
||||
if (pose - posi >= (size_t)INT_MAX) /* arithmetic overflow? */
|
||||
return luaL_error(L, "string slice too long");
|
||||
n = (int)(pose - posi) + 1;
|
||||
luaL_checkstack(L, n, "string slice too long");
|
||||
@@ -1159,7 +1159,7 @@ static int str_format (lua_State *L) {
|
||||
char *buff = luaL_prepbuffsize(&b, MAX_ITEM); /* to put formatted item */
|
||||
int nb = 0; /* number of bytes in added item */
|
||||
if (++arg > top)
|
||||
luaL_argerror(L, arg, "no value");
|
||||
return luaL_argerror(L, arg, "no value");
|
||||
strfrmt = scanformat(L, strfrmt, form);
|
||||
switch (*strfrmt++) {
|
||||
case 'c': {
|
||||
@@ -1186,6 +1186,8 @@ static int str_format (lua_State *L) {
|
||||
break;
|
||||
}
|
||||
case 'q': {
|
||||
if (form[2] != '\0') /* modifiers? */
|
||||
return luaL_error(L, "specifier '%%q' cannot have modifiers");
|
||||
addliteral(L, &b, arg);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user