diff --git a/src/gmt_io.c b/src/gmt_io.c index 5a69da91a34..25dfb1f99e3 100644 --- a/src/gmt_io.c +++ b/src/gmt_io.c @@ -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); } diff --git a/src/gmt_support.c b/src/gmt_support.c index 6941e47d04f..6399b7d065f 100644 --- a/src/gmt_support.c +++ b/src/gmt_support.c @@ -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; diff --git a/src/psxy.c b/src/psxy.c index 2a6c99af45b..0341eba1915 100644 --- a/src/psxy.c +++ b/src/psxy.c @@ -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); }