From 3dbc9ea26491dc676888fca091e78cddf9a8760c Mon Sep 17 00:00:00 2001 From: Zimoch Dirk Date: Wed, 1 Feb 2023 08:33:18 -0800 Subject: [PATCH] iocsh: fix argument splitting Since commit 60128ee9 "Com: separate iocsh argument splitting", iocsh is broken on VxWorks (tested with version 6.9.4.12) Any command prints the error "Unbalanced quote." > iocsh epics> echo Unbalanced quote. epics> "echo" Unbalanced quote. epics> "echo Unbalanced quote. epics> echo bla Unbalanced quote. epics> echo 1 2 3 Unbalanced quote. epics> exit Unbalanced quote. --- modules/libcom/src/iocsh/iocsh.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/libcom/src/iocsh/iocsh.cpp b/modules/libcom/src/iocsh/iocsh.cpp index 43fcb9cab..fc323d39a 100644 --- a/modules/libcom/src/iocsh/iocsh.cpp +++ b/modules/libcom/src/iocsh/iocsh.cpp @@ -266,16 +266,16 @@ struct Tokenize { int icout = 0; bool inword = false; bool backslash = false; - char quote = EOF; + char quote = 0; for (;;) { char c = line[icin++]; if (c == '\0') break; - bool sep = (quote == EOF) && !backslash && (strchr (" \t(),\r", c)); + bool sep = !quote && !backslash && (strchr (" \t(),\r", c)); - if ((quote == EOF) && !backslash) { + if (!quote && !backslash) { int redirectFd = 1; if (c == '\\') { backslash = true; @@ -310,10 +310,10 @@ struct Tokenize { } if (inword) { if (c == quote) { - quote = EOF; + quote = 0; } else { - if ((quote == EOF) && !backslash) { + if (!quote && !backslash) { if (sep) { inword = false; // this "closes" a sub-string which was previously @@ -347,7 +347,7 @@ struct Tokenize { else { argv.push_back(line + icout); } - if (quote == EOF) + if (!quote) line[icout++] = c; inword = true; } @@ -364,7 +364,7 @@ struct Tokenize { showError(filename, lineno, "Illegal redirection."); return true; } - if (quote != EOF) { + if (quote) { if(noise) showError(filename, lineno, "Unbalanced quote."); return true;