From 0a352fe5190c7ba40dec2c29bafd181c1984bb95 Mon Sep 17 00:00:00 2001 From: Baptiste Jonglez Date: Wed, 2 May 2012 16:19:30 +0200 Subject: src/utils.c: Get rid of "semantic range checks" when parsing duration Don't restrict ranges when entering durations. We now accept duration like "+1d42h600m". This might not seem very logical, but it's perfectly valid, and being able to enter "+36h" is useful when you don't want to do the maths yourself. Signed-off-by: Baptiste Jonglez Signed-off-by: Lukas Fleischer --- src/utils.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/utils.c b/src/utils.c index 56295f6..aa4a2d6 100644 --- a/src/utils.c +++ b/src/utils.c @@ -729,9 +729,6 @@ parse_time (const char *string, unsigned *hour, unsigned *minute) * * "\d" is used as a placeholder for "(0|1|2|3|4|5|6|7|8|9)". * - * Note that this function performs an additional range check on each token to - * ensure we do not accept semantically invalid strings such as "42:23". - * * Returns 1 on success and 0 on failure. */ int @@ -779,15 +776,11 @@ parse_duration (const char *string, unsigned *duration) } else if (*p == 'h') { - if (in >= DAYINHOURS) - return 0; dur += in * HOURINMIN; state = STATE_DDHHMM_MM; } else if (*p == 'm') { - if (in >= HOURINMIN) - return 0; dur += in; state = STATE_DONE; } @@ -797,15 +790,11 @@ parse_duration (const char *string, unsigned *duration) case STATE_DDHHMM_HH: if (*p == 'h') { - if (in >= DAYINHOURS) - return 0; dur += in * HOURINMIN; state = STATE_DDHHMM_MM; } else if (*p == 'm') { - if (in >= HOURINMIN) - return 0; dur += in; state = STATE_DONE; } @@ -815,8 +804,6 @@ parse_duration (const char *string, unsigned *duration) case STATE_DDHHMM_MM: if (*p == 'm') { - if (in >= HOURINMIN) - return 0; dur += in; state = STATE_DONE; } -- cgit v1.2.3-70-g09d2