@@ -309,6 +309,11 @@ enum GMTAPI_enum_status {
309
309
GMTAPI_GOT_SEGHEADER = -1, /* Read a segment header */
310
310
GMTAPI_GOT_SEGGAP = -2}; /* Detected a gap and insertion of new segment header */
311
311
312
+ enum GMTAPI_enum_takes_mod {
313
+ GMTAPI_MOD_NOTSET = 0, /* Not assigned */
314
+ GMTAPI_MOD_SPECIAL = 1, /* Found = and possibly modifiers */
315
+ GMTAPI_MOD_NORMAL = 2}; /* No arg found after stripping modifiers (if any) */
316
+
312
317
/*==================================================================================================
313
318
* PRIVATE FUNCTIONS ONLY USED BY THIS LIBRARY FILE
314
319
*==================================================================================================
@@ -12958,7 +12963,7 @@ GMT_LOCAL const char *gmtapi_retrieve_module_keys (void *V_API, char *module) {
12958
12963
return_null (V_API, GMT_NOT_A_VALID_MODULE);
12959
12964
}
12960
12965
12961
- GMT_LOCAL int gmtapi_extract_argument (char *optarg, char *argument, char **key, int k, bool colon, char colon_opt, int *n_pre, unsigned int *takes_mod) {
12966
+ GMT_LOCAL int gmtapi_extract_argument (char *optarg, char *argument, char **key, int k, bool colon, char colon_opt, int *n_pre, enum GMTAPI_enum_takes_mod *takes_mod) {
12962
12967
/* A few separate actions:
12963
12968
* 1) If key ends with "=" then we pull out the option argument after stripping off +<stuff>.
12964
12969
* 2) If key ends with "=q" then we see if +q is given and return pos to this modifiers argument.
@@ -12974,7 +12979,7 @@ GMT_LOCAL int gmtapi_extract_argument (char *optarg, char *argument, char **key,
12974
12979
unsigned int pos = 0;
12975
12980
size_t L;
12976
12981
*n_pre = 0;
12977
- *takes_mod = 0 ;
12982
+ *takes_mod = GMTAPI_MOD_NOTSET ;
12978
12983
12979
12984
L = (k >= 0) ? strlen (key[k]) : 0;
12980
12985
if (colon_opt) { /* Either -S (from psxy[z]) or -G (from grdcontour or pscontour) */
@@ -12989,28 +12994,28 @@ GMT_LOCAL int gmtapi_extract_argument (char *optarg, char *argument, char **key,
12989
12994
}
12990
12995
12991
12996
if (k >= 0 && key[k][K_EQUAL] == '=') { /* Special handling */
12992
- *takes_mod = 1 ; /* Flag that KEY was special */
12997
+ *takes_mod = GMTAPI_MOD_SPECIAL ; /* Flag that KEY was special */
12993
12998
*n_pre = (L > K_MODIFIER && key[k][K_MODIFIER] && isdigit (key[k][K_MODIFIER])) ? (int)(key[k][K_MODIFIER]-'0') : 0;
12994
12999
if ((*n_pre || key[k][K_MODIFIER] == 0) && (c = strchr (inarg, '+'))) { /* Strip off trailing +<modifiers> */
12995
13000
c[0] = 0;
12996
13001
strcpy (argument, inarg);
12997
13002
c[0] = '+';
12998
- if (!argument[0]) *takes_mod = 2 ; /* Flag that option is missing the arg and needs it later */
13003
+ if (!argument[0]) *takes_mod = GMTAPI_MOD_NORMAL ; /* Flag that option is missing the arg and needs it later */
12999
13004
}
13000
13005
else if (L > K_MODIFIER && key[k][K_MODIFIER]) { /* Look for a specific +<mod> in the option */
13001
13006
char code[3] = {"+?"};
13002
13007
code[1] = key[k][K_MODIFIER];
13003
13008
if ((c = strstr (inarg, code))) { /* Found +<modifier> */
13004
13009
strcpy (argument, inarg);
13005
- if (!c[2] || c[2] == '+') *takes_mod = 2 ; /* Flag that option had no argument that KEY was looking for */
13010
+ if (!c[2] || c[2] == '+') *takes_mod = GMTAPI_MOD_NORMAL ; /* Flag that option had no argument that KEY was looking for */
13006
13011
pos = (unsigned int) (c - inarg + 2); /* Position of this modifier's argument. E.g., -E+f<file> will have pos = 2 as start of <file> */
13007
13012
}
13008
13013
else /* No modifier involved */
13009
13014
strcpy (argument, inarg);
13010
13015
}
13011
13016
else
13012
13017
strcpy (argument, inarg);
13013
- if (!argument[0]) *takes_mod = 2 ; /* Flag that option is missing the arg and needs it later */
13018
+ if (!argument[0]) *takes_mod = GMTAPI_MOD_NORMAL ; /* Flag that option is missing the arg and needs it later */
13014
13019
}
13015
13020
else
13016
13021
strcpy (argument, inarg);
@@ -13184,7 +13189,8 @@ struct GMT_RESOURCE * GMT_Encode_Options (void *V_API, const char *module_name,
13184
13189
*/
13185
13190
13186
13191
unsigned int n_keys, direction = 0, kind, pos = 0, n_items = 0, ku, n_out = 0, nn[2][2];
13187
- unsigned int output_pos = 0, input_pos = 0, mod_pos, takes_mod;
13192
+ unsigned int output_pos = 0, input_pos = 0, mod_pos;
13193
+ enum GMTAPI_enum_takes_mod takes_mod;
13188
13194
int family = GMT_NOTSET; /* -1, or one of GMT_IS_DATASET, GMT_IS_GRID, GMT_IS_PALETTE, GMT_IS_IMAGE */
13189
13195
int geometry = GMT_NOTSET; /* -1, or one of GMT_IS_NONE, GMT_IS_TEXT, GMT_IS_POINT, GMT_IS_LINE, GMT_IS_POLY, GMT_IS_SURFACE */
13190
13196
int sdir, k = 0, n_in_added = 0, n_to_add, e, n_pre_arg, n_per_family[GMT_N_FAMILIES];
@@ -13539,7 +13545,7 @@ struct GMT_RESOURCE * GMT_Encode_Options (void *V_API, const char *module_name,
13539
13545
13540
13546
else if (k >= 0 && key[k][K_OPT] != GMT_OPT_INFILE && family != GMT_NOTSET && key[k][K_DIR] != '-') { /* Got some option like -G or -Lu with further args */
13541
13547
bool implicit = true;
13542
- if (takes_mod == 1 ) /* Got some option like -E[+f] but no +f was given so no implicit file needed */
13548
+ if (takes_mod == GMTAPI_MOD_SPECIAL ) /* Got some option like -E[+f] but no +f was given so no implicit file needed */
13543
13549
implicit = false;
13544
13550
else if ((len = strlen (argument)) == (size_t)n_pre_arg) /* Got some option like -G or -Lu with no further args */
13545
13551
GMT_Report (API, GMT_MSG_DEBUG, "GMT_Encode_Options: Option -%c needs implicit arg [offset = %d]\n", opt->option, n_pre_arg);
0 commit comments