From 2151ca6b20ef7941d5ca6e9523a0ba0aa6eb13e5 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 26 Oct 2012 17:37:42 -0700 Subject: [PATCH] Restore 'register'. * asctime.c (asctime_r, asctime): * date.c (main, dogmt, reset, nondigit, sametm, convert, checkfinal): * ialloc.c (icatalloc): * localtime.c (detzcode, detzcode64, settzname, tzload) (typesequiv, getzname, getqzname, getnum, getsecs, getoffset) (getrule, transtime, tzparse, tzset, localsub, gmtsub) (leaps_thru_end_of, timesub, increment_overflow) (long_increment_overflow, normalize_overflow) (long_normalize_overflow, tmcomp, time2sub, time1, leapcorr): * scheck.c (scheck): * strftime.c (_yconv): * zdump.c (my_localtime, abbrok, main, yeartot, hunt) (delta, show, abbr, dumptime): * zic.c (main, dolink, itsdir, associate, infile, inrule) (inzone, inzcont, inzsub, inleap, inlink, rulesub, convert64) (writezone, doabbr, stringoffset, stringrule, stringzone) (outzone, addtype, leapadd, adjleap, ciequal, itsabbr, byword) (getfields, rpytime, newabbr, mkdirs): Restore the uses of 'register', reverting that part of the "More C modernization" patch. See Arthur David Olson in . --- asctime.c | 8 +- date.c | 55 ++++++------ ialloc.c | 4 +- localtime.c | 253 +++++++++++++++++++++++++-------------------------- scheck.c | 12 +-- strftime.c | 4 +- zdump.c | 82 ++++++++--------- zic.c | 254 ++++++++++++++++++++++++++-------------------------- 8 files changed, 337 insertions(+), 335 deletions(-) diff --git a/asctime.c b/asctime.c index e81b4f0..152b0db 100644 --- a/asctime.c +++ b/asctime.c @@ -69,7 +69,7 @@ static char buf_asctime[MAX_ASCTIME_BUF_SIZE]; */ char * -asctime_r(const struct tm *timeptr, char *buf) +asctime_r(register const struct tm *timeptr, char *buf) { static const char wday_name[][3] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" @@ -78,8 +78,8 @@ asctime_r(const struct tm *timeptr, char *buf) "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; - const char *wn; - const char *mn; + register const char * wn; + register const char * mn; char year[INT_STRLEN_MAXIMUM(int) + 2]; char result[MAX_ASCTIME_BUF_SIZE]; @@ -126,7 +126,7 @@ asctime_r(const struct tm *timeptr, char *buf) */ char * -asctime(const struct tm *timeptr) +asctime(register const struct tm *timeptr) { return asctime_r(timeptr, buf_asctime); } diff --git a/date.c b/date.c index 1839397..b721ad9 100644 --- a/date.c +++ b/date.c @@ -85,20 +85,20 @@ static void wildinput(const char *, const char *, int main(const int argc, char *argv[]) { - const char * format; - const char * value; - const char * cp; - int ch; - int dousg; - int aflag = 0; - int dflag = 0; - int nflag = 0; - int tflag = 0; - int minuteswest; - int dsttime; - double adjust; - time_t now; - time_t t; + register const char * format; + register const char * value; + register const char * cp; + register int ch; + register int dousg; + register int aflag = 0; + register int dflag = 0; + register int nflag = 0; + register int tflag = 0; + register int minuteswest; + register int dsttime; + register double adjust; + time_t now; + time_t t; INITIALIZE(dousg); INITIALIZE(minuteswest); @@ -305,9 +305,9 @@ dogmt(void) static char ** fakeenv; if (fakeenv == NULL) { - int from; - int to; - int n; + register int from; + register int to; + register int n; static char tzegmt0[] = "TZ=GMT0"; for (n = 0; environ[n] != NULL; ++n) @@ -343,7 +343,7 @@ dogmt(void) static void reset(const time_t newt, const int nflag) { - int fid; + register int fid; time_t oldt; static struct { struct utmp before; @@ -449,7 +449,7 @@ static int netsettime(struct timeval); static void reset(const time_t newt, const int nflag) { - const char * username; + register const char * username; static struct timeval tv; /* static so tv_usec is 0 */ #ifdef EBUG @@ -495,7 +495,7 @@ errensure(void) } static const char * -nondigit(const char *cp) +nondigit(register const char *cp) { while (is_digit(*cp)) ++cp; @@ -577,7 +577,8 @@ timeout(FILE *const fp, const char *const format, const struct tm *const tmp) } static int -sametm(const struct tm *const atmp, const struct tm *const btmp) +sametm(register const struct tm *const atmp, + register const struct tm *const btmp) { return atmp->tm_year == btmp->tm_year && atmp->tm_mon == btmp->tm_mon && @@ -595,11 +596,11 @@ sametm(const struct tm *const atmp, const struct tm *const btmp) #define ATOI2(ar) (ar[0] - '0') * 10 + (ar[1] - '0'); ar += 2; static time_t -convert(const char * const value, const int dousg, const time_t t) +convert(register const char * const value, const int dousg, const time_t t) { - const char * cp; - const char * dotp; - int cent, year_in_cent, month, hour, day, mins, secs; + register const char * cp; + register const char * dotp; + register int cent, year_in_cent, month, hour, day, mins, secs; struct tm tm, outtm; time_t outt; @@ -707,8 +708,8 @@ checkfinal(const char * const value, time_t othert; struct tm tm; struct tm othertm; - int pass; - long offset; + register int pass; + register long offset; /* ** See if there's both a USG and a BSD interpretation. diff --git a/ialloc.c b/ialloc.c index 6a565c6..b6f0188 100644 --- a/ialloc.c +++ b/ialloc.c @@ -10,8 +10,8 @@ char * icatalloc(char *const old, const char *const new) { - char * result; - int oldsize, newsize; + register char * result; + register int oldsize, newsize; newsize = (new == NULL) ? 0 : strlen(new); if (old == NULL) diff --git a/localtime.c b/localtime.c index b045b93..e074c54 100644 --- a/localtime.c +++ b/localtime.c @@ -226,8 +226,8 @@ time_t altzone = 0; static long detzcode(const char *const codep) { - long result; - int i; + register long result; + register int i; result = (codep[0] & 0x80) ? ~0L : 0; for (i = 0; i < 4; ++i) @@ -238,8 +238,8 @@ detzcode(const char *const codep) static time_t detzcode64(const char *const codep) { - time_t result; - int i; + register time_t result; + register int i; result = (codep[0] & 0x80) ? (~(int_fast64_t) 0) : 0; for (i = 0; i < 8; ++i) @@ -250,8 +250,8 @@ detzcode64(const char *const codep) static void settzname(void) { - struct state * const sp = lclptr; - int i; + register struct state * const sp = lclptr; + register int i; tzname[0] = wildabbr; tzname[1] = wildabbr; @@ -272,7 +272,7 @@ settzname(void) ** And to get the latest zone names into tzname. . . */ for (i = 0; i < sp->timecnt; ++i) { - const struct ttinfo * const ttisp = + register const struct ttinfo * const ttisp = &sp->ttis[ sp->types[i]]; @@ -300,8 +300,8 @@ settzname(void) ** Second, truncate long abbreviations. */ for (i = 0; i < sp->typecnt; ++i) { - const struct ttinfo * const ttisp = &sp->ttis[i]; - char * cp = &sp->chars[ttisp->tt_abbrind]; + register const struct ttinfo * const ttisp = &sp->ttis[i]; + register char * cp = &sp->chars[ttisp->tt_abbrind]; if (strlen(cp) > TZ_ABBR_MAX_LEN && strcmp(cp, GRANDPARENTED) != 0) @@ -319,13 +319,14 @@ differ_by_repeat(const time_t t1, const time_t t0) } static int -tzload(const char *name, struct state *const sp, const int doextend) +tzload(register const char *name, register struct state *const sp, + register const int doextend) { - const char * p; - int i; - int fid; - int stored; - int nread; + register const char * p; + register int i; + register int fid; + register int stored; + register int nread; typedef union { struct tzhead tzhead; char buf[2 * sizeof(struct tzhead) + @@ -333,21 +334,21 @@ tzload(const char *name, struct state *const sp, const int doextend) 4 * TZ_MAX_TIMES]; } u_t; #ifdef ALL_STATE - u_t * up; + register u_t * up; up = (u_t *) calloc(1, sizeof *up); if (up == NULL) return -1; #else /* !defined ALL_STATE */ - u_t u; - u_t * const up = &u; + u_t u; + register u_t * const up = &u; #endif /* !defined ALL_STATE */ sp->goback = sp->goahead = FALSE; if (name == NULL && (name = TZDEFAULT) == NULL) goto oops; { - int doaccess; + register int doaccess; /* ** Section 4.9.1 of the C standard says that ** "FILENAME_MAX expands to an integral constant expression @@ -421,7 +422,7 @@ tzload(const char *name, struct state *const sp, const int doextend) goto oops; } for (i = 0; i < sp->typecnt; ++i) { - struct ttinfo * ttisp; + register struct ttinfo * ttisp; ttisp = &sp->ttis[i]; ttisp->tt_gmtoff = detzcode(p); @@ -438,7 +439,7 @@ tzload(const char *name, struct state *const sp, const int doextend) sp->chars[i] = *p++; sp->chars[i] = '\0'; /* ensure '\0' at end */ for (i = 0; i < sp->leapcnt; ++i) { - struct lsinfo * lsisp; + register struct lsinfo * lsisp; lsisp = &sp->lsis[i]; lsisp->ls_trans = (stored == 4) ? @@ -448,7 +449,7 @@ tzload(const char *name, struct state *const sp, const int doextend) p += 4; } for (i = 0; i < sp->typecnt; ++i) { - struct ttinfo * ttisp; + register struct ttinfo * ttisp; ttisp = &sp->ttis[i]; if (ttisstdcnt == 0) @@ -461,7 +462,7 @@ tzload(const char *name, struct state *const sp, const int doextend) } } for (i = 0; i < sp->typecnt; ++i) { - struct ttinfo * ttisp; + register struct ttinfo * ttisp; ttisp = &sp->ttis[i]; if (ttisgmtcnt == 0) @@ -490,7 +491,7 @@ tzload(const char *name, struct state *const sp, const int doextend) /* ** Ignore the beginning (harder). */ - int j; + register int j; for (j = 0; j + i < sp->timecnt; ++j) { sp->ats[j] = sp->ats[j + i]; @@ -518,7 +519,7 @@ tzload(const char *name, struct state *const sp, const int doextend) up->buf[0] == '\n' && up->buf[nread - 1] == '\n' && sp->typecnt + 2 <= TZ_MAX_TYPES) { struct state ts; - int result; + register int result; up->buf[nread - 1] = '\0'; result = tzparse(&up->buf[1], &ts, FALSE); @@ -579,15 +580,15 @@ oops: static int typesequiv(const struct state *const sp, const int a, const int b) { - int result; + register int result; if (sp == NULL || a < 0 || a >= sp->typecnt || b < 0 || b >= sp->typecnt) result = FALSE; else { - const struct ttinfo * ap = &sp->ttis[a]; - const struct ttinfo * bp = &sp->ttis[b]; + register const struct ttinfo * ap = &sp->ttis[a]; + register const struct ttinfo * bp = &sp->ttis[b]; result = ap->tt_gmtoff == bp->tt_gmtoff && ap->tt_isdst == bp->tt_isdst && ap->tt_ttisstd == bp->tt_ttisstd && @@ -614,9 +615,9 @@ static const int year_lengths[2] = { */ static const char * -getzname(const char *strp) +getzname(register const char *strp) { - char c; + register char c; while ((c = *strp) != '\0' && !is_digit(c) && c != ',' && c != '-' && c != '+') @@ -634,9 +635,9 @@ getzname(const char *strp) */ static const char * -getqzname(const char *strp, const int delim) +getqzname(register const char *strp, const int delim) { - int c; + register int c; while ((c = *strp) != '\0' && c != delim) ++strp; @@ -651,10 +652,10 @@ getqzname(const char *strp, const int delim) */ static const char * -getnum(const char *strp, int *const nump, const int min, const int max) +getnum(register const char *strp, int *const nump, const int min, const int max) { - char c; - int num; + register char c; + register int num; if (strp == NULL || !is_digit(c = *strp)) return NULL; @@ -680,7 +681,7 @@ getnum(const char *strp, int *const nump, const int min, const int max) */ static const char * -getsecs(const char *strp, long *const secsp) +getsecs(register const char *strp, long *const secsp) { int num; @@ -720,9 +721,9 @@ getsecs(const char *strp, long *const secsp) */ static const char * -getoffset(const char *strp, long *const offsetp) +getoffset(register const char *strp, long *const offsetp) { - int neg = 0; + register int neg = 0; if (*strp == '-') { neg = 1; @@ -745,7 +746,7 @@ getoffset(const char *strp, long *const offsetp) */ static const char * -getrule(const char *strp, struct rule *const rulep) +getrule(const char *strp, register struct rule *const rulep) { if (*strp == 'J') { /* @@ -798,12 +799,12 @@ getrule(const char *strp, struct rule *const rulep) static time_t transtime(const time_t janfirst, const int year, - const struct rule *const rulep, const long offset) + register const struct rule *const rulep, const long offset) { - int leapyear; - time_t value; - int i; - int d, m1, yy0, yy1, yy2, dow; + register int leapyear; + register time_t value; + register int i; + int d, m1, yy0, yy1, yy2, dow; INITIALIZE(value); leapyear = isleap(year); @@ -889,20 +890,20 @@ transtime(const time_t janfirst, const int year, */ static int -tzparse(const char *name, struct state *const sp, +tzparse(const char *name, register struct state *const sp, const int lastditch) { - const char * stdname; - const char * dstname; - size_t stdlen; - size_t dstlen; - long stdoffset; - long dstoffset; - time_t * atp; - unsigned char * typep; - char * cp; - int load_result; - static struct ttinfo zttinfo; + const char * stdname; + const char * dstname; + size_t stdlen; + size_t dstlen; + long stdoffset; + long dstoffset; + register time_t * atp; + register unsigned char * typep; + register char * cp; + register int load_result; + static struct ttinfo zttinfo; INITIALIZE(dstname); stdname = name; @@ -957,8 +958,8 @@ tzparse(const char *name, struct state *const sp, if (*name == ',' || *name == ';') { struct rule start; struct rule end; - int year; - time_t janfirst; + register int year; + register time_t janfirst; time_t starttime; time_t endtime; @@ -1015,12 +1016,12 @@ tzparse(const char *name, struct state *const sp, janfirst = newfirst; } } else { - long theirstdoffset; - long theirdstoffset; - long theiroffset; - int isdst; - int i; - int j; + register long theirstdoffset; + register long theirdstoffset; + register long theiroffset; + register int isdst; + register int i; + register int j; if (*name != '\0') return -1; @@ -1162,7 +1163,7 @@ tzsetwall(void) void tzset(void) { - const char * name; + register const char * name; name = getenv("TZ"); if (name == NULL) { @@ -1215,11 +1216,11 @@ tzset(void) static struct tm * localsub(const time_t *const timep, const long offset, struct tm *const tmp) { - struct state * sp; - const struct ttinfo * ttisp; - int i; - struct tm * result; - const time_t t = *timep; + register struct state * sp; + register const struct ttinfo * ttisp; + register int i; + register struct tm * result; + const time_t t = *timep; sp = lclptr; #ifdef ALL_STATE @@ -1228,10 +1229,10 @@ localsub(const time_t *const timep, const long offset, struct tm *const tmp) #endif /* defined ALL_STATE */ if ((sp->goback && t < sp->ats[0]) || (sp->goahead && t > sp->ats[sp->timecnt - 1])) { - time_t newt = t; - time_t seconds; - time_t tcycles; - int_fast64_t icycles; + time_t newt = t; + register time_t seconds; + register time_t tcycles; + register int_fast64_t icycles; if (t < sp->ats[0]) seconds = sp->ats[0] - t; @@ -1253,7 +1254,7 @@ localsub(const time_t *const timep, const long offset, struct tm *const tmp) return NULL; /* "cannot happen" */ result = localsub(&newt, offset, tmp); if (result == tmp) { - time_t newy; + register time_t newy; newy = tmp->tm_year; if (t < sp->ats[0]) @@ -1273,11 +1274,11 @@ localsub(const time_t *const timep, const long offset, struct tm *const tmp) break; } } else { - int lo = 1; - int hi = sp->timecnt; + register int lo = 1; + register int hi = sp->timecnt; while (lo < hi) { - int mid = (lo + hi) >> 1; + register int mid = (lo + hi) >> 1; if (t < sp->ats[mid]) hi = mid; @@ -1325,7 +1326,7 @@ localtime_r(const time_t *const timep, struct tm *tmp) static struct tm * gmtsub(const time_t *const timep, const long offset, struct tm *const tmp) { - struct tm * result; + register struct tm * result; if (!gmt_is_set) { gmt_is_set = TRUE; @@ -1390,7 +1391,7 @@ offtime(const time_t *const timep, const long offset) */ static int -leaps_thru_end_of(const int y) +leaps_thru_end_of(register const int y) { return (y >= 0) ? (y / 4 - y / 100 + y / 400) : -(leaps_thru_end_of(-(y + 1)) + 1); @@ -1398,18 +1399,18 @@ leaps_thru_end_of(const int y) static struct tm * timesub(const time_t *const timep, const long offset, - const struct state *const sp, - struct tm *const tmp) + register const struct state *const sp, + register struct tm *const tmp) { - const struct lsinfo * lp; - time_t tdays; - int idays; /* unsigned would be so 2003 */ - long rem; - int y; - const int * ip; - long corr; - int hit; - int i; + register const struct lsinfo * lp; + register time_t tdays; + register int idays; /* unsigned would be so 2003 */ + register long rem; + int y; + register const int * ip; + register long corr; + register int hit; + register int i; corr = 0; hit = 0; @@ -1443,10 +1444,10 @@ timesub(const time_t *const timep, const long offset, tdays = *timep / SECSPERDAY; rem = *timep - tdays * SECSPERDAY; while (tdays < 0 || tdays >= year_lengths[isleap(y)]) { - int newy; - time_t tdelta; - int idelta; - int leapdays; + int newy; + register time_t tdelta; + register int idelta; + register int leapdays; tdelta = tdays / DAYSPERLYEAR; idelta = tdelta; @@ -1464,7 +1465,7 @@ timesub(const time_t *const timep, const long offset, y = newy; } { - long seconds; + register long seconds; seconds = tdays * SECSPERDAY + 0.5; tdays = seconds / SECSPERDAY; @@ -1568,7 +1569,7 @@ ctime_r(const time_t *const timep, char *buf) static int increment_overflow(int *const ip, int j) { - int const i = *ip; + register int const i = *ip; /* ** If i >= 0 there can only be overflow if i + j > INT_MAX @@ -1585,7 +1586,7 @@ increment_overflow(int *const ip, int j) static int long_increment_overflow(long *const lp, int const m) { - long const l = *lp; + register long const l = *lp; if ((l >= 0) ? (m > LONG_MAX - l) : (m < LONG_MIN - l)) return TRUE; @@ -1596,7 +1597,7 @@ long_increment_overflow(long *const lp, int const m) static int normalize_overflow(int *const tensptr, int *const unitsptr, const int base) { - int tensdelta; + register int tensdelta; tensdelta = (*unitsptr >= 0) ? (*unitsptr / base) : @@ -1608,7 +1609,7 @@ normalize_overflow(int *const tensptr, int *const unitsptr, const int base) static int long_normalize_overflow(long *const tensptr, int *const unitsptr, const int base) { - int tensdelta; + register int tensdelta; tensdelta = (*unitsptr >= 0) ? (*unitsptr / base) : @@ -1618,10 +1619,10 @@ long_normalize_overflow(long *const tensptr, int *const unitsptr, const int base } static int -tmcomp(const struct tm *const atmp, - const struct tm *const btmp) +tmcomp(register const struct tm *const atmp, + register const struct tm *const btmp) { - int result; + register int result; if ((result = (atmp->tm_year - btmp->tm_year)) == 0 && (result = (atmp->tm_mon - btmp->tm_mon)) == 0 && @@ -1639,17 +1640,17 @@ time2sub(struct tm *const tmp, int *const okayp, const int do_norm_secs) { - const struct state * sp; - int dir; - int i, j; - int saved_seconds; - long li; - time_t lo; - time_t hi; - long y; - time_t newt; - time_t t; - struct tm yourtm, mytm; + register const struct state * sp; + register int dir; + register int i, j; + register int saved_seconds; + register long li; + register time_t lo; + register time_t hi; + long y; + time_t newt; + time_t t; + struct tm yourtm, mytm; *okayp = FALSE; yourtm = *tmp; @@ -1837,15 +1838,15 @@ time1(struct tm *const tmp, struct tm *(*const funcp) (const time_t *, long, struct tm *), const long offset) { - time_t t; - const struct state * sp; - int samei, otheri; - int sameind, otherind; - int i; - int nseen; - int seen[TZ_MAX_TYPES]; - int types[TZ_MAX_TYPES]; - int okay; + register time_t t; + register const struct state * sp; + register int samei, otheri; + register int sameind, otherind; + register int i; + register int nseen; + int seen[TZ_MAX_TYPES]; + int types[TZ_MAX_TYPES]; + int okay; if (tmp == NULL) { errno = EINVAL; @@ -1979,9 +1980,9 @@ gtime(struct tm *const tmp) static long leapcorr(time_t *timep) { - struct state * sp; - struct lsinfo * lp; - int i; + register struct state * sp; + register struct lsinfo * lp; + register int i; sp = lclptr; i = sp->leapcnt; diff --git a/scheck.c b/scheck.c index 95bb716..ed60980 100644 --- a/scheck.c +++ b/scheck.c @@ -10,12 +10,12 @@ const char * scheck(const char *const string, const char *const format) { - char * fbuf; - const char * fp; - char * tp; - int c; - const char * result; - char dummy; + register char * fbuf; + register const char * fp; + register char * tp; + register int c; + register const char * result; + char dummy; result = ""; if (string == NULL || format == NULL) diff --git a/strftime.c b/strftime.c index 5b302ac..4950f74 100644 --- a/strftime.c +++ b/strftime.c @@ -587,8 +587,8 @@ static char * _yconv(const int a, const int b, const int convert_top, const int convert_yy, char *pt, const char *const ptlim) { - int lead; - int trail; + register int lead; + register int trail; #define DIVISOR 100 trail = a % DIVISOR + b % DIVISOR; diff --git a/zdump.c b/zdump.c index ddb46b9..805267d 100644 --- a/zdump.c +++ b/zdump.c @@ -200,12 +200,12 @@ static time_t yeartot(long y) ATTRIBUTE_PURE; static struct tm * my_localtime(time_t *tp) { - struct tm * tmp; + register struct tm * tmp; tmp = localtime(tp); if (tp != NULL && tmp != NULL) { struct tm tm; - time_t t; + register time_t t; tm = *tmp; t = mktime(&tm); @@ -233,8 +233,8 @@ my_localtime(time_t *tp) static void abbrok(const char *const abbrp, const char *const zone) { - const char * cp; - const char * wp; + register const char * cp; + register const char * wp; if (warned) return; @@ -280,22 +280,22 @@ Report bugs to tz@elsie.nci.nih.gov.\n"), int main(int argc, char *argv[]) { - int i; - int c; - int vflag; - char * cutarg; - long cutloyear = ZDUMP_LO_YEAR; - long cuthiyear = ZDUMP_HI_YEAR; - time_t cutlotime; - time_t cuthitime; - char ** fakeenv; - time_t now; - time_t t; - time_t newt; - struct tm tm; - struct tm newtm; - struct tm * tmp; - struct tm * newtmp; + register int i; + register int c; + register int vflag; + register char * cutarg; + register long cutloyear = ZDUMP_LO_YEAR; + register long cuthiyear = ZDUMP_HI_YEAR; + register time_t cutlotime; + register time_t cuthitime; + register char ** fakeenv; + time_t now; + time_t t; + time_t newt; + struct tm tm; + struct tm newtm; + register struct tm * tmp; + register struct tm * newtmp; INITIALIZE(cutlotime); INITIALIZE(cuthitime); @@ -352,8 +352,8 @@ main(int argc, char *argv[]) if (strlen(argv[i]) > longest) longest = strlen(argv[i]); { - int from; - int to; + register int from; + register int to; for (i = 0; environ[i] != NULL; ++i) continue; @@ -445,9 +445,9 @@ _("%s: use of -v on system with floating time_t other than float or double\n"), static time_t yeartot(const long y) { - long myy; - long seconds; - time_t t; + register long myy; + register long seconds; + register time_t t; myy = EPOCH_YEAR; t = 0; @@ -476,13 +476,13 @@ yeartot(const long y) static time_t hunt(char *name, time_t lot, time_t hit) { - time_t t; - long diff; - struct tm lotm; - struct tm * lotmp; - struct tm tm; - struct tm * tmp; - char loab[MAX_STRING_LENGTH]; + time_t t; + long diff; + struct tm lotm; + register struct tm * lotmp; + struct tm tm; + register struct tm * tmp; + char loab[MAX_STRING_LENGTH]; lotmp = my_localtime(&lot); if (lotmp != NULL) { @@ -523,8 +523,8 @@ hunt(char *name, time_t lot, time_t hit) static long delta(struct tm * newp, struct tm *oldp) { - long result; - int tmy; + register long result; + register int tmy; if (newp->tm_year < oldp->tm_year) return -delta(oldp, newp); @@ -544,7 +544,7 @@ delta(struct tm * newp, struct tm *oldp) static void show(char *zone, time_t t, int v) { - struct tm * tmp; + register struct tm * tmp; (void) printf("%-*s ", (int) longest, zone); if (v) { @@ -577,7 +577,7 @@ show(char *zone, time_t t, int v) static char * abbr(struct tm *tmp) { - char * result; + register char * result; static char nada; if (tmp->tm_isdst != 0 && tmp->tm_isdst != 1) @@ -614,7 +614,7 @@ tformat(void) } static void -dumptime(const struct tm *timeptr) +dumptime(register const struct tm *timeptr) { static const char wday_name[][3] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" @@ -623,10 +623,10 @@ dumptime(const struct tm *timeptr) "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; - const char * wn; - const char * mn; - int lead; - int trail; + register const char * wn; + register const char * mn; + register int lead; + register int trail; if (timeptr == NULL) { (void) printf("NULL"); diff --git a/zic.c b/zic.c index 28b2a24..64af1b2 100644 --- a/zic.c +++ b/zic.c @@ -440,9 +440,9 @@ static const char * yitcommand; int main(int argc, char **argv) { - int i; - int j; - int c; + register int i; + register int j; + register int c; #ifdef unix (void) umask(umask(S_IWGRP | S_IWOTH) | (S_IWGRP | S_IWOTH)); @@ -579,8 +579,8 @@ _("%s: More than one -L option specified\n"), static void dolink(const char *const fromfield, const char *const tofield) { - char * fromname; - char * toname; + register char * fromname; + register char * toname; if (fromfield[0] == '/') fromname = ecpyalloc(fromfield); @@ -614,7 +614,7 @@ dolink(const char *const fromfield, const char *const tofield) access(fromname, F_OK) == 0 && !itsdir(fromname)) { const char *s = tofield; - char *symlinkcontents = NULL; + register char * symlinkcontents = NULL; while ((s = strchr(s+1, '/')) != NULL) symlinkcontents = @@ -651,8 +651,8 @@ static const zic_t max_time = -1 - ((zic_t) -1 << (TIME_T_BITS_IN_FILE - 1)); static int itsdir(const char *const name) { - char * myname; - int accres; + register char * myname; + register int accres; myname = ecpyalloc(name); myname = ecatalloc(myname, "/."); @@ -679,10 +679,10 @@ rcomp(const void *cp1, const void *cp2) static void associate(void) { - struct zone * zp; - struct rule * rp; - int base, out; - int i, j; + register struct zone * zp; + register struct rule * rp; + register int base, out; + register int i, j; if (nrules != 0) { (void) qsort(rules, nrules, sizeof *rules, rcomp); @@ -754,14 +754,14 @@ associate(void) static void infile(const char *name) { - FILE * fp; - char ** fields; - char * cp; - const struct lookup * lp; - int nfields; - int wantcont; - int num; - char buf[BUFSIZ]; + register FILE * fp; + register char ** fields; + register char * cp; + register const struct lookup * lp; + register int nfields; + register int wantcont; + register int num; + char buf[BUFSIZ]; if (strcmp(name, "-") == 0) { name = _("standard input"); @@ -897,7 +897,7 @@ warning(_("values over 24 hours not handled by pre-2007 versions of zic")); } static void -inrule(char **const fields, const int nfields) +inrule(register char **const fields, const int nfields) { static struct rule r; @@ -923,9 +923,9 @@ inrule(char **const fields, const int nfields) } static int -inzone(char **const fields, const int nfields) +inzone(register char **const fields, const int nfields) { - int i; + register int i; static char * buf; if (nfields < ZONE_MINFIELDS || nfields > ZONE_MAXFIELDS) { @@ -966,7 +966,7 @@ _("duplicate zone name %s (file \"%s\", line %d)"), } static int -inzcont(char **const fields, const int nfields) +inzcont(register char **const fields, const int nfields) { if (nfields < ZONEC_MINFIELDS || nfields > ZONEC_MAXFIELDS) { error(_("wrong number of fields on Zone continuation line")); @@ -976,14 +976,14 @@ inzcont(char **const fields, const int nfields) } static int -inzsub(char **const fields, const int nfields, const int iscont) +inzsub(register char **const fields, const int nfields, const int iscont) { - char * cp; + register char * cp; static struct zone z; - int i_gmtoff, i_rule, i_format; - int i_untilyear, i_untilmonth; - int i_untilday, i_untiltime; - int hasuntil; + register int i_gmtoff, i_rule, i_format; + register int i_untilyear, i_untilmonth; + register int i_untilday, i_untiltime; + register int hasuntil; if (iscont) { i_gmtoff = ZFC_GMTOFF; @@ -1053,14 +1053,14 @@ inzsub(char **const fields, const int nfields, const int iscont) } static void -inleap(char ** const fields, const int nfields) +inleap(register char ** const fields, const int nfields) { - const char * cp; - const struct lookup * lp; - int i, j; - int year, month, day; - long dayoff, tod; - zic_t t; + register const char * cp; + register const struct lookup * lp; + register int i, j; + int year, month, day; + long dayoff, tod; + zic_t t; if (nfields != LEAP_FIELDS) { error(_("wrong number of fields on Leap line")); @@ -1125,8 +1125,8 @@ inleap(char ** const fields, const int nfields) tod = gethms(fields[LP_TIME], _("invalid time of day"), FALSE); cp = fields[LP_CORR]; { - int positive; - int count; + register int positive; + int count; if (strcmp(cp, "") == 0) { /* infile() turns "-" into "" */ positive = FALSE; @@ -1155,7 +1155,7 @@ inleap(char ** const fields, const int nfields) } static void -inlink(char **const fields, const int nfields) +inlink(register char **const fields, const int nfields) { struct link l; @@ -1180,7 +1180,7 @@ inlink(char **const fields, const int nfields) } static void -rulesub(struct rule *const rp, +rulesub(register struct rule *const rp, const char *const loyearp, const char *const hiyearp, const char *const typep, @@ -1188,10 +1188,10 @@ rulesub(struct rule *const rp, const char *const dayp, const char *const timep) { - const struct lookup * lp; - const char * cp; - char * dp; - char * ep; + register const struct lookup * lp; + register const char * cp; + register char * dp; + register char * ep; if ((lp = byword(monthp, mon_names)) == NULL) { error(_("invalid month name")); @@ -1332,8 +1332,8 @@ rulesub(struct rule *const rp, static void convert(const long val, char *const buf) { - int i; - int shift; + register int i; + register int shift; unsigned char *const b = (unsigned char *) buf; for (i = 0, shift = 24; i < 4; ++i, shift -= 8) @@ -1343,8 +1343,8 @@ convert(const long val, char *const buf) static void convert64(const zic_t val, char *const buf) { - int i; - int shift; + register int i; + register int shift; unsigned char *const b = (unsigned char *) buf; for (i = 0, shift = 56; i < 8; ++i, shift -= 8) @@ -1387,11 +1387,11 @@ is32(const zic_t x) static void writezone(const char *const name, const char *const string) { - FILE * fp; - int i, j; - int leapcnt32, leapi32; - int timecnt32, timei32; - int pass; + register FILE * fp; + register int i, j; + register int leapcnt32, leapi32; + register int timecnt32, timei32; + register int pass; static char * fullname; static const struct tzhead tzh0; static struct tzhead tzh; @@ -1494,15 +1494,15 @@ writezone(const char *const name, const char *const string) } } for (pass = 1; pass <= 2; ++pass) { - int thistimei, thistimecnt; - int thisleapi, thisleapcnt; - int thistimelim, thisleaplim; - int writetype[TZ_MAX_TIMES]; - int typemap[TZ_MAX_TYPES]; - int thistypecnt; - char thischars[TZ_MAX_CHARS]; - char thischarcnt; - int indmap[TZ_MAX_CHARS]; + register int thistimei, thistimecnt; + register int thisleapi, thisleapcnt; + register int thistimelim, thisleaplim; + int writetype[TZ_MAX_TIMES]; + int typemap[TZ_MAX_TYPES]; + register int thistypecnt; + char thischars[TZ_MAX_CHARS]; + char thischarcnt; + int indmap[TZ_MAX_CHARS]; if (pass == 1) { thistimei = timei32; @@ -1546,7 +1546,7 @@ writezone(const char *const name, const char *const string) ** set correctly). */ { - int mrudst, mrustd, hidst, histd, type; + register int mrudst, mrustd, hidst, histd, type; hidst = histd = mrudst = mrustd = -1; for (i = thistimei; i < thistimelim; ++i) @@ -1590,7 +1590,7 @@ writezone(const char *const name, const char *const string) indmap[i] = -1; thischarcnt = 0; for (i = 0; i < typecnt; ++i) { - char * thisabbr; + register char * thisabbr; if (!writetype[i]) continue; @@ -1647,7 +1647,7 @@ writezone(const char *const name, const char *const string) (void) fwrite(thischars, sizeof thischars[0], thischarcnt, fp); for (i = thisleapi; i < thisleaplim; ++i) { - zic_t todo; + register zic_t todo; if (roll[i]) { if (timecnt == 0 || trans[i] < ats[0]) { @@ -1690,9 +1690,9 @@ static void doabbr(char *const abbr, const char *const format, const char *const letters, const int isdst, const int doquotes) { - char * cp; - char * slashp; - int len; + register char * cp; + register char * slashp; + register int len; slashp = strchr(format, '/'); if (slashp == NULL) { @@ -1734,9 +1734,9 @@ updateminmax(const int x) static int stringoffset(char *result, long offset) { - int hours; - int minutes; - int seconds; + register int hours; + register int minutes; + register int seconds; result[0] = '\0'; if (offset < 0) { @@ -1765,11 +1765,11 @@ static int stringrule(char *result, const struct rule *const rp, const long dstoff, const long gmtoff) { - long tod; + register long tod; result = end(result); if (rp->r_dycode == DC_DOM) { - int month, total; + register int month, total; if (rp->r_dayofmonth == 29 && rp->r_month == TM_FEBRUARY) return -1; @@ -1778,7 +1778,7 @@ stringrule(char *result, const struct rule *const rp, const long dstoff, total += len_months[0][month]; (void) sprintf(result, "J%d", total + rp->r_dayofmonth); } else { - int week; + register int week; if (rp->r_dycode == DC_DOWGEQ) { if ((rp->r_dayofmonth % DAYSPERWEEK) != 1) @@ -1816,12 +1816,12 @@ stringrule(char *result, const struct rule *const rp, const long dstoff, static void stringzone(char *result, const struct zone *const zpfirst, const int zonecount) { - const struct zone * zp; - struct rule * rp; - struct rule * stdrp; - struct rule * dstrp; - int i; - const char * abbrvar; + register const struct zone * zp; + register struct rule * rp; + register struct rule * stdrp; + register struct rule * dstrp; + register int i; + register const char * abbrvar; result[0] = '\0'; zp = zpfirst + zonecount - 1; @@ -1896,24 +1896,24 @@ stringzone(char *result, const struct zone *const zpfirst, const int zonecount) static void outzone(const struct zone * const zpfirst, const int zonecount) { - const struct zone * zp; - struct rule * rp; - int i, j; - int usestart, useuntil; - zic_t starttime, untiltime; - long gmtoff; - long stdoff; - int year; - long startoff; - int startttisstd; - int startttisgmt; - int type; - char * startbuf; - char * ab; - char * envvar; - int max_abbr_len; - int max_envvar_len; - int prodstic; /* all rules are min to max */ + register const struct zone * zp; + register struct rule * rp; + register int i, j; + register int usestart, useuntil; + register zic_t starttime, untiltime; + register long gmtoff; + register long stdoff; + register int year; + register long startoff; + register int startttisstd; + register int startttisgmt; + register int type; + register char * startbuf; + register char * ab; + register char * envvar; + register int max_abbr_len; + register int max_envvar_len; + register int prodstic; /* all rules are min to max */ max_abbr_len = 2 + max_format_len + max_abbrvar_len; max_envvar_len = 2 * max_abbr_len + 5 * 9; @@ -1959,7 +1959,7 @@ outzone(const struct zone * const zpfirst, const int zonecount) */ stringzone(envvar, zpfirst, zonecount); if (noise && envvar[0] == '\0') { - char * wp; + register char * wp; wp = ecpyalloc(_("no POSIX environment variable for zone")); wp = ecatalloc(wp, " "); @@ -2037,9 +2037,9 @@ wp = ecpyalloc(_("no POSIX environment variable for zone")); rp->r_temp = rpytime(rp, year); } for ( ; ; ) { - int k; - zic_t jtime, ktime; - long offset; + register int k; + register zic_t jtime, ktime; + register long offset; INITIALIZE(ktime); if (useuntil) { @@ -2184,7 +2184,7 @@ static int addtype(const long gmtoff, const char *const abbr, const int isdst, const int ttisstd, const int ttisgmt) { - int i, j; + register int i, j; if (isdst != TRUE && isdst != FALSE) { error(_("internal error - addtype called with bad isdst")); @@ -2239,7 +2239,7 @@ addtype(const long gmtoff, const char *const abbr, const int isdst, static void leapadd(const zic_t t, const int positive, const int rolling, int count) { - int i, j; + register int i, j; if (leapcnt + (positive ? count : 1) > TZ_MAX_LEAPS) { error(_("too many leap seconds")); @@ -2269,8 +2269,8 @@ leapadd(const zic_t t, const int positive, const int rolling, int count) static void adjleap(void) { - int i; - long last = 0; + register int i; + register long last = 0; /* ** propagate leap seconds forward @@ -2314,7 +2314,7 @@ lowerit(int a) /* case-insensitive equality */ static ATTRIBUTE_PURE int -ciequal(const char *ap, const char *bp) +ciequal(register const char *ap, register const char *bp) { while (lowerit(*ap) == lowerit(*bp++)) if (*ap++ == '\0') @@ -2323,7 +2323,7 @@ ciequal(const char *ap, const char *bp) } static ATTRIBUTE_PURE int -itsabbr(const char *abbr, const char *word) +itsabbr(register const char *abbr, register const char *word) { if (lowerit(*abbr) != lowerit(*word)) return FALSE; @@ -2337,11 +2337,11 @@ itsabbr(const char *abbr, const char *word) } static ATTRIBUTE_PURE const struct lookup * -byword(const char *const word, - const struct lookup *const table) +byword(register const char *const word, + register const struct lookup *const table) { - const struct lookup * foundlp; - const struct lookup * lp; + register const struct lookup * foundlp; + register const struct lookup * lp; if (word == NULL || table == NULL) return NULL; @@ -2365,11 +2365,11 @@ byword(const char *const word, } static char ** -getfields(char *cp) +getfields(register char *cp) { - char * dp; - char ** array; - int nsubs; + register char * dp; + register char ** array; + register int nsubs; if (cp == NULL) return NULL; @@ -2434,11 +2434,11 @@ tadd(const zic_t t1, const long t2) */ static zic_t -rpytime(const struct rule *const rp, const int wantedy) +rpytime(register const struct rule *const rp, register const int wantedy) { - int y, m, i; - long dayoff; /* with a nod to Margaret O. */ - zic_t t; + register int y, m, i; + register long dayoff; /* with a nod to Margaret O. */ + register zic_t t; if (wantedy == INT_MIN) return min_time; @@ -2474,7 +2474,7 @@ rpytime(const struct rule *const rp, const int wantedy) --i; dayoff = oadd(dayoff, eitol(i)); if (rp->r_dycode == DC_DOWGEQ || rp->r_dycode == DC_DOWLEQ) { - long wday; + register long wday; #define LDAYSPERWEEK ((long) DAYSPERWEEK) wday = eitol(EPOCH_WDAY); @@ -2517,11 +2517,11 @@ will not work with pre-2004 versions of zic")); static void newabbr(const char *const string) { - int i; + register int i; if (strcmp(string, GRANDPARENTED) != 0) { - const char * cp; - const char * mp; + register const char * cp; + const char * mp; /* ** Want one to ZIC_MAX_ABBR_LEN_WO_WARN alphabetics @@ -2569,8 +2569,8 @@ mp = _("time zone abbreviation differs from POSIX standard"); static int mkdirs(char *argname) { - char * name; - char * cp; + register char * name; + register char * cp; if (argname == NULL || *argname == '\0') return 0;