1
0
mirror of https://github.com/irssi/irssi.git synced 2024-11-03 04:27:19 -05:00

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
This commit is contained in:
Timo Sirainen 2003-11-16 17:26:43 +00:00 committed by cras
parent 91be647710
commit 1141081c34

View File

@ -793,7 +793,7 @@ int parse_time_interval(const char *time, int *msecs)
*msecs = 0; *msecs = 0;
/* max. return value is about 1.6 years */ /* max. return value is around 24 days */
number = 0; ret = TRUE; number = 0; ret = TRUE;
for (;;) { for (;;) {
if (i_isdigit(*time)) { if (i_isdigit(*time)) {
@ -815,10 +815,14 @@ int parse_time_interval(const char *time, int *msecs)
return TRUE; return TRUE;
} }
if (g_strncasecmp(desc, "weeks", len) == 0) if (g_strncasecmp(desc, "days", len) == 0) {
*msecs += number * 1000*3600*7; if (number > 24) {
if (g_strncasecmp(desc, "days", len) == 0) /* would overflow */
*msecs += number * 1000*3600; 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 || else if (g_strncasecmp(desc, "minutes", len) == 0 ||
g_strncasecmp(desc, "mins", len) == 0) g_strncasecmp(desc, "mins", len) == 0)
*msecs += number * 1000*60; *msecs += number * 1000*60;