mirror of
https://github.com/lua/lua
synced 2026-09-29 04:35:58 +03:00
better treatment of integer formats in string.format
This commit is contained in:
parent
c1de1fdac6
commit
f4eed60ca9
1 changed files with 6 additions and 7 deletions
13
lstrlib.c
13
lstrlib.c
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lstrlib.c,v 1.141 2008/06/12 14:21:18 roberto Exp roberto $
|
||||
** $Id: lstrlib.c,v 1.142 2009/02/03 19:39:19 roberto Exp roberto $
|
||||
** Standard library for string operations and pattern-matching
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
|
@ -777,14 +777,13 @@ static int str_format (lua_State *L) {
|
|||
sprintf(buff, form, (int)luaL_checknumber(L, arg));
|
||||
break;
|
||||
}
|
||||
case 'd': case 'i': {
|
||||
addintlen(form);
|
||||
sprintf(buff, form, (LUA_INTFRM_T)luaL_checknumber(L, arg));
|
||||
break;
|
||||
}
|
||||
case 'd': case 'i':
|
||||
case 'o': case 'u': case 'x': case 'X': {
|
||||
lua_Number n = luaL_checknumber(L, arg);
|
||||
LUA_INTFRM_T r = (n < 0) ? (LUA_INTFRM_T)n :
|
||||
(LUA_INTFRM_T)(unsigned LUA_INTFRM_T)n;
|
||||
addintlen(form);
|
||||
sprintf(buff, form, (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg));
|
||||
sprintf(buff, form, r);
|
||||
break;
|
||||
}
|
||||
case 'e': case 'E': case 'f':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue