summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2017-08-25 19:06:28 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-08-25 21:06:09 (GMT)
commit0db3dc75f30239aa3b36071c7b9ff21c16ba449a (patch)
tree11e43bd7bdc21c097edfd8cf8b20ff2c186fa5ec
parente4905019df568762d5f9ab66227eefcb32915b40 (diff)
downloadgit-0db3dc75f30239aa3b36071c7b9ff21c16ba449a.zip
git-0db3dc75f30239aa3b36071c7b9ff21c16ba449a.tar.gz
git-0db3dc75f30239aa3b36071c7b9ff21c16ba449a.tar.bz2
apply: remove epoch date from regex
We check the date of epoch timestamp candidates already with starts_with(). Move beyond that part using skip_prefix() instead of checking it again using a regular expression. Also group the minutes part, so that we can access them using a substring match instead of using a magic number. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--apply.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/apply.c b/apply.c
index e5d7959..3997f73 100644
--- a/apply.c
+++ b/apply.c
@@ -812,9 +812,7 @@ static int has_epoch_timestamp(const char *nameline)
* 1970-01-01, and the seconds part must be "00".
*/
const char stamp_regexp[] =
- "^(1969-12-31|1970-01-01)"
- " "
- "[0-2][0-9]:[0-5][0-9]:00(\\.0+)?"
+ "^[0-2][0-9]:([0-5][0-9]):00(\\.0+)?"
" "
"([-+][0-2][0-9]:?[0-5][0-9])\n";
const char *timestamp = NULL, *cp, *colon;
@@ -834,9 +832,9 @@ static int has_epoch_timestamp(const char *nameline)
* YYYY-MM-DD hh:mm:ss must be from either 1969-12-31
* (west of GMT) or 1970-01-01 (east of GMT)
*/
- if (starts_with(timestamp, "1969-12-31"))
+ if (skip_prefix(timestamp, "1969-12-31 ", &timestamp))
epoch_hour = 24;
- else if (starts_with(timestamp, "1970-01-01"))
+ else if (skip_prefix(timestamp, "1970-01-01 ", &timestamp))
epoch_hour = 0;
else
return 0;
@@ -858,8 +856,8 @@ static int has_epoch_timestamp(const char *nameline)
return 0;
}
- hour = strtol(timestamp + 11, NULL, 10);
- minute = strtol(timestamp + 14, NULL, 10);
+ hour = strtol(timestamp, NULL, 10);
+ minute = strtol(timestamp + m[1].rm_so, NULL, 10);
zoneoffset = strtol(timestamp + m[3].rm_so + 1, (char **) &colon, 10);
if (*colon == ':')