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.
This commit is contained in:
2023-02-01 08:33:18 -08:00
committed by Michael Davidsaver
parent 80da400f9c
commit 3dbc9ea264
+7 -7
View File
@@ -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;