1
0
mirror of https://frontier.innolan.net/rainlance/amiga-tz.git synced 2025-12-09 00:50:38 +00:00

yet more GNU work

SCCS-file: zic.c
SCCS-SID: 7.61
This commit is contained in:
Arthur David Olson
1996-02-21 15:47:26 -05:00
committed by Paul Eggert
parent ab2825fcc6
commit 08b835269a

76
zic.c
View File

@ -5,6 +5,7 @@ static char elsieid[] = "%W%";
#endif /* !defined lint */ #endif /* !defined lint */
#include "private.h" #include "private.h"
#include "locale.h"
#include "tzfile.h" #include "tzfile.h"
#ifdef unix #ifdef unix
#include "sys/stat.h" /* for umask manifest constants */ #include "sys/stat.h" /* for umask manifest constants */
@ -135,6 +136,10 @@ static void usage P((void));
static void writezone P((const char * name)); static void writezone P((const char * name));
static int yearistype P((int year, const char * type)); static int yearistype P((int year, const char * type));
#if ! HAVE_STRERROR
static char * strerror P((int));
#endif
static int charcnt; static int charcnt;
static int errors; static int errors;
static const char * filename; static const char * filename;
@ -351,7 +356,9 @@ memcheck(ptr)
char * const ptr; char * const ptr;
{ {
if (ptr == NULL) { if (ptr == NULL) {
(void) perror(progname); const char *e = strerror(errno);
(void) fprintf(stderr, _("%s: Memory exhausted: %s\n"),
progname, e);
(void) exit(EXIT_FAILURE); (void) exit(EXIT_FAILURE);
} }
return ptr; return ptr;
@ -366,6 +373,20 @@ char * const ptr;
** Error handling. ** Error handling.
*/ */
#if ! HAVE_STRERROR
static char *
strerror(errnum)
int errnum;
{
extern char *sys_errlist[];
extern int sys_nerr;
if (errnum > 0 && errnum <= sys_nerr)
return sys_errlist[errnum];
return "Unknown system error";
}
#endif /* ! HAVE_STRERROR */
static void static void
eats(name, num, rname, rnum) eats(name, num, rname, rnum)
const char * const name; const char * const name;
@ -434,6 +455,13 @@ char * argv[];
#ifdef unix #ifdef unix
(void) umask(umask(S_IWGRP | S_IWOTH) | (S_IWGRP | S_IWOTH)); (void) umask(umask(S_IWGRP | S_IWOTH) | (S_IWGRP | S_IWOTH));
#endif /* defined unix */ #endif /* defined unix */
#if HAVE_GETTEXT - 0
(void) setlocale(LC_MESSAGES, "");
#ifdef TZ_DOMAINDIR
(void) bindtextdomain(TZ_DOMAIN, TZ_DOMAINDIR);
#endif /* defined TEXTDOMAINDIR */
(void) textdomain(TZ_DOMAIN);
#endif /* HAVE_GETTEXT - 0 */
progname = argv[0]; progname = argv[0];
while ((c = getopt(argc, argv, "d:l:p:L:vsy:")) != EOF) while ((c = getopt(argc, argv, "d:l:p:L:vsy:")) != EOF)
switch (c) { switch (c) {
@ -567,9 +595,10 @@ const char * const tofile;
if (mkdirs(toname) != 0) if (mkdirs(toname) != 0)
(void) exit(EXIT_FAILURE); (void) exit(EXIT_FAILURE);
if (link(fromname, toname) != 0) { if (link(fromname, toname) != 0) {
(void) fprintf(stderr, _("%s: Can't link from %s to "), const char *e = strerror(errno);
progname, fromname); (void) fprintf(stderr,
(void) perror(toname); _("%s: Can't link from %s to %s: %s\n"),
progname, fromname, toname, e);
(void) exit(EXIT_FAILURE); (void) exit(EXIT_FAILURE);
} }
} }
@ -682,7 +711,8 @@ associate P((void))
** Maybe we have a local standard time offset. ** Maybe we have a local standard time offset.
*/ */
eat(zp->z_filename, zp->z_linenum); eat(zp->z_filename, zp->z_linenum);
zp->z_stdoff = gethms(zp->z_rule, "unruly zone", TRUE); zp->z_stdoff = gethms(zp->z_rule, _("unruly zone"),
TRUE);
/* /*
** Note, though, that if there's no rule, ** Note, though, that if there's no rule,
** a '%s' in the format is a bad thing. ** a '%s' in the format is a bad thing.
@ -712,8 +742,9 @@ const char * name;
name = _("standard input"); name = _("standard input");
fp = stdin; fp = stdin;
} else if ((fp = fopen(name, "r")) == NULL) { } else if ((fp = fopen(name, "r")) == NULL) {
(void) fprintf(stderr, _("%s: Can't open "), progname); const char *e = strerror(errno);
(void) perror(name); (void) fprintf(stderr, _("%s: Can't open %s: %s\n"),
progname, name, e);
(void) exit(EXIT_FAILURE); (void) exit(EXIT_FAILURE);
} }
wantcont = FALSE; wantcont = FALSE;
@ -774,13 +805,14 @@ _("%s: panic: Invalid l_value %d\n"),
ifree((char *) fields); ifree((char *) fields);
} }
if (ferror(fp)) { if (ferror(fp)) {
(void) fprintf(stderr, _("%s: Error reading "), progname); (void) fprintf(stderr, _("%s: Error reading %s\n"),
(void) perror(filename); progname, filename);
(void) exit(EXIT_FAILURE); (void) exit(EXIT_FAILURE);
} }
if (fp != stdin && fclose(fp)) { if (fp != stdin && fclose(fp)) {
(void) fprintf(stderr, _("%s: Error closing "), progname); const char *e = strerror(errno);
(void) perror(filename); (void) fprintf(stderr, _("%s: Error closing %s: %s\n"),
progname, filename, e);
(void) exit(EXIT_FAILURE); (void) exit(EXIT_FAILURE);
} }
if (wantcont) if (wantcont)
@ -1048,7 +1080,7 @@ const int nfields;
} }
dayoff = oadd(dayoff, eitol(day - 1)); dayoff = oadd(dayoff, eitol(day - 1));
if (dayoff < 0 && !TYPE_SIGNED(time_t)) { if (dayoff < 0 && !TYPE_SIGNED(time_t)) {
error("time before zero"); error(_("time before zero"));
return; return;
} }
t = (time_t) dayoff * SECSPERDAY; t = (time_t) dayoff * SECSPERDAY;
@ -1059,7 +1091,7 @@ const int nfields;
error(_("time overflow")); error(_("time overflow"));
return; return;
} }
tod = gethms(fields[LP_TIME], "invalid time of day", FALSE); tod = gethms(fields[LP_TIME], _("invalid time of day"), FALSE);
cp = fields[LP_CORR]; cp = fields[LP_CORR];
{ {
register int positive; register int positive;
@ -1161,7 +1193,7 @@ const char * const timep;
break; break;
} }
} }
rp->r_tod = gethms(dp, "invalid time of day", FALSE); rp->r_tod = gethms(dp, _("invalid time of day"), FALSE);
ifree(dp); ifree(dp);
/* /*
** Year work. ** Year work.
@ -1303,9 +1335,9 @@ const char * const name;
if (mkdirs(fullname) != 0) if (mkdirs(fullname) != 0)
(void) exit(EXIT_FAILURE); (void) exit(EXIT_FAILURE);
if ((fp = fopen(fullname, "wb")) == NULL) { if ((fp = fopen(fullname, "wb")) == NULL) {
(void) fprintf(stderr, _("%s: Can't create "), const char *e = strerror(errno);
progname); (void) fprintf(stderr, _("%s: Can't create %s: %s\n"),
(void) perror(fullname); progname, fullname, e);
(void) exit(EXIT_FAILURE); (void) exit(EXIT_FAILURE);
} }
} }
@ -1369,8 +1401,8 @@ const char * const name;
for (i = 0; i < typecnt; ++i) for (i = 0; i < typecnt; ++i)
(void) putc(ttisgmts[i], fp); (void) putc(ttisgmts[i], fp);
if (ferror(fp) || fclose(fp)) { if (ferror(fp) || fclose(fp)) {
(void) fprintf(stderr, _("%s: Write error on "), progname); (void) fprintf(stderr, _("%s: Error writing %s\n"),
(void) perror(fullname); progname, fullname);
(void) exit(EXIT_FAILURE); (void) exit(EXIT_FAILURE);
} }
} }
@ -1977,10 +2009,10 @@ char * const argname;
** It doesn't seem to exist, so we try to create it. ** It doesn't seem to exist, so we try to create it.
*/ */
if (mkdir(name, 0755) != 0) { if (mkdir(name, 0755) != 0) {
const char *e = strerror(errno);
(void) fprintf(stderr, (void) fprintf(stderr,
_("%s: Can't create directory "), _("%s: Can't create directory %s: %s\n"),
progname); progname, name, e);
(void) perror(name);
ifree(name); ifree(name);
return -1; return -1;
} }