[dovecot-cvs] dovecot/src/lib-mail message-date.c,1.4,1.5

cras at procontrol.fi cras at procontrol.fi
Mon Jan 13 22:00:40 EET 2003


Update of /home/cvs/dovecot/src/lib-mail
In directory danu:/tmp/cvs-serv27858/lib-mail

Modified Files:
	message-date.c 
Log Message:
Handle one-digit hour in dates.



Index: message-date.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-mail/message-date.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- message-date.c	10 Jan 2003 00:30:42 -0000	1.4
+++ message-date.c	13 Jan 2003 20:00:38 -0000	1.5
@@ -120,7 +120,7 @@
 	}
 
 	/* dd */
-	if (token != 'A' || len > 2 || !i_isdigit(value[0]))
+	if (token != 'A' || len < 1 || len > 2 || !i_isdigit(value[0]))
 		return FALSE;
 
 	tm.tm_mday = value[0]-'0';
@@ -165,12 +165,16 @@
 		tm.tm_year -= 1900;
 	}
 
-	/* hh */
+	/* hh, allow also single digit */
 	token = next_token(ctx, &value, &len);
-	if (token != 'A' || len != 2 ||
-	    !i_isdigit(value[0]) || !i_isdigit(value[1]))
+	if (token != 'A' || len < 1 || len > 2 || !i_isdigit(value[0]))
 		return FALSE;
-	tm.tm_hour = (value[0]-'0') * 10 + (value[1]-'0');
+	tm.tm_hour = value[0]-'0';
+	if (len == 2) {
+		if (!i_isdigit(value[1]))
+			return FALSE;
+		tm.tm_hour = tm.tm_hour * 10 + (value[1]-'0');
+	}
 
 	/* :mm */
 	token = next_token(ctx, &value, &len);




More information about the dovecot-cvs mailing list