static const char elsieid[] = "@(#)zic.c 7.116";
+#include <sys/cdefs.h>
#ifndef lint
-static const char rcsid[] =
+__unused static const char rcsid[] =
"$FreeBSD: src/usr.sbin/zic/zic.c,v 1.18 2007/12/03 10:45:44 kevlo Exp $";
#endif /* not lint */
*/
static char *
-memcheck(ptr)
-char * const ptr;
+memcheck(char * const ptr)
{
if (ptr == NULL)
errx(EXIT_FAILURE, _("memory exhausted"));
#if !(HAVE_STRERROR - 0)
static char *
-strerror(errnum)
-int errnum;
+strerror(int errnum)
{
extern char * sys_errlist[];
extern int sys_nerr;
#endif /* !(HAVE_STRERROR - 0) */
static void
-eats(name, num, rname, rnum)
-const char * const name;
-const int num;
-const char * const rname;
-const int rnum;
+eats(const char * const name, const int num, const char * const rname,
+ const int rnum)
{
filename = name;
linenum = num;
}
static void
-eat(name, num)
-const char * const name;
-const int num;
+eat(const char * const name, const int num)
{
eats(name, num, (char *) NULL, -1);
}
static void
-error(string)
-const char * const string;
+error(const char * const string)
{
/*
** Match the format of "cc" to allow sh users to
}
static void
-warning(string)
-const char * const string;
+warning(const char * const string)
{
char * cp;
| S_IWUSR);
int
-main(argc, argv)
-int argc;
-char * argv[];
+main(int argc, char * argv[])
{
- register int i;
- register int j;
- register int c;
+ int i;
+ int j;
+ int c;
#ifdef unix
(void) umask(umask(S_IWGRP | S_IWOTH) | (S_IWGRP | S_IWOTH));
}
static void
-dolink(fromfile, tofile)
-const char * const fromfile;
-const char * const tofile;
+dolink(const char * const fromfile, const char * const tofile)
{
- register char * fromname;
- register char * toname;
+ char * fromname;
+ char * toname;
if (fromfile[0] == '/')
fromname = ecpyalloc(fromfile);
access(fromname, F_OK) == 0 &&
!itsdir(fromname)) {
const char *s = tofile;
- register char * symlinkcontents = NULL;
+ char * symlinkcontents = NULL;
while ((s = strchr(s+1, '/')) != NULL)
symlinkcontents = ecatalloc(symlinkcontents, "../");
symlinkcontents = ecatalloc(symlinkcontents, fromfile);
}
static int
-itsdir(name)
-const char * const name;
+itsdir(const char * const name)
{
- register char * myname;
- register int accres;
+ char * myname;
+ int accres;
myname = ecpyalloc(name);
myname = ecatalloc(myname, "/.");
*/
static int
-rcomp(cp1, cp2)
-const void * cp1;
-const void * cp2;
+rcomp(const void *cp1, const void *cp2)
{
return strcmp(((const struct rule *) cp1)->r_name,
((const struct rule *) cp2)->r_name);
static void
associate P((void))
{
- register struct zone * zp;
- register struct rule * rp;
- register int base, out;
- register int i, j;
+ struct zone * zp;
+ struct rule * rp;
+ int base, out;
+ int i, j;
if (nrules != 0) {
(void) qsort((void *) rules, (size_t) nrules,
}
static void
-infile(name)
-const char * name;
+infile(const char * name)
{
- 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];
+ FILE * fp;
+ char ** fields;
+ char * cp;
+ const struct lookup * lp;
+ int nfields;
+ int wantcont;
+ int num;
+ char buf[BUFSIZ];
if (strcmp(name, "-") == 0) {
name = _("standard input");
*/
static long
-gethms(string, errstring, signable)
-const char * string;
-const char * const errstring;
-const int signable;
+gethms(const char *string, const char * const errstring, const int signable)
{
int hh, mm, ss, sign;
}
static void
-inrule(fields, nfields)
-register char ** const fields;
-const int nfields;
+inrule(char ** const fields, const int nfields)
{
static struct rule r;
}
static int
-inzone(fields, nfields)
-register char ** const fields;
-const int nfields;
+inzone(char ** const fields, const int nfields)
{
- register int i;
+ int i;
static char * buf;
if (nfields < ZONE_MINFIELDS || nfields > ZONE_MAXFIELDS) {
}
static int
-inzcont(fields, nfields)
-register char ** const fields;
-const int nfields;
+inzcont(char ** const fields, const int nfields)
{
if (nfields < ZONEC_MINFIELDS || nfields > ZONEC_MAXFIELDS) {
error(_("wrong number of fields on Zone continuation line"));
}
static int
-inzsub(fields, nfields, iscont)
-register char ** const fields;
-const int nfields;
-const int iscont;
+inzsub(char ** const fields, const int nfields, const int iscont)
{
- register char * cp;
+ char * cp;
static struct zone z;
- register int i_gmtoff, i_rule, i_format;
- register int i_untilyear, i_untilmonth;
- register int i_untilday, i_untiltime;
- register int hasuntil;
+ int i_gmtoff, i_rule, i_format;
+ int i_untilyear, i_untilmonth;
+ int i_untilday, i_untiltime;
+ int hasuntil;
if (iscont) {
i_gmtoff = ZFC_GMTOFF;
}
static void
-inleap(fields, nfields)
-register char ** const fields;
-const int nfields;
+inleap(char ** const fields, const int nfields)
{
- register const char * cp;
- register const struct lookup * lp;
- register int i, j;
- int year, month, day;
- long dayoff, tod;
- time_t t;
+ const char * cp;
+ const struct lookup * lp;
+ int i, j;
+ int year, month, day;
+ long dayoff, tod;
+ time_t t;
if (nfields != LEAP_FIELDS) {
error(_("wrong number of fields on Leap line"));
tod = gethms(fields[LP_TIME], _("invalid time of day"), FALSE);
cp = fields[LP_CORR];
{
- register int positive;
- int count;
+ int positive;
+ int count;
if (strcmp(cp, "") == 0) { /* infile() turns "-" into "" */
positive = FALSE;
}
static void
-inlink(fields, nfields)
-register char ** const fields;
-const int nfields;
+inlink(char ** const fields, const int nfields)
{
struct link l;
}
static void
-rulesub(rp, loyearp, hiyearp, typep, monthp, dayp, timep)
-register struct rule * const rp;
-const char * const loyearp;
-const char * const hiyearp;
-const char * const typep;
-const char * const monthp;
-const char * const dayp;
-const char * const timep;
+rulesub(struct rule * const rp, const char * const loyearp,
+ const char * const hiyearp, const char * const typep,
+ const char * const monthp, const char * const dayp,
+ const char * const timep)
{
- register const struct lookup * lp;
- register const char * cp;
- register char * dp;
- register char * ep;
+ const struct lookup * lp;
+ const char * cp;
+ char * dp;
+ char * ep;
if ((lp = byword(monthp, mon_names)) == NULL) {
error(_("invalid month name"));
}
static void
-convert(val, buf)
-const long val;
-char * const buf;
+convert(const long val, char * const buf)
{
- register int i;
- register long shift;
+ int i;
+ long shift;
for (i = 0, shift = 24; i < 4; ++i, shift -= 8)
buf[i] = val >> shift;
}
static void
-puttzcode(val, fp)
-const long val;
-FILE * const fp;
+puttzcode(const long val, FILE * const fp)
{
char buf[4];
}
static int
-atcomp(avp, bvp)
-void * avp;
-void * bvp;
+atcomp(const void *avp, const void *bvp)
{
- if (((struct attype *) avp)->at < ((struct attype *) bvp)->at)
+ if (((const struct attype *) avp)->at < ((const struct attype *) bvp)->at)
return -1;
- else if (((struct attype *) avp)->at > ((struct attype *) bvp)->at)
+ else if (((const struct attype *) avp)->at > ((const struct attype *) bvp)->at)
return 1;
else return 0;
}
static void
-writezone(name)
-const char * const name;
+writezone(const char * const name)
{
- register FILE * fp;
- register int i, j;
+ FILE * fp;
+ int i, j;
static char * fullname;
static struct tzhead tzh;
time_t ats[TZ_MAX_TIMES];
}
static void
-doabbr(abbr, format, letters, isdst)
-char * const abbr;
-const char * const format;
-const char * const letters;
-const int isdst;
+doabbr(char * const abbr, const char * const format, const char * const letters,
+ const int isdst)
{
if (strchr(format, '/') == NULL) {
if (letters == NULL)
}
static void
-outzone(zpfirst, zonecount)
-const struct zone * const zpfirst;
-const int zonecount;
+outzone(const struct zone * const zpfirst, const int zonecount)
{
- register const struct zone * zp;
- register struct rule * rp;
- register int i, j;
- register int usestart, useuntil;
- register time_t starttime, untiltime;
- register long gmtoff;
- register long stdoff;
- register int year;
- register long startoff;
- register int startttisstd;
- register int startttisgmt;
- register int type;
- char startbuf[BUFSIZ];
+ const struct zone * zp;
+ struct rule * rp;
+ int i, j;
+ int usestart, useuntil;
+ time_t starttime, untiltime;
+ long gmtoff;
+ long stdoff;
+ int year;
+ long startoff;
+ int startttisstd;
+ int startttisgmt;
+ int type;
+ char startbuf[BUFSIZ];
INITIALIZE(untiltime);
INITIALIZE(starttime);
rp->r_temp = rpytime(rp, year);
}
for ( ; ; ) {
- register int k;
- register time_t jtime, ktime;
- register long offset;
- char buf[BUFSIZ];
+ int k;
+ time_t jtime, ktime;
+ long offset;
+ char buf[BUFSIZ];
INITIALIZE(ktime);
if (useuntil) {
}
static void
-addtt(starttime, type)
-const time_t starttime;
-int type;
+addtt(const time_t starttime, int type)
{
if (starttime <= min_time ||
(timecnt == 1 && attypes[0].at < min_time)) {
if (abbrinds[type] != 0)
(void) strcpy(chars, &chars[abbrinds[type]]);
abbrinds[0] = 0;
- charcnt = strlen(chars) + 1;
+ charcnt = (int)strlen(chars) + 1;
typecnt = 1;
timecnt = 0;
type = 0;
}
static int
-addtype(gmtoff, abbr, isdst, ttisstd, ttisgmt)
-const long gmtoff;
-const char * const abbr;
-const int isdst;
-const int ttisstd;
-const int ttisgmt;
+addtype(const long gmtoff, const char * const abbr, const int isdst,
+ const int ttisstd, const int ttisgmt)
{
- register int i, j;
+ int i, j;
if (isdst != TRUE && isdst != FALSE) {
error(_("internal error - addtype called with bad isdst"));
}
static void
-leapadd(t, positive, rolling, count)
-const time_t t;
-const int positive;
-const int rolling;
-int count;
+leapadd(const time_t t, const int positive, const int rolling, int count)
{
- register int i, j;
+ int i, j;
if (leapcnt + (positive ? count : 1) > TZ_MAX_LEAPS) {
error(_("too many leap seconds"));
static void
adjleap P((void))
{
- register int i;
- register long last = 0;
+ int i;
+ long last = 0;
/*
** propagate leap seconds forward
}
static int
-yearistype(year, type)
-const int year;
-const char * const type;
+yearistype(const int year, const char * const type)
{
static char * buf;
int result;
}
static int
-lowerit(a)
-int a;
+lowerit(int a)
{
a = (unsigned char) a;
return (isascii(a) && isupper(a)) ? tolower(a) : a;
}
+/* case-insensitive equality */
static int
-ciequal(ap, bp) /* case-insensitive equality */
-register const char * ap;
-register const char * bp;
+ciequal(const char *ap, const char *bp)
{
while (lowerit(*ap) == lowerit(*bp++))
if (*ap++ == '\0')
}
static int
-itsabbr(abbr, word)
-register const char * abbr;
-register const char * word;
+itsabbr(const char *abbr, const char *word)
{
if (lowerit(*abbr) != lowerit(*word))
return FALSE;
}
static const struct lookup *
-byword(word, table)
-register const char * const word;
-register const struct lookup * const table;
+byword(const char * const word, const struct lookup * const table)
{
- register const struct lookup * foundlp;
- register const struct lookup * lp;
+ const struct lookup * foundlp;
+ const struct lookup * lp;
if (word == NULL || table == NULL)
return NULL;
}
static char **
-getfields(cp)
-register char * cp;
+getfields(char *cp)
{
- register char * dp;
- register char ** array;
- register int nsubs;
+ char * dp;
+ char ** array;
+ int nsubs;
if (cp == NULL)
return NULL;
}
static long
-oadd(t1, t2)
-const long t1;
-const long t2;
+oadd(const long t1, const long t2)
{
- register long t;
+ long t;
t = t1 + t2;
if ((t2 > 0 && t <= t1) || (t2 < 0 && t >= t1)) {
}
static time_t
-tadd(t1, t2)
-const time_t t1;
-const long t2;
+tadd(const time_t t1, const long t2)
{
- register time_t t;
+ time_t t;
if (t1 == max_time && t2 > 0)
return max_time;
*/
static time_t
-rpytime(rp, wantedy)
-register const struct rule * const rp;
-register const int wantedy;
+rpytime(const struct rule * const rp, const int wantedy)
{
- register int y, m, i;
- register long dayoff; /* with a nod to Margaret O. */
- register time_t t;
+ int y, m, i;
+ long dayoff; /* with a nod to Margaret O. */
+ time_t t;
if (wantedy == INT_MIN)
return min_time;
--i;
dayoff = oadd(dayoff, eitol(i));
if (rp->r_dycode == DC_DOWGEQ || rp->r_dycode == DC_DOWLEQ) {
- register long wday;
+ long wday;
#define LDAYSPERWEEK ((long) DAYSPERWEEK)
wday = eitol(EPOCH_WDAY);
}
static void
-newabbr(string)
-const char * const string;
+newabbr(const char * const string)
{
- register int i;
+ int i;
- i = strlen(string) + 1;
+ i = (int)strlen(string) + 1;
if (charcnt + i > TZ_MAX_CHARS) {
error(_("too many, or too long, time zone abbreviations"));
(void) exit(EXIT_FAILURE);
}
static int
-mkdirs(argname)
-char * const argname;
+mkdirs(char * const argname)
{
- register char * name;
- register char * cp;
+ char * name;
+ char * cp;
if (argname == NULL || *argname == '\0' || Dflag)
return 0;
}
static long
-eitol(i)
-const int i;
+eitol(const int i)
{
long l;
#include <pwd.h>
static void
-setgroup(flag, name)
- gid_t *flag;
- const char *name;
+setgroup(gid_t *flag, const char *name)
{
struct group *gr;
ul = strtoul(name, &ep, 10);
if (ul == (unsigned long)(gid_t)ul && *ep == '\0') {
- *flag = ul;
+ *flag = (gid_t)ul;
return;
}
errx(EXIT_FAILURE, _("group `%s' not found"), name);
}
static void
-setuser(flag, name)
- uid_t *flag;
- const char *name;
+setuser(uid_t *flag, const char *name)
{
struct passwd *pw;
ul = strtoul(name, &ep, 10);
if (ul == (unsigned long)(gid_t)ul && *ep == '\0') {
- *flag = ul;
+ *flag = (uid_t)ul;
return;
}
errx(EXIT_FAILURE, _("user `%s' not found"), name);