From 1aeb7e756c82d31e46712ec7557c4cbae37dccd9 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 21 Apr 2017 12:45:44 +0200 Subject: parse_timestamp(): specify explicitly where we parse timestamps Currently, Git's source code represents all timestamps as `unsigned long`. In preparation for using a more appropriate data type, let's introduce a symbol `parse_timestamp` (currently being defined to `strtoul`) where appropriate, so that we can later easily switch to, say, use `strtoull()` instead. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- builtin/am.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin/am.c') diff --git a/builtin/am.c b/builtin/am.c index f7a7a971fb..2c93adc69c 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -882,7 +882,7 @@ static int hg_patch_to_mail(FILE *out, FILE *in, int keep_cr) char *end; errno = 0; - timestamp = strtoul(str, &end, 10); + timestamp = parse_timestamp(str, &end, 10); if (errno) return error(_("invalid timestamp")); -- cgit v1.2.3 From dddbad728c93280fe54ef86699b6d70e2aab44d1 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 26 Apr 2017 21:29:31 +0200 Subject: timestamp_t: a new data type for timestamps Git's source code assumes that unsigned long is at least as precise as time_t. Which is incorrect, and causes a lot of problems, in particular where unsigned long is only 32-bit (notably on Windows, even in 64-bit versions). So let's just use a more appropriate data type instead. In preparation for this, we introduce the new `timestamp_t` data type. By necessity, this is a very, very large patch, as it has to replace all timestamps' data type in one go. As we will use a data type that is not necessarily identical to `time_t`, we need to be very careful to use `time_t` whenever we interact with the system functions, and `timestamp_t` everywhere else. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- builtin/am.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin/am.c') diff --git a/builtin/am.c b/builtin/am.c index 2c93adc69c..89914ed875 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -877,7 +877,7 @@ static int hg_patch_to_mail(FILE *out, FILE *in, int keep_cr) if (skip_prefix(sb.buf, "# User ", &str)) fprintf(out, "From: %s\n", str); else if (skip_prefix(sb.buf, "# Date ", &str)) { - unsigned long timestamp; + timestamp_t timestamp; long tz, tz2; char *end; -- cgit v1.2.3