Skip to content

Commit 887307d

Browse files
author
hackorum
committed
Apply rm_tzp.diff
1 parent 4255812 commit 887307d

1 file changed

Lines changed: 10 additions & 41 deletions

File tree

‎src/interfaces/ecpg/pgtypeslib/dt_common.c‎

Lines changed: 10 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,7 +1541,8 @@ DecodeTimezone(char *str, int *tzp)
15411541
if (*str == '-')
15421542
tz = -tz;
15431543

1544-
*tzp = -tz;
1544+
if (tzp != NULL)
1545+
*tzp = -tz;
15451546
return *cp != '\0';
15461547
} /* DecodeTimezone() */
15471548

@@ -1578,7 +1579,8 @@ DecodePosixTimezone(char *str, int *tzp)
15781579
{
15791580
case DTZ:
15801581
case TZ:
1581-
*tzp = -(val + tz);
1582+
if (tzp != NULL)
1583+
*tzp = -(val + tz);
15821584
break;
15831585

15841586
default:
@@ -1804,8 +1806,6 @@ DecodeDateTime(char **field, int *ftype, int nf,
18041806
bool haveTextMonth = false;
18051807
bool is2digits = false;
18061808
bool bc = false;
1807-
int t = 0;
1808-
int *tzp = &t;
18091809

18101810
/***
18111811
* We'll insist on at least all of the date fields, but initialize the
@@ -1818,8 +1818,6 @@ DecodeDateTime(char **field, int *ftype, int nf,
18181818
*fsec = 0;
18191819
/* don't know daylight savings time status apriori */
18201820
tm->tm_isdst = -1;
1821-
if (tzp != NULL)
1822-
*tzp = 0;
18231821

18241822
for (i = 0; i < nf; i++)
18251823
{
@@ -1836,16 +1834,13 @@ DecodeDateTime(char **field, int *ftype, int nf,
18361834
char *cp;
18371835
int jday;
18381836

1839-
if (tzp == NULL)
1840-
return -1;
1841-
18421837
jday = strtoint(field[i], &cp, 10);
18431838
if (*cp != '-')
18441839
return -1;
18451840

18461841
j2date(jday, &tm->tm_year, &tm->tm_mon, &tm->tm_mday);
18471842
/* Get the time zone from the end of the string */
1848-
if (DecodeTimezone(cp, tzp) != 0)
1843+
if (DecodeTimezone(cp, NULL) != 0)
18491844
return -1;
18501845

18511846
tmask = DTK_DATE_M | DTK_TIME_M | DTK_M(TZ);
@@ -1861,10 +1856,6 @@ DecodeDateTime(char **field, int *ftype, int nf,
18611856
else if (((fmask & DTK_DATE_M) == DTK_DATE_M)
18621857
|| (ptype != 0))
18631858
{
1864-
/* No time zone accepted? Then quit... */
1865-
if (tzp == NULL)
1866-
return -1;
1867-
18681859
if (isdigit((unsigned char) *field[i]) || ptype != 0)
18691860
{
18701861
char *cp;
@@ -1889,7 +1880,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
18891880
return -1;
18901881

18911882
/* Get the time zone from the end of the string */
1892-
if (DecodeTimezone(cp, tzp) != 0)
1883+
if (DecodeTimezone(cp, NULL) != 0)
18931884
return -1;
18941885
*cp = '\0';
18951886

@@ -1909,7 +1900,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
19091900
}
19101901
else
19111902
{
1912-
if (DecodePosixTimezone(field[i], tzp) != 0)
1903+
if (DecodePosixTimezone(field[i], NULL) != 0)
19131904
return -1;
19141905

19151906
ftype[i] = DTK_TZ;
@@ -1936,12 +1927,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
19361927

19371928
case DTK_TZ:
19381929
{
1939-
int tz;
1940-
1941-
if (tzp == NULL)
1942-
return -1;
1943-
1944-
if (DecodeTimezone(field[i], &tz) != 0)
1930+
if (DecodeTimezone(field[i], NULL) != 0)
19451931
return -1;
19461932

19471933
/*
@@ -1951,15 +1937,9 @@ DecodeDateTime(char **field, int *ftype, int nf,
19511937
if (i > 0 && (fmask & DTK_M(TZ)) != 0 &&
19521938
ftype[i - 1] == DTK_TZ &&
19531939
isalpha((unsigned char) *field[i - 1]))
1954-
{
1955-
*tzp -= tz;
19561940
tmask = 0;
1957-
}
19581941
else
1959-
{
1960-
*tzp = tz;
19611942
tmask = DTK_M(TZ);
1962-
}
19631943
}
19641944
break;
19651945

@@ -2051,7 +2031,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
20512031

20522032
case DTK_TZ:
20532033
tmask = DTK_M(TZ);
2054-
if (DecodeTimezone(field[i], tzp) != 0)
2034+
if (DecodeTimezone(field[i], NULL) != 0)
20552035
return -1;
20562036
break;
20572037

@@ -2187,8 +2167,6 @@ DecodeDateTime(char **field, int *ftype, int nf,
21872167
tm->tm_hour = 0;
21882168
tm->tm_min = 0;
21892169
tm->tm_sec = 0;
2190-
if (tzp != NULL)
2191-
*tzp = 0;
21922170
break;
21932171

21942172
default:
@@ -2221,9 +2199,6 @@ DecodeDateTime(char **field, int *ftype, int nf,
22212199
*/
22222200
tmask |= DTK_M(DTZ);
22232201
tm->tm_isdst = 1;
2224-
if (tzp == NULL)
2225-
return -1;
2226-
*tzp -= val;
22272202
break;
22282203

22292204
case DTZ:
@@ -2234,17 +2209,11 @@ DecodeDateTime(char **field, int *ftype, int nf,
22342209
*/
22352210
tmask |= DTK_M(TZ);
22362211
tm->tm_isdst = 1;
2237-
if (tzp == NULL)
2238-
return -1;
2239-
*tzp = -val;
22402212
ftype[i] = DTK_TZ;
22412213
break;
22422214

22432215
case TZ:
22442216
tm->tm_isdst = 0;
2245-
if (tzp == NULL)
2246-
return -1;
2247-
*tzp = -val;
22482217
ftype[i] = DTK_TZ;
22492218
break;
22502219

@@ -2350,7 +2319,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
23502319
* result afterwards anyway so we only check for this error: daylight
23512320
* savings time modifier but no standard timezone?
23522321
*/
2353-
if ((fmask & DTK_DATE_M) == DTK_DATE_M && tzp != NULL && !(fmask & DTK_M(TZ)) && (fmask & DTK_M(DTZMOD)))
2322+
if ((fmask & DTK_DATE_M) == DTK_DATE_M && !(fmask & DTK_M(TZ)) && (fmask & DTK_M(DTZMOD)))
23542323
return -1;
23552324
}
23562325

0 commit comments

Comments
 (0)