FreeCalypso > hg > freecalypso-hwlab
diff simtool/dispatch.c @ 116:c8685074c845
fc-simtool command parser: fancier handling of quoted strings
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 28 Jan 2021 03:14:32 +0000 |
parents | 0dcd666292e4 |
children | 06e2d5c60cbd |
line wrap: on
line diff
--- a/simtool/dispatch.c Thu Jan 28 02:56:10 2021 +0000 +++ b/simtool/dispatch.c Thu Jan 28 03:14:32 2021 +0000 @@ -125,12 +125,19 @@ } if (*cp == '"') { *ap++ = ++cp; - while (*cp && *cp != '"') - cp++; - if (*cp != '"') { - fprintf(stderr, + for (;;) { + if (!*cp) { +unterm_qstring: fprintf(stderr, "error: unterminated quoted string\n"); - return(-1); + return(-1); + } + if (*cp == '"') + break; + if (*cp++ == '\\') { + if (!*cp) + goto unterm_qstring; + cp++; + } } *cp++ = '\0'; } else {