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 <baptiste--git@jonglez.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
parent
6fd0ae2ea7
commit
0a352fe519
13
src/utils.c
13
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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user