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

Commitc202ecf

Browse files
committed
Another zic portability fix.
I should have remembered that we can't use INT64_MODIFIER with sscanf():configure chooses that to work with snprintf(), but it might be for oursrc/port/snprintf.c implementation and so not compatible with theplatform's sscanf(). This appears to be the explanation for buildfarmmember frogmouth's continuing unhappiness with the tzcode update.Fortunately, in all of the places where zic is attempting to read intoan int64 variable, it's reading a year which certainly will fit just fineinto an int. So make it read into an int with %d, and then cast or copyas necessary.
1 parent61608d3 commitc202ecf

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

‎src/timezone/zic.c

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
typedefint64zic_t;
2424
#defineZIC_MIN PG_INT64_MIN
2525
#defineZIC_MAX PG_INT64_MAX
26-
#defineSCNdZIC INT64_MODIFIER "d"
2726

2827
#ifndefZIC_MAX_ABBR_LEN_WO_WARN
2928
#defineZIC_MAX_ABBR_LEN_WO_WARN 6
@@ -1145,7 +1144,8 @@ infile(const char *name)
11451144
staticzic_t
11461145
gethms(charconst*string,charconst*errstring,boolsignable)
11471146
{
1148-
zic_thh;
1147+
/* PG: make hh be int not zic_t to avoid sscanf portability issues */
1148+
inthh;
11491149
intmm,
11501150
ss,
11511151
sign;
@@ -1162,11 +1162,11 @@ gethms(char const * string, char const * errstring, bool signable)
11621162
}
11631163
else
11641164
sign=1;
1165-
if (sscanf(string,"%"SCNdZIC"%c",&hh,&xs)==1)
1165+
if (sscanf(string,"%d%c",&hh,&xs)==1)
11661166
mm=ss=0;
1167-
elseif (sscanf(string,"%"SCNdZIC":%d%c",&hh,&mm,&xs)==2)
1167+
elseif (sscanf(string,"%d:%d%c",&hh,&mm,&xs)==2)
11681168
ss=0;
1169-
elseif (sscanf(string,"%"SCNdZIC":%d:%d%c",&hh,&mm,&ss,&xs)
1169+
elseif (sscanf(string,"%d:%d:%d%c",&hh,&mm,&ss,&xs)
11701170
!=3)
11711171
{
11721172
error("%s",errstring);
@@ -1179,15 +1179,15 @@ gethms(char const * string, char const * errstring, bool signable)
11791179
error("%s",errstring);
11801180
return0;
11811181
}
1182-
if (ZIC_MAX /SECSPERHOUR<hh)
1182+
if (ZIC_MAX /SECSPERHOUR<(zic_t)hh)
11831183
{
11841184
error(_("time overflow"));
11851185
return0;
11861186
}
11871187
if (noise&& (hh>HOURSPERDAY||
11881188
(hh==HOURSPERDAY&& (mm!=0||ss!=0))))
11891189
warning(_("values over 24 hours not handled by pre-2007 versions of zic"));
1190-
returnoadd(sign*hh*SECSPERHOUR,
1190+
returnoadd(sign*(zic_t)hh*SECSPERHOUR,
11911191
sign* (mm*SECSPERMIN+ss));
11921192
}
11931193

@@ -1374,7 +1374,9 @@ inleap(char **fields, int nfields)
13741374
conststructlookup*lp;
13751375
inti,
13761376
j;
1377-
zic_tyear;
1377+
1378+
/* PG: make year be int not zic_t to avoid sscanf portability issues */
1379+
intyear;
13781380
intmonth,
13791381
day;
13801382
zic_tdayoff,
@@ -1389,7 +1391,7 @@ inleap(char **fields, int nfields)
13891391
}
13901392
dayoff=0;
13911393
cp=fields[LP_YEAR];
1392-
if (sscanf(cp,"%"SCNdZIC"%c",&year,&xs)!=1)
1394+
if (sscanf(cp,"%d%c",&year,&xs)!=1)
13931395
{
13941396
/*
13951397
* Leapin' Lizards!
@@ -1531,6 +1533,9 @@ rulesub(struct rule * rp, const char *loyearp, const char *hiyearp,
15311533
char*ep;
15321534
charxs;
15331535

1536+
/* PG: year_tmp is to avoid sscanf portability issues */
1537+
intyear_tmp;
1538+
15341539
if ((lp=byword(monthp,mon_names))==NULL)
15351540
{
15361541
error(_("invalid month name"));
@@ -1588,7 +1593,9 @@ rulesub(struct rule * rp, const char *loyearp, const char *hiyearp,
15881593
progname,lp->l_value);
15891594
exit(EXIT_FAILURE);
15901595
}
1591-
elseif (sscanf(cp,"%"SCNdZIC"%c",&rp->r_loyear,&xs)!=1)
1596+
elseif (sscanf(cp,"%d%c",&year_tmp,&xs)==1)
1597+
rp->r_loyear=year_tmp;
1598+
else
15921599
{
15931600
error(_("invalid starting year"));
15941601
return;
@@ -1614,7 +1621,9 @@ rulesub(struct rule * rp, const char *loyearp, const char *hiyearp,
16141621
progname,lp->l_value);
16151622
exit(EXIT_FAILURE);
16161623
}
1617-
elseif (sscanf(cp,"%"SCNdZIC"%c",&rp->r_hiyear,&xs)!=1)
1624+
elseif (sscanf(cp,"%d%c",&year_tmp,&xs)==1)
1625+
rp->r_hiyear=year_tmp;
1626+
else
16181627
{
16191628
error(_("invalid ending year"));
16201629
return;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp