Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 16 additions & 2 deletions src/gmt_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -7831,8 +7831,22 @@ bool gmt_parse_segment_item (struct GMT_CTRL *GMT, char *in_string, char *patter
sscanf (++t, "%[^\"]", out_string);
else if (t[0] == '\'') /* Single quoted argument, must scan from next character until terminal quote */
sscanf (++t, "%[^\']", out_string);
else /* Scan until next white space; stop also when there is leading white space, indicating no argument at all! */
sscanf (t, "%[^ \t]", out_string);
else { /* Scan until next unquoted white space; stop also when there is leading white space, indicating no argument at all! */
size_t i = 0;
bool in_quote = false;
char quote_char = 0;
while (t[i] && (in_quote || (t[i] != ' ' && t[i] != '\t'))) {
if (!in_quote && (t[i] == '"' || t[i] == '\'')) {
in_quote = true;
quote_char = t[i];
}
else if (in_quote && t[i] == quote_char)
in_quote = false;
out_string[i] = t[i];
i++;
}
out_string[i] = '\0';
}
return (true);
}

Expand Down
10 changes: 9 additions & 1 deletion src/gmt_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -10711,7 +10711,15 @@ int gmt_contlabel_specs (struct GMT_CTRL *GMT, char *txt, struct GMT_CONTOUR *G)
bad++;
break;
case 'l': /* Exact Label specification */
strncpy (G->label, &p[1], GMT_BUFSIZ-1);
if (p[1] == '"' || p[1] == '\'') { /* Strip surrounding quotes from label */
char q = p[1];
L = strlen (&p[2]);
if (L > 0 && p[2 + L - 1] == q) L--; /* Exclude trailing quote */
strncpy (G->label, &p[2], MIN(L, GMT_BUFSIZ-1));
G->label[MIN(L, GMT_BUFSIZ-1)] = '\0';
}
else
strncpy (G->label, &p[1], GMT_BUFSIZ-1);
G->label_type = GMT_LABEL_IS_CONSTANT;
break;

Expand Down
13 changes: 13 additions & 0 deletions src/psxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -2784,6 +2784,19 @@ EXTERN_MSC int GMT_psxy (void *V_API, int mode, void *args) {
}
else if (S.symbol == GMT_SYMBOL_QUOTED_LINE || S.symbol == GMT_SYMBOL_DECORATED_LINE || S.symbol == GMT_SYMBOL_FRONT)
GMT_Report (API, GMT_MSG_ERROR, "Segment header tries to switch from -S%c to another symbol (%s) - ignored\n", S.symbol, s_args);
else if (s_args[0] == 'q' || s_args[0] == '~' || s_args[0] == 'f') { /* Create new front, quoted, or decorated line from segment header */
if ((error = gmt_parse_symbol_option (GMT, s_args, &S, 0, false))) {
Return (error);
}
if (S.symbol == GMT_SYMBOL_QUOTED_LINE) {
if (gmt_contlabel_prep (GMT, &S.G, NULL)) Return (GMT_RUNTIME_ERROR);
penset_OK = false;
}
else if (S.symbol == GMT_SYMBOL_DECORATED_LINE) {
if (gmt_decorate_prep (GMT, &S.D, NULL)) Return (GMT_RUNTIME_ERROR);
}
if (change & 1) change -= 1;
}
else /* Probably just junk -S in header */
GMT_Report (API, GMT_MSG_INFORMATION, "Segment header contained -S%s - ignored\n", s_args);
}
Expand Down
Loading