| 886 | If S is valid, return true. Otherwise, give a diagnostic and exit. */ |
| 887 | |
| 888 | static void |
| 889 | decode_field_spec (char const *s, int *file_index, idx_t *field_index) |
| 890 | { |
| 891 | /* The first character must be 0, 1, or 2. */ |
| 892 | switch (s[0]) |
| 893 | { |
| 894 | case '0': |
| 895 | if (s[1]) |
| 896 | { |
| 897 | /* '0' must be all alone -- no '.FIELD'. */ |
| 898 | error (EXIT_FAILURE, 0, _("invalid field specifier: %s"), quote (s)); |
| 899 | } |
| 900 | *file_index = 0; |
| 901 | *field_index = 0; |
| 902 | break; |
| 903 | |
| 904 | case '1': |
| 905 | case '2': |
| 906 | if (s[1] != '.') |
| 907 | error (EXIT_FAILURE, 0, _("invalid field specifier: %s"), quote (s)); |
| 908 | *file_index = s[0] - '0'; |
| 909 | *field_index = string_to_join_field (s + 2); |
| 910 | break; |
| 911 | |
| 912 | default: |
| 913 | error (EXIT_FAILURE, 0, |
| 914 | _("invalid file number in field spec: %s"), quote (s)); |
| 915 | } |
| 916 | } |
| 917 | |
| 918 | static bool |
| 919 | comma_or_blank (mcel_t g) |
no test coverage detected