36 static const lu_byte log_2[256] = {
37 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
38 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
39 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
40 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
41 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
42 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
43 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
44 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
48 while (x >= 256) { l += 8; x >>= 8; }
137 else return (
ltolower(c) -
'a') + 10;
142 if (**s ==
'-') { (*s)++;
return 1; }
143 else if (**s ==
'+') (*s)++;
155 #if !defined(lua_strx2number) 176 if (!(*s ==
'0' && (*(s + 1) ==
'x' || *(s + 1) ==
'X')))
178 for (s += 2; ; s++) {
184 if (sigdig == 0 && *s ==
'0')
186 else if (++sigdig <= MAXSIGDIG)
193 if (nosigdig + sigdig == 0)
197 if (*s ==
'p' || *s ==
'P') {
205 exp1 = exp1 * 10 + *(s++) -
'0';
206 if (neg1) exp1 = -
exp1;
219 #if !defined (L_MAXLENNUM) 220 #define L_MAXLENNUM 200 232 if (endptr == s)
return NULL;
234 return (*endptr ==
'\0') ? endptr : NULL;
253 const char *pmode = strpbrk(s,
".xXnN");
258 if (endptr == NULL) {
260 const char *pdot = strchr(s,
'.');
267 endptr = s + (endptr - buff);
273 #define MAXBY10 cast(lua_Unsigned, LUA_MAXINTEGER / 10) 274 #define MAXLASTD cast_int(LUA_MAXINTEGER % 10) 283 (s[1] ==
'x' || s[1] ==
'X')) {
300 if (empty || *s !=
'\0')
return NULL;
314 else if ((e =
l_str2d(s, &n)) != NULL) {
329 unsigned int mfb = 0x3f;
349 #define MAXNUMBER2STR 44 362 if (buff[strspn(buff,
"-0123456789")] ==
'\0') {
436 #define addsize(b,sz) ((b)->blen += (sz)) 446 memcpy(bf, str, slen);
475 while ((e = strchr(fmt,
'%')) != NULL) {
479 const char *s = va_arg(argp,
char *);
480 if (s == NULL) s =
"(null)";
508 const int sz = 3 *
sizeof(
void*) + 8;
510 void *p = va_arg(argp,
void *);
526 luaG_runerror(L,
"invalid option '%%%c' to 'lua_pushfstring'",
552 #define PRE "[string \"" 555 #define addstr(a,b,l) ( memcpy(a,b,(l) * sizeof(char)), a += (l) ) 559 if (*source ==
'=') {
560 if (srclen <= bufflen)
561 memcpy(out, source + 1, srclen *
sizeof(
char));
563 addstr(out, source + 1, bufflen - 1);
567 else if (*source ==
'@') {
568 if (srclen <= bufflen)
569 memcpy(out, source + 1, srclen *
sizeof(
char));
573 memcpy(out, source + 1 + srclen - bufflen, bufflen *
sizeof(
char));
577 const char *nl = strchr(source,
'\n');
580 if (srclen < bufflen && nl == NULL) {
581 addstr(out, source, srclen);
584 if (nl != NULL) srclen = nl - source;
585 if (srclen > bufflen) srclen = bufflen;
586 addstr(out, source, srclen);
589 memcpy(out, POS, (
LL(POS) + 1) *
sizeof(
char));
static int isneg(const char **s)
#define luai_numunm(L, a)
static void exp1(LexState *ls)
int luaO_rawarith(lua_State *L, int op, const TValue *p1, const TValue *p2, TValue *res)
#define lua_number2str(s, sz, n)
lua_Integer luaV_idiv(lua_State *L, lua_Integer m, lua_Integer n)
lua_Number luaV_modf(lua_State *L, lua_Number m, lua_Number n)
#define lua_strx2number(s, p)
static lua_Number numarith(lua_State *L, int op, lua_Number v1, lua_Number v2)
#define luai_numsub(L, a, b)
static const char * l_str2dloc(const char *s, lua_Number *result, int mode)
#define intop(op, v1, v2)
lua_Integer luaV_shiftl(lua_Integer x, lua_Integer y)
static int tostringbuff(TValue *obj, char *buff)
TString * luaS_newlstr(lua_State *L, const char *str, size_t l)
static const char * l_str2d(const char *s, lua_Number *result)
#define tointegerns(o, i)
int luaO_ceillog2(unsigned int x)
static void clearbuff(BuffFS *buff)
static const char * l_str2int(const char *s, lua_Integer *result)
#define luai_numpow(L, a, b)
void luaO_chunkid(char *out, const char *source, size_t srclen)
#define luai_numidiv(L, a, b)
l_noret luaG_runerror(lua_State *L, const char *fmt,...)
#define setsvalue2s(L, o, s)
const char * luaO_pushvfstring(lua_State *L, const char *fmt, va_list argp)
#define lua_getlocaledecpoint()
int luaO_hexavalue(int c)
#define setivalue(obj, x)
lua_Integer luaV_mod(lua_State *L, lua_Integer m, lua_Integer n)
#define luai_numadd(L, a, b)
void luaO_tostring(lua_State *L, TValue *obj)
#define setfltvalue(obj, x)
#define lua_pointer2str(buff, sz, p)
#define luai_nummul(L, a, b)
LUA_UNSIGNED lua_Unsigned
#define luai_numdiv(L, a, b)
void luaV_concat(lua_State *L, int total)
static char * getbuff(BuffFS *buff, int sz)
#define lua_integer2str(s, sz, n)
#define lua_str2number(s, p)
int luaO_utf8esc(char *buff, unsigned long x)
const char * luaO_pushfstring(lua_State *L, const char *fmt,...)
size_t luaO_str2num(const char *s, TValue *o)
void luaO_arith(lua_State *L, int op, const TValue *p1, const TValue *p2, StkId res)
LUAI_UACNUMBER l_uacNumber
void luaT_trybinTM(lua_State *L, const TValue *p1, const TValue *p2, StkId res, TMS event)
static void addnum2buff(BuffFS *buff, TValue *num)
static void addstr2buff(BuffFS *buff, const char *str, size_t slen)
static lua_Integer intarith(lua_State *L, int op, lua_Integer v1, lua_Integer v2)
static void pushstr(BuffFS *buff, const char *str, size_t l)
#define setsvalue(L, obj, x)