1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Make parse_time_interval recognize negative times. Patch by Danijel Tasov and Elmar Hoffmann (Bug 23)

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3990 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Wouter Coekaerts 2005-09-10 12:51:43 +00:00 committed by coekie
parent 262086c781
commit f55a35185a

View File

@ -803,13 +803,19 @@ int nearest_power(int num)
int parse_time_interval(const char *time, int *msecs) int parse_time_interval(const char *time, int *msecs)
{ {
const char *desc; const char *desc;
int number, len, ret; int number, sign, len, ret;
*msecs = 0; *msecs = 0;
/* max. return value is around 24 days */ /* max. return value is around 24 days */
number = 0; ret = TRUE; number = 0; sign = 1; ret = TRUE;
for (;;) { for (;;) {
if (*time == '-') {
sign = -sign;
time++;
continue;
}
if (i_isdigit(*time)) { if (i_isdigit(*time)) {
number = number*10 + (*time - '0'); number = number*10 + (*time - '0');
time++; time++;
@ -826,6 +832,7 @@ int parse_time_interval(const char *time, int *msecs)
if (len == 0) { if (len == 0) {
*msecs += number * 1000; /* assume seconds */ *msecs += number * 1000; /* assume seconds */
*msecs *= sign;
return TRUE; return TRUE;
} }
@ -862,6 +869,7 @@ int parse_time_interval(const char *time, int *msecs)
number = 0; number = 0;
} }
*msecs *= sign;
return ret; return ret;
} }