1
0
mirror of https://github.com/postgres/postgres.git synced 2025-04-29 13:56:47 +03:00

Convert DOS newlines to Unix newlines.

This commit is contained in:
Bruce Momjian 2004-04-30 04:44:06 +00:00
parent 7146eb0bc3
commit e9a028f81f
9 changed files with 4751 additions and 4753 deletions

View File

@ -1,75 +1,75 @@
#include "pgtz.h" #include "pgtz.h"
/* /*
** This file is in the public domain, so clarified as of ** This file is in the public domain, so clarified as of
** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). ** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
*/ */
#ifndef lint #ifndef lint
#ifndef NOID #ifndef NOID
static char elsieid[] = "@(#)asctime.c 7.9"; static char elsieid[] = "@(#)asctime.c 7.9";
#endif /* !defined NOID */ #endif /* !defined NOID */
#endif /* !defined lint */ #endif /* !defined lint */
/*LINTLIBRARY*/ /*LINTLIBRARY*/
#include "private.h" #include "private.h"
#include "tzfile.h" #include "tzfile.h"
/* /*
** A la ISO/IEC 9945-1, ANSI/IEEE Std 1003.1, Second Edition, 1996-07-12. ** A la ISO/IEC 9945-1, ANSI/IEEE Std 1003.1, Second Edition, 1996-07-12.
*/ */
char * char *
asctime_r(timeptr, buf) asctime_r(timeptr, buf)
register const struct tm * timeptr; register const struct tm * timeptr;
char * buf; char * buf;
{ {
static const char wday_name[][3] = { static const char wday_name[][3] = {
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
}; };
static const char mon_name[][3] = { static const char mon_name[][3] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
}; };
register const char * wn; register const char * wn;
register const char * mn; register const char * mn;
if (timeptr->tm_wday < 0 || timeptr->tm_wday >= DAYSPERWEEK) if (timeptr->tm_wday < 0 || timeptr->tm_wday >= DAYSPERWEEK)
wn = "???"; wn = "???";
else wn = wday_name[timeptr->tm_wday]; else wn = wday_name[timeptr->tm_wday];
if (timeptr->tm_mon < 0 || timeptr->tm_mon >= MONSPERYEAR) if (timeptr->tm_mon < 0 || timeptr->tm_mon >= MONSPERYEAR)
mn = "???"; mn = "???";
else mn = mon_name[timeptr->tm_mon]; else mn = mon_name[timeptr->tm_mon];
/* /*
** The X3J11-suggested format is ** The X3J11-suggested format is
** "%.3s %.3s%3d %02.2d:%02.2d:%02.2d %d\n" ** "%.3s %.3s%3d %02.2d:%02.2d:%02.2d %d\n"
** Since the .2 in 02.2d is ignored, we drop it. ** Since the .2 in 02.2d is ignored, we drop it.
*/ */
(void) sprintf(buf, "%.3s %.3s%3d %02d:%02d:%02d %d\n", (void) sprintf(buf, "%.3s %.3s%3d %02d:%02d:%02d %d\n",
wn, mn, wn, mn,
timeptr->tm_mday, timeptr->tm_hour, timeptr->tm_mday, timeptr->tm_hour,
timeptr->tm_min, timeptr->tm_sec, timeptr->tm_min, timeptr->tm_sec,
TM_YEAR_BASE + timeptr->tm_year); TM_YEAR_BASE + timeptr->tm_year);
return buf; return buf;
} }
/* /*
** A la X3J11, with core dump avoidance. ** A la X3J11, with core dump avoidance.
*/ */
char * char *
asctime(timeptr) asctime(timeptr)
register const struct tm * timeptr; register const struct tm * timeptr;
{ {
/* /*
** Big enough for something such as ** Big enough for something such as
** ??? ???-2147483648 -2147483648:-2147483648:-2147483648 -2147483648\n ** ??? ???-2147483648 -2147483648:-2147483648:-2147483648 -2147483648\n
** (two three-character abbreviations, five strings denoting integers, ** (two three-character abbreviations, five strings denoting integers,
** three explicit spaces, two explicit colons, a newline, ** three explicit spaces, two explicit colons, a newline,
** and a trailing ASCII nul). ** and a trailing ASCII nul).
*/ */
static char result[3 * 2 + 5 * INT_STRLEN_MAXIMUM(int) + static char result[3 * 2 + 5 * INT_STRLEN_MAXIMUM(int) +
3 + 2 + 1 + 1]; 3 + 2 + 1 + 1];
return asctime_r(timeptr, result); return asctime_r(timeptr, result);
} }

View File

@ -1,84 +1,84 @@
#include "pgtz.h" #include "pgtz.h"
/* /*
** This file is in the public domain, so clarified as of ** This file is in the public domain, so clarified as of
** June 5, 1996 by Arthur David Olson (arthur_david_olson@nih.gov). ** June 5, 1996 by Arthur David Olson (arthur_david_olson@nih.gov).
*/ */
#ifndef lint #ifndef lint
#ifndef NOID #ifndef NOID
static char elsieid[] = "@(#)difftime.c 7.9"; static char elsieid[] = "@(#)difftime.c 7.9";
#endif /* !defined NOID */ #endif /* !defined NOID */
#endif /* !defined lint */ #endif /* !defined lint */
/*LINTLIBRARY*/ /*LINTLIBRARY*/
#include "private.h" #include "private.h"
/* /*
** Algorithm courtesy Paul Eggert (eggert@twinsun.com). ** Algorithm courtesy Paul Eggert (eggert@twinsun.com).
*/ */
#ifdef HAVE_LONG_DOUBLE #ifdef HAVE_LONG_DOUBLE
#define long_double long double #define long_double long double
#endif /* defined HAVE_LONG_DOUBLE */ #endif /* defined HAVE_LONG_DOUBLE */
#ifndef HAVE_LONG_DOUBLE #ifndef HAVE_LONG_DOUBLE
#define long_double double #define long_double double
#endif /* !defined HAVE_LONG_DOUBLE */ #endif /* !defined HAVE_LONG_DOUBLE */
double double
difftime(time1, time0) difftime(time1, time0)
const time_t time1; const time_t time1;
const time_t time0; const time_t time0;
{ {
time_t delta; time_t delta;
time_t hibit; time_t hibit;
{ {
time_t tt; time_t tt;
double d; double d;
long_double ld; long_double ld;
if (sizeof tt < sizeof d) if (sizeof tt < sizeof d)
return (double) time1 - (double) time0; return (double) time1 - (double) time0;
if (sizeof tt < sizeof ld) if (sizeof tt < sizeof ld)
return (long_double) time1 - (long_double) time0; return (long_double) time1 - (long_double) time0;
} }
if (time1 < time0) if (time1 < time0)
return -difftime(time0, time1); return -difftime(time0, time1);
/* /*
** As much as possible, avoid loss of precision ** As much as possible, avoid loss of precision
** by computing the difference before converting to double. ** by computing the difference before converting to double.
*/ */
delta = time1 - time0; delta = time1 - time0;
if (delta >= 0) if (delta >= 0)
return delta; return delta;
/* /*
** Repair delta overflow. ** Repair delta overflow.
*/ */
hibit = (~ (time_t) 0) << (TYPE_BIT(time_t) - 1); hibit = (~ (time_t) 0) << (TYPE_BIT(time_t) - 1);
/* /*
** The following expression rounds twice, which means ** The following expression rounds twice, which means
** the result may not be the closest to the true answer. ** the result may not be the closest to the true answer.
** For example, suppose time_t is 64-bit signed int, ** For example, suppose time_t is 64-bit signed int,
** long_double is IEEE 754 double with default rounding, ** long_double is IEEE 754 double with default rounding,
** time1 = 9223372036854775807 and time0 = -1536. ** time1 = 9223372036854775807 and time0 = -1536.
** Then the true difference is 9223372036854777343, ** Then the true difference is 9223372036854777343,
** which rounds to 9223372036854777856 ** which rounds to 9223372036854777856
** with a total error of 513. ** with a total error of 513.
** But delta overflows to -9223372036854774273, ** But delta overflows to -9223372036854774273,
** which rounds to -9223372036854774784, and correcting ** which rounds to -9223372036854774784, and correcting
** this by subtracting 2 * (long_double) hibit ** this by subtracting 2 * (long_double) hibit
** (i.e. by adding 2**64 = 18446744073709551616) ** (i.e. by adding 2**64 = 18446744073709551616)
** yields 9223372036854776832, which ** yields 9223372036854776832, which
** rounds to 9223372036854775808 ** rounds to 9223372036854775808
** with a total error of 1535 instead. ** with a total error of 1535 instead.
** This problem occurs only with very large differences. ** This problem occurs only with very large differences.
** It's too painful to fix this portably. ** It's too painful to fix this portably.
** We are not alone in this problem; ** We are not alone in this problem;
** some C compilers round twice when converting ** some C compilers round twice when converting
** large unsigned types to small floating types, ** large unsigned types to small floating types,
** so if time_t is unsigned the "return delta" above ** so if time_t is unsigned the "return delta" above
** has the same double-rounding problem with those compilers. ** has the same double-rounding problem with those compilers.
*/ */
return delta - 2 * (long_double) hibit; return delta - 2 * (long_double) hibit;
} }

View File

@ -1,81 +1,81 @@
#ifndef lint #ifndef lint
#ifndef NOID #ifndef NOID
static char elsieid[] = "@(#)ialloc.c 8.29"; static char elsieid[] = "@(#)ialloc.c 8.29";
#endif /* !defined NOID */ #endif /* !defined NOID */
#endif /* !defined lint */ #endif /* !defined lint */
/*LINTLIBRARY*/ /*LINTLIBRARY*/
#include "private.h" #include "private.h"
#define nonzero(n) (((n) == 0) ? 1 : (n)) #define nonzero(n) (((n) == 0) ? 1 : (n))
char * char *
imalloc(n) imalloc(n)
const int n; const int n;
{ {
return malloc((size_t) nonzero(n)); return malloc((size_t) nonzero(n));
} }
char * char *
icalloc(nelem, elsize) icalloc(nelem, elsize)
int nelem; int nelem;
int elsize; int elsize;
{ {
if (nelem == 0 || elsize == 0) if (nelem == 0 || elsize == 0)
nelem = elsize = 1; nelem = elsize = 1;
return calloc((size_t) nelem, (size_t) elsize); return calloc((size_t) nelem, (size_t) elsize);
} }
void * void *
irealloc(pointer, size) irealloc(pointer, size)
void * const pointer; void * const pointer;
const int size; const int size;
{ {
if (pointer == NULL) if (pointer == NULL)
return imalloc(size); return imalloc(size);
return realloc((void *) pointer, (size_t) nonzero(size)); return realloc((void *) pointer, (size_t) nonzero(size));
} }
char * char *
icatalloc(old, new) icatalloc(old, new)
char * const old; char * const old;
const char * const new; const char * const new;
{ {
register char * result; register char * result;
register int oldsize, newsize; register int oldsize, newsize;
newsize = (new == NULL) ? 0 : strlen(new); newsize = (new == NULL) ? 0 : strlen(new);
if (old == NULL) if (old == NULL)
oldsize = 0; oldsize = 0;
else if (newsize == 0) else if (newsize == 0)
return old; return old;
else oldsize = strlen(old); else oldsize = strlen(old);
if ((result = irealloc(old, oldsize + newsize + 1)) != NULL) if ((result = irealloc(old, oldsize + newsize + 1)) != NULL)
if (new != NULL) if (new != NULL)
(void) strcpy(result + oldsize, new); (void) strcpy(result + oldsize, new);
return result; return result;
} }
char * char *
icpyalloc(string) icpyalloc(string)
const char * const string; const char * const string;
{ {
return icatalloc((char *) NULL, string); return icatalloc((char *) NULL, string);
} }
void void
ifree(p) ifree(p)
char * const p; char * const p;
{ {
if (p != NULL) if (p != NULL)
(void) free(p); (void) free(p);
} }
void void
icfree(p) icfree(p)
char * const p; char * const p;
{ {
if (p != NULL) if (p != NULL)
(void) free(p); (void) free(p);
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,6 @@
#include "postgres.h" #include "postgres.h"
#define NOID #define NOID
#define HAVE_SYMLINK 0
#define HAVE_SYS_WAIT_H 0
#define TZDIR pgwin32_TZDIR() #define TZDIR pgwin32_TZDIR()
char *pgwin32_TZDIR(void); char *pgwin32_TZDIR(void);

View File

@ -1,294 +1,294 @@
#ifndef PRIVATE_H #ifndef PRIVATE_H
#define PRIVATE_H #define PRIVATE_H
/* /*
** This file is in the public domain, so clarified as of ** This file is in the public domain, so clarified as of
** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). ** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
*/ */
/* /*
** This header is for use ONLY with the time conversion code. ** This header is for use ONLY with the time conversion code.
** There is no guarantee that it will remain unchanged, ** There is no guarantee that it will remain unchanged,
** or that it will remain at all. ** or that it will remain at all.
** Do NOT copy it to any system include directory. ** Do NOT copy it to any system include directory.
** Thank you! ** Thank you!
*/ */
/* /*
** ID ** ID
*/ */
#ifndef lint #ifndef lint
#ifndef NOID #ifndef NOID
static char privatehid[] = "@(#)private.h 7.53"; static char privatehid[] = "@(#)private.h 7.53";
#endif /* !defined NOID */ #endif /* !defined NOID */
#endif /* !defined lint */ #endif /* !defined lint */
/* /*
** Defaults for preprocessor symbols. ** Defaults for preprocessor symbols.
** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'. ** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'.
*/ */
#ifndef HAVE_ADJTIME #ifndef HAVE_ADJTIME
#define HAVE_ADJTIME 1 #define HAVE_ADJTIME 1
#endif /* !defined HAVE_ADJTIME */ #endif /* !defined HAVE_ADJTIME */
#ifndef HAVE_GETTEXT #ifndef HAVE_GETTEXT
#define HAVE_GETTEXT 0 #define HAVE_GETTEXT 0
#endif /* !defined HAVE_GETTEXT */ #endif /* !defined HAVE_GETTEXT */
#ifndef HAVE_INCOMPATIBLE_CTIME_R #ifndef HAVE_INCOMPATIBLE_CTIME_R
#define HAVE_INCOMPATIBLE_CTIME_R 0 #define HAVE_INCOMPATIBLE_CTIME_R 0
#endif /* !defined INCOMPATIBLE_CTIME_R */ #endif /* !defined INCOMPATIBLE_CTIME_R */
#ifndef HAVE_SETTIMEOFDAY #ifndef HAVE_SETTIMEOFDAY
#define HAVE_SETTIMEOFDAY 3 #define HAVE_SETTIMEOFDAY 3
#endif /* !defined HAVE_SETTIMEOFDAY */ #endif /* !defined HAVE_SETTIMEOFDAY */
#ifndef HAVE_STRERROR #ifndef HAVE_STRERROR
#define HAVE_STRERROR 1 #define HAVE_STRERROR 1
#endif /* !defined HAVE_STRERROR */ #endif /* !defined HAVE_STRERROR */
#ifndef HAVE_SYMLINK #ifndef HAVE_SYMLINK
#define HAVE_SYMLINK 1 #define HAVE_SYMLINK 1
#endif /* !defined HAVE_SYMLINK */ #endif /* !defined HAVE_SYMLINK */
#ifndef HAVE_SYS_STAT_H #ifndef HAVE_SYS_STAT_H
#define HAVE_SYS_STAT_H 1 #define HAVE_SYS_STAT_H 1
#endif /* !defined HAVE_SYS_STAT_H */ #endif /* !defined HAVE_SYS_STAT_H */
#ifndef HAVE_SYS_WAIT_H #ifndef HAVE_SYS_WAIT_H
#define HAVE_SYS_WAIT_H 1 #define HAVE_SYS_WAIT_H 1
#endif /* !defined HAVE_SYS_WAIT_H */ #endif /* !defined HAVE_SYS_WAIT_H */
#ifndef HAVE_UNISTD_H #ifndef HAVE_UNISTD_H
#define HAVE_UNISTD_H 1 #define HAVE_UNISTD_H 1
#endif /* !defined HAVE_UNISTD_H */ #endif /* !defined HAVE_UNISTD_H */
#ifndef HAVE_UTMPX_H #ifndef HAVE_UTMPX_H
#define HAVE_UTMPX_H 0 #define HAVE_UTMPX_H 0
#endif /* !defined HAVE_UTMPX_H */ #endif /* !defined HAVE_UTMPX_H */
#ifndef LOCALE_HOME #ifndef LOCALE_HOME
#define LOCALE_HOME "/usr/lib/locale" #define LOCALE_HOME "/usr/lib/locale"
#endif /* !defined LOCALE_HOME */ #endif /* !defined LOCALE_HOME */
#if HAVE_INCOMPATIBLE_CTIME_R #if HAVE_INCOMPATIBLE_CTIME_R
#define asctime_r _incompatible_asctime_r #define asctime_r _incompatible_asctime_r
#define ctime_r _incompatible_ctime_r #define ctime_r _incompatible_ctime_r
#endif /* HAVE_INCOMPATIBLE_CTIME_R */ #endif /* HAVE_INCOMPATIBLE_CTIME_R */
/* /*
** Nested includes ** Nested includes
*/ */
#include "sys/types.h" /* for time_t */ #include "sys/types.h" /* for time_t */
#include "stdio.h" #include "stdio.h"
#include "errno.h" #include "errno.h"
#include "string.h" #include "string.h"
#include "limits.h" /* for CHAR_BIT */ #include "limits.h" /* for CHAR_BIT */
#include "time.h" #include "time.h"
#include "stdlib.h" #include "stdlib.h"
#if HAVE_GETTEXT - 0 #if HAVE_GETTEXT - 0
#include "libintl.h" #include "libintl.h"
#endif /* HAVE_GETTEXT - 0 */ #endif /* HAVE_GETTEXT - 0 */
#if HAVE_SYS_WAIT_H - 0 #if HAVE_SYS_WAIT_H - 0
#include <sys/wait.h> /* for WIFEXITED and WEXITSTATUS */ #include <sys/wait.h> /* for WIFEXITED and WEXITSTATUS */
#endif /* HAVE_SYS_WAIT_H - 0 */ #endif /* HAVE_SYS_WAIT_H - 0 */
#ifndef WIFEXITED #ifndef WIFEXITED
#define WIFEXITED(status) (((status) & 0xff) == 0) #define WIFEXITED(status) (((status) & 0xff) == 0)
#endif /* !defined WIFEXITED */ #endif /* !defined WIFEXITED */
#ifndef WEXITSTATUS #ifndef WEXITSTATUS
#define WEXITSTATUS(status) (((status) >> 8) & 0xff) #define WEXITSTATUS(status) (((status) >> 8) & 0xff)
#endif /* !defined WEXITSTATUS */ #endif /* !defined WEXITSTATUS */
#if HAVE_UNISTD_H - 0 #if HAVE_UNISTD_H - 0
#include "unistd.h" /* for F_OK and R_OK */ #include "unistd.h" /* for F_OK and R_OK */
#endif /* HAVE_UNISTD_H - 0 */ #endif /* HAVE_UNISTD_H - 0 */
#if !(HAVE_UNISTD_H - 0) #if !(HAVE_UNISTD_H - 0)
#ifndef F_OK #ifndef F_OK
#define F_OK 0 #define F_OK 0
#endif /* !defined F_OK */ #endif /* !defined F_OK */
#ifndef R_OK #ifndef R_OK
#define R_OK 4 #define R_OK 4
#endif /* !defined R_OK */ #endif /* !defined R_OK */
#endif /* !(HAVE_UNISTD_H - 0) */ #endif /* !(HAVE_UNISTD_H - 0) */
/* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */ /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX. */
#define is_digit(c) ((unsigned)(c) - '0' <= 9) #define is_digit(c) ((unsigned)(c) - '0' <= 9)
/* /*
** Workarounds for compilers/systems. ** Workarounds for compilers/systems.
*/ */
/* /*
** SunOS 4.1.1 cc lacks prototypes. ** SunOS 4.1.1 cc lacks prototypes.
*/ */
#ifndef P #ifndef P
#ifdef __STDC__ #ifdef __STDC__
#define P(x) x #define P(x) x
#endif /* defined __STDC__ */ #endif /* defined __STDC__ */
#ifndef __STDC__ #ifndef __STDC__
#define P(x) () #define P(x) ()
#endif /* !defined __STDC__ */ #endif /* !defined __STDC__ */
#endif /* !defined P */ #endif /* !defined P */
/* /*
** SunOS 4.1.1 headers lack EXIT_SUCCESS. ** SunOS 4.1.1 headers lack EXIT_SUCCESS.
*/ */
#ifndef EXIT_SUCCESS #ifndef EXIT_SUCCESS
#define EXIT_SUCCESS 0 #define EXIT_SUCCESS 0
#endif /* !defined EXIT_SUCCESS */ #endif /* !defined EXIT_SUCCESS */
/* /*
** SunOS 4.1.1 headers lack EXIT_FAILURE. ** SunOS 4.1.1 headers lack EXIT_FAILURE.
*/ */
#ifndef EXIT_FAILURE #ifndef EXIT_FAILURE
#define EXIT_FAILURE 1 #define EXIT_FAILURE 1
#endif /* !defined EXIT_FAILURE */ #endif /* !defined EXIT_FAILURE */
/* /*
** SunOS 4.1.1 headers lack FILENAME_MAX. ** SunOS 4.1.1 headers lack FILENAME_MAX.
*/ */
#ifndef FILENAME_MAX #ifndef FILENAME_MAX
#ifndef MAXPATHLEN #ifndef MAXPATHLEN
#ifdef unix #ifdef unix
#include "sys/param.h" #include "sys/param.h"
#endif /* defined unix */ #endif /* defined unix */
#endif /* !defined MAXPATHLEN */ #endif /* !defined MAXPATHLEN */
#ifdef MAXPATHLEN #ifdef MAXPATHLEN
#define FILENAME_MAX MAXPATHLEN #define FILENAME_MAX MAXPATHLEN
#endif /* defined MAXPATHLEN */ #endif /* defined MAXPATHLEN */
#ifndef MAXPATHLEN #ifndef MAXPATHLEN
#define FILENAME_MAX 1024 /* Pure guesswork */ #define FILENAME_MAX 1024 /* Pure guesswork */
#endif /* !defined MAXPATHLEN */ #endif /* !defined MAXPATHLEN */
#endif /* !defined FILENAME_MAX */ #endif /* !defined FILENAME_MAX */
/* /*
** SunOS 4.1.1 libraries lack remove. ** SunOS 4.1.1 libraries lack remove.
*/ */
#ifndef remove #ifndef remove
extern int unlink P((const char * filename)); extern int unlink P((const char * filename));
#define remove unlink #define remove unlink
#endif /* !defined remove */ #endif /* !defined remove */
/* /*
** Some ancient errno.h implementations don't declare errno. ** Some ancient errno.h implementations don't declare errno.
** But some newer errno.h implementations define it as a macro. ** But some newer errno.h implementations define it as a macro.
** Fix the former without affecting the latter. ** Fix the former without affecting the latter.
*/ */
#ifndef errno #ifndef errno
extern int errno; extern int errno;
#endif /* !defined errno */ #endif /* !defined errno */
/* /*
** Private function declarations. ** Private function declarations.
*/ */
char * icalloc P((int nelem, int elsize)); char * icalloc P((int nelem, int elsize));
char * icatalloc P((char * old, const char * new)); char * icatalloc P((char * old, const char * new));
char * icpyalloc P((const char * string)); char * icpyalloc P((const char * string));
char * imalloc P((int n)); char * imalloc P((int n));
void * irealloc P((void * pointer, int size)); void * irealloc P((void * pointer, int size));
void icfree P((char * pointer)); void icfree P((char * pointer));
void ifree P((char * pointer)); void ifree P((char * pointer));
char * scheck P((const char *string, const char *format)); char * scheck P((const char *string, const char *format));
/* /*
** Finally, some convenience items. ** Finally, some convenience items.
*/ */
#ifndef TRUE #ifndef TRUE
#define TRUE 1 #define TRUE 1
#endif /* !defined TRUE */ #endif /* !defined TRUE */
#ifndef FALSE #ifndef FALSE
#define FALSE 0 #define FALSE 0
#endif /* !defined FALSE */ #endif /* !defined FALSE */
#ifndef TYPE_BIT #ifndef TYPE_BIT
#define TYPE_BIT(type) (sizeof (type) * CHAR_BIT) #define TYPE_BIT(type) (sizeof (type) * CHAR_BIT)
#endif /* !defined TYPE_BIT */ #endif /* !defined TYPE_BIT */
#ifndef TYPE_SIGNED #ifndef TYPE_SIGNED
#define TYPE_SIGNED(type) (((type) -1) < 0) #define TYPE_SIGNED(type) (((type) -1) < 0)
#endif /* !defined TYPE_SIGNED */ #endif /* !defined TYPE_SIGNED */
#ifndef INT_STRLEN_MAXIMUM #ifndef INT_STRLEN_MAXIMUM
/* /*
** 302 / 1000 is log10(2.0) rounded up. ** 302 / 1000 is log10(2.0) rounded up.
** Subtract one for the sign bit if the type is signed; ** Subtract one for the sign bit if the type is signed;
** add one for integer division truncation; ** add one for integer division truncation;
** add one more for a minus sign if the type is signed. ** add one more for a minus sign if the type is signed.
*/ */
#define INT_STRLEN_MAXIMUM(type) \ #define INT_STRLEN_MAXIMUM(type) \
((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type)) ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type))
#endif /* !defined INT_STRLEN_MAXIMUM */ #endif /* !defined INT_STRLEN_MAXIMUM */
/* /*
** INITIALIZE(x) ** INITIALIZE(x)
*/ */
#ifndef GNUC_or_lint #ifndef GNUC_or_lint
#ifdef lint #ifdef lint
#define GNUC_or_lint #define GNUC_or_lint
#endif /* defined lint */ #endif /* defined lint */
#ifndef lint #ifndef lint
#ifdef __GNUC__ #ifdef __GNUC__
#define GNUC_or_lint #define GNUC_or_lint
#endif /* defined __GNUC__ */ #endif /* defined __GNUC__ */
#endif /* !defined lint */ #endif /* !defined lint */
#endif /* !defined GNUC_or_lint */ #endif /* !defined GNUC_or_lint */
#ifndef INITIALIZE #ifndef INITIALIZE
#ifdef GNUC_or_lint #ifdef GNUC_or_lint
#define INITIALIZE(x) ((x) = 0) #define INITIALIZE(x) ((x) = 0)
#endif /* defined GNUC_or_lint */ #endif /* defined GNUC_or_lint */
#ifndef GNUC_or_lint #ifndef GNUC_or_lint
#define INITIALIZE(x) #define INITIALIZE(x)
#endif /* !defined GNUC_or_lint */ #endif /* !defined GNUC_or_lint */
#endif /* !defined INITIALIZE */ #endif /* !defined INITIALIZE */
/* /*
** For the benefit of GNU folk... ** For the benefit of GNU folk...
** `_(MSGID)' uses the current locale's message library string for MSGID. ** `_(MSGID)' uses the current locale's message library string for MSGID.
** The default is to use gettext if available, and use MSGID otherwise. ** The default is to use gettext if available, and use MSGID otherwise.
*/ */
#ifndef _ #ifndef _
#if HAVE_GETTEXT - 0 #if HAVE_GETTEXT - 0
#define _(msgid) gettext(msgid) #define _(msgid) gettext(msgid)
#else /* !(HAVE_GETTEXT - 0) */ #else /* !(HAVE_GETTEXT - 0) */
#define _(msgid) msgid #define _(msgid) msgid
#endif /* !(HAVE_GETTEXT - 0) */ #endif /* !(HAVE_GETTEXT - 0) */
#endif /* !defined _ */ #endif /* !defined _ */
#ifndef TZ_DOMAIN #ifndef TZ_DOMAIN
#define TZ_DOMAIN "tz" #define TZ_DOMAIN "tz"
#endif /* !defined TZ_DOMAIN */ #endif /* !defined TZ_DOMAIN */
#if HAVE_INCOMPATIBLE_CTIME_R #if HAVE_INCOMPATIBLE_CTIME_R
#undef asctime_r #undef asctime_r
#undef ctime_r #undef ctime_r
char *asctime_r P((struct tm const *, char *)); char *asctime_r P((struct tm const *, char *));
char *ctime_r P((time_t const *, char *)); char *ctime_r P((time_t const *, char *));
#endif /* HAVE_INCOMPATIBLE_CTIME_R */ #endif /* HAVE_INCOMPATIBLE_CTIME_R */
/* /*
** UNIX was a registered trademark of The Open Group in 2003. ** UNIX was a registered trademark of The Open Group in 2003.
*/ */
#endif /* !defined PRIVATE_H */ #endif /* !defined PRIVATE_H */

View File

@ -1,59 +1,59 @@
#ifndef lint #ifndef lint
#ifndef NOID #ifndef NOID
static char elsieid[] = "@(#)scheck.c 8.15"; static char elsieid[] = "@(#)scheck.c 8.15";
#endif /* !defined lint */ #endif /* !defined lint */
#endif /* !defined NOID */ #endif /* !defined NOID */
/*LINTLIBRARY*/ /*LINTLIBRARY*/
#include "private.h" #include "private.h"
char * char *
scheck(string, format) scheck(string, format)
const char * const string; const char * const string;
const char * const format; const char * const format;
{ {
register char * fbuf; register char * fbuf;
register const char * fp; register const char * fp;
register char * tp; register char * tp;
register int c; register int c;
register char * result; register char * result;
char dummy; char dummy;
static char nada; static char nada;
result = &nada; result = &nada;
if (string == NULL || format == NULL) if (string == NULL || format == NULL)
return result; return result;
fbuf = imalloc((int) (2 * strlen(format) + 4)); fbuf = imalloc((int) (2 * strlen(format) + 4));
if (fbuf == NULL) if (fbuf == NULL)
return result; return result;
fp = format; fp = format;
tp = fbuf; tp = fbuf;
while ((*tp++ = c = *fp++) != '\0') { while ((*tp++ = c = *fp++) != '\0') {
if (c != '%') if (c != '%')
continue; continue;
if (*fp == '%') { if (*fp == '%') {
*tp++ = *fp++; *tp++ = *fp++;
continue; continue;
} }
*tp++ = '*'; *tp++ = '*';
if (*fp == '*') if (*fp == '*')
++fp; ++fp;
while (is_digit(*fp)) while (is_digit(*fp))
*tp++ = *fp++; *tp++ = *fp++;
if (*fp == 'l' || *fp == 'h') if (*fp == 'l' || *fp == 'h')
*tp++ = *fp++; *tp++ = *fp++;
else if (*fp == '[') else if (*fp == '[')
do *tp++ = *fp++; do *tp++ = *fp++;
while (*fp != '\0' && *fp != ']'); while (*fp != '\0' && *fp != ']');
if ((*tp++ = *fp++) == '\0') if ((*tp++ = *fp++) == '\0')
break; break;
} }
*(tp - 1) = '%'; *(tp - 1) = '%';
*tp++ = 'c'; *tp++ = 'c';
*tp = '\0'; *tp = '\0';
if (sscanf(string, fbuf, &dummy) != 1) if (sscanf(string, fbuf, &dummy) != 1)
result = (char *) format; result = (char *) format;
ifree(fbuf); ifree(fbuf);
return result; return result;
} }

View File

@ -1,188 +1,188 @@
#ifndef TZFILE_H #ifndef TZFILE_H
#define TZFILE_H #define TZFILE_H
/* /*
** This file is in the public domain, so clarified as of ** This file is in the public domain, so clarified as of
** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov). ** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
*/ */
/* /*
** This header is for use ONLY with the time conversion code. ** This header is for use ONLY with the time conversion code.
** There is no guarantee that it will remain unchanged, ** There is no guarantee that it will remain unchanged,
** or that it will remain at all. ** or that it will remain at all.
** Do NOT copy it to any system include directory. ** Do NOT copy it to any system include directory.
** Thank you! ** Thank you!
*/ */
/* /*
** ID ** ID
*/ */
#ifndef lint #ifndef lint
#ifndef NOID #ifndef NOID
static char tzfilehid[] = "@(#)tzfile.h 7.14"; static char tzfilehid[] = "@(#)tzfile.h 7.14";
#endif /* !defined NOID */ #endif /* !defined NOID */
#endif /* !defined lint */ #endif /* !defined lint */
/* /*
** Information about time zone files. ** Information about time zone files.
*/ */
#ifndef TZDIR #ifndef TZDIR
#define TZDIR "/usr/local/etc/zoneinfo" /* Time zone object file directory */ #define TZDIR "/usr/local/etc/zoneinfo" /* Time zone object file directory */
#endif /* !defined TZDIR */ #endif /* !defined TZDIR */
#ifndef TZDEFAULT #ifndef TZDEFAULT
#define TZDEFAULT "localtime" #define TZDEFAULT "localtime"
#endif /* !defined TZDEFAULT */ #endif /* !defined TZDEFAULT */
#ifndef TZDEFRULES #ifndef TZDEFRULES
#define TZDEFRULES "posixrules" #define TZDEFRULES "posixrules"
#endif /* !defined TZDEFRULES */ #endif /* !defined TZDEFRULES */
/* /*
** Each file begins with. . . ** Each file begins with. . .
*/ */
#define TZ_MAGIC "TZif" #define TZ_MAGIC "TZif"
struct tzhead { struct tzhead {
char tzh_magic[4]; /* TZ_MAGIC */ char tzh_magic[4]; /* TZ_MAGIC */
char tzh_reserved[16]; /* reserved for future use */ char tzh_reserved[16]; /* reserved for future use */
char tzh_ttisgmtcnt[4]; /* coded number of trans. time flags */ char tzh_ttisgmtcnt[4]; /* coded number of trans. time flags */
char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */ char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */
char tzh_leapcnt[4]; /* coded number of leap seconds */ char tzh_leapcnt[4]; /* coded number of leap seconds */
char tzh_timecnt[4]; /* coded number of transition times */ char tzh_timecnt[4]; /* coded number of transition times */
char tzh_typecnt[4]; /* coded number of local time types */ char tzh_typecnt[4]; /* coded number of local time types */
char tzh_charcnt[4]; /* coded number of abbr. chars */ char tzh_charcnt[4]; /* coded number of abbr. chars */
}; };
/* /*
** . . .followed by. . . ** . . .followed by. . .
** **
** tzh_timecnt (char [4])s coded transition times a la time(2) ** tzh_timecnt (char [4])s coded transition times a la time(2)
** tzh_timecnt (unsigned char)s types of local time starting at above ** tzh_timecnt (unsigned char)s types of local time starting at above
** tzh_typecnt repetitions of ** tzh_typecnt repetitions of
** one (char [4]) coded UTC offset in seconds ** one (char [4]) coded UTC offset in seconds
** one (unsigned char) used to set tm_isdst ** one (unsigned char) used to set tm_isdst
** one (unsigned char) that's an abbreviation list index ** one (unsigned char) that's an abbreviation list index
** tzh_charcnt (char)s '\0'-terminated zone abbreviations ** tzh_charcnt (char)s '\0'-terminated zone abbreviations
** tzh_leapcnt repetitions of ** tzh_leapcnt repetitions of
** one (char [4]) coded leap second transition times ** one (char [4]) coded leap second transition times
** one (char [4]) total correction after above ** one (char [4]) total correction after above
** tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition ** tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition
** time is standard time, if FALSE, ** time is standard time, if FALSE,
** transition time is wall clock time ** transition time is wall clock time
** if absent, transition times are ** if absent, transition times are
** assumed to be wall clock time ** assumed to be wall clock time
** tzh_ttisgmtcnt (char)s indexed by type; if TRUE, transition ** tzh_ttisgmtcnt (char)s indexed by type; if TRUE, transition
** time is UTC, if FALSE, ** time is UTC, if FALSE,
** transition time is local time ** transition time is local time
** if absent, transition times are ** if absent, transition times are
** assumed to be local time ** assumed to be local time
*/ */
/* /*
** In the current implementation, "tzset()" refuses to deal with files that ** In the current implementation, "tzset()" refuses to deal with files that
** exceed any of the limits below. ** exceed any of the limits below.
*/ */
#ifndef TZ_MAX_TIMES #ifndef TZ_MAX_TIMES
/* /*
** The TZ_MAX_TIMES value below is enough to handle a bit more than a ** The TZ_MAX_TIMES value below is enough to handle a bit more than a
** year's worth of solar time (corrected daily to the nearest second) or ** year's worth of solar time (corrected daily to the nearest second) or
** 138 years of Pacific Presidential Election time ** 138 years of Pacific Presidential Election time
** (where there are three time zone transitions every fourth year). ** (where there are three time zone transitions every fourth year).
*/ */
#define TZ_MAX_TIMES 370 #define TZ_MAX_TIMES 370
#endif /* !defined TZ_MAX_TIMES */ #endif /* !defined TZ_MAX_TIMES */
#ifndef TZ_MAX_TYPES #ifndef TZ_MAX_TYPES
#ifndef NOSOLAR #ifndef NOSOLAR
#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */ #define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */
#endif /* !defined NOSOLAR */ #endif /* !defined NOSOLAR */
#ifdef NOSOLAR #ifdef NOSOLAR
/* /*
** Must be at least 14 for Europe/Riga as of Jan 12 1995, ** Must be at least 14 for Europe/Riga as of Jan 12 1995,
** as noted by Earl Chew <earl@hpato.aus.hp.com>. ** as noted by Earl Chew <earl@hpato.aus.hp.com>.
*/ */
#define TZ_MAX_TYPES 20 /* Maximum number of local time types */ #define TZ_MAX_TYPES 20 /* Maximum number of local time types */
#endif /* !defined NOSOLAR */ #endif /* !defined NOSOLAR */
#endif /* !defined TZ_MAX_TYPES */ #endif /* !defined TZ_MAX_TYPES */
#ifndef TZ_MAX_CHARS #ifndef TZ_MAX_CHARS
#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */ #define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */
/* (limited by what unsigned chars can hold) */ /* (limited by what unsigned chars can hold) */
#endif /* !defined TZ_MAX_CHARS */ #endif /* !defined TZ_MAX_CHARS */
#ifndef TZ_MAX_LEAPS #ifndef TZ_MAX_LEAPS
#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */ #define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */
#endif /* !defined TZ_MAX_LEAPS */ #endif /* !defined TZ_MAX_LEAPS */
#define SECSPERMIN 60 #define SECSPERMIN 60
#define MINSPERHOUR 60 #define MINSPERHOUR 60
#define HOURSPERDAY 24 #define HOURSPERDAY 24
#define DAYSPERWEEK 7 #define DAYSPERWEEK 7
#define DAYSPERNYEAR 365 #define DAYSPERNYEAR 365
#define DAYSPERLYEAR 366 #define DAYSPERLYEAR 366
#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR) #define SECSPERHOUR (SECSPERMIN * MINSPERHOUR)
#define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY) #define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY)
#define MONSPERYEAR 12 #define MONSPERYEAR 12
#define TM_SUNDAY 0 #define TM_SUNDAY 0
#define TM_MONDAY 1 #define TM_MONDAY 1
#define TM_TUESDAY 2 #define TM_TUESDAY 2
#define TM_WEDNESDAY 3 #define TM_WEDNESDAY 3
#define TM_THURSDAY 4 #define TM_THURSDAY 4
#define TM_FRIDAY 5 #define TM_FRIDAY 5
#define TM_SATURDAY 6 #define TM_SATURDAY 6
#define TM_JANUARY 0 #define TM_JANUARY 0
#define TM_FEBRUARY 1 #define TM_FEBRUARY 1
#define TM_MARCH 2 #define TM_MARCH 2
#define TM_APRIL 3 #define TM_APRIL 3
#define TM_MAY 4 #define TM_MAY 4
#define TM_JUNE 5 #define TM_JUNE 5
#define TM_JULY 6 #define TM_JULY 6
#define TM_AUGUST 7 #define TM_AUGUST 7
#define TM_SEPTEMBER 8 #define TM_SEPTEMBER 8
#define TM_OCTOBER 9 #define TM_OCTOBER 9
#define TM_NOVEMBER 10 #define TM_NOVEMBER 10
#define TM_DECEMBER 11 #define TM_DECEMBER 11
#define TM_YEAR_BASE 1900 #define TM_YEAR_BASE 1900
#define EPOCH_YEAR 1970 #define EPOCH_YEAR 1970
#define EPOCH_WDAY TM_THURSDAY #define EPOCH_WDAY TM_THURSDAY
/* /*
** Accurate only for the past couple of centuries; ** Accurate only for the past couple of centuries;
** that will probably do. ** that will probably do.
*/ */
#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) #define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
#ifndef USG #ifndef USG
/* /*
** Use of the underscored variants may cause problems if you move your code to ** Use of the underscored variants may cause problems if you move your code to
** certain System-V-based systems; for maximum portability, use the ** certain System-V-based systems; for maximum portability, use the
** underscore-free variants. The underscored variants are provided for ** underscore-free variants. The underscored variants are provided for
** backward compatibility only; they may disappear from future versions of ** backward compatibility only; they may disappear from future versions of
** this file. ** this file.
*/ */
#define SECS_PER_MIN SECSPERMIN #define SECS_PER_MIN SECSPERMIN
#define MINS_PER_HOUR MINSPERHOUR #define MINS_PER_HOUR MINSPERHOUR
#define HOURS_PER_DAY HOURSPERDAY #define HOURS_PER_DAY HOURSPERDAY
#define DAYS_PER_WEEK DAYSPERWEEK #define DAYS_PER_WEEK DAYSPERWEEK
#define DAYS_PER_NYEAR DAYSPERNYEAR #define DAYS_PER_NYEAR DAYSPERNYEAR
#define DAYS_PER_LYEAR DAYSPERLYEAR #define DAYS_PER_LYEAR DAYSPERLYEAR
#define SECS_PER_HOUR SECSPERHOUR #define SECS_PER_HOUR SECSPERHOUR
#define SECS_PER_DAY SECSPERDAY #define SECS_PER_DAY SECSPERDAY
#define MONS_PER_YEAR MONSPERYEAR #define MONS_PER_YEAR MONSPERYEAR
#endif /* !defined USG */ #endif /* !defined USG */
#endif /* !defined TZFILE_H */ #endif /* !defined TZFILE_H */

File diff suppressed because it is too large Load Diff