Discard leading whitespace after semicolon properly

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

@ -18,7 +18,7 @@ int main()
send_cmd("*SRE 4\n"); // enable SRQ on error
send_cmd("FOO:BAR:BAZ\n"); // invalid command causes error
send_cmd("SYST:ERR:COUNT?\n"); // error subsystem
send_cmd("SYST:ERR:NEXT?;COUNT?;NEXT?\n"); // semicolon works according to spec
send_cmd("SYST:ERR:NEXT?; COUNT?; NEXT?\n"); // semicolon works according to spec
send_cmd("DATA:BLOB #216abcdefghijklmnop\n"); // binary data block
send_cmd("APPLY:SINE 50, 1.0, 2.17\n"); // floats

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!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>
<data>
<variable>EnvironmentId</variable>

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

Loading…
Cancel
Save