Skip to content

Commit e22d410

Browse files
committed
zic now uses is_digit
Refactor zic.c to use is_digit like others use. * zic.c (is_digit): New static function, copied from localtime.c and from zdump.c. It’s too bad we can’t avoid duplication by putting this into private.h, because gcc -Wunused-function would then complain about it. Perhaps ‘inline’ would pacify gcc but then we’d have to port ‘inline’ to ancient compilers and anyway ‘inline’ is supposed to be just a performance hint which is not needed here.
1 parent f57cadd commit e22d410

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

zic.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,13 @@ static bool rulesub(struct rule * rp,
229229
const char * dayp, const char * timep);
230230
static zic_t tadd(zic_t t1, zic_t t2);
231231

232+
/* Is C an ASCII digit? */
233+
static bool
234+
is_digit(char c)
235+
{
236+
return '0' <= c && c <= '9';
237+
}
238+
232239
/* Bound on length of what %z can expand to. */
233240
enum { PERCENT_Z_LEN_BOUND = sizeof "+995959" - 1 };
234241

@@ -1852,7 +1859,7 @@ gethms(char const *string, char const *errstring)
18521859
&hh, &hhx, &mm, &mmx, &ss, &ssx, &tenths, &xr, &xs)) {
18531860
default: ok = false; break;
18541861
case 8:
1855-
ok = '0' <= xr && xr <= '9';
1862+
ok = is_digit(xr);
18561863
ATTRIBUTE_FALLTHROUGH;
18571864
case 7:
18581865
ok &= ssx == '.';
@@ -3952,7 +3959,7 @@ newabbr(const char *string)
39523959

39533960
cp = string;
39543961
mp = NULL;
3955-
while (is_alpha(*cp) || ('0' <= *cp && *cp <= '9')
3962+
while (is_alpha(*cp) || is_digit(*cp)
39563963
|| *cp == '-' || *cp == '+')
39573964
++cp;
39583965
if (noise && cp - string < 3)

0 commit comments

Comments
 (0)