Changeset View
Changeset View
Standalone View
Standalone View
contrib/lua/src/lstrlib.c
/* | /* | ||||
** $Id: lstrlib.c,v 1.254 2016/12/22 13:08:50 roberto Exp $ | ** $Id: lstrlib.c,v 1.254.1.1 2017/04/19 17:29:57 roberto Exp $ | ||||
** Standard library for string operations and pattern-matching | ** Standard library for string operations and pattern-matching | ||||
** See Copyright Notice in lua.h | ** See Copyright Notice in lua.h | ||||
*/ | */ | ||||
#define lstrlib_c | #define lstrlib_c | ||||
#define LUA_LIB | #define LUA_LIB | ||||
#include "lprefix.h" | #include "lprefix.h" | ||||
▲ Show 20 Lines • Show All 863 Lines • ▼ Show 20 Lines | static int lua_number2strx (lua_State *L, char *buff, int sz, | ||||
const char *fmt, lua_Number x) { | const char *fmt, lua_Number x) { | ||||
int n = num2straux(buff, sz, x); | int n = num2straux(buff, sz, x); | ||||
if (fmt[SIZELENMOD] == 'A') { | if (fmt[SIZELENMOD] == 'A') { | ||||
int i; | int i; | ||||
for (i = 0; i < n; i++) | for (i = 0; i < n; i++) | ||||
buff[i] = toupper(uchar(buff[i])); | buff[i] = toupper(uchar(buff[i])); | ||||
} | } | ||||
else if (fmt[SIZELENMOD] != 'a') | else if (fmt[SIZELENMOD] != 'a') | ||||
luaL_error(L, "modifiers for format '%%a'/'%%A' not implemented"); | return luaL_error(L, "modifiers for format '%%a'/'%%A' not implemented"); | ||||
return n; | return n; | ||||
} | } | ||||
#endif /* } */ | #endif /* } */ | ||||
/* | /* | ||||
** Maximum size of each formatted item. This maximum size is produced | ** Maximum size of each formatted item. This maximum size is produced | ||||
▲ Show 20 Lines • Show All 313 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
** Read an integer numeral and raises an error if it is larger | ** Read an integer numeral and raises an error if it is larger | ||||
** than the maximum size for integers. | ** than the maximum size for integers. | ||||
*/ | */ | ||||
static int getnumlimit (Header *h, const char **fmt, int df) { | static int getnumlimit (Header *h, const char **fmt, int df) { | ||||
int sz = getnum(fmt, df); | int sz = getnum(fmt, df); | ||||
if (sz > MAXINTSIZE || sz <= 0) | if (sz > MAXINTSIZE || sz <= 0) | ||||
luaL_error(h->L, "integral size (%d) out of limits [1,%d]", | return luaL_error(h->L, "integral size (%d) out of limits [1,%d]", | ||||
sz, MAXINTSIZE); | sz, MAXINTSIZE); | ||||
return sz; | return sz; | ||||
} | } | ||||
/* | /* | ||||
** Initialize Header | ** Initialize Header | ||||
*/ | */ | ||||
static void initheader (lua_State *L, Header *h) { | static void initheader (lua_State *L, Header *h) { | ||||
▲ Show 20 Lines • Show All 383 Lines • Show Last 20 Lines |