MCPcopy Create free account
hub / github.com/coreutils/coreutils / decode_field_spec

Function decode_field_spec

src/join.c:888–916  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

886 If S is valid, return true. Otherwise, give a diagnostic and exit. */
887
888static void
889decode_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
918static bool
919comma_or_blank (mcel_t g)

Callers 1

add_field_listFunction · 0.85

Calls 1

string_to_join_fieldFunction · 0.85

Tested by

no test coverage detected