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

Function parse_repeat_count

src/csplit.c:1044–1070  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1042 ARGNUM is the ARGV index of STR. */
1043
1044static void
1045parse_repeat_count (int argnum, struct control *p, char *str)
1046{
1047 char *end;
1048
1049 end = str + strlen (str) - 1;
1050 if (*end != '}')
1051 error (EXIT_FAILURE, 0, _("%s: '}' is required in repeat count"),
1052 quote (str));
1053 *end = '\0';
1054
1055 if (str + 1 == end - 1 && *(str + 1) == '*')
1056 p->repeat_forever = true;
1057 else
1058 {
1059 uintmax_t val;
1060 if (xstrtoumax (str + 1, NULL, 10, &val, "") != LONGINT_OK
1061 || ckd_add (&p->repeat, val, 0))
1062 {
1063 error (EXIT_FAILURE, 0,
1064 _("%s}: integer required between '{' and '}'"),
1065 quote (global_argv[argnum]));
1066 }
1067 }
1068
1069 *end = '}';
1070}
1071
1072/* Extract the regular expression from STR and check for a numeric offset.
1073 STR should start with the regexp delimiter character.

Callers 1

parse_patternsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected