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
1c2fad53
Commit
1c2fad53
authored
Nov 22, 2015
by
devsaurus
Browse files
re-add detection of CR as newline
parent
b216e6a8
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/lua/lua.c
View file @
1c2fad53
...
...
@@ -541,6 +541,7 @@ extern bool uart0_echo;
extern
bool
run_input
;
extern
uint16_t
need_len
;
extern
int16_t
end_char
;
static
char
last_nl_char
=
'\0'
;
static
bool
readline
(
lua_Load
*
load
){
// NODE_DBG("readline() is called.\n");
bool
need_dojob
=
false
;
...
...
@@ -549,11 +550,18 @@ static bool readline(lua_Load *load){
{
if
(
run_input
)
{
/* skip CR key */
if
(
ch
==
'\r'
)
char
tmp_last_nl_char
=
last_nl_char
;
// reset marker, will be finally set below when newline is processed
last_nl_char
=
'\0'
;
/* handle CR & LF characters
filters second char of LF&CR (\n\r) or CR&LF (\r\n) sequences */
if
((
ch
==
'\r'
&&
tmp_last_nl_char
==
'\n'
)
||
// \n\r sequence -> skip \r
(
ch
==
'\n'
&&
tmp_last_nl_char
==
'\r'
))
// \r\n sequence -> skip \n
{
continue
;
}
/* backspace key */
else
if
(
ch
==
0x7f
||
ch
==
0x08
)
{
...
...
@@ -578,8 +586,10 @@ static bool readline(lua_Load *load){
// }
/* end of line */
if
(
ch
==
'\n'
)
if
(
ch
==
'\r'
||
ch
==
'\n'
)
{
last_nl_char
=
ch
;
load
->
line
[
load
->
line_position
]
=
0
;
if
(
uart0_echo
)
uart_putc
(
'\n'
);
uart_on_data_cb
(
load
->
line
,
load
->
line_position
);
...
...
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