25 #ifndef lua_str2number
26 #define lua_str2number(s,p) strtod((s), (p))
43 return (m << 3) |
cast(
int, x);
48 static const lu_byte log_8[255] = {
53 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
54 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
55 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,
56 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,
57 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,
58 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,
59 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,
60 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
62 if (x >= 0x00010000) {
63 if (x >= 0x01000000)
return log_8[((x>>24) & 0xff) - 1]+24;
64 else return log_8[((x>>16) & 0xff) - 1]+16;
67 if (x >= 0x00000100)
return log_8[((x>>8) & 0xff) - 1]+8;
68 else if (x)
return log_8[(x & 0xff) - 1];
76 else switch (
ttype(t1)) {
83 case LUA_TLIGHTUSERDATA:
95 if (endptr == s)
return 0;
96 while (isspace((
unsigned char)(*endptr))) endptr++;
97 if (*endptr !=
'\0')
return 0;
117 const char *e = strchr(fmt,
'%');
118 if (e == NULL)
break;
123 pushstr(L, va_arg(argp,
char *));
127 buff[0] =
cast(
char, va_arg(argp,
int));
166 if (*source ==
'=') {
167 strncpy(out, source+1, bufflen);
168 out[bufflen-1] =
'\0';
171 if (*source ==
'@') {
174 bufflen -=
sizeof(
" `...' ");
178 source += (l-bufflen);
184 int len = strcspn(source,
"\n");
185 bufflen -=
sizeof(
" [string \"...\"] ");
186 if (len > bufflen) len = bufflen;
187 strcpy(out,
"[string \"");
188 if (source[len] !=
'\0') {
189 strncat(out, source, len);