| 788 | } |
| 789 | |
| 790 | static int parse (struct GMT_CTRL *GMT, struct GMTMATH_CTRL *Ctrl, struct GMT_OPTION *options) { |
| 791 | /* This parses the options provided to gmtmath and sets parameters in CTRL. |
| 792 | * Any GMT common options will override values set previously by other commands. |
| 793 | * It also replaces any file names specified as input or output with the data ID |
| 794 | * returned when registering these sources/destinations with the API. |
| 795 | */ |
| 796 | |
| 797 | unsigned int n_errors = 0, k = 0; |
| 798 | bool missing_equal = true; |
| 799 | char *c = NULL, *t_arg = NULL; |
| 800 | struct GMT_OPTION *opt = NULL; |
| 801 | struct GMTAPI_CTRL *API = GMT->parent; |
| 802 | int gmt_parse_o_option (struct GMT_CTRL *GMT, char *arg); |
| 803 | |
| 804 | for (opt = options; opt; opt = opt->next) { |
| 805 | switch (opt->option) { |
| 806 | |
| 807 | case '<': /* Input files */ |
| 808 | if (opt->arg[0] == '=' && opt->arg[1] == 0) { /* No it was an = [outfile] sequence */ |
| 809 | missing_equal = false; |
| 810 | opt->option = GMT_OPT_OUTFILE; /* Prevents further use later */ |
| 811 | if (opt->next && (opt->next->option == GMT_OPT_INFILE || opt->next->option == GMT_OPT_OUTFILE)) { |
| 812 | opt = opt->next; /* Skip ahead */ |
| 813 | n_errors += gmt_M_repeated_module_option (API, Ctrl->Out.active); |
| 814 | if (opt->arg[0]) Ctrl->Out.file = strdup (opt->arg); /* Optional output file since stdout is default */ |
| 815 | opt->option = GMT_OPT_OUTFILE; /* Prevents further use later */ |
| 816 | } |
| 817 | } |
| 818 | break; |
| 819 | case '>': /* Output file specified via an API; set required output file here */ |
| 820 | n_errors += gmt_M_repeated_module_option (API, Ctrl->Out.active); |
| 821 | n_errors += gmt_get_required_file (GMT, opt->arg, opt->option, 0, GMT_IS_DATASET, GMT_OUT, GMT_FILE_LOCAL, &(Ctrl->Out.file)); |
| 822 | missing_equal = false; |
| 823 | break; |
| 824 | case '#': /* Skip numbers */ |
| 825 | break; |
| 826 | |
| 827 | /* Processes program-specific parameters */ |
| 828 | |
| 829 | case 'A': /* y(x) table for LSQFIT/SVDFIT operations */ |
| 830 | n_errors += gmt_M_repeated_module_option (API, Ctrl->A.active); |
| 831 | if (opt->arg[0] == '-') { /* Old-style leading hyphen to the filename has been replaced by modifier +r */ |
| 832 | if (gmt_M_compat_check (GMT, 5)) { |
| 833 | GMT_Report (API, GMT_MSG_COMPAT, "The leading hyphen in -A is deprecated. Append modifier +r instead.\n"); |
| 834 | Ctrl->A.null = true; |
| 835 | k = 1; |
| 836 | } |
| 837 | else { |
| 838 | GMT_Report (API, GMT_MSG_ERROR, "Option -A: Unable to decode arguments\n"); |
| 839 | n_errors++; |
| 840 | } |
| 841 | } |
| 842 | if ((c = strchr(opt->arg, '+')) != NULL && strchr("ersw", c[1]) != NULL) { /* Got a valid modifier */ |
| 843 | unsigned int pos = 0; |
| 844 | char p[GMT_LEN256] = {""}; |
| 845 | c[0] = '\0'; /* Temporarily chop off modifiers */ |
| 846 | Ctrl->A.file = strdup (&opt->arg[k]); |
| 847 | c[0] = '+'; /* Restore the modifier */ |
no test coverage detected