Clean up approxidate() in preparation for fixes
Our approxidate cannot handle simple times like "5 PM yesterday", and to fix that, we will need to add some logic for number handling. This just splits that out into a function of its own (the same way the _real_ date parsing works). Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Linus Torvalds committed
Sep 28, 2006 at 12:12 UTC
e92a54d99cb36eab6e29069fe3b135e6e6b24f12
1 file changed
+10
-3
date.c
+10
-3
@@ -712,6 +712,15 @@ static const char *approxidate_alpha(const char *date, struct tm *tm, int *num)
712
return end;
713
}
714
715
+static const char *approxidate_digit(const char *date, struct tm *tm, int *num)
716
+{
717
+ char *end;
718
+ unsigned long number = strtoul(date, &end, 10);
719
+
720
+ *num = number;
721
+ return end;
722
+}
723
+
724
unsigned long approxidate(const char *date)
725
{
726
int number = 0;
@@ -731,9 +740,7 @@ unsigned long approxidate(const char *date)
740
break;
741
date++;
742
if (isdigit(c)) {
734
- char *end;
735
- number = strtoul(date-1, &end, 10);
736
- date = end;
743
+ date = approxidate_digit(date-1, &tm, &number);
744
continue;
745
}
746
if (isalpha(c))