From: Jonathan Nieder <jrnieder@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Anders Kaseorg <andersk@ksplice.com>, git@vger.kernel.org
Subject: Re: [PATCH] apply: Recognize epoch timestamps with : in the timezone
Date: Wed, 13 Oct 2010 17:50:12 -0500 [thread overview]
Message-ID: <20101013225012.GB9509@burratino> (raw)
In-Reply-To: <7vvd55lwjl.fsf@alter.siamese.dyndns.org>
Junio C Hamano wrote:
> Junio C Hamano <gitster@pobox.com> writes:
>> Neither the patch nor your suggestion makes much sense to me. With the
>> patch, the regexp is now
>>
>> ^(1969-12-31|1970-01-01) <time>(\.0+)? ([-+][0-2][0-9]):?([0-5][0-9])
[...]
> Well, I was missing that without ':' strtol() goes through to parse $3$4
> as a single integer
So maybe something like the following would make this easier to follow.
diff --git a/builtin/apply.c b/builtin/apply.c
index 0fa9a8d..000d3e5 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -733,8 +733,8 @@ static int has_epoch_timestamp(const char *nameline)
" "
"[0-2][0-9]:[0-5][0-9]:00(\\.0+)?"
" "
- "([-+][0-2][0-9]):?([0-5][0-9])\n";
+ "([-+][0-2][0-9]:?[0-5][0-9])\n";
- const char *timestamp = NULL, *cp;
+ const char *timestamp = NULL, *cp, *colon;
static regex_t *stamp;
regmatch_t m[10];
int zoneoffset;
@@ -764,10 +764,11 @@ static int has_epoch_timestamp(const char *nameline)
return 0;
}
- zoneoffset = strtol(timestamp + m[3].rm_so + 1, NULL, 10);
+ zoneoffset = strtol(timestamp + m[3].rm_so + 1, (char **) &colon, 10);
- if (m[4].rm_so == m[3].rm_so + 3)
- zoneoffset /= 100;
- zoneoffset = zoneoffset * 60 + strtol(timestamp + m[4].rm_so, NULL, 10);
+ if (*colon == ':')
+ zoneoffset = zoneoffset * 60 + strtol(colon + 1, NULL, 10);
+ else
+ zoneoffset = (zoneoffset / 100) * 60 + (zoneoffset % 100);
if (timestamp[m[3].rm_so] == '-')
zoneoffset = -zoneoffset;
next prev parent reply other threads:[~2010-10-13 22:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-29 20:49 [PATCH] apply: Recognize epoch timestamps with : in the timezone Anders Kaseorg
2010-09-29 21:41 ` Jonathan Nieder
2010-09-29 21:49 ` Jonathan Nieder
2010-10-13 18:59 ` Junio C Hamano
2010-10-13 19:31 ` Junio C Hamano
2010-10-13 22:50 ` Jonathan Nieder [this message]
2010-10-13 23:37 ` Junio C Hamano
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=20101013225012.GB9509@burratino \
--to=jrnieder@gmail.com \
--cc=andersk@ksplice.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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).