summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2003-11-16 16:22:07 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2003-11-16 16:22:07 +0000
commitf764a8665c9a9c70a6d9f1a08b4a7ee1c0bafa16 (patch)
tree98a38e781b5acc46b76e6910557e9757d419222c /src
parentb5dd35aad5b78ceb3ea1ed12dc057de500c7d5b5 (diff)
downloadirssi-f764a8665c9a9c70a6d9f1a08b4a7ee1c0bafa16.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/core/misc.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/core/misc.c b/src/core/misc.c
index 0c36bf6b..94682368 100644
--- a/src/core/misc.c
+++ b/src/core/misc.c
@@ -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)