diff --git a/src/interfaces/ecpg/pgtypeslib/dt_common.c b/src/interfaces/ecpg/pgtypeslib/dt_common.c index 99bdc94d6d..7783316596 100644 --- a/src/interfaces/ecpg/pgtypeslib/dt_common.c +++ b/src/interfaces/ecpg/pgtypeslib/dt_common.c @@ -1790,8 +1790,7 @@ DecodeDateTime(char **field, int *ftype, int nf, bool haveTextMonth = false; bool is2digits = false; bool bc = false; - int t = 0; - int *tzp = &t; + int tzp = 0; /*** * We'll insist on at least all of the date fields, but initialize the @@ -1804,8 +1803,6 @@ DecodeDateTime(char **field, int *ftype, int nf, *fsec = 0; /* don't know daylight savings time status apriori */ tm->tm_isdst = -1; - if (tzp != NULL) - *tzp = 0; for (i = 0; i < nf; i++) { @@ -1822,16 +1819,13 @@ DecodeDateTime(char **field, int *ftype, int nf, char *cp; int jday; - if (tzp == NULL) - return -1; - jday = strtoint(field[i], &cp, 10); if (*cp != '-') return -1; j2date(jday, &tm->tm_year, &tm->tm_mon, &tm->tm_mday); /* Get the time zone from the end of the string */ - if (DecodeTimezone(cp, tzp) != 0) + if (DecodeTimezone(cp, &tzp) != 0) return -1; tmask = DTK_DATE_M | DTK_TIME_M | DTK_M(TZ); @@ -1847,10 +1841,6 @@ DecodeDateTime(char **field, int *ftype, int nf, else if (((fmask & DTK_DATE_M) == DTK_DATE_M) || (ptype != 0)) { - /* No time zone accepted? Then quit... */ - if (tzp == NULL) - return -1; - if (isdigit((unsigned char) *field[i]) || ptype != 0) { char *cp; @@ -1875,7 +1865,7 @@ DecodeDateTime(char **field, int *ftype, int nf, return -1; /* Get the time zone from the end of the string */ - if (DecodeTimezone(cp, tzp) != 0) + if (DecodeTimezone(cp, &tzp) != 0) return -1; *cp = '\0'; @@ -1895,7 +1885,7 @@ DecodeDateTime(char **field, int *ftype, int nf, } else { - if (DecodePosixTimezone(field[i], tzp) != 0) + if (DecodePosixTimezone(field[i], &tzp) != 0) return -1; ftype[i] = DTK_TZ; @@ -1924,9 +1914,6 @@ DecodeDateTime(char **field, int *ftype, int nf, { int tz; - if (tzp == NULL) - return -1; - if (DecodeTimezone(field[i], &tz) != 0) return -1; @@ -1938,12 +1925,12 @@ DecodeDateTime(char **field, int *ftype, int nf, ftype[i - 1] == DTK_TZ && isalpha((unsigned char) *field[i - 1])) { - *tzp -= tz; + tzp -= tz; tmask = 0; } else { - *tzp = tz; + tzp = tz; tmask = DTK_M(TZ); } } @@ -2037,7 +2024,7 @@ DecodeDateTime(char **field, int *ftype, int nf, case DTK_TZ: tmask = DTK_M(TZ); - if (DecodeTimezone(field[i], tzp) != 0) + if (DecodeTimezone(field[i], &tzp) != 0) return -1; break; @@ -2173,8 +2160,7 @@ DecodeDateTime(char **field, int *ftype, int nf, tm->tm_hour = 0; tm->tm_min = 0; tm->tm_sec = 0; - if (tzp != NULL) - *tzp = 0; + tzp = 0; break; default: @@ -2207,9 +2193,7 @@ DecodeDateTime(char **field, int *ftype, int nf, */ tmask |= DTK_M(DTZ); tm->tm_isdst = 1; - if (tzp == NULL) - return -1; - *tzp -= val; + tzp -= val; break; case DTZ: @@ -2220,17 +2204,13 @@ DecodeDateTime(char **field, int *ftype, int nf, */ tmask |= DTK_M(TZ); tm->tm_isdst = 1; - if (tzp == NULL) - return -1; - *tzp = -val; + tzp = -val; ftype[i] = DTK_TZ; break; case TZ: tm->tm_isdst = 0; - if (tzp == NULL) - return -1; - *tzp = -val; + tzp = -val; ftype[i] = DTK_TZ; break; @@ -2336,7 +2316,7 @@ DecodeDateTime(char **field, int *ftype, int nf, * result afterwards anyway so we only check for this error: daylight * savings time modifier but no standard timezone? */ - if ((fmask & DTK_DATE_M) == DTK_DATE_M && tzp != NULL && !(fmask & DTK_M(TZ)) && (fmask & DTK_M(DTZMOD))) + if ((fmask & DTK_DATE_M) == DTK_DATE_M && !(fmask & DTK_M(TZ)) && (fmask & DTK_M(DTZMOD))) return -1; }