aboutsummaryrefslogtreecommitdiff
path: root/timezone/zic.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2016-01-07 11:45:07 +0000
committerJoseph Myers <joseph@codesourcery.com>2016-01-07 11:45:07 +0000
commit670a687dea6773147a227bebfa9d801dae739ee0 (patch)
tree380b348ef7d52bd144e78f4a661dda0b40e87477 /timezone/zic.c
parent45c4f3665aaa63cab148cc9cc96fa07c666c1c38 (diff)
downloadglibc-670a687dea6773147a227bebfa9d801dae739ee0.tar.xz
glibc-670a687dea6773147a227bebfa9d801dae739ee0.zip
Update timezone code from tzcode 2015g.
This patch updates the timezone code from tzcode 2015g. The Makefile and README changes are based on those in Paul's patch <https://sourceware.org/ml/libc-alpha/2015-05/msg00553.html>. Tested for x86_64 and x86. 2016-01-06 Paul Eggert <eggert@cs.ucla.edu> Joseph Myers <joseph@codesourcery.com> * timezone/private.h: Update from tzcode 2015g. * timezone/tzfile.h: Likewise. * timezone/tzselect.ksh: Likewise. * timezone/zdump.c: Likewise. * timezone/zic.c: Likewise. * timezone/ialloc.c: Remove file. * timezone/scheck.c: Likewise. * timezone/Makefile (extra-objs): Remove variable. ($(objpfx)zic): Do not depend on scheck.o and ialloc.o. (tz-cflags): Add -DHAVE_GETTEXT -DUSE_LTZ=0 -Wno-maybe-uninitialized. (CFLAGS-zdump.c): Remove -fwrapv -DNOID -DHAVE_GETTEXT. (CFLAGS-zic.c): Remove -DNOID -DHAVE_GETTEXT. (CFLAGS-ialloc.c): Remove variable. (CFLAGS-scheck.c): Likewise. * timezone/README: Update list of files from tzcode.
Diffstat (limited to 'timezone/zic.c')
-rw-r--r--timezone/zic.c1061
1 files changed, 616 insertions, 445 deletions
diff --git a/timezone/zic.c b/timezone/zic.c
index 07d6c30ae2..78ab870941 100644
--- a/timezone/zic.c
+++ b/timezone/zic.c
@@ -23,7 +23,7 @@ typedef int_fast64_t zic_t;
#endif /* !defined ZIC_MAX_ABBR_LEN_WO_WARN */
#if HAVE_SYS_STAT_H
-#include "sys/stat.h"
+#include <sys/stat.h>
#endif
#ifdef S_IRUSR
#define MKDIR_UMASK (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)
@@ -31,21 +31,6 @@ typedef int_fast64_t zic_t;
#define MKDIR_UMASK 0755
#endif
-/*
-** On some ancient hosts, predicates like `isspace(C)' are defined
-** only if isascii(C) || C == EOF. Modern hosts obey the C Standard,
-** which says they are defined only if C == ((unsigned char) C) || C == EOF.
-** Neither the C Standard nor Posix require that `isascii' exist.
-** For portability, we check both ancient and modern requirements.
-** If isascii is not defined, the isascii check succeeds trivially.
-*/
-#include "ctype.h"
-#ifndef isascii
-#define isascii(x) 1
-#endif
-
-#define end(cp) (strchr((cp), '\0'))
-
struct rule {
const char * r_filename;
int r_linenum;
@@ -54,8 +39,8 @@ struct rule {
zic_t r_loyear; /* for example, 1986 */
zic_t r_hiyear; /* for example, 1986 */
const char * r_yrtype;
- int r_lowasnum;
- int r_hiwasnum;
+ bool r_lowasnum;
+ bool r_hiwasnum;
int r_month; /* 0..11 */
@@ -64,10 +49,10 @@ struct rule {
int r_wday;
zic_t r_tod; /* time from midnight */
- int r_todisstd; /* above is standard time if TRUE */
- /* or wall clock time if FALSE */
- int r_todisgmt; /* above is GMT if TRUE */
- /* or local time if FALSE */
+ bool r_todisstd; /* above is standard time if 1 */
+ /* or wall clock time if 0 */
+ bool r_todisgmt; /* above is GMT if 1 */
+ /* or local time if 0 */
zic_t r_stdoff; /* offset from standard time */
const char * r_abbrvar; /* variable part of abbreviation */
@@ -91,6 +76,7 @@ struct zone {
zic_t z_gmtoff;
const char * z_rule;
const char * z_format;
+ char z_format_specifier;
zic_t z_stdoff;
@@ -115,25 +101,25 @@ extern int optind;
#endif
static void addtt(zic_t starttime, int type);
-static int addtype(zic_t gmtoff, const char * abbr, int isdst,
- int ttisstd, int ttisgmt);
-static void leapadd(zic_t t, int positive, int rolling, int count);
+static int addtype(zic_t, char const *, bool, bool, bool);
+static void leapadd(zic_t, bool, int, int);
static void adjleap(void);
static void associate(void);
static void dolink(const char * fromfield, const char * tofield);
static char ** getfields(char * buf);
-static zic_t gethms(const char * string, const char * errstrng,
- int signable);
+static zic_t gethms(const char * string, const char * errstring,
+ bool);
static void infile(const char * filename);
static void inleap(char ** fields, int nfields);
static void inlink(char ** fields, int nfields);
static void inrule(char ** fields, int nfields);
-static int inzcont(char ** fields, int nfields);
-static int inzone(char ** fields, int nfields);
-static int inzsub(char ** fields, int nfields, int iscont);
+static bool inzcont(char ** fields, int nfields);
+static bool inzone(char ** fields, int nfields);
+static bool inzsub(char **, int, bool);
static int itsdir(const char * name);
-static int lowerit(int c);
-static int mkdirs(char * filename);
+static bool is_alpha(char a);
+static char lowerit(char);
+static bool mkdirs(char *);
static void newabbr(const char * abbr);
static zic_t oadd(zic_t t1, zic_t t2);
static void outzone(const struct zone * zp, int ntzones);
@@ -143,21 +129,25 @@ static void rulesub(struct rule * rp,
const char * typep, const char * monthp,
const char * dayp, const char * timep);
static zic_t tadd(zic_t t1, zic_t t2);
-static int yearistype(int year, const char * type);
+static bool yearistype(int year, const char * type);
+
+/* Bound on length of what %z can expand to. */
+enum { PERCENT_Z_LEN_BOUND = sizeof "+995959" - 1 };
static int charcnt;
-static int errors;
+static bool errors;
+static bool warnings;
static const char * filename;
static int leapcnt;
-static int leapseen;
+static bool leapseen;
static zic_t leapminyear;
static zic_t leapmaxyear;
static int linenum;
-static int max_abbrvar_len;
+static int max_abbrvar_len = PERCENT_Z_LEN_BOUND;
static int max_format_len;
static zic_t max_year;
static zic_t min_year;
-static int noise;
+static bool noise;
static const char * rfilename;
static int rlinenum;
static const char * progname;
@@ -333,8 +323,8 @@ static struct lookup const end_years[] = {
};
static struct lookup const leap_types[] = {
- { "Rolling", TRUE },
- { "Stationary", FALSE },
+ { "Rolling", true },
+ { "Stationary", false },
{ NULL, 0 }
};
@@ -354,8 +344,8 @@ static struct attype {
static zic_t gmtoffs[TZ_MAX_TYPES];
static char isdsts[TZ_MAX_TYPES];
static unsigned char abbrinds[TZ_MAX_TYPES];
-static char ttisstds[TZ_MAX_TYPES];
-static char ttisgmts[TZ_MAX_TYPES];
+static bool ttisstds[TZ_MAX_TYPES];
+static bool ttisgmts[TZ_MAX_TYPES];
static char chars[TZ_MAX_CHARS];
static zic_t trans[TZ_MAX_LEAPS];
static zic_t corr[TZ_MAX_LEAPS];
@@ -376,22 +366,44 @@ static ATTRIBUTE_PURE size_t
size_product(size_t nitems, size_t itemsize)
{
if (SIZE_MAX / itemsize < nitems)
- memory_exhausted("size overflow");
+ memory_exhausted(_("size overflow"));
return nitems * itemsize;
}
+#if !HAVE_STRDUP
+static char *
+strdup(char const *str)
+{
+ char *result = malloc(strlen(str) + 1);
+ return result ? strcpy(result, str) : result;
+}
+#endif
+
static ATTRIBUTE_PURE void *
-memcheck(void *const ptr)
+memcheck(void *ptr)
{
if (ptr == NULL)
memory_exhausted(strerror(errno));
return ptr;
}
-#define emalloc(size) memcheck(malloc(size))
-#define erealloc(ptr, size) memcheck(realloc(ptr, size))
-#define ecpyalloc(ptr) memcheck(icpyalloc(ptr))
-#define ecatalloc(oldp, newp) memcheck(icatalloc((oldp), (newp)))
+static void *
+emalloc(size_t size)
+{
+ return memcheck(malloc(size));
+}
+
+static void *
+erealloc(void *ptr, size_t size)
+{
+ return memcheck(realloc(ptr, size));
+}
+
+static char *
+ecpyalloc (char const *str)
+{
+ return memcheck(strdup(str));
+}
static void *
growalloc(void *ptr, size_t itemsize, int nitems, int *nitems_alloc)
@@ -401,7 +413,7 @@ growalloc(void *ptr, size_t itemsize, int nitems, int *nitems_alloc)
else {
int amax = INT_MAX < SIZE_MAX ? INT_MAX : SIZE_MAX;
if ((amax - 1) / 3 * 2 < *nitems_alloc)
- memory_exhausted("int overflow");
+ memory_exhausted(_("int overflow"));
*nitems_alloc = *nitems_alloc + (*nitems_alloc >> 1) + 1;
return erealloc(ptr, size_product(*nitems_alloc, itemsize));
}
@@ -435,13 +447,13 @@ verror(const char *const string, va_list args)
** zic ... 2>&1 | error -t "*" -v
** on BSD systems.
*/
- fprintf(stderr, _("\"%s\", line %d: "), filename, linenum);
+ if (filename)
+ fprintf(stderr, _("\"%s\", line %d: "), filename, linenum);
vfprintf(stderr, string, args);
if (rfilename != NULL)
- (void) fprintf(stderr, _(" (rule from \"%s\", line %d)"),
+ fprintf(stderr, _(" (rule from \"%s\", line %d)"),
rfilename, rlinenum);
- (void) fprintf(stderr, "\n");
- ++errors;
+ fprintf(stderr, "\n");
}
static void ATTRIBUTE_FORMAT((printf, 1, 2))
@@ -451,6 +463,7 @@ error(const char *const string, ...)
va_start(args, string);
verror(string, args);
va_end(args);
+ errors = true;
}
static void ATTRIBUTE_FORMAT((printf, 1, 2))
@@ -461,19 +474,35 @@ warning(const char *const string, ...)
va_start(args, string);
verror(string, args);
va_end(args);
- --errors;
+ warnings = true;
+}
+
+static void
+close_file(FILE *stream, char const *name)
+{
+ char const *e = (ferror(stream) ? _("I/O error")
+ : fclose(stream) != 0 ? strerror(errno) : NULL);
+ if (e) {
+ fprintf(stderr, "%s: ", progname);
+ if (name)
+ fprintf(stderr, "%s: ", name);
+ fprintf(stderr, "%s\n", e);
+ exit(EXIT_FAILURE);
+ }
}
static _Noreturn void
usage(FILE *stream, int status)
{
- (void) fprintf(stream, _("%s: usage is %s \
-[ --version ] [ --help ] [ -v ] [ -l localtime ] [ -p posixrules ] \\\n\
-\t[ -d directory ] [ -L leapseconds ] [ -y yearistype ] [ filename ... ]\n\
-\n\
-Report bugs to %s.\n"),
- progname, progname, REPORT_BUGS_TO);
- exit(status);
+ fprintf(stream,
+ _("%s: usage is %s [ --version ] [ --help ] [ -v ] \\\n"
+ "\t[ -l localtime ] [ -p posixrules ] [ -d directory ] \\\n"
+ "\t[ -L leapseconds ] [ filename ... ]\n\n"
+ "Report bugs to %s.\n"),
+ progname, progname, REPORT_BUGS_TO);
+ if (status == EXIT_SUCCESS)
+ close_file(stream, NULL);
+ exit(status);
}
static const char * psxrules;
@@ -490,25 +519,26 @@ main(int argc, char **argv)
register int c;
#ifdef S_IWGRP
- (void) umask(umask(S_IWGRP | S_IWOTH) | (S_IWGRP | S_IWOTH));
+ umask(umask(S_IWGRP | S_IWOTH) | (S_IWGRP | S_IWOTH));
#endif
#if HAVE_GETTEXT
- (void) setlocale(LC_ALL, "");
+ setlocale(LC_ALL, "");
#ifdef TZ_DOMAINDIR
- (void) bindtextdomain(TZ_DOMAIN, TZ_DOMAINDIR);
+ bindtextdomain(TZ_DOMAIN, TZ_DOMAINDIR);
#endif /* defined TEXTDOMAINDIR */
- (void) textdomain(TZ_DOMAIN);
+ textdomain(TZ_DOMAIN);
#endif /* HAVE_GETTEXT */
progname = argv[0];
if (TYPE_BIT(zic_t) < 64) {
- (void) fprintf(stderr, "%s: %s\n", progname,
+ fprintf(stderr, "%s: %s\n", progname,
_("wild compilation-time specification of zic_t"));
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
for (i = 1; i < argc; ++i)
if (strcmp(argv[i], "--version") == 0) {
- (void) printf("zic %s%s\n", PKGVERSION, TZVERSION);
- exit(EXIT_SUCCESS);
+ printf("zic %s%s\n", PKGVERSION, TZVERSION);
+ close_file(stdout, NULL);
+ return EXIT_SUCCESS;
} else if (strcmp(argv[i], "--help") == 0) {
usage(stdout, EXIT_SUCCESS);
}
@@ -520,57 +550,57 @@ main(int argc, char **argv)
if (directory == NULL)
directory = optarg;
else {
- (void) fprintf(stderr,
+ fprintf(stderr,
_("%s: More than one -d option specified\n"),
progname);
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
break;
case 'l':
if (lcltime == NULL)
lcltime = optarg;
else {
- (void) fprintf(stderr,
+ fprintf(stderr,
_("%s: More than one -l option specified\n"),
progname);
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
break;
case 'p':
if (psxrules == NULL)
psxrules = optarg;
else {
- (void) fprintf(stderr,
+ fprintf(stderr,
_("%s: More than one -p option specified\n"),
progname);
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
break;
case 'y':
if (yitcommand == NULL)
yitcommand = optarg;
else {
- (void) fprintf(stderr,
+ fprintf(stderr,
_("%s: More than one -y option specified\n"),
progname);
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
break;
case 'L':
if (leapsec == NULL)
leapsec = optarg;
else {
- (void) fprintf(stderr,
+ fprintf(stderr,
_("%s: More than one -L option specified\n"),
progname);
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
break;
case 'v':
- noise = TRUE;
+ noise = true;
break;
case 's':
- (void) printf("%s: -s ignored\n", progname);
+ warning(_("-s ignored"));
break;
}
if (optind == argc - 1 && strcmp(argv[optind], "=") == 0)
@@ -588,7 +618,7 @@ _("%s: More than one -L option specified\n"),
for (i = optind; i < argc; ++i)
infile(argv[i]);
if (errors)
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
associate();
for (i = 0; i < nzones; i = j) {
/*
@@ -611,53 +641,137 @@ _("%s: More than one -L option specified\n"),
warning(_("link to link"));
}
if (lcltime != NULL) {
- eat("command line", 1);
+ eat(_("command line"), 1);
dolink(lcltime, TZDEFAULT);
}
if (psxrules != NULL) {
- eat("command line", 1);
+ eat(_("command line"), 1);
dolink(psxrules, TZDEFRULES);
}
- return (errors == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+ if (warnings && (ferror(stderr) || fclose(stderr) != 0))
+ return EXIT_FAILURE;
+ return errors ? EXIT_FAILURE : EXIT_SUCCESS;
+}
+
+static bool
+componentcheck(char const *name, char const *component,
+ char const *component_end)
+{
+ enum { component_len_max = 14 };
+ size_t component_len = component_end - component;
+ if (component_len == 0) {
+ if (!*name)
+ error (_("empty file name"));
+ else
+ error (_(component == name
+ ? "file name '%s' begins with '/'"
+ : *component_end
+ ? "file name '%s' contains '//'"
+ : "file name '%s' ends with '/'"),
+ name);
+ return false;
+ }
+ if (0 < component_len && component_len <= 2
+ && component[0] == '.' && component_end[-1] == '.') {
+ error(_("file name '%s' contains '%.*s' component"),
+ name, (int) component_len, component);
+ return false;
+ }
+ if (noise) {
+ if (0 < component_len && component[0] == '-')
+ warning(_("file name '%s' component contains leading '-'"),
+ name);
+ if (component_len_max < component_len)
+ warning(_("file name '%s' contains overlength component"
+ " '%.*s...'"),
+ name, component_len_max, component);
+ }
+ return true;
+}
+
+static bool
+namecheck(const char *name)
+{
+ register char const *cp;
+
+ /* Benign characters in a portable file name. */
+ static char const benign[] =
+ "-/_"
+ "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
+ /* Non-control chars in the POSIX portable character set,
+ excluding the benign characters. */
+ static char const printable_and_not_benign[] =
+ " !\"#$%&'()*+,.0123456789:;<=>?@[\\]^`{|}~";
+
+ register char const *component = name;
+ for (cp = name; *cp; cp++) {
+ unsigned char c = *cp;
+ if (noise && !strchr(benign, c)) {
+ warning((strchr(printable_and_not_benign, c)
+ ? _("file name '%s' contains byte '%c'")
+ : _("file name '%s' contains byte '\\%o'")),
+ name, c);
+ }
+ if (c == '/') {
+ if (!componentcheck(name, component, cp))
+ return false;
+ component = cp + 1;
+ }
+ }
+ return componentcheck(name, component, cp);
+}
+
+static char *
+relname(char const *dir, char const *base)
+{
+ if (*base == '/')
+ return ecpyalloc(base);
+ else {
+ size_t dir_len = strlen(dir);
+ bool needs_slash = dir_len && dir[dir_len - 1] != '/';
+ char *result = emalloc(dir_len + needs_slash + strlen(base) + 1);
+ result[dir_len] = '/';
+ strcpy(result + dir_len + needs_slash, base);
+ return memcpy(result, dir, dir_len);
+ }
}
static void
-dolink(const char *const fromfield, const char *const tofield)
+dolink(char const *fromfield, char const *tofield)
{
register char * fromname;
register char * toname;
+ register int fromisdir;
- if (fromfield[0] == '/')
- fromname = ecpyalloc(fromfield);
- else {
- fromname = ecpyalloc(directory);
- fromname = ecatalloc(fromname, "/");
- fromname = ecatalloc(fromname, fromfield);
- }
- if (tofield[0] == '/')
- toname = ecpyalloc(tofield);
- else {
- toname = ecpyalloc(directory);
- toname = ecatalloc(toname, "/");
- toname = ecatalloc(toname, tofield);
- }
+ fromname = relname(directory, fromfield);
+ toname = relname(directory, tofield);
/*
** We get to be careful here since
** there's a fair chance of root running us.
*/
- if (!itsdir(toname))
- (void) remove(toname);
- if (link(fromname, toname) != 0
- && access(fromname, F_OK) == 0 && !itsdir(fromname)) {
+ fromisdir = itsdir(fromname);
+ if (fromisdir) {
+ char const *e = strerror(fromisdir < 0 ? errno : EPERM);
+ fprintf(stderr, _("%s: link from %s failed: %s"),
+ progname, fromname, e);
+ exit(EXIT_FAILURE);
+ }
+ if (itsdir(toname) <= 0)
+ remove(toname);
+ if (link(fromname, toname) != 0) {
int result;
- if (mkdirs(toname) != 0)
+ if (! mkdirs(toname))
exit(EXIT_FAILURE);
result = link(fromname, toname);
if (result != 0) {
const char *s = fromfield;
const char *t;
+ char *p;
+ size_t dotdots = 0;
register char * symlinkcontents = NULL;
do
@@ -666,13 +780,13 @@ dolink(const char *const fromfield, const char *const tofield)
&& ! strncmp (fromfield, tofield,
++s - fromfield));
- for (s = tofield + (t - fromfield);
- (s = strchr(s, '/'));
- s++)
- symlinkcontents =
- ecatalloc(symlinkcontents,
- "../");
- symlinkcontents = ecatalloc(symlinkcontents, t);
+ for (s = tofield + (t - fromfield); *s; s++)
+ dotdots += *s == '/';
+ symlinkcontents
+ = emalloc(3 * dotdots + strlen(t) + 1);
+ for (p = symlinkcontents; dotdots-- != 0; p += 3)
+ memcpy(p, "../", 3);
+ strcpy(p, t);
result = symlink(symlinkcontents, toname);
if (result == 0)
warning(_("hard link failed, symbolic link used"));
@@ -684,7 +798,7 @@ warning(_("hard link failed, symbolic link used"));
fp = fopen(fromname, "rb");
if (!fp) {
const char *e = strerror(errno);
- (void) fprintf(stderr,
+ fprintf(stderr,
_("%s: Can't read %s: %s\n"),
progname, fromname, e);
exit(EXIT_FAILURE);
@@ -692,25 +806,15 @@ warning(_("hard link failed, symbolic link used"));
tp = fopen(toname, "wb");
if (!tp) {
const char *e = strerror(errno);
- (void) fprintf(stderr,
+ fprintf(stderr,
_("%s: Can't create %s: %s\n"),
progname, toname, e);
exit(EXIT_FAILURE);
}
while ((c = getc(fp)) != EOF)
putc(c, tp);
- if (ferror(fp) || fclose(fp)) {
- (void) fprintf(stderr,
- _("%s: Error reading %s\n"),
- progname, fromname);
- exit(EXIT_FAILURE);
- }
- if (ferror(tp) || fclose(tp)) {
- (void) fprintf(stderr,
- _("%s: Error writing %s\n"),
- progname, toname);
- exit(EXIT_FAILURE);
- }
+ close_file(fp, fromname);
+ close_file(tp, toname);
warning(_("link failed, copy used"));
}
}
@@ -720,8 +824,8 @@ warning(_("hard link failed, symbolic link used"));
#define TIME_T_BITS_IN_FILE 64
-static const zic_t min_time = (zic_t) -1 << (TIME_T_BITS_IN_FILE - 1);
-static const zic_t max_time = -1 - ((zic_t) -1 << (TIME_T_BITS_IN_FILE - 1));
+static zic_t const min_time = MINVAL (zic_t, TIME_T_BITS_IN_FILE);
+static zic_t const max_time = MAXVAL (zic_t, TIME_T_BITS_IN_FILE);
/* Estimated time of the Big Bang, in seconds since the POSIX epoch.
rounded downward to the negation of a power of two that is
@@ -753,17 +857,24 @@ static const zic_t max_time = -1 - ((zic_t) -1 << (TIME_T_BITS_IN_FILE - 1));
static const zic_t big_bang_time = BIG_BANG;
+/* Return 1 if NAME is a directory, 0 if it's something else, -1 if trouble. */
static int
-itsdir(const char *const name)
+itsdir(char const *name)
{
- register char * myname;
- register int accres;
-
- myname = ecpyalloc(name);
- myname = ecatalloc(myname, "/.");
- accres = access(myname, F_OK);
- free(myname);
- return accres == 0;
+ struct stat st;
+ int res = stat(name, &st);
+ if (res != 0)
+ return res;
+#ifdef S_ISDIR
+ return S_ISDIR(st.st_mode) != 0;
+#else
+ {
+ char *nameslashdot = relname(name, ".");
+ res = stat(nameslashdot, &st);
+ free(nameslashdot);
+ return res == 0;
+ }
+#endif
}
/*
@@ -790,7 +901,7 @@ associate(void)
register int i, j;
if (nrules != 0) {
- (void) qsort(rules, nrules, sizeof *rules, rcomp);
+ qsort(rules, nrules, sizeof *rules, rcomp);
for (i = 0; i < nrules - 1; ++i) {
if (strcmp(rules[i].r_name,
rules[i + 1].r_name) != 0)
@@ -843,12 +954,12 @@ associate(void)
*/
eat(zp->z_filename, zp->z_linenum);
zp->z_stdoff = gethms(zp->z_rule, _("unruly zone"),
- TRUE);
+ true);
/*
** Note, though, that if there's no rule,
** a '%s' in the format is a bad thing.
*/
- if (strchr(zp->z_format, '%') != 0)
+ if (zp->z_format_specifier == 's')
error("%s", _("%s in ruleless zone"));
}
}
@@ -864,7 +975,7 @@ infile(const char *name)
register char * cp;
register const struct lookup * lp;
register int nfields;
- register int wantcont;
+ register bool wantcont;
register int num;
char buf[BUFSIZ];
@@ -874,11 +985,11 @@ infile(const char *name)
} else if ((fp = fopen(name, "r")) == NULL) {
const char *e = strerror(errno);
- (void) fprintf(stderr, _("%s: Can't open %s: %s\n"),
+ fprintf(stderr, _("%s: Can't open %s: %s\n"),
progname, name, e);
exit(EXIT_FAILURE);
}
- wantcont = FALSE;
+ wantcont = false;
for (num = 1; ; ++num) {
eat(name, num);
if (fgets(buf, sizeof buf, fp) != buf)
@@ -909,25 +1020,25 @@ infile(const char *name)
else switch ((int) (lp->l_value)) {
case LC_RULE:
inrule(fields, nfields);
- wantcont = FALSE;
+ wantcont = false;
break;
case LC_ZONE:
wantcont = inzone(fields, nfields);
break;
case LC_LINK:
inlink(fields, nfields);
- wantcont = FALSE;
+ wantcont = false;
break;
case LC_LEAP:
if (name != leapsec)
- (void) fprintf(stderr,
-_("%s: Leap line in non leap seconds file %s\n"),
- progname, name);
+ warning(_("%s: Leap line in non leap"
+ " seconds file %s"),
+ progname, name);
else inleap(fields, nfields);
- wantcont = FALSE;
+ wantcont = false;