| 368 | } |
| 369 | |
| 370 | static double |
| 371 | parse_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 | |
| 393 | static void |
| 394 | unblock_signal (int sig) |
no test coverage detected