diff --git a/src/interfaces/ecpg/pgtypeslib/dt_common.c b/src/interfaces/ecpg/pgtypeslib/dt_common.c index 99bdc94d6d..97800a51c8 100644 --- a/src/interfaces/ecpg/pgtypeslib/dt_common.c +++ b/src/interfaces/ecpg/pgtypeslib/dt_common.c @@ -1530,7 +1530,8 @@ DecodeTimezone(char *str, int *tzp) if (*str == '-') tz = -tz; - *tzp = -tz; + if (tzp != NULL) + *tzp = -tz; return *cp != '\0'; } /* DecodeTimezone() */ @@ -1566,7 +1567,8 @@ DecodePosixTimezone(char *str, int *tzp) { case DTZ: case TZ: - *tzp = -(val + tz); + if (tzp != NULL) + *tzp = -(val + tz); break; default: @@ -1790,8 +1792,6 @@ DecodeDateTime(char **field, int *ftype, int nf, bool haveTextMonth = false; bool is2digits = false; bool bc = false; - int t = 0; - int *tzp = &t; /*** * We'll insist on at least all of the date fields, but initialize the @@ -1804,8 +1804,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 +1820,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, NULL) != 0) return -1; tmask = DTK_DATE_M | DTK_TIME_M | DTK_M(TZ); @@ -1847,10 +1842,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 +1866,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, NULL) != 0) return -1; *cp = '\0'; @@ -1895,7 +1886,7 @@ DecodeDateTime(char **field, int *ftype, int nf, } else { - if (DecodePosixTimezone(field[i], tzp) != 0) + if (DecodePosixTimezone(field[i], NULL) != 0) return -1; ftype[i] = DTK_TZ; @@ -1922,12 +1913,7 @@ DecodeDateTime(char **field, int *ftype, int nf, case DTK_TZ: { - int tz; - - if (tzp == NULL) - return -1; - - if (DecodeTimezone(field[i], &tz) != 0) + if (DecodeTimezone(field[i], NULL) != 0) return -1; /* @@ -1937,15 +1923,9 @@ DecodeDateTime(char **field, int *ftype, int nf, if (i > 0 && (fmask & DTK_M(TZ)) != 0 && ftype[i - 1] == DTK_TZ && isalpha((unsigned char) *field[i - 1])) - { - *tzp -= tz; tmask = 0; - } else - { - *tzp = tz; tmask = DTK_M(TZ); - } } break; @@ -2037,7 +2017,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], NULL) != 0) return -1; break; @@ -2173,8 +2153,6 @@ DecodeDateTime(char **field, int *ftype, int nf, tm->tm_hour = 0; tm->tm_min = 0; tm->tm_sec = 0; - if (tzp != NULL) - *tzp = 0; break; default: @@ -2207,9 +2185,6 @@ DecodeDateTime(char **field, int *ftype, int nf, */ tmask |= DTK_M(DTZ); tm->tm_isdst = 1; - if (tzp == NULL) - return -1; - *tzp -= val; break; case DTZ: @@ -2220,17 +2195,11 @@ DecodeDateTime(char **field, int *ftype, int nf, */ tmask |= DTK_M(TZ); tm->tm_isdst = 1; - if (tzp == NULL) - return -1; - *tzp = -val; ftype[i] = DTK_TZ; break; case TZ: tm->tm_isdst = 0; - if (tzp == NULL) - return -1; - *tzp = -val; ftype[i] = DTK_TZ; break; @@ -2336,7 +2305,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; }