From 92777700d297c23825e785e6f6a0161bd398705d Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Tue, 27 Feb 1996 00:55:03 +0000 Subject: Mon Feb 26 10:22:30 1996 Roland McGrath * sysdeps/unix/dirstream.h: Rewritten. * sysdeps/unix/readdir.c: Rewritten. * sysdeps/unix/telldir.c: Rewritten. * sysdeps/unix/closedir.c: Use <...> instead of "..." for dirstream.h. Remove __ from DIR struct member names. * sysdeps/unix/dirfd.c: Likewise. * sysdeps/unix/seekdir.c: Likewise. * sysdeps/unix/rewinddir.c: Likewise. * sysdeps/unix/opendir.c: Likewise. Don't allocate extra space after DIR structure. * sysdeps/stub/direct.h: File removed. * sysdeps/unix/bsd/bsd4.4/direct.h: File removed. * sysdeps/unix/bsd/direct.h: File removed. * sysdeps/unix/common/direct.h: File removed. * sysdeps/unix/sysv/irix4/direct.h: File removed. * sysdeps/unix/sysv/isc3/direct.h: File removed. * sysdeps/unix/sysv/sco3.2.4/direct.h: File removed. * sysdeps/unix/sysv/sysv4/solaris2/direct.h: File removed. * sysdeps/unix/common/direntry.h: New file. * sysdeps/unix/bsd/direntry.h: New file. * sysdeps/unix/bsd/bsd4.4/direntry.h: New file. * sysdeps/unix/sysv/direntry.h: New file. * sysdeps/stub/direntry.h: New file. * dirent/dirent.h (struct dirent): Type removed. Include to define it. (_D_EXACT_NAMLEN, _D_ALLOC_NAMLEN): New macros. * dirent/Makefile (headers): Add direntry.h. (distribute): Remove direct.h. * sysdeps/posix/getcwd.c: Use new macros instead of d_namlen. * dirent/scandir.c: Likewise. * io/fts.c (fts_build): Likewise. * io/ftw.c (ftw_dir): Likewise. * sysdeps/posix/ttyname.c: Likewise. * sysdeps/unix/sysv/sysv4/solaris2/syscalls.list: New file. * sysdeps/mach/hurd/profil.c (MAX_PC_SAMPLES): New macro. (collector_timeout): New static variable. (update_waiter): Actually call __task_enable_pc_sampling. Set collector_timeout based on the `tick' count returned. (profile_waiter): Use MAX_PC_SAMPLES. Set nsamples before RPC. Use collector_timeout in __mach_msg call. * gmon/Makefile (noprof): New variable containing mcount. Append profil unless it is in $(unix-syscalls). (mcount.po): Use $(noprof) for list of targets in this rule. * libc-symbols.h: Define _LIBC before #include . Sun Feb 25 12:29:23 1996 Roland McGrath * config.h.in [_LIBC] (HAVE_STRERROR): Define it. Protect 2nd page of #undef's for generator programs with #ifndef _LIBC. * time/zic.c, time/zdump.c, time/private.h: Updated from ADO's latest. Fri Feb 9 12:40:19 1996 Brendan Kehoe * libio/cleanup.c (_IO_cleanup_registration_needed) [!_G_HAVE_ATEXIT]: Init to NULL. * libio/filedoalloc.c (_IO_cleanup_registration_needed): Remove decl. Thu Feb 8 08:12:50 1996 Brendan Kehoe * libio/filedoalloc.c (_IO_cleanup_registration_needed): Revert previous change, since cleanup.c only defines it if _G_HAVE_ATEXIT. Wed Feb 7 15:10:17 1996 Brendan Kehoe * libio/filedoalloc.c (_IO_cleanup_registration_needed): Declare as extern. Sat Feb 24 11:34:13 1996 Roland McGrath * sysdeps/i386/memcmp.S: Fix argument %esp offsets. * time/sys/time.h (timeradd, timersub): New macros; BSD has these. --- time/private.h | 35 ++++++++++++++++++++++++-- time/sys/time.h | 29 +++++++++++++++++---- time/zdump.c | 26 +++++++++++++++++-- time/zic.c | 78 ++++++++++++++++++++++++++++++++++++++++----------------- 4 files changed, 136 insertions(+), 32 deletions(-) (limited to 'time') diff --git a/time/private.h b/time/private.h index de7039539d..69fcca3822 100644 --- a/time/private.h +++ b/time/private.h @@ -16,7 +16,7 @@ #ifndef lint #ifndef NOID -static char privatehid[] = "@(#)private.h 7.40"; +static char privatehid[] = "@(#)private.h 7.42"; #endif /* !defined NOID */ #endif /* !defined lint */ @@ -29,10 +29,18 @@ static char privatehid[] = "@(#)private.h 7.40"; #define HAVE_ADJTIME 1 #endif /* !defined HAVE_ADJTIME */ +#ifndef HAVE_GETTEXT +#define HAVE_GETTEXT 0 +#endif /* !defined HAVE_GETTEXT */ + #ifndef HAVE_SETTIMEOFDAY #define HAVE_SETTIMEOFDAY 3 #endif /* !defined HAVE_SETTIMEOFDAY */ +#ifndef HAVE_STRERROR +#define HAVE_STRERROR 0 +#endif /* !defined HAVE_STRERROR */ + #ifndef HAVE_UNISTD_H #define HAVE_UNISTD_H 1 #endif /* !defined HAVE_UNISTD_H */ @@ -57,6 +65,10 @@ static char privatehid[] = "@(#)private.h 7.40"; #include "time.h" #include "stdlib.h" +#if HAVE_GETTEXT - 0 +#include "libintl.h" +#endif /* HAVE_GETTEXT - 0 */ + #if HAVE_UNISTD_H - 0 #include "unistd.h" /* for F_OK and R_OK */ #endif /* HAVE_UNISTD_H - 0 */ @@ -146,6 +158,15 @@ extern int unlink P((const char * filename)); #define remove unlink #endif /* !defined remove */ +/* +** Some ancient errno.h implementations don't declare errno. +** But some newer errno.h implementations define it as a macro. +** Fix the former without affecting the latter. +*/ +#ifndef errno +extern int errno; +#endif /* !defined errno */ + /* ** Finally, some convenience items. */ @@ -203,12 +224,22 @@ extern int unlink P((const char * filename)); /* ** For the benefit of GNU folk... +** `_(MSGID)' uses the current locale's message library string for MSGID. +** The default is to use gettext if available, and use MSGID otherwise. */ #ifndef _ -#define _(x) x +#if HAVE_GETTEXT - 0 +#define _(msgid) gettext(msgid) +#else /* !(HAVE_GETTEXT - 0) */ +#define _(msgid) msgid +#endif /* !(HAVE_GETTEXT - 0) */ #endif /* !defined _ */ +#ifndef TZ_DOMAIN +#define TZ_DOMAIN "tz" +#endif /* !defined TZ_DOMAIN */ + /* ** UNIX was a registered trademark of UNIX System Laboratories in 1993. */ diff --git a/time/sys/time.h b/time/sys/time.h index 7275561541..d615b2ebd7 100644 --- a/time/sys/time.h +++ b/time/sys/time.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. +/* Copyright (C) 1991, 92, 93, 94, 96 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -135,11 +135,30 @@ extern int utimes __P ((__const char *__file, struct timeval __tvp[2])); /* Convenience macros for operations on timevals. NOTE: `timercmp' does not work for >= or <=. */ #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) -#define timercmp(tvp, uvp, CMP) \ - ((tvp)->tv_sec CMP (uvp)->tv_sec || \ - (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec CMP (uvp)->tv_usec) #define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0) - +#define timercmp(a, b, CMP) \ + (((a)->tv_sec == (b)->tv_sec) ? \ + ((a)->tv_usec CMP (b)->tv_usec) : \ + ((a)->tv_sec CMP (b)->tv_sec)) +#define timeradd(a, b, result) \ + do { \ + (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \ + (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \ + if ((result)->tv_usec >= 1000000) \ + { \ + ++(result)->tv_sec; \ + (result)->tv_usec -= 1000000; \ + } \ + } while (0) +#define timersub(a, b, result) \ + do { \ + (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ + (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ + if ((result)->tv_usec < 0) { \ + --(result)->tv_sec; \ + (result)->tv_usec += 1000000; \ + } \ + } while (0) __END_DECLS diff --git a/time/zdump.c b/time/zdump.c index 5169c20299..f56e09d007 100644 --- a/time/zdump.c +++ b/time/zdump.c @@ -1,6 +1,6 @@ #ifndef lint #ifndef NOID -static char elsieid[] = "@(#)zdump.c 7.22"; +static char elsieid[] = "@(#)zdump.c 7.23"; #endif /* !defined NOID */ #endif /* !defined lint */ @@ -68,6 +68,11 @@ static char elsieid[] = "@(#)zdump.c 7.22"; #define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0) #endif /* !defined isleap */ +#if HAVE_GETTEXT - 0 +#include "locale.h" /* for setlocale */ +#include "libintl.h" +#endif /* HAVE_GETTEXT - 0 */ + #ifndef GNUC_or_lint #ifdef lint #define GNUC_or_lint @@ -90,12 +95,22 @@ static char elsieid[] = "@(#)zdump.c 7.22"; /* ** For the benefit of GNU folk... +** `_(MSGID)' uses the current locale's message library string for MSGID. +** The default is to use gettext if available, and use MSGID otherwise. */ #ifndef _ -#define _(x) x +#if HAVE_GETTEXT - 0 +#define _(msgid) gettext(msgid) +#else /* !(HAVE_GETTEXT - 0) */ +#define _(msgid) msgid +#endif /* !(HAVE_GETTEXT - 0) */ #endif /* !defined _ */ +#ifndef TZ_DOMAIN +#define TZ_DOMAIN "tz" +#endif /* !defined TZ_DOMAIN */ + extern char ** environ; extern int getopt(); extern char * optarg; @@ -130,6 +145,13 @@ char * argv[]; struct tm newtm; INITIALIZE(cuttime); +#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]; vflag = 0; cutoff = NULL; diff --git a/time/zic.c b/time/zic.c index c0ce5be138..756b7eb84a 100644 --- a/time/zic.c +++ b/time/zic.c @@ -1,10 +1,11 @@ #ifndef lint #ifndef NOID -static char elsieid[] = "@(#)zic.c 7.60"; +static char elsieid[] = "@(#)zic.c 7.62"; #endif /* !defined NOID */ #endif /* !defined lint */ #include "private.h" +#include "locale.h" #include "tzfile.h" #ifdef unix #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 int yearistype P((int year, const char * type)); +#if !HAVE_STRERROR +static char * strerror P((int)); +#endif /* !HAVE_STRERROR */ + static int charcnt; static int errors; static const char * filename; @@ -351,7 +356,9 @@ memcheck(ptr) char * const ptr; { 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); } return ptr; @@ -366,6 +373,20 @@ char * const ptr; ** 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 eats(name, num, rname, rnum) const char * const name; @@ -434,6 +455,13 @@ char * argv[]; #ifdef unix (void) umask(umask(S_IWGRP | S_IWOTH) | (S_IWGRP | S_IWOTH)); #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]; while ((c = getopt(argc, argv, "d:l:p:L:vsy:")) != EOF) switch (c) { @@ -567,9 +595,10 @@ const char * const tofile; if (mkdirs(toname) != 0) (void) exit(EXIT_FAILURE); if (link(fromname, toname) != 0) { - (void) fprintf(stderr, _("%s: Can't link from %s to "), - progname, fromname); - (void) perror(toname); + const char *e = strerror(errno); + (void) fprintf(stderr, + _("%s: Can't link from %s to %s: %s\n"), + progname, fromname, toname, e); (void) exit(EXIT_FAILURE); } } @@ -682,7 +711,8 @@ associate P((void)) ** Maybe we have a local standard time offset. */ 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, ** a '%s' in the format is a bad thing. @@ -712,8 +742,9 @@ const char * name; name = _("standard input"); fp = stdin; } else if ((fp = fopen(name, "r")) == NULL) { - (void) fprintf(stderr, _("%s: Can't open "), progname); - (void) perror(name); + const char *e = strerror(errno); + (void) fprintf(stderr, _("%s: Can't open %s: %s\n"), + progname, name, e); (void) exit(EXIT_FAILURE); } wantcont = FALSE; @@ -774,13 +805,14 @@ _("%s: panic: Invalid l_value %d\n"), ifree((char *) fields); } if (ferror(fp)) { - (void) fprintf(stderr, _("%s: Error reading "), progname); - (void) perror(filename); + (void) fprintf(stderr, _("%s: Error reading %s\n"), + progname, filename); (void) exit(EXIT_FAILURE); } if (fp != stdin && fclose(fp)) { - (void) fprintf(stderr, _("%s: Error closing "), progname); - (void) perror(filename); + const char *e = strerror(errno); + (void) fprintf(stderr, _("%s: Error closing %s: %s\n"), + progname, filename, e); (void) exit(EXIT_FAILURE); } if (wantcont) @@ -1048,7 +1080,7 @@ const int nfields; } dayoff = oadd(dayoff, eitol(day - 1)); if (dayoff < 0 && !TYPE_SIGNED(time_t)) { - error("time before zero"); + error(_("time before zero")); return; } t = (time_t) dayoff * SECSPERDAY; @@ -1059,7 +1091,7 @@ const int nfields; error(_("time overflow")); 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]; { register int positive; @@ -1161,7 +1193,7 @@ const char * const timep; break; } } - rp->r_tod = gethms(dp, "invalid time of day", FALSE); + rp->r_tod = gethms(dp, _("invalid time of day"), FALSE); ifree(dp); /* ** Year work. @@ -1303,9 +1335,9 @@ const char * const name; if (mkdirs(fullname) != 0) (void) exit(EXIT_FAILURE); if ((fp = fopen(fullname, "wb")) == NULL) { - (void) fprintf(stderr, _("%s: Can't create "), - progname); - (void) perror(fullname); + const char *e = strerror(errno); + (void) fprintf(stderr, _("%s: Can't create %s: %s\n"), + progname, fullname, e); (void) exit(EXIT_FAILURE); } } @@ -1369,8 +1401,8 @@ const char * const name; for (i = 0; i < typecnt; ++i) (void) putc(ttisgmts[i], fp); if (ferror(fp) || fclose(fp)) { - (void) fprintf(stderr, _("%s: Write error on "), progname); - (void) perror(fullname); + (void) fprintf(stderr, _("%s: Error writing %s\n"), + progname, fullname); (void) exit(EXIT_FAILURE); } } @@ -1977,10 +2009,10 @@ char * const argname; ** It doesn't seem to exist, so we try to create it. */ if (mkdir(name, 0755) != 0) { + const char *e = strerror(errno); (void) fprintf(stderr, - _("%s: Can't create directory "), - progname); - (void) perror(name); + _("%s: Can't create directory %s: %s\n"), + progname, name, e); ifree(name); return -1; } -- cgit v1.2.3