mirror of
https://github.com/irssi/irssi.git
synced 2024-11-03 04:27:19 -05:00
Time parsing: allow omitting time unit without warning for backwards
compatibility. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3139 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
b5dd35aad5
commit
f764a8665c
@ -789,12 +789,12 @@ int nearest_power(int num)
|
||||
int parse_time_interval(const char *time, int *msecs)
|
||||
{
|
||||
const char *desc;
|
||||
int number, len;
|
||||
int number, len, ret;
|
||||
|
||||
*msecs = 0;
|
||||
|
||||
/* max. return value is about 1.6 years */
|
||||
number = 0;
|
||||
number = 0; ret = TRUE;
|
||||
for (;;) {
|
||||
if (i_isdigit(*time)) {
|
||||
number = number*10 + (*time - '0');
|
||||
@ -811,13 +811,8 @@ int parse_time_interval(const char *time, int *msecs)
|
||||
len++;
|
||||
|
||||
if (len == 0) {
|
||||
if (number == 0) {
|
||||
/* "0" - allow it */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
*msecs += number * 1000; /* assume seconds */
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (g_strncasecmp(desc, "weeks", len) == 0)
|
||||
@ -835,6 +830,9 @@ int parse_time_interval(const char *time, int *msecs)
|
||||
g_strncasecmp(desc, "mseconds", len) == 0 ||
|
||||
g_strncasecmp(desc, "msecs", len) == 0)
|
||||
*msecs += number;
|
||||
else {
|
||||
ret = FALSE;
|
||||
}
|
||||
|
||||
/* skip punctuation */
|
||||
while (*time != '\0' && i_ispunct(*time))
|
||||
@ -846,7 +844,7 @@ int parse_time_interval(const char *time, int *msecs)
|
||||
number = 0;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int parse_size(const char *size, int *bytes)
|
||||
|
Loading…
Reference in New Issue
Block a user