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
f9533ed8
Commit
f9533ed8
authored
Oct 16, 2016
by
Philip Gladstone
Committed by
Marcel Stör
Oct 16, 2016
Browse files
Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
parent
880bd985
Changes
4
Hide whitespace changes
Inline
Side-by-side
app/lua/liolib.c
View file @
f9533ed8
...
...
@@ -343,28 +343,19 @@ static int read_line (lua_State *L, int f) {
static
int
read_line
(
lua_State
*
L
,
int
f
)
{
luaL_Buffer
b
;
luaL_buffinit
(
L
,
&
b
);
char
*
p
=
luaL_prepbuffer
(
&
b
);
signed
char
c
=
EOF
;
int
i
=
0
;
do
{
signed
char
c
;
do
{
c
=
(
signed
char
)
vfs_getc
(
f
);
if
(
c
==
EOF
){
if
(
c
==
EOF
)
{
break
;
}
p
[
i
++
]
=
c
;
}
while
((
c
!=
EOF
)
&&
(
c
!=
'\n'
)
&&
(
i
<
LUAL_BUFFERSIZE
)
);
if
(
i
>
0
&&
p
[
i
-
1
]
==
'\n'
)
i
--
;
/* do not include `eol' */
if
(
i
==
0
){
luaL_pushresult
(
&
b
);
/* close buffer */
return
(
lua_objlen
(
L
,
-
1
)
>
0
);
/* check whether read something */
}
if
(
c
!=
'\n'
)
{
luaL_addchar
(
&
b
,
c
);
}
}
while
(
c
!=
'\n'
);
luaL_addsize
(
&
b
,
i
);
luaL_pushresult
(
&
b
);
/* close buffer */
return
1
;
/* read at least an `eol'
*/
return
(
lua_objlen
(
L
,
-
1
)
>
0
);
/* check whether read something
*/
}
#endif
...
...
app/lua/luaconf.h
View file @
f9533ed8
...
...
@@ -556,7 +556,7 @@ extern int readline4lua(const char *prompt, char *buffer, int length);
** For example: If set to 4K a call to string.gsub will need more than
** 5k C stack space.
*/
#define LUAL_BUFFERSIZE
BUFSIZ
#define LUAL_BUFFERSIZE
256
/* }================================================================== */
...
...
app/modules/ow.c
View file @
f9533ed8
...
...
@@ -134,6 +134,8 @@ static int ow_read_bytes( lua_State *L )
if
(
size
==
0
)
return
0
;
luaL_argcheck
(
L
,
size
<=
LUAL_BUFFERSIZE
,
2
,
"Attempt to read too many characters"
);
luaL_Buffer
b
;
luaL_buffinit
(
L
,
&
b
);
char
*
p
=
luaL_prepbuffer
(
&
b
);
...
...
docs/en/modules/ow.md
View file @
f9533ed8
...
...
@@ -84,7 +84,7 @@ Reads multi bytes.
#### Parameters
-
`pin`
1~12, I/O index
-
`size`
number of bytes to be read from slave device
-
`size`
number of bytes to be read from slave device
(up to 256)
#### Returns
`string`
bytes read from slave device
...
...
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