Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1f4e9da

Browse files
committed
Sync tzload() and tzparse() APIs with IANA release tzcode2016c.
This brings us a bit closer to matching upstream, but since it affectsfiles outside src/timezone/, we might choose not to back-patch it.Hence keep it separate from the main update patch.
1 parentf5f15ea commit1f4e9da

File tree

4 files changed

+26
-29
lines changed

4 files changed

+26
-29
lines changed

‎src/bin/initdb/findtimezone.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@ pg_load_tz(const char *name)
9999
*/
100100
if (strcmp(name,"GMT")==0)
101101
{
102-
if (tzparse(name,&tz.state,TRUE)!=0)
102+
if (!tzparse(name,&tz.state,true))
103103
{
104104
/* This really, really should not happen ... */
105105
returnNULL;
106106
}
107107
}
108-
elseif (tzload(name,NULL,&tz.state,TRUE)!=0)
108+
elseif (tzload(name,NULL,&tz.state,true)!=0)
109109
{
110-
if (name[0]==':'||tzparse(name,&tz.state,FALSE)!=0)
110+
if (name[0]==':'||!tzparse(name,&tz.state,false))
111111
{
112112
returnNULL;/* unknown timezone */
113113
}

‎src/timezone/localtime.c

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ tzloadbody(char const * name, char *canonname, struct state * sp, bool doextend,
409409
structstate*ts=&lsp->u.st;
410410

411411
up->buf[nread-1]='\0';
412-
if (tzparse(&up->buf[1],ts, false)==0
412+
if (tzparse(&up->buf[1],ts, false)
413413
&&ts->typecnt==2)
414414
{
415415
/*
@@ -534,7 +534,7 @@ tzloadbody(char const * name, char *canonname, struct state * sp, bool doextend,
534534
* given name is stored there (the buffer must be > TZ_STRLEN_MAX bytes!).
535535
*/
536536
int
537-
tzload(constchar*name,char*canonname,structstate*sp,intdoextend)
537+
tzload(constchar*name,char*canonname,structstate*sp,booldoextend)
538538
{
539539
unionlocal_storagels;
540540

@@ -864,13 +864,10 @@ transtime(int year, const struct rule * rulep,
864864
/*
865865
* Given a POSIX section 8-style TZ string, fill in the rule tables as
866866
* appropriate.
867-
*
868-
* Returns 0 on success, -1 on failure. (Note: tzcode has converted this
869-
* to a bool true-on-success convention, but we're holding the line in PG
870-
* for the moment, to avoid external API changes.)
867+
* Returns true on success, false on failure.
871868
*/
872-
int
873-
tzparse(constchar*name,structstate*sp,intlastditch)
869+
bool
870+
tzparse(constchar*name,structstate*sp,boollastditch)
874871
{
875872
constchar*stdname;
876873
constchar*dstname=NULL;
@@ -908,7 +905,7 @@ tzparse(const char *name, struct state * sp, int lastditch)
908905
stdname=name;
909906
name=getqzname(name,'>');
910907
if (*name!='>')
911-
return-1;
908+
returnfalse;
912909
stdlen=name-stdname;
913910
name++;
914911
}
@@ -918,13 +915,13 @@ tzparse(const char *name, struct state * sp, int lastditch)
918915
stdlen=name-stdname;
919916
}
920917
if (*name=='\0')/* we allow empty STD abbrev, unlike IANA */
921-
return-1;
918+
returnfalse;
922919
name=getoffset(name,&stdoffset);
923920
if (name==NULL)
924-
return-1;
921+
returnfalse;
925922
charcnt=stdlen+1;
926923
if (sizeofsp->chars<charcnt)
927-
return-1;
924+
returnfalse;
928925
load_ok=tzload(TZDEFRULES,NULL,sp, false)==0;
929926
}
930927
if (!load_ok)
@@ -936,7 +933,7 @@ tzparse(const char *name, struct state * sp, int lastditch)
936933
dstname=++name;
937934
name=getqzname(name,'>');
938935
if (*name!='>')
939-
return-1;
936+
returnfalse;
940937
dstlen=name-dstname;
941938
name++;
942939
}
@@ -947,15 +944,15 @@ tzparse(const char *name, struct state * sp, int lastditch)
947944
dstlen=name-dstname;/* length of DST zone name */
948945
}
949946
if (!dstlen)
950-
return-1;
947+
returnfalse;
951948
charcnt+=dstlen+1;
952949
if (sizeofsp->chars<charcnt)
953-
return-1;
950+
returnfalse;
954951
if (*name!='\0'&&*name!=','&&*name!=';')
955952
{
956953
name=getoffset(name,&dstoffset);
957954
if (name==NULL)
958-
return-1;
955+
returnfalse;
959956
}
960957
else
961958
dstoffset=stdoffset-SECSPERHOUR;
@@ -972,13 +969,13 @@ tzparse(const char *name, struct state * sp, int lastditch)
972969

973970
++name;
974971
if ((name=getrule(name,&start))==NULL)
975-
return-1;
972+
returnfalse;
976973
if (*name++!=',')
977-
return-1;
974+
returnfalse;
978975
if ((name=getrule(name,&end))==NULL)
979-
return-1;
976+
returnfalse;
980977
if (*name!='\0')
981-
return-1;
978+
returnfalse;
982979
sp->typecnt=2;/* standard time and DST */
983980

984981
/*
@@ -1044,7 +1041,7 @@ tzparse(const char *name, struct state * sp, int lastditch)
10441041
intj;
10451042

10461043
if (*name!='\0')
1047-
return-1;
1044+
returnfalse;
10481045

10491046
/*
10501047
* Initial values of theirstdoffset and theirdstoffset.
@@ -1148,7 +1145,7 @@ tzparse(const char *name, struct state * sp, int lastditch)
11481145
memcpy(cp,dstname,dstlen);
11491146
*(cp+dstlen)='\0';
11501147
}
1151-
return0;
1148+
returntrue;
11521149
}
11531150

11541151
staticvoid

‎src/timezone/pgtz.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ pg_tzset(const char *name)
256256
*/
257257
if (strcmp(uppername,"GMT")==0)
258258
{
259-
if (tzparse(uppername,&tzstate, true)!=0)
259+
if (!tzparse(uppername,&tzstate, true))
260260
{
261261
/* This really, really should not happen ... */
262262
elog(ERROR,"could not initialize GMT time zone");
@@ -266,7 +266,7 @@ pg_tzset(const char *name)
266266
}
267267
elseif (tzload(uppername,canonname,&tzstate, true)!=0)
268268
{
269-
if (uppername[0]==':'||tzparse(uppername,&tzstate, false)!=0)
269+
if (uppername[0]==':'||!tzparse(uppername,&tzstate, false))
270270
{
271271
/* Unknown timezone. Fail our call instead of loading GMT! */
272272
returnNULL;

‎src/timezone/pgtz.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ extern intpg_open_tzfile(const char *name, char *canonname);
6969

7070
/* in localtime.c */
7171
externinttzload(constchar*name,char*canonname,structstate*sp,
72-
intdoextend);
73-
externinttzparse(constchar*name,structstate*sp,intlastditch);
72+
booldoextend);
73+
externbooltzparse(constchar*name,structstate*sp,boollastditch);
7474

7575
#endif/* _PGTZ_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp