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') {
211 return l_mathop(ldexp)(r, e);
219 #if !defined (L_MAXLENNUM)
220 #define L_MAXLENNUM 200
231 : lua_str2number(
s, &endptr);
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) )
560 if (srclen <= bufflen)
561 memcpy(out,
source + 1, srclen *
sizeof(
char));
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) {
584 if (nl != NULL) srclen = nl -
source;
585 if (srclen > bufflen) srclen = bufflen;
589 memcpy(out,
POS, (
LL(
POS) + 1) *
sizeof(
char));