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

Function parse_duration

src/timeout.c:370–391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

368}
369
370static double
371parse_duration (char const *str)
372{
373 char *ep;
374 errno = 0;
375 double duration = cl_strtod (str, &ep);
376 double s = dtimespec_bound (duration, errno);
377
378 if (ep == str
379 /* Nonnegative interval. */
380 || ! (0 <= s)
381 /* No extra chars after the number and an optional s,m,h,d char. */
382 || (*ep && *(ep + 1))
383 /* Check any suffix char and update timeout based on the suffix. */
384 || !apply_time_suffix (&s, *ep))
385 {
386 error (0, 0, _("invalid time interval %s"), quote (str));
387 usage (EXIT_CANCELED);
388 }
389
390 return s;
391}
392
393static void
394unblock_signal (int sig)

Callers 1

mainFunction · 0.85

Calls 3

dtimespec_boundFunction · 0.85
apply_time_suffixFunction · 0.85
usageFunction · 0.70

Tested by

no test coverage detected