! . */
| 17511 | |
| 17512 | /*! . */ |
| 17513 | unsigned int gmt_validate_modifiers (struct GMT_CTRL *GMT, const char *string, const char option, const char *valid_modifiers, unsigned int verbosity) { |
| 17514 | /* Looks for modifiers +<mod> in string and making sure <mod> is |
| 17515 | * only from the set given by valid_modifiers. if verbosity is GMT_MSQ_QUIET |
| 17516 | * we file no errors but just returns the number of valid modifiers found. |
| 17517 | * Otherwise we return the number of invalid modifiers or 0. |
| 17518 | */ |
| 17519 | bool quoted = false; |
| 17520 | unsigned int n_bad = 0, n_good = 0; |
| 17521 | size_t k, len, start = 0; |
| 17522 | |
| 17523 | if (!string || string[0] == 0) return 0; /* Nothing to check */ |
| 17524 | len = strlen (string); |
| 17525 | for (k = 0; start == 0 && k < (len-1); k++) { |
| 17526 | if (string[k] == '\"') quoted = !quoted; /* Initially false, becomes true at start of quote, then false when exits the quote */ |
| 17527 | if (quoted) continue; /* Not consider +<mod> inside quoted strings */ |
| 17528 | if (string[k] == '+') { /* Possibly a modifier */ |
| 17529 | if (k && string[k-1] == 'e' && isdigit (string[k+1])) continue; /* Exponential notation, e.g. 1e+5 */ |
| 17530 | if (strchr (valid_modifiers, string[k+1])) /* Found a recognized valid modifier */ |
| 17531 | n_good++; |
| 17532 | else { /* Found an invalid modifier or some part of a filename that has + in it */ |
| 17533 | if (option) |
| 17534 | GMT_Report (GMT->parent, verbosity, "Option -%c option: Modifier +%c unrecognized\n", option, string[k+1]); |
| 17535 | else |
| 17536 | GMT_Report (GMT->parent, verbosity, "Modifier +%c unrecognized\n", string[k+1]); |
| 17537 | n_bad++; |
| 17538 | } |
| 17539 | } |
| 17540 | } |
| 17541 | return ((verbosity == GMT_MSG_QUIET) ? n_good : n_bad); |
| 17542 | } |
| 17543 | |
| 17544 | /*! . */ |
| 17545 | double gmt_pol_area (double x[], double y[], uint64_t n) { |
no test coverage detected