| 1012 | /* Used instead of XARGMATCH() to provide a custom error message. */ |
| 1013 | #ifdef XARGMATCH |
| 1014 | static inline ptrdiff_t |
| 1015 | x_timestyle_match (char const * style, bool allow_posix, |
| 1016 | char const *const * timestyle_args, |
| 1017 | char const * timestyle_types, |
| 1018 | size_t timestyle_types_size, |
| 1019 | int fail_status) |
| 1020 | { |
| 1021 | ptrdiff_t res = argmatch (style, timestyle_args, |
| 1022 | (char const *) timestyle_types, |
| 1023 | timestyle_types_size); |
| 1024 | if (res < 0) |
| 1025 | { |
| 1026 | /* This whole block used to be a simple use of XARGMATCH. |
| 1027 | but that didn't print the "posix-"-prefixed variants or |
| 1028 | the "+"-prefixed format string option upon failure. */ |
| 1029 | argmatch_invalid ("time style", style, res); |
| 1030 | |
| 1031 | /* The following is a manual expansion of argmatch_valid, |
| 1032 | but with the added "+ ..." description and the [posix-] |
| 1033 | prefixes prepended. Note that this simplification works |
| 1034 | only because all four existing time_style_types values |
| 1035 | are distinct. */ |
| 1036 | fputs (_("Valid arguments are:\n"), stderr); |
| 1037 | char const *const *p = timestyle_args; |
| 1038 | char const *posix_prefix = allow_posix ? "[posix-]" : ""; |
| 1039 | while (*p) |
| 1040 | fprintf (stderr, " - %s%s\n", posix_prefix, *p++); |
| 1041 | fputs (_(" - +FORMAT (e.g., +%H:%M) for a 'date'-style" |
| 1042 | " format\n"), stderr); |
| 1043 | usage (fail_status); |
| 1044 | } |
| 1045 | |
| 1046 | return res; |
| 1047 | } |
| 1048 | #endif |
no test coverage detected