Discard leading whitespace after semicolon properly

master 0.0.1
Ondřej Hruška 9 years ago
parent c7f3337c6f
commit 430e2ca7ba
  1. 2
      scpi.pro.user
  2. 5
      source/scpi_parser.c

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.5.1, 2015-12-05T17:34:08. --> <!-- Written by QtCreator 3.5.1, 2015-12-05T18:39:54. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>

@ -431,7 +431,7 @@ static void pars_cmd_colon(void)
if (pst.cur_level_i == 0 || pst.cmdbuf_kept) { if (pst.cur_level_i == 0 || pst.cmdbuf_kept) {
// top level command starts with colon (or after semicolon - reset level) // top level command starts with colon (or after semicolon - reset level)
pars_reset_cmd(); pars_reset_cmd(); // clears keep flag
} else { } else {
// colon after nothing - error // colon after nothing - error
scpi_add_error(E_CMD_SYNTAX_ERROR, "Unexpected colon."); scpi_add_error(E_CMD_SYNTAX_ERROR, "Unexpected colon.");
@ -443,6 +443,7 @@ static void pars_cmd_colon(void)
// internal colon - partial match // internal colon - partial match
if (match_cmd(true)) { if (match_cmd(true)) {
// ok // ok
pst.cmdbuf_kept = false; // drop the flag (needed for rejecting whitespace)
} else { } else {
// error // error
err_no_such_command_partial(); err_no_such_command_partial();
@ -517,7 +518,7 @@ static void pars_cmd_newline(void)
/** Whitespace received when collecting command parts */ /** Whitespace received when collecting command parts */
static void pars_cmd_space(void) static void pars_cmd_space(void)
{ {
if (pst.cur_level_i == 0 && pst.charbuf_i == 0) { if ((pst.cmdbuf_kept || pst.cur_level_i == 0) && pst.charbuf_i == 0) {
// leading whitespace, ignore // leading whitespace, ignore
return; return;
} }

Loading…
Cancel
Save