@@ -7645,6 +7645,7 @@ void gmtlib_explain_options (struct GMT_CTRL *GMT, char *options) {
76457645 case 'k': /* -di option to tell GMT the relationship between NaN and a nan-proxy for input */
76467646
76477647 GMT_Usage (API, 1, "\n%s Replace any <nodata> values in input data with NaN.", GMT_di_OPT);
7648+ GMT_Usage (API, 3, "+c Append first column to be affected [2].");
76487649 break;
76497650
76507651 case 'l': /* -l option to set up auto-legend items*/
@@ -7671,6 +7672,7 @@ void gmtlib_explain_options (struct GMT_CTRL *GMT, char *options) {
76717672
76727673 GMT_Usage (API, 1, "\n%s", GMT_do_OPT);
76737674 GMT_Usage (API, -2, "Replace any NaNs in output data with <nodata>.");
7675+ GMT_Usage (API, 3, "+c Append first column to be affected [0].");
76747676 break;
76757677
76767678 case 'f': /* -f option to tell GMT which columns are time (and optionally geographical) */
@@ -9064,29 +9066,38 @@ GMT_LOCAL int gmtinit_parse_data_range (struct GMT_CTRL *GMT, char *arg, unsigne
90649066
90659067/*! . */
90669068unsigned int gmt_parse_d_option (struct GMT_CTRL *GMT, char *arg) {
9067- unsigned int dir, first, last;
9068- char *c = NULL;
9069+ unsigned int dir, first, last, col, def_col[2] = {GMT_Z, GMT_X} ;
9070+ char *c = NULL, *q = NULL ;
90699071
90709072 if (!arg || !arg[0]) return (GMT_PARSE_ERROR); /* -d requires an argument */
9073+ if ((q = strstr (arg, "+c"))) { /* Want to override start columns */
9074+ col = atoi (&q[2]);
9075+ q[0] = '\0'; /* Chop off for now */
9076+ }
90719077 if (arg[0] == 'i') {
90729078 first = last = GMT_IN;
90739079 c = &arg[1];
9080+ if (q) def_col[GMT_IN] = col;
90749081 }
90759082 else if (arg[0] == 'o') {
90769083 first = last = GMT_OUT;
90779084 c = &arg[1];
9085+ if (q) def_col[GMT_OUT] = col;
90789086 }
90799087 else {
90809088 first = GMT_IN; last = GMT_OUT;
90819089 c = arg;
9090+ if (q) def_col[GMT_IN] = def_col[GMT_OUT] = col;
90829091 }
90839092
90849093 for (dir = first; dir <= last; dir++) {
90859094 GMT->common.d.active[dir] = true;
90869095 GMT->common.d.nan_proxy[dir] = atof (c);
90879096 /* Need to know if 0 is used as NaN proxy since we must use a different comparison macro later */
90889097 GMT->common.d.is_zero[dir] = doubleAlmostEqualZero (0.0, GMT->common.d.nan_proxy[dir]);
9098+ GMT->common.d.first_col[dir] = def_col[dir];
90899099 }
9100+ if (q) q[0] = '+'; /* Restore modifier */
90909101 if (first == GMT_IN) strncpy (GMT->common.d.string, arg, GMT_LEN64-1); /* Verbatim copy */
90919102 return (GMT_NOERROR);
90929103}
0 commit comments