diff options
author | Timo Sirainen <cras@irssi.org> | 2003-11-16 17:26:43 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2003-11-16 17:26:43 +0000 |
commit | 1141081c34d0e8b560c06916ae41f78d2fd7b16d (patch) | |
tree | 2f3f52e2a2ec4fb448934a13a0dcccff9e95784f /src/core | |
parent | 91be647710d6d6df27b83211d9ff083e4949c7f1 (diff) | |
download | irssi-1141081c34d0e8b560c06916ae41f78d2fd7b16d.zip |
parse_time_interval: x days were actually returned as hours. weeks were
returned as hours*7.. which also means I calculated the max. return value of
over 1 year wrong. It's actually 24 days, but it's hopefully enough. Removed
"weeks" unit to discourage usage of large values..
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3143 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/misc.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/core/misc.c b/src/core/misc.c index 94682368..1359b71b 100644 --- a/src/core/misc.c +++ b/src/core/misc.c @@ -793,7 +793,7 @@ int parse_time_interval(const char *time, int *msecs) *msecs = 0; - /* max. return value is about 1.6 years */ + /* max. return value is around 24 days */ number = 0; ret = TRUE; for (;;) { if (i_isdigit(*time)) { @@ -815,10 +815,14 @@ int parse_time_interval(const char *time, int *msecs) return TRUE; } - if (g_strncasecmp(desc, "weeks", len) == 0) - *msecs += number * 1000*3600*7; - if (g_strncasecmp(desc, "days", len) == 0) - *msecs += number * 1000*3600; + if (g_strncasecmp(desc, "days", len) == 0) { + if (number > 24) { + /* would overflow */ + return FALSE; + } + *msecs += number * 1000*3600*24; + } else if (g_strncasecmp(desc, "hours", len) == 0) + *msecs += number * 1000*60*3600; else if (g_strncasecmp(desc, "minutes", len) == 0 || g_strncasecmp(desc, "mins", len) == 0) *msecs += number * 1000*60; |