Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Improve grdcall.c string breaking #5972

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Check for both single and double quotes
  • Loading branch information
PaulWessel committed Nov 12, 2021
commit 3b430fe03546556b74cc823d1efd6e18b61260d9
4 changes: 2 additions & 2 deletions src/gmt_gdalcall.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ GMT_LOCAL char ** breakMe(struct GMT_CTRL *GMT, char *in) {
* these items by temporarily replacing spaces inside single quoted strings with ASCII 31 US (Unit Separator), do the strtok on
* space, and then replace all ASCII 31 with space at the end (we do the same for tab using ASCII 29 GS (group separator) */
for (k = 0, quoted = false; txt_in[k]; k++) {
if (txt_in[k] == '\'') quoted = !quoted; /* Initially false, becomes true at start of quote, then false when exit quote */
if (txt_in[k] == '\'' || txt_in[k] == '\"') quoted = !quoted; /* Initially false, becomes true at start of quote, then false when exit quote */
else if (quoted && txt_in[k] == '\t') txt_in[k] = GMT_ASCII_GS;
else if (quoted && txt_in[k] == ' ') txt_in[k] = GMT_ASCII_US;
}
Expand All @@ -139,7 +139,7 @@ GMT_LOCAL char ** breakMe(struct GMT_CTRL *GMT, char *in) {
p[k] = ' '; /* Replace spaces and tabs masked above */
}
for (i = o = 0; p[i]; i++)
if (p[i] != '\'') p[o++] = p[i]; /* Ignore any single quotes */
if (!(p[i] == '\'' || p[i] == '\"')) p[o++] = p[i]; /* Ignore any single or double quotes */
p[o] = '\0';
args[n_args++] = strdup(p);

Expand Down