git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1a9b061)
Prevent timetz2tm() from scribbling on its input in HAVE_INT64_TIMESTAMP case.
2003年2月13日 17:04:19 +0000 (17:04 +0000)
2003年2月13日 17:04:19 +0000 (17:04 +0000)

diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c
index 09d0e9aa25603062d5e210c3b4e06cb1147203e6..a31cce92073a6425a08ff6a40d778cee221f385c 100644 (file)
--- a/src/backend/utils/adt/date.c
+++ b/src/backend/utils/adt/date.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.78 2003年01月31日 01:08:08 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.79 2003年02月13日 17:04:19 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1349,23 +1349,22 @@ timetz_out(PG_FUNCTION_ARGS)
/* timetz2tm()
* Convert TIME WITH TIME ZONE data type to POSIX time structure.
- * For dates within the system-supported time_t range, convert to the
- * local time zone. If out of this range, leave as GMT. - tgl 97/05/27
*/
static int
timetz2tm(TimeTzADT *time, struct tm * tm, fsec_t *fsec, int *tzp)
{
#ifdef HAVE_INT64_TIMESTAMP
- tm->tm_hour = (time->time / INT64CONST(3600000000));
- time->time -= (tm->tm_hour * INT64CONST(3600000000));
- tm->tm_min = (time->time / INT64CONST(60000000));
- time->time -= (tm->tm_min * INT64CONST(60000000));
- tm->tm_sec = (time->time / INT64CONST(1000000));
- *fsec = (time->time - (tm->tm_sec * INT64CONST(1000000)));
+ int64 trem = time->time;
+
+ tm->tm_hour = (trem / INT64CONST(3600000000));
+ trem -= (tm->tm_hour * INT64CONST(3600000000));
+ tm->tm_min = (trem / INT64CONST(60000000));
+ trem -= (tm->tm_min * INT64CONST(60000000));
+ tm->tm_sec = (trem / INT64CONST(1000000));
+ *fsec = (trem - (tm->tm_sec * INT64CONST(1000000)));
#else
- double trem;
+ double trem = time->time;
- trem = time->time;
TMODULO(trem, tm->tm_hour, 3600e0);
TMODULO(trem, tm->tm_min, 60e0);
TMODULO(trem, tm->tm_sec, 1e0);
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /