time_t parse_duration (char const * pz) { while (isspace ((unsigned char)*pz)) pz++; switch (*pz) { case 'P': return parse_period (pz + 1); case 'T': return parse_time (pz + 1); default: if (isdigit ((unsigned char)*pz)) return parse_non_iso8601 (pz); errno = EINVAL; return BAD_TIME; } }
time_t parse_duration (char const * pz) { time_t res = 0; while (isspace ((unsigned char)*pz)) pz++; do { if (*pz == 'P') { res = parse_period (pz + 1); if ((errno != 0) || (res == BAD_TIME)) break; return res; } if (*pz == 'T') { res = parse_time (pz + 1); if ((errno != 0) || (res == BAD_TIME)) break; return res; } if (! isdigit ((unsigned char)*pz)) break; res = parse_non_iso8601 (pz); if ((errno == 0) && (res != BAD_TIME)) return res; } while (0); fprintf (stderr, _("Invalid time duration: %s\n"), pz); if (errno == 0) errno = EINVAL; return BAD_TIME; }