Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
310faf7f
Unverified
Commit
310faf7f
authored
Sep 07, 2019
by
Terry Ellison
Committed by
GitHub
Sep 07, 2019
Browse files
Merge pull request #2886 from nodemcu/dev
Next master drop
parents
68c425c0
a08e74d9
Changes
368
Show whitespace changes
Inline
Side-by-side
app/lua/lstring.h
View file @
310faf7f
...
...
@@ -17,7 +17,7 @@
#define sizeudata(u) (sizeof(union Udata)+(u)->len)
#define luaS_new(L, s) (luaS_newlstr(L, s,
c_
strlen(s)))
#define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s)))
#define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \
(sizeof(s)/sizeof(char))-1))
...
...
app/lua/lstrlib.c
View file @
310faf7f
...
...
@@ -10,17 +10,17 @@
#define LUAC_CROSS_FILE
#include "lua.h"
#include
C_HEADER_STDIO
#include
C_HEADER_STRING
#include
<stdio.h>
#include
<string.h>
#include "lauxlib.h"
#include "lualib.h"
#include "lrotable.h"
/* macro to `unsign' a character */
#define uchar(c) ((unsigned char)(c))
static
int
str_len
(
lua_State
*
L
)
{
size_t
l
;
luaL_checklstring
(
L
,
1
,
&
l
);
...
...
@@ -352,7 +352,7 @@ static const char *match_capture (MatchState *ms, const char *s, int l) {
l
=
check_capture
(
ms
,
l
);
len
=
ms
->
capture
[
l
].
len
;
if
((
size_t
)(
ms
->
src_end
-
s
)
>=
len
&&
c_
memcmp
(
ms
->
capture
[
l
].
init
,
s
,
len
)
==
0
)
memcmp
(
ms
->
capture
[
l
].
init
,
s
,
len
)
==
0
)
return
s
+
len
;
else
return
NULL
;
}
...
...
@@ -447,7 +447,7 @@ static const char *lmemfind (const char *s1, size_t l1,
l1
=
l1
-
l2
;
/* `s2' cannot be found after that */
while
(
l1
>
0
&&
(
init
=
(
const
char
*
)
memchr
(
s1
,
*
s2
,
l1
))
!=
NULL
)
{
init
++
;
/* 1st char is already checked */
if
(
c_
memcmp
(
init
,
s2
+
1
,
l2
)
==
0
)
if
(
memcmp
(
init
,
s2
+
1
,
l2
)
==
0
)
return
init
-
1
;
else
{
/* correct `l1' and `s1' to try again */
l1
-=
init
-
s1
;
...
...
@@ -496,7 +496,7 @@ static int str_find_aux (lua_State *L, int find) {
if
(
init
<
0
)
init
=
0
;
else
if
((
size_t
)(
init
)
>
l1
)
init
=
(
ptrdiff_t
)
l1
;
if
(
find
&&
(
lua_toboolean
(
L
,
4
)
||
/* explicit request? */
c_
strpbrk
(
p
,
SPECIALS
)
==
NULL
))
{
/* or no special characters? */
strpbrk
(
p
,
SPECIALS
)
==
NULL
))
{
/* or no special characters? */
/* do a plain search */
const
char
*
s2
=
lmemfind
(
s
+
init
,
l1
-
init
,
p
,
l2
);
if
(
s2
)
{
...
...
@@ -576,7 +576,7 @@ static int gmatch (lua_State *L) {
return
1
;
}
#if
LUA_OPTIMIZE_MEMORY == 0 || !defined(
LUA_COMPAT_GFIND
)
#if
ndef
LUA_COMPAT_GFIND
static
int
gfind_nodef
(
lua_State
*
L
)
{
return
luaL_error
(
L
,
LUA_QL
(
"string.gfind"
)
" was renamed to "
LUA_QL
(
"string.gmatch"
));
...
...
@@ -723,7 +723,7 @@ static void addquoted (lua_State *L, luaL_Buffer *b, int arg) {
static
const
char
*
scanformat
(
lua_State
*
L
,
const
char
*
strfrmt
,
char
*
form
)
{
const
char
*
p
=
strfrmt
;
while
(
*
p
!=
'\0'
&&
c_
strchr
(
FLAGS
,
*
p
)
!=
NULL
)
p
++
;
/* skip flags */
while
(
*
p
!=
'\0'
&&
strchr
(
FLAGS
,
*
p
)
!=
NULL
)
p
++
;
/* skip flags */
if
((
size_t
)(
p
-
strfrmt
)
>=
sizeof
(
FLAGS
))
luaL_error
(
L
,
"invalid format (repeated flags)"
);
if
(
isdigit
(
uchar
(
*
p
)))
p
++
;
/* skip width */
...
...
@@ -736,7 +736,7 @@ static const char *scanformat (lua_State *L, const char *strfrmt, char *form) {
if
(
isdigit
(
uchar
(
*
p
)))
luaL_error
(
L
,
"invalid format (width or precision too long)"
);
*
(
form
++
)
=
'%'
;
c_
strncpy
(
form
,
strfrmt
,
p
-
strfrmt
+
1
);
strncpy
(
form
,
strfrmt
,
p
-
strfrmt
+
1
);
form
+=
p
-
strfrmt
+
1
;
*
form
=
'\0'
;
return
p
;
...
...
@@ -744,9 +744,9 @@ static const char *scanformat (lua_State *L, const char *strfrmt, char *form) {
static
void
addintlen
(
char
*
form
)
{
size_t
l
=
c_
strlen
(
form
);
size_t
l
=
strlen
(
form
);
char
spec
=
form
[
l
-
1
];
c_
strcpy
(
form
+
l
-
1
,
LUA_INTFRMLEN
);
strcpy
(
form
+
l
-
1
,
LUA_INTFRMLEN
);
form
[
l
+
sizeof
(
LUA_INTFRMLEN
)
-
2
]
=
spec
;
form
[
l
+
sizeof
(
LUA_INTFRMLEN
)
-
1
]
=
'\0'
;
}
...
...
@@ -773,23 +773,23 @@ static int str_format (lua_State *L) {
strfrmt
=
scanformat
(
L
,
strfrmt
,
form
);
switch
(
*
strfrmt
++
)
{
case
'c'
:
{
c_
sprintf
(
buff
,
form
,
(
int
)
luaL_checknumber
(
L
,
arg
));
sprintf
(
buff
,
form
,
(
int
)
luaL_checknumber
(
L
,
arg
));
break
;
}
case
'd'
:
case
'i'
:
{
addintlen
(
form
);
c_
sprintf
(
buff
,
form
,
(
LUA_INTFRM_T
)
luaL_checknumber
(
L
,
arg
));
sprintf
(
buff
,
form
,
(
LUA_INTFRM_T
)
luaL_checknumber
(
L
,
arg
));
break
;
}
case
'o'
:
case
'u'
:
case
'x'
:
case
'X'
:
{
addintlen
(
form
);
c_
sprintf
(
buff
,
form
,
(
unsigned
LUA_INTFRM_T
)
luaL_checknumber
(
L
,
arg
));
sprintf
(
buff
,
form
,
(
unsigned
LUA_INTFRM_T
)
luaL_checknumber
(
L
,
arg
));
break
;
}
#if !defined LUA_NUMBER_INTEGRAL
case
'e'
:
case
'E'
:
case
'f'
:
case
'g'
:
case
'G'
:
{
c_
sprintf
(
buff
,
form
,
(
double
)
luaL_checknumber
(
L
,
arg
));
sprintf
(
buff
,
form
,
(
double
)
luaL_checknumber
(
L
,
arg
));
break
;
}
#endif
...
...
@@ -800,7 +800,7 @@ static int str_format (lua_State *L) {
case
's'
:
{
size_t
l
;
const
char
*
s
=
luaL_checklstring
(
L
,
arg
,
&
l
);
if
(
!
c_
strchr
(
form
,
'.'
)
&&
l
>=
100
)
{
if
(
!
strchr
(
form
,
'.'
)
&&
l
>=
100
)
{
/* no precision and string is too long to be formatted;
keep original string */
lua_pushvalue
(
L
,
arg
);
...
...
@@ -808,7 +808,7 @@ static int str_format (lua_State *L) {
continue
;
/* skip the `addsize' at the end */
}
else
{
c_
sprintf
(
buff
,
form
,
s
);
sprintf
(
buff
,
form
,
s
);
break
;
}
}
...
...
@@ -817,74 +817,44 @@ static int str_format (lua_State *L) {
LUA_QL
(
"format"
),
*
(
strfrmt
-
1
));
}
}
luaL_addlstring
(
&
b
,
buff
,
c_
strlen
(
buff
));
luaL_addlstring
(
&
b
,
buff
,
strlen
(
buff
));
}
}
luaL_pushresult
(
&
b
);
return
1
;
}
#undef MIN_OPT_LEVEL
#define MIN_OPT_LEVEL 1
#include "lrodefs.h"
const
LUA_REG_TYPE
strlib
[]
=
{
{
LSTRKEY
(
"byte"
),
LFUNCVAL
(
str_byte
)},
{
LSTRKEY
(
"char"
),
LFUNCVAL
(
str_char
)},
{
LSTRKEY
(
"dump"
),
LFUNCVAL
(
str_dump
)},
{
LSTRKEY
(
"find"
),
LFUNCVAL
(
str_find
)},
{
LSTRKEY
(
"format"
),
LFUNCVAL
(
str_format
)},
#if LUA_OPTIMIZE_MEMORY > 0 && defined(LUA_COMPAT_GFIND)
{
LSTRKEY
(
"gfind"
),
LFUNCVAL
(
gmatch
)},
LROT_PUBLIC_BEGIN
(
strlib
)
LROT_FUNCENTRY
(
byte
,
str_byte
)
LROT_FUNCENTRY
(
char
,
str_char
)
LROT_FUNCENTRY
(
dump
,
str_dump
)
LROT_FUNCENTRY
(
find
,
str_find
)
LROT_FUNCENTRY
(
format
,
str_format
)
#ifdef LUA_COMPAT_GFIND
LROT_FUNCENTRY
(
gfind
,
gmatch
)
#else
{
LSTRKEY
(
"gfind"
),
LFUNCVAL
(
gfind_nodef
)},
#endif
{
LSTRKEY
(
"gmatch"
),
LFUNCVAL
(
gmatch
)},
{
LSTRKEY
(
"gsub"
),
LFUNCVAL
(
str_gsub
)},
{
LSTRKEY
(
"len"
),
LFUNCVAL
(
str_len
)},
{
LSTRKEY
(
"lower"
),
LFUNCVAL
(
str_lower
)},
{
LSTRKEY
(
"match"
),
LFUNCVAL
(
str_match
)},
{
LSTRKEY
(
"rep"
),
LFUNCVAL
(
str_rep
)},
{
LSTRKEY
(
"reverse"
),
LFUNCVAL
(
str_reverse
)},
{
LSTRKEY
(
"sub"
),
LFUNCVAL
(
str_sub
)},
{
LSTRKEY
(
"upper"
),
LFUNCVAL
(
str_upper
)},
#if LUA_OPTIMIZE_MEMORY > 0
{
LSTRKEY
(
"__index"
),
LROVAL
(
strlib
)},
#endif
{
LNILKEY
,
LNILVAL
}
};
#if LUA_OPTIMIZE_MEMORY != 2
static
void
createmetatable
(
lua_State
*
L
)
{
lua_createtable
(
L
,
0
,
1
);
/* create metatable for strings */
lua_pushliteral
(
L
,
""
);
/* dummy string */
lua_pushvalue
(
L
,
-
2
);
lua_setmetatable
(
L
,
-
2
);
/* set string metatable */
lua_pop
(
L
,
1
);
/* pop dummy string */
lua_pushvalue
(
L
,
-
2
);
/* string library... */
lua_setfield
(
L
,
-
2
,
"__index"
);
/* ...is the __index metamethod */
lua_pop
(
L
,
1
);
/* pop metatable */
}
LROT_FUNCENTRY
(
gfind
,
gfind_nodef
)
#endif
LROT_FUNCENTRY
(
gmatch
,
gmatch
)
LROT_FUNCENTRY
(
gsub
,
str_gsub
)
LROT_FUNCENTRY
(
len
,
str_len
)
LROT_FUNCENTRY
(
lower
,
str_lower
)
LROT_FUNCENTRY
(
match
,
str_match
)
LROT_FUNCENTRY
(
rep
,
str_rep
)
LROT_FUNCENTRY
(
reverse
,
str_reverse
)
LROT_FUNCENTRY
(
sub
,
str_sub
)
LROT_FUNCENTRY
(
upper
,
str_upper
)
LROT_TABENTRY
(
__index
,
strlib
)
LROT_END
(
strlib
,
NULL
,
0
)
// OR DO WE NEED LRTO_MASK_INDEX **TODO**
/*
** Open string library
*/
LUALIB_API
int
luaopen_string
(
lua_State
*
L
)
{
#if LUA_OPTIMIZE_MEMORY == 0
luaL_register
(
L
,
LUA_STRLIBNAME
,
strlib
);
#if defined(LUA_COMPAT_GFIND)
lua_getfield
(
L
,
-
1
,
"gmatch"
);
lua_setfield
(
L
,
-
2
,
"gfind"
);
#endif
createmetatable
(
L
);
return
1
;
#else
lua_pushliteral
(
L
,
""
);
lua_pushrotable
(
L
,
(
void
*
)
strlib
);
lua_pushrotable
(
L
,
LROT_TABLEREF
(
strlib
)
)
;
lua_setmetatable
(
L
,
-
2
);
lua_pop
(
L
,
1
);
return
0
;
#endif
}
app/lua/ltable.c
View file @
310faf7f
...
...
@@ -23,8 +23,8 @@
#define LUAC_CROSS_FILE
#include "lua.h"
#include
C_HEADER_MATH
#include
C_HEADER_STRING
#include
<math.h>
#include
<string.h>
#include "ldebug.h"
#include "ldo.h"
...
...
@@ -86,7 +86,7 @@ static Node *hashnum (const Table *t, lua_Number n) {
int
i
;
if
(
luai_numeq
(
n
,
0
))
/* avoid problems with -0 */
return
gnode
(
t
,
0
);
c_
memcpy
(
a
,
&
n
,
sizeof
(
a
));
memcpy
(
a
,
&
n
,
sizeof
(
a
));
for
(
i
=
1
;
i
<
numints
;
i
++
)
a
[
0
]
+=
a
[
i
];
return
hashmod
(
t
,
a
[
0
]);
}
...
...
@@ -580,7 +580,7 @@ const TValue *luaH_getnum (Table *t, int key) {
/* same thing for rotables */
const
TValue
*
luaH_getnum_ro
(
void
*
t
,
int
key
)
{
const
TValue
*
res
=
luaR_findentryN
(
t
,
key
,
NULL
);
const
TValue
*
res
=
NULL
;
// integer values not supported:
luaR_findentryN(t, key, NULL);
return
res
?
res
:
luaO_nilobject
;
}
...
...
@@ -739,11 +739,7 @@ int luaH_getn (Table *t) {
/* same thing for rotables */
int
luaH_getn_ro
(
void
*
t
)
{
int
i
=
1
,
len
=
0
;
while
(
luaR_findentryN
(
t
,
i
++
,
NULL
))
len
++
;
return
len
;
return
0
;
// Integer Keys are not currently supported for ROTables
}
int
luaH_isdummy
(
Node
*
n
)
{
return
n
==
dummynode
;
}
...
...
app/lua/ltablib.c
View file @
310faf7f
...
...
@@ -13,6 +13,7 @@
#include "lauxlib.h"
#include "lualib.h"
#include "lrotable.h"
#define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_getn(L, n))
...
...
@@ -265,22 +266,18 @@ static int sort (lua_State *L) {
/* }====================================================== */
#undef MIN_OPT_LEVEL
#define MIN_OPT_LEVEL 1
#include "lrodefs.h"
const
LUA_REG_TYPE
tab_funcs
[]
=
{
{
LSTRKEY
(
"concat"
),
LFUNCVAL
(
tconcat
)},
{
LSTRKEY
(
"foreach"
),
LFUNCVAL
(
foreach
)},
{
LSTRKEY
(
"foreachi"
),
LFUNCVAL
(
foreachi
)},
{
LSTRKEY
(
"getn"
),
LFUNCVAL
(
getn
)},
{
LSTRKEY
(
"maxn"
),
LFUNCVAL
(
maxn
)},
{
LSTRKEY
(
"insert"
),
LFUNCVAL
(
tinsert
)},
{
LSTRKEY
(
"remove"
),
LFUNCVAL
(
tremove
)},
{
LSTRKEY
(
"setn"
),
LFUNCVAL
(
setn
)},
{
LSTRKEY
(
"sort"
),
LFUNCVAL
(
sort
)},
{
LNILKEY
,
LNILVAL
}
};
LROT_PUBLIC_BEGIN
(
tab_funcs
)
LROT_FUNCENTRY
(
concat
,
tconcat
)
LROT_FUNCENTRY
(
foreach
,
foreach
)
LROT_FUNCENTRY
(
foreachi
,
foreachi
)
LROT_FUNCENTRY
(
getn
,
getn
)
LROT_FUNCENTRY
(
maxn
,
maxn
)
LROT_FUNCENTRY
(
insert
,
tinsert
)
LROT_FUNCENTRY
(
remove
,
tremove
)
LROT_FUNCENTRY
(
setn
,
setn
)
LROT_FUNCENTRY
(
sort
,
sort
)
LROT_END
(
tab_funcs
,
NULL
,
0
)
LUALIB_API
int
luaopen_table
(
lua_State
*
L
)
{
LREGISTER
(
L
,
LUA_TABLIBNAME
,
tab_funcs
)
;
return
1
;
}
app/lua/ltm.c
View file @
310faf7f
...
...
@@ -10,7 +10,7 @@
#define LUAC_CROSS_FILE
#include "lua.h"
#include
C_HEADER_STRING
#include
<string.h>
#include "lobject.h"
#include "lstate.h"
...
...
app/lua/lua.c
View file @
310faf7f
...
...
@@ -5,10 +5,9 @@
*/
// #include "c_signal.h"
#include "c_stdio.h"
#include "c_stdlib.h"
#include "c_string.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "user_interface.h"
#include "user_version.h"
#include "driver/readline.h"
...
...
@@ -22,9 +21,7 @@
#include "lauxlib.h"
#include "lualib.h"
#include "legc.h"
#ifdef LUA_FLASH_STORE
#include "lflash.h"
#endif
#include "os_type.h"
lua_State
*
globalL
=
NULL
;
...
...
@@ -34,9 +31,9 @@ static const char *progname = LUA_PROGNAME;
static
void
l_message
(
const
char
*
pname
,
const
char
*
msg
)
{
#if defined(LUA_USE_STDIO)
if
(
pname
)
c_
fprintf
(
c_stderr
,
"%s: "
,
pname
);
c_
fprintf
(
c_stderr
,
"%s
\n
"
,
msg
);
c_
fflush
(
c_stderr
);
if
(
pname
)
fprintf
(
c_stderr
,
"%s: "
,
pname
);
fprintf
(
c_stderr
,
"%s
\n
"
,
msg
);
fflush
(
c_stderr
);
#else
if
(
pname
)
luai_writestringerror
(
"%s: "
,
pname
);
luai_writestringerror
(
"%s
\n
"
,
msg
);
...
...
@@ -124,7 +121,7 @@ static int dofsfile (lua_State *L, const char *name) {
static
int
dostring
(
lua_State
*
L
,
const
char
*
s
,
const
char
*
name
)
{
int
status
=
luaL_loadbuffer
(
L
,
s
,
c_
strlen
(
s
),
name
)
||
docall
(
L
,
0
,
1
);
int
status
=
luaL_loadbuffer
(
L
,
s
,
strlen
(
s
),
name
)
||
docall
(
L
,
0
,
1
);
return
report
(
L
,
status
);
}
...
...
@@ -150,7 +147,7 @@ static int incomplete (lua_State *L, int status) {
size_t
lmsg
;
const
char
*
msg
=
lua_tolstring
(
L
,
-
1
,
&
lmsg
);
const
char
*
tp
=
msg
+
lmsg
-
(
sizeof
(
LUA_QL
(
"<eof>"
))
-
1
);
if
(
c_
strstr
(
msg
,
LUA_QL
(
"<eof>"
))
==
tp
)
{
if
(
strstr
(
msg
,
LUA_QL
(
"<eof>"
))
==
tp
)
{
lua_pop
(
L
,
1
);
return
1
;
}
...
...
@@ -216,7 +213,7 @@ static int runargs (lua_State *L, char **argv, int n) {
int
memlimit
=
0
;
if
(
*
limit
==
'\0'
)
limit
=
argv
[
++
i
];
lua_assert
(
limit
!=
NULL
);
memlimit
=
c_
atoi
(
limit
);
memlimit
=
atoi
(
limit
);
lua_gc
(
L
,
LUA_GCSETMEMLIMIT
,
memlimit
);
break
;
}
...
...
@@ -309,7 +306,7 @@ int lua_main (int argc, char **argv) {
gLoad
.
L
=
L
;
gLoad
.
firstline
=
1
;
gLoad
.
done
=
0
;
gLoad
.
line
=
c_
malloc
(
LUA_MAXINPUT
);
gLoad
.
line
=
malloc
(
LUA_MAXINPUT
);
gLoad
.
len
=
LUA_MAXINPUT
;
gLoad
.
line_position
=
0
;
gLoad
.
prmt
=
get_prompt
(
L
,
1
);
...
...
@@ -326,7 +323,7 @@ int lua_main (int argc, char **argv) {
int
lua_put_line
(
const
char
*
s
,
size_t
l
)
{
if
(
s
==
NULL
||
++
l
>
LUA_MAXINPUT
||
gLoad
.
line_position
>
0
)
return
0
;
c_
memcpy
(
gLoad
.
line
,
s
,
l
);
memcpy
(
gLoad
.
line
,
s
,
l
);
gLoad
.
line
[
l
]
=
'\0'
;
gLoad
.
line_position
=
l
;
gLoad
.
done
=
1
;
...
...
@@ -338,7 +335,7 @@ void lua_handle_input (bool force)
{
while
(
gLoad
.
L
&&
(
force
||
readline
(
&
gLoad
)))
{
NODE_DBG
(
"Handle Input: first=%u, pos=%u, len=%u, actual=%u, line=%s
\n
"
,
gLoad
.
firstline
,
gLoad
.
line_position
,
gLoad
.
len
,
c_
strlen
(
gLoad
.
line
),
gLoad
.
line
);
gLoad
.
line_position
,
gLoad
.
len
,
strlen
(
gLoad
.
line
),
gLoad
.
line
);
dojob
(
&
gLoad
);
force
=
false
;
}
...
...
@@ -359,7 +356,7 @@ static void dojob(lua_Load *load){
do
{
if
(
load
->
done
==
1
){
l
=
c_
strlen
(
b
);
l
=
strlen
(
b
);
if
(
l
>
0
&&
b
[
l
-
1
]
==
'\n'
)
/* line ends with newline? */
b
[
l
-
1
]
=
'\0'
;
/* remove it */
if
(
load
->
firstline
&&
b
[
0
]
==
'='
)
/* first line starts with `=' ? */
...
...
@@ -403,8 +400,8 @@ static void dojob(lua_Load *load){
load
->
done
=
0
;
load
->
line_position
=
0
;
c_
memset
(
load
->
line
,
0
,
load
->
len
);
c_
puts
(
load
->
prmt
);
memset
(
load
->
line
,
0
,
load
->
len
);
puts
(
load
->
prmt
);
}
#ifndef uart_putc
...
...
@@ -470,7 +467,7 @@ static bool readline(lua_Load *load){
if
(
load
->
line_position
==
0
)
{
/* Get a empty line, then go to get a new line */
c_
puts
(
load
->
prmt
);
puts
(
load
->
prmt
);
continue
;
}
else
{
load
->
done
=
1
;
...
...
app/lua/lua.h
View file @
310faf7f
...
...
@@ -11,16 +11,10 @@
#ifdef LUAC_CROSS_FILE
#include "luac_cross.h"
#endif
#ifdef LUA_CROSS_COMPILER
#include <stdarg.h>
#include <stddef.h>
#include <ctype.h>
#else
#include "c_stdarg.h"
#include "c_stddef.h"
#include "c_types.h"
#include <ctype.h>
#endif
#include <stdint.h>
#include "stdarg.h"
#include "stddef.h"
#include "ctype.h"
#include "luaconf.h"
...
...
app/lua/luac_cross.h
View file @
310faf7f
...
...
@@ -6,73 +6,14 @@
#define luac_cross_h
#ifdef LUA_CROSS_COMPILER
#define C_HEADER_ASSERT <assert.h>
#define C_HEADER_CTYPE <ctype.h>
#define C_HEADER_ERRNO <errno.h>
#define C_HEADER_FCNTL <fcntl.h>
#define C_HEADER_LOCALE <locale.h>
#define C_HEADER_MATH <math.h>
#define C_HEADER_STDIO <stdio.h>
#define C_HEADER_STDLIB <stdlib.h>
#define C_HEADER_STRING <string.h>
#define C_HEADER_TIME <time.h>
#define ICACHE_RODATA_ATTR
#define c_abs abs
#define c_exit exit
#define c_fclose fclose
#define c_feof feof
#define c_ferror ferror
#define c_fopen fopen
#define c_fread fread
#define c_free free
#define c_freopen freopen
#define c_getc getc
#define c_getenv getenv
#define c_malloc malloc
#define c_memcmp memcmp
#define c_memcpy memcpy
#define c_printf printf
#define c_puts puts
#define c_reader reader
#define c_realloc realloc
#define c_sprintf sprintf
#define c_stderr stderr
#define c_stdin stdin
#define c_stdout stdout
#define c_strcat strcat
#define c_strchr strchr
#define c_strcmp strcmp
#define c_strcoll strcoll
#define c_strcpy strcpy
#define c_strcspn strcspn
#define c_strerror strerror
#define c_strlen strlen
#define c_strncat strncat
#define c_strncmp strncmp
#define c_strncpy strncpy
#define c_strpbrk strpbrk
#define c_strrchr strrchr
#define c_strstr strstr
double
c_strtod
(
const
char
*
__n
,
char
**
__end_PTR
);
#define c_ungetc ungetc
#define c_strtol strtol
#define c_strtoul strtoul
#define dbg_printf printf
#else
#define C_HEADER_ASSERT "c_assert.h"
#define C_HEADER_CTYPE "c_ctype.h"
#define C_HEADER_ERRNO "c_errno.h"
#define C_HEADER_FCNTL "c_fcntl.h"
#define C_HEADER_LOCALE "c_locale.h"
#define C_HEADER_MATH "c_math.h"
#define C_HEADER_STDIO "c_stdio.h"
#define C_HEADER_STDLIB "c_stdlib.h"
#define C_HEADER_STRING "c_string.h"
#define C_HEADER_TIME "c_time.h"
#endif
/* LUA_CROSS_COMPILER */
#endif
/* luac_cross_h */
app/lua/luac_cross/Makefile
View file @
310faf7f
...
...
@@ -8,12 +8,12 @@
summary
?=
@true
CCFLAGS
:=
-I
..
-I
../../include
-I
../../libc
-I
../../uzlib
CCFLAGS
:=
-I
..
-I
../../include
-I
../../uzlib
LDFLAGS
:=
-L
$(SDK_DIR)
/lib
-L
$(SDK_DIR)
/ld
-lm
-ldl
-Wl
,-Map
=
mapfile
CCFLAGS
+=
-Wall
DEFINES
+=
-DLUA_CROSS_COMPILER
-DLUA_OPTIMIZE_MEMORY
=
2
DEFINES
+=
-DLUA_CROSS_COMPILER
TARGET
=
host
...
...
@@ -33,13 +33,12 @@ LUASRC := lapi.c lauxlib.c lbaselib.c lcode.c ldblib.c ldebug.c
lmathlib.c lmem.c loadlib.c lobject.c lopcodes.c lparser.c
\
lrotable.c lstate.c lstring.c lstrlib.c ltable.c ltablib.c
\
ltm.c lundump.c lvm.c lzio.c
LIBCSRC
:=
c_stdlib.c
UZSRC
:=
uzlib_deflate.c crc32.c
#
# This relies on the files being unique on the vpath
#
SRC
:=
$(LUACSRC)
$(LUASRC)
$(LIBCSRC)
$(UZSRC)
SRC
:=
$(LUACSRC)
$(LUASRC)
$(UZSRC)
vpath %.c .
:
..:../../libc:../../uzlib
ODIR
:=
.output/
$(TARGET)
/
$(FLAVOR)
/obj
...
...
@@ -54,7 +53,7 @@ CC := $(WRAPCC) gcc
ECHO
:=
echo
BUILD_TYPE
:=
$(
shell
$(CC)
$(EXTRA_CCFLAGS)
-E
-dM
- <../../
../app/
include/user_config.h |
grep
LUA_NUMBER_INTEGRAL |
wc
-l
)
BUILD_TYPE
:=
$(
shell
$(CC)
$(EXTRA_CCFLAGS)
-E
-dM
- <../../include/user_config.h |
grep
LUA_NUMBER_INTEGRAL |
wc
-l
)
ifeq
($(BUILD_TYPE),0)
IMAGE
:=
../../../luac.cross
else
...
...
app/lua/luac_cross/lflashimg.c
View file @
310faf7f
...
...
@@ -7,17 +7,15 @@
#define LUAC_CROSS_FILE
#include "luac_cross.h"
#include
C_HEADER_CTYPE
#include
C_HEADER_STDIO
#include
C_HEADER_STDLIB
#include
C_HEADER_STRING
#include
<ctype.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
#define lflashimg_c
#define LUA_CORE
#include "lobject.h"
#include "lstring.h"
#undef LUA_FLASH_STORE
#define LUA_FLASH_STORE
#include "lflash.h"
#include "uzlib.h"
...
...
app/lua/luac_cross/liolib.c
View file @
310faf7f
...
...
@@ -12,12 +12,12 @@
#define liolib_c
#define LUA_LIB
#define LUA_OPTIMIZE_MEMORY 2
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
#include "lrotable.h"
#define IO_INPUT 1
#define IO_OUTPUT 2
...
...
@@ -439,36 +439,31 @@ static int f_flush (lua_State *L) {
return
pushresult
(
L
,
fflush
(
tofile
(
L
))
==
0
,
NULL
);
}
#define MIN_OPT_LEVEL 2
#include "lrodefs.h"
const
LUA_REG_TYPE
iolib_funcs
[]
=
{
{
LSTRKEY
(
"close"
),
LFUNCVAL
(
io_close
)},
{
LSTRKEY
(
"flush"
),
LFUNCVAL
(
io_flush
)},
{
LSTRKEY
(
"input"
),
LFUNCVAL
(
io_input
)},
{
LSTRKEY
(
"lines"
),
LFUNCVAL
(
io_lines
)},
{
LSTRKEY
(
"open"
),
LFUNCVAL
(
io_open
)},
{
LSTRKEY
(
"output"
),
LFUNCVAL
(
io_output
)},
{
LSTRKEY
(
"read"
),
LFUNCVAL
(
io_read
)},
{
LSTRKEY
(
"type"
),
LFUNCVAL
(
io_type
)},
{
LSTRKEY
(
"write"
),
LFUNCVAL
(
io_write
)},
{
LSTRKEY
(
"__index"
),
LROVAL
(
iolib_funcs
)},
{
LNILKEY
,
LNILVAL
}
};
#include "lrodefs.h"
const
LUA_REG_TYPE
flib
[]
=
{
{
LSTRKEY
(
"close"
),
LFUNCVAL
(
io_close
)},
{
LSTRKEY
(
"flush"
),
LFUNCVAL
(
f_flush
)},
{
LSTRKEY
(
"lines"
),
LFUNCVAL
(
f_lines
)},
{
LSTRKEY
(
"read"
),
LFUNCVAL
(
f_read
)},
{
LSTRKEY
(
"seek"
),
LFUNCVAL
(
f_seek
)},
{
LSTRKEY
(
"setvbuf"
),
LFUNCVAL
(
f_setvbuf
)},
{
LSTRKEY
(
"write"
),
LFUNCVAL
(
f_write
)},
{
LSTRKEY
(
"__gc"
),
LFUNCVAL
(
io_gc
)},
{
LSTRKEY
(
"__tostring"
),
LFUNCVAL
(
io_tostring
)},
{
LSTRKEY
(
"__index"
),
LROVAL
(
flib
)},
{
LNILKEY
,
LNILVAL
}
};
LROT_PUBLIC_BEGIN
(
iolib
)
LROT_FUNCENTRY
(
close
,
io_close
)
LROT_FUNCENTRY
(
flush
,
io_flush
)
LROT_FUNCENTRY
(
input
,
io_input
)
LROT_FUNCENTRY
(
lines
,
io_lines
)
LROT_FUNCENTRY
(
open
,
io_open
)
LROT_FUNCENTRY
(
output
,
io_output
)
LROT_FUNCENTRY
(
read
,
io_read
)
LROT_FUNCENTRY
(
type
,
io_type
)
LROT_FUNCENTRY
(
write
,
io_write
)
LROT_TABENTRY
(
__index
,
iolib
)
LROT_END
(
iolib
,
NULL
,
0
)
LROT_BEGIN
(
flib
)
LROT_FUNCENTRY
(
close
,
io_close
)
LROT_FUNCENTRY
(
flush
,
f_flush
)
LROT_FUNCENTRY
(
lines
,
f_lines
)
LROT_FUNCENTRY
(
read
,
f_read
)
LROT_FUNCENTRY
(
seek
,
f_seek
)
LROT_FUNCENTRY
(
setvbuf
,
f_setvbuf
)
LROT_FUNCENTRY
(
write
,
f_write
)
LROT_FUNCENTRY
(
__gc
,
io_gc
)
LROT_FUNCENTRY
(
__tostring
,
io_tostring
)
LROT_TABENTRY
(
__index
,
flib
)
LROT_END
(
flib
,
NULL
,
LROT_MASK_GC_INDEX
)
static
const
luaL_Reg
io_base
[]
=
{{
NULL
,
NULL
}};
...
...
@@ -481,12 +476,12 @@ static void createstdfile (lua_State *L, FILE *f, int k, const char *fname) {
}
LUALIB_API
int
luaopen_io
(
lua_State
*
L
)
{
luaL_rometatable
(
L
,
LUA_FILEHANDLE
,
(
void
*
)
flib
);
/* create metatable for file handles */
luaL_rometatable
(
L
,
LUA_FILEHANDLE
,
LROT_TABLEREF
(
flib
)
)
;
/* create metatable for file handles */
luaL_register_light
(
L
,
LUA_IOLIBNAME
,
io_base
);
lua_pushvalue
(
L
,
-
1
);
lua_setmetatable
(
L
,
-
2
);
lua_pushliteral
(
L
,
"__index"
);
lua_pushrotable
(
L
,
(
void
*
)
iolib_funcs
);
lua_pushrotable
(
L
,
LROT_TABLEREF
(
iolib
)
);
lua_rawset
(
L
,
-
3
);
/* create (and set) default files */
...
...
app/lua/luac_cross/loslib.c
View file @
310faf7f
...
...
@@ -7,11 +7,11 @@
#define LUAC_CROSS_FILE
#include "luac_cross.h"
#include
C_HEADER_ERRNO
#include
C_HEADER_LOCALE
#include
C_HEADER_STDLIB
#include
C_HEADER_STRING
#include
C_HEADER_TIME
#include
<errno.h>
#include
<locale.h>
#include
<stdlib.h>
#include
<string.h>
#include
<time.h>
#define loslib_c
#define LUA_LIB
...
...
@@ -20,6 +20,7 @@
#include "lauxlib.h"
#include "lualib.h"
#include "lrotable.h"
static
int
os_pushresult
(
lua_State
*
L
,
int
i
,
const
char
*
filename
)
{
int
en
=
errno
;
/* calls to Lua API may change this value */
...
...
@@ -216,33 +217,28 @@ static int os_setlocale (lua_State *L) {
static
int
os_exit
(
lua_State
*
L
)
{
c_
exit
(
luaL_optint
(
L
,
1
,
EXIT_SUCCESS
));
exit
(
luaL_optint
(
L
,
1
,
EXIT_SUCCESS
));
}
#undef MIN_OPT_LEVEL
#define MIN_OPT_LEVEL 1
#include "lrodefs.h"
const
LUA_REG_TYPE
syslib
[]
=
{
{
LSTRKEY
(
"clock"
),
LFUNCVAL
(
os_clock
)},
{
LSTRKEY
(
"date"
),
LFUNCVAL
(
os_date
)},
LROT_PUBLIC_BEGIN
(
oslib
)
LROT_FUNCENTRY
(
clock
,
os_clock
)
LROT_FUNCENTRY
(
date
,
os_date
)
#if !defined LUA_NUMBER_INTEGRAL
{
LSTRKE
Y
(
"
difftime
"
),
LFUNCVAL
(
os_difftime
)
},
LROT_FUNCENTR
Y
(
difftime
,
os_difftime
)
#endif
{
LSTRKEY
(
"execute"
),
LFUNCVAL
(
os_execute
)},
{
LSTRKEY
(
"exit"
),
LFUNCVAL
(
os_exit
)},
{
LSTRKEY
(
"getenv"
),
LFUNCVAL
(
os_getenv
)},
{
LSTRKEY
(
"remove"
),
LFUNCVAL
(
os_remove
)},
{
LSTRKEY
(
"rename"
),
LFUNCVAL
(
os_rename
)},
{
LSTRKEY
(
"setlocale"
),
LFUNCVAL
(
os_setlocale
)},
{
LSTRKEY
(
"time"
),
LFUNCVAL
(
os_time
)},
{
LSTRKEY
(
"tmpname"
),
LFUNCVAL
(
os_tmpname
)},
{
LNILKEY
,
LNILVAL
}
};
LROT_FUNCENTRY
(
execute
,
os_execute
)
LROT_FUNCENTRY
(
exit
,
os_exit
)
LROT_FUNCENTRY
(
getenv
,
os_getenv
)
LROT_FUNCENTRY
(
remove
,
os_remove
)
LROT_FUNCENTRY
(
rename
,
os_rename
)
LROT_FUNCENTRY
(
setlocale
,
os_setlocale
)
LROT_FUNCENTRY
(
time
,
os_time
)
LROT_FUNCENTRY
(
tmpname
,
os_tmpname
)
LROT_END
(
oslib
,
NULL
,
0
)
/* }====================================================== */
LUALIB_API
int
luaopen_os
(
lua_State
*
L
)
{
LREGISTER
(
L
,
LUA_OSLIBNAME
,
syslib
)
;
return
1
;
}
app/lua/luac_cross/luac.c
View file @
310faf7f
...
...
@@ -7,10 +7,10 @@
#define LUAC_CROSS_FILE
#include "luac_cross.h"
#include
C_HEADER_ERRNO
#include
C_HEADER_STDIO
#include
C_HEADER_STDLIB
#include
C_HEADER_STRING
#include
<errno.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
#include <time.h>
#define luac_c
...
...
app/lua/luac_cross/mingw32-Makefile.mak
View file @
310faf7f
...
...
@@ -38,12 +38,11 @@ LUASRC := lapi.c lauxlib.c lbaselib.c lcode.c ldblib.c ldebug.c
lmathlib.c
lmem.c
loadlib.c
lobject.c
lopcodes.c
lparser.c
\
lrotable.c
lstate.c
lstring.c
lstrlib.c
ltable.c
ltablib.c
\
ltm.c
lundump.c
lvm.c
lzio.c
LIBCSRC
:=
c_stdlib.c
UZSRC
:=
uzlib_deflate.c crc32.c
#
# This relies on the files being unique on the vpath
#
SRC
:=
$(LUACSRC)
$(LUASRC)
$(LIBCSRC)
$(UZSRC)
SRC
:=
$(LUACSRC)
$(LUASRC)
$(UZSRC)
vpath %.c .
:
..:../../libc:../../uzlib
...
...
app/lua/luac_cross/print.c
View file @
310faf7f
...
...
@@ -7,8 +7,8 @@
#define LUAC_CROSS_FILE
#include "luac_cross.h"
#include
C_HEADER_CTYPE
#include
C_HEADER_STDIO
#include
<ctype.h>
#include
<stdio.h>
#define luac_c
#define LUA_CORE
...
...
app/lua/luaconf.h
View file @
310faf7f
...
...
@@ -8,13 +8,9 @@
#ifndef lconfig_h
#define lconfig_h
#ifdef LUA_CROSS_COMPILER
#include <limits.h>
#include <stddef.h>
#else
#include "c_limits.h"
#include "c_stddef.h"
#endif
#include <stdbool.h>
#include "user_config.h"
/*
...
...
@@ -262,11 +258,7 @@
#define lua_stdin_is_tty() isatty(0)
#elif defined(LUA_WIN)
#include <io.h>
#ifdef LUA_CROSS_COMPILER
#include <stdio.h>
#else
#include "c_stdio.h"
#endif
#define lua_stdin_is_tty() _isatty(_fileno(stdin))
#else
...
...
@@ -317,11 +309,11 @@
#define lua_saveline(L,idx) \
if (lua_strlen(L,idx) > 0)
/* non-empty line? */
\
add_history(lua_tostring(L, idx));
/* add it to history */
#define lua_freeline(L,b) ((void)L,
c_
free(b))
#define lua_freeline(L,b) ((void)L, free(b))
#else // #if defined(LUA_CROSS_COMPILER) && defined(LUA_USE_READLINE)
#define lua_readline(L,b,p) \
((void)L,
c_
fputs(p, c_stdout),
c_
fflush(c_stdout),
/* show prompt */
\
c_
fgets(b, LUA_MAXINPUT, c_stdin) != NULL)
/* get line */
((void)L, fputs(p, c_stdout), fflush(c_stdout),
/* show prompt */
\
fgets(b, LUA_MAXINPUT, c_stdin) != NULL)
/* get line */
#define lua_saveline(L,idx) { (void)L; (void)idx; }
#define lua_freeline(L,b) { (void)L; (void)b; }
#endif // #if defined(LUA_USE_READLINE)
...
...
@@ -342,8 +334,8 @@ extern int readline4lua(const char *prompt, char *buffer, int length);
** avoids including 'stdio.h' everywhere.)
*/
#if !defined(LUA_USE_STDIO)
#define luai_writestring(s, l)
c_
puts(s)
#define luai_writeline()
c_
puts("\n")
#define luai_writestring(s, l) puts(s)
#define luai_writeline() puts("\n")
#endif // defined(LUA_USE_STDIO)
/*
...
...
@@ -622,31 +614,23 @@ extern int readline4lua(const char *prompt, char *buffer, int length);
#define LUA_NUMBER_SCAN "%lf"
#define LUA_NUMBER_FMT "%.14g"
#endif // #if defined LUA_NUMBER_INTEGRAL
#define lua_number2str(s,n)
c_
sprintf((s), LUA_NUMBER_FMT, (n))
#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
#define LUAI_MAXNUMBER2STR 32
/* 16 digits, sign, point, and \0 */
#if defined LUA_NUMBER_INTEGRAL
#if !defined LUA_INTEGRAL_LONGLONG
#define lua_str2number(s,p)
c_
strtol((s), (p), 10)
#define lua_str2number(s,p) strtol((s), (p), 10)
#else
#define lua_str2number(s,p)
c_
strtoll((s), (p), 10)
#define lua_str2number(s,p) strtoll((s), (p), 10)
#endif // #if !defined LUA_INTEGRAL_LONGLONG
#else
#ifdef _MSC_VER //what's wrong with stdlib strtod?
#define lua_str2number(s,p) strtod((s), (p))
#else
#define lua_str2number(s,p) c_strtod((s), (p))
#endif
#endif // #if defined LUA_NUMBER_INTEGRAL
/*
@@ The luai_num* macros define the primitive operations over numbers.
*/
#if defined(LUA_CORE) || defined(LUA_LIB)
#ifdef LUA_CROSS_COMPILER
#include <math.h>
#else
#include "c_math.h"
#endif
#define luai_numadd(a,b) ((a)+(b))
#define luai_numsub(a,b) ((a)-(b))
#define luai_nummul(a,b) ((a)*(b))
...
...
@@ -801,7 +785,7 @@ union luai_Cast { double l_d; long l_l; };
#include <unistd.h>
#define LUA_TMPNAMBUFSIZE 32
#define lua_tmpnam(b,e) { \
c_
strcpy(b, "/tmp/lua_XXXXXX"); \
strcpy(b, "/tmp/lua_XXXXXX"); \
e = mkstemp(b); \
if (e != -1) close(e); \
e = (e == -1); }
...
...
@@ -821,7 +805,7 @@ union luai_Cast { double l_d; long l_l; };
*/
#if defined(LUA_USE_POPEN)
#define lua_popen(L,c,m) ((void)L,
c_
fflush(NULL), popen(c,m))
#define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m))
#define lua_pclose(L,file) ((void)L, (pclose(file) != -1))
#elif defined(LUA_WIN)
...
...
@@ -910,8 +894,8 @@ union luai_Cast { double l_d; long l_l; };
** without modifying the main part of the file.
*/
#if
LUA_OPTIMIZE_MEMORY == 2 &&
defined(LUA_USE_POPEN)
#error "Pipes not supported
in aggresive optimization mode (LUA_OPTIMIZE_MEMORY=2)
"
#if defined(LUA_USE_POPEN)
#error "Pipes not supported
NodeMCU firmware
"
#endif
#endif
app/lua/lundump.c
View file @
310faf7f
...
...
@@ -9,7 +9,7 @@
#define LUAC_CROSS_FILE
#include "lua.h"
#include
C_HEADER_STRING
#include
<string.h>
#include "ldebug.h"
#include "ldo.h"
...
...
@@ -309,7 +309,7 @@ static void LoadHeader(LoadState* S)
S
->
numsize
=
h
[
10
]
=
s
[
10
];
/* length of lua_Number */
S
->
toflt
=
(
s
[
11
]
>
intck
);
/* check if conversion from int lua_Number to flt is needed */
if
(
S
->
toflt
)
s
[
11
]
=
h
[
11
];
IF
(
c_
memcmp
(
h
,
s
,
LUAC_HEADERSIZE
)
!=
0
,
"bad header"
);
IF
(
memcmp
(
h
,
s
,
LUAC_HEADERSIZE
)
!=
0
,
"bad header"
);
}
/*
...
...
@@ -338,7 +338,7 @@ Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name)
void
luaU_header
(
char
*
h
)
{
int
x
=
1
;
c_
memcpy
(
h
,
LUA_SIGNATURE
,
sizeof
(
LUA_SIGNATURE
)
-
1
);
memcpy
(
h
,
LUA_SIGNATURE
,
sizeof
(
LUA_SIGNATURE
)
-
1
);
h
+=
sizeof
(
LUA_SIGNATURE
)
-
1
;
*
h
++=
(
char
)
LUAC_VERSION
;
*
h
++=
(
char
)
LUAC_FORMAT
;
...
...
app/lua/lundump.h
View file @
310faf7f
...
...
@@ -7,11 +7,7 @@
#ifndef lundump_h
#define lundump_h
#ifdef LUA_CROSS_COMPILER
#include <stdint.h>
#else
#include "c_stdint.h"
#endif
#include "lobject.h"
#include "lzio.h"
...
...
app/lua/lvm.c
View file @
310faf7f
...
...
@@ -10,9 +10,9 @@
#define LUAC_CROSS_FILE
#include "lua.h"
#include
C_HEADER_STDIO
#include
C_HEADER_STRING
#include
C_HEADER_MATH
#include
<stdio.h>
#include
<string.h>
#include
<math.h>
#include "ldebug.h"
#include "ldo.h"
...
...
@@ -252,10 +252,10 @@ static int l_strcmp (const TString *ls, const TString *rs) {
const
char
*
r
=
getstr
(
rs
);
size_t
lr
=
rs
->
tsv
.
len
;
for
(;;)
{
int
temp
=
c_
strcoll
(
l
,
r
);
int
temp
=
strcoll
(
l
,
r
);
if
(
temp
!=
0
)
return
temp
;
else
{
/* strings are equal up to a `\0' */
size_t
len
=
c_
strlen
(
l
);
/* index of first `\0' in both strings */
size_t
len
=
strlen
(
l
);
/* index of first `\0' in both strings */
if
(
len
==
lr
)
/* r is finished? */
return
(
len
==
ll
)
?
0
:
1
;
else
if
(
len
==
ll
)
/* l is finished? */
...
...
@@ -363,7 +363,7 @@ void luaV_concat (lua_State *L, int total, int last) {
tl
=
0
;
for
(
i
=
n
;
i
>
0
;
i
--
)
{
/* concat all strings */
size_t
l
=
tsvalue
(
top
-
i
)
->
len
;
c_
memcpy
(
buffer
+
tl
,
svalue
(
top
-
i
),
l
);
memcpy
(
buffer
+
tl
,
svalue
(
top
-
i
),
l
);
tl
+=
l
;
}
setsvalue2s
(
L
,
top
-
n
,
luaS_newlstr
(
L
,
buffer
,
tl
));
...
...
app/lua/lzio.c
View file @
310faf7f
...
...
@@ -10,7 +10,7 @@
#define LUAC_CROSS_FILE
#include "lua.h"
#include
C_HEADER_STRING
#include
<string.h>
#include "llimits.h"
#include "lmem.h"
...
...
@@ -62,7 +62,7 @@ size_t luaZ_read (ZIO *z, void *b, size_t n) {
return
n
;
/* return number of missing bytes */
m
=
(
n
<=
z
->
n
)
?
n
:
z
->
n
;
/* min. between n and z->n */
if
(
b
)
c_
memcpy
(
b
,
z
->
p
,
m
);
memcpy
(
b
,
z
->
p
,
m
);
z
->
n
-=
m
;
z
->
i
+=
m
;
z
->
p
+=
m
;
...
...
Prev
1
…
3
4
5
6
7
8
9
10
11
…
19
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment