From: Linus Torvalds <torvalds@osdl.org>
To: Junio C Hamano <junkio@cox.net>, Git Mailing List <git@vger.kernel.org>
Subject: Clean up approxidate() in preparation for fixes
Date: Thu, 28 Sep 2006 12:12:28 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.64.0609281211260.3952@g5.osdl.org> (raw)
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>
---
This should change no code what-so-ever, just split it up in preparation
for the next patch..
diff --git a/date.c b/date.c
index e387dcd..4ff6604 100644
--- a/date.c
+++ b/date.c
@@ -712,6 +712,15 @@ static const char *approxidate_alpha(con
return end;
}
+static const char *approxidate_digit(const char *date, struct tm *tm, int *num)
+{
+ char *end;
+ unsigned long number = strtoul(date, &end, 10);
+
+ *num = number;
+ return end;
+}
+
unsigned long approxidate(const char *date)
{
int number = 0;
@@ -731,9 +740,7 @@ unsigned long approxidate(const char *da
break;
date++;
if (isdigit(c)) {
- char *end;
- number = strtoul(date-1, &end, 10);
- date = end;
+ date = approxidate_digit(date-1, &tm, &number);
continue;
}
if (isalpha(c))
next reply other threads:[~2006-09-28 19:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-28 19:12 Linus Torvalds [this message]
2006-09-28 19:14 ` Fix approxidate() to understand more extended numbers Linus Torvalds
2006-09-29 0:12 ` Morten Welinder
2006-09-29 6:03 ` Linus Torvalds
2006-09-29 6:14 ` Junio C Hamano
2006-09-29 6:42 ` Linus Torvalds
2006-09-29 7:09 ` Junio C Hamano
2006-09-29 14:04 ` Johannes Schindelin
2006-09-29 19:36 ` Linus Torvalds
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.64.0609281211260.3952@g5.osdl.org \
--to=torvalds@osdl.org \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).