From 4832a677bdc5f8b057d74087ff1eecc969fd52b9 Mon Sep 17 00:00:00 2001
From: Stefan Farfeleder
Date: Sun, 20 Jun 2004 12:04:00 +0000
Subject: [PATCH 001/453] Remove files no longer on the vendor branch.
---
usr.sbin/zic/Arts.htm | 177 ------------------------------------------
usr.sbin/zic/WWW.htm | 97 -----------------------
2 files changed, 274 deletions(-)
delete mode 100644 usr.sbin/zic/Arts.htm
delete mode 100644 usr.sbin/zic/WWW.htm
diff --git a/usr.sbin/zic/Arts.htm b/usr.sbin/zic/Arts.htm
deleted file mode 100644
index 39dcab7cd19..00000000000
--- a/usr.sbin/zic/Arts.htm
+++ /dev/null
@@ -1,177 +0,0 @@
-
-
-
-Time and the Arts
-
-
-Time and the Arts
-
-
-@(#)Arts.htm 7.18
-
-
-
-Data on recordings of "Save That Time," Russ Long, Serrob Publishing, BMI:
---------------------------------------------------------------------------
-Artist: Karrin Allyson
-CD: I Didn't Know About You
-Copyright Date: 1993
-Label: Concord Jazz, Inc.
-ID: CCD-4543
-Track Time: 3:44
-Personnel: Karrin Allyson, vocal
- Russ Long, piano
- Gerald Spaits, bass
- Todd Strait, drums
-Notes: CD notes "additional lyric by Karrin Allyson;
- arranged by Russ Long and Karrin Allyson"
-ADO Rating: 1 star
-AMG Rating: 3.5 stars
-Penguin Rating: 3.5 stars
---------------------------------------------------------------------------
-Artist: Kevin Mahogany
-CD: Double Rainbow
-Copyright Date: 1993
-Label: Enja Records
-ID: ENJ-7097 2
-Track Time: 6:27
-Personnel: Kevin Mahogany, vocal
- Kenny Barron, piano
- Ray Drummond, bss
- Ralph Moore, tenor saxophone
- Lewis Nash, drums
-ADO Rating: 1.5 stars
-AMG Rating: unrated
-Penguin Rating: 3 stars
---------------------------------------------------------------------------
-Artist: Joe Williams
-CD: Here's to Life
-Copyright Date: 1994
-Label: Telarc International Corporation
-ID: CD-83357
-Track Time: 3:58
-Personnel: Joe Williams, vocal
- The Robert Farnon [39 piece] Orchestra
-Notes: On-line information and samples available at
- http://telarc.dmn.com/telarc/releases/release.req?ID=83357
-ADO Rating: black dot
-AMG Rating: 2 stars
-Penguin Rating: 3 stars
---------------------------------------------------------------------------
-Artist: Charles Fambrough
-CD: Keeper of the Spirit
-Copyright Date: 1995
-Label: AudioQuest Music
-ID: AQ-CD1033
-Track Time: 7:07
-Personnel: Charles Fambrough, bass
- Joel Levine, tenor recorder
- Edward Simon, piano
- Lenny White, drums
- Marion Simon, percussion
-Notes: On-line information and samples available at
- http://wwmusic.com/~music/audioq/rel/1033.html
-ADO Rating: 2 stars
-AMG Rating: unrated
-Penguin Rating: 3 stars
-==========================================================================
-Also of note:
---------------------------------------------------------------------------
-Artist: Holly Cole Trio
-CD: Blame It On My Youth
-Copyright Date: 1992
-Label: Manhattan
-ID: CDP 7 97349 2
-Total Time: 37:45
-Personnel: Holly Cole, voice
- Aaron Davis, piano
- David Piltch, string bass
-Notes: Lyrical reference to "Eastern Standard Time" in
- Tom Waits' "Purple Avenue"
-ADO Rating: 2.5 stars
-AMG Rating: 2 stars
-Penguin Rating: unrated
---------------------------------------------------------------------------
-Artist: Milt Hinton
-CD: Old Man Time
-Copyright Date: 1990
-Label: Chiaroscuro
-ID: CR(D) 310
-Total Time: 149:38 (two CDs)
-Personnel: Milt Hinton, bass
- Doc Cheatham, Dizzy Gillespie, Clark Terry, trumpet
- Al Grey, trombone
- Eddie Barefield, Joe Camel (Flip Phillips), Buddy Tate,
- clarinet and saxophone
- John Bunch, Red Richards, Norman Simmons, Derek Smith,
- Ralph Sutton, piano
- Danny Barker, Al Casey, guitar
- Gus Johnson, Gerryck King, Bob Rosengarden, Jackie Williams,
- drums
- Lionel Hampton, vibraphone
- Cab Calloway, Joe Williams, vocal
- Buck Clayton, arrangements
-Notes: tunes include Old Man Time, Time After Time,
- Sometimes I'm Happy,
- A Hot Time in the Old Town Tonight,
- Four or Five Times, Now's the Time,
- Time on My Hands, This Time It's Us,
- and Good Time Charlie
- On-line samples available at
- http://www.globalmusic.com/labels/chiaroscuro/chiaro_cd_gallery.html
-ADO Rating: 3 stars
-AMG Rating: 4.5 stars
-Penguin Rating: 3 stars
---------------------------------------------------------------------------
-Artist: Paul Broadbent
-CD: Pacific Standard Time
-Copyright Date: 1995
-Label: Concord Jazz, Inc.
-ID: CCD-4664
-Total Time: 62:42
-Personnel: Paul Broadbent, piano
- Putter Smith, Bass
- Frank Gibson, Jr., drums
-Notes: The CD cover features an analemma for equation of time fans
-ADO Rating: 1 star
-AMG Rating: 3 stars
-Penguin Rating: 3.5 stars
---------------------------------------------------------------------------
-Artist: Anthony Braxton/Richard Teitelbaum
-CD: Silence/Time Zones
-Copyright Date: 1996
-Label: Black Lion
-ID: BLCD 760221
-Total Time: 72:58
-Personnel: Anthony Braxton, sporanino and alto saxophones,
- contrebasse clarinet, miscellaneous instruments
- Leo Smith, trumpet and miscellaneous instruments
- Leroy Jenkins, violin and miscellaneous instruments
- Richard Teitelbaum, modular moog and micromoog synthesizer
-ADO Rating: black dot
-AMG Rating: unrated
---------------------------------------------------------------------------
-Artist: Jules Verne
-Book: Le Tour du Monde en Quatre-Vingts Jours
- (Around the World in Eighty Days)
-Notes: Wall-clock time plays a central role in the plot.
- European readers of the 1870s clearly held the U.S. press in
- deep contempt; the protagonists cross the U.S. without once
- reading a paper.
- An on-line French-language version of the book
- "with illustrations from the original 1873 French-language edition"
- is available at
- http://fourmilab.ch/etexts/www/tdm80j
- An on-line English-language translation of the book is available at
- http://www.literature.org/Works/Jules-Verne/eighty
---------------------------------------------------------------------------
-Film: Bell Science - About Time
-Notes: The Frank Baxter/Richard Deacon extravaganza
- Information on ordering is available at
- http://www.videoflicks.com/VF/38/038332.htm
---------------------------------------------------------------------------
-The syndicated comic strip "Dilbert" featured an all-too-rare example of
-time zone humor on 1998-03-14.
-
-
-
diff --git a/usr.sbin/zic/WWW.htm b/usr.sbin/zic/WWW.htm
deleted file mode 100644
index 2151c898e37..00000000000
--- a/usr.sbin/zic/WWW.htm
+++ /dev/null
@@ -1,97 +0,0 @@
-
-
-
-Sources for Time Zone and Daylight Saving Time Data
-
-
-Sources for Time Zone and Daylight Saving Time Data
-
-
-@(#)WWW.htm 7.16
-
-Paul Eggert writes:
-The public-domain tz database contains code and data
-that represent the history of local time
-for many representative locations around the globe.
-It is updated periodically to reflect changes made by political bodies
-to UTC offsets and daylight-saving rules.
-This database (often called zoneinfo)
-is used by several implementations,
-including BSD, DJGPP, GNU/Linux, HP-UX, IRIX, Solaris, and UnixWare.
-In the tz database's
-FTP distribution,
-the code is in the file tzcodeC.tar.gz,
-where C is the code's version;
-similarly, the data are in tzdataD.tar.gz,
-where D is the data's version.
-
-The GNU C Library
-has an independent, thread-safe implementation of
-a time zone file reader.
-This library is freely available under the GNU Library General Public License,
-and is widely used in GNU/Linux systems.
-
-The Web has several other sources for time zone and daylight saving time data.
-Here are some recent links that may be of interest.
-
-- Date and Time Gateway
-is a text-based source for tables of current time throughout the world.
-Its point-and-click interface accesses a recent version of the tz data.
-
- WORLDTIME: interactive atlas,
-time info, public holidays
-contains information on local time, sunrise and sunset,
-and public holidays in several hundred cities around the world.
-
- Local Times Around the World
-is a text-based system containing links to local time servers
-throughout the world; though the coverage is limited,
-the live data provide a nice way to check one's tables.
-
- World Time Zones
-contains US Naval Observatory data, used as the source
-for the usno* files.
-
- The United States Central Intelligence agency publishes time zone maps;
-the
-
-Perry-Castañeda Library Map Collection
-of the University of Texas at Austin has on-line copies of
-the 1995 and 1997 editions.
-The pictorial quality is good,
-but the maps do not indicate summer time,
-and parts of the data are a few years out of date.
-
- The
-Time of Internet
-contains good descriptions of Time Zones and daylight saving time,
-with diagrams.
-The time zone map is out of date, however.
-
- A
-Few Facts Concerning GMT, UT, and the RGO
-answers questions like ``What is the difference between GMT and UTC?''
-
- Daylight
-Saving Time -- Saving Time, Saving Energy
-is a history of DST in the US.
-
- Yahoo! - Science:Measurements and Units:Time:Time Zones
-is where the famous Internet indexing service Yahoo! collects its time zone
-info.
-
- The International Air Transport Association
-publishes the IATA Standard Schedules Information Manual (SSIM),
-which gives current time zone rules for
-all the airports served by commercial aviation.
-
- Bulletins
-of IERS contains official publications of the
-International Earth Rotation Service, the committee that decides
-when leap seconds occur.
-
-
--- eggert@twinsun.com
-(1998-09-22)
-
-Arthur David Olson writes:
-A good source of information about ISO 8601 seems to be
-International
-Standard Date and Time Notation
-maintained by Markus Kuhn.
-
--- arthur_david_olson@nih.gov
-(1996-01-04)
-
-
-
From 5197bde3b8832b8061853c0e72f300f16c10b9ed Mon Sep 17 00:00:00 2001
From: Edwin Groothuis
Date: Sat, 27 Sep 2008 11:30:00 +0000
Subject: [PATCH 002/453] Flatten the dist tree of vendor/tzcode
---
{lib/libc => libc}/stdtime/asctime.c | 0
{lib/libc => libc}/stdtime/difftime.c | 0
{lib/libc => libc}/stdtime/localtime.c | 0
{lib/libc => libc}/stdtime/private.h | 0
{lib/libc => libc}/stdtime/strftime.c | 0
{lib/libc => libc}/stdtime/time2posix.3 | 0
{lib/libc => libc}/stdtime/tzfile.5 | 0
{lib/libc => libc}/stdtime/tzfile.h | 0
{usr.sbin/zic => zic}/Makefile | 0
{usr.sbin/zic => zic}/Music | 0
{usr.sbin/zic => zic}/README | 0
{usr.sbin/zic => zic}/Theory | 0
{usr.sbin/zic => zic}/WWW | 0
{usr.sbin/zic => zic}/ialloc.c | 0
{usr.sbin/zic => zic}/private.h | 0
{usr.sbin/zic => zic}/scheck.c | 0
{usr.sbin/zic => zic}/tz-art.htm | 0
{usr.sbin/zic => zic}/tz-link.htm | 0
{usr.sbin/zic => zic}/zdump.8 | 0
{usr.sbin/zic => zic}/zdump.c | 0
{usr.sbin/zic => zic}/zic.8 | 0
{usr.sbin/zic => zic}/zic.c | 0
22 files changed, 0 insertions(+), 0 deletions(-)
rename {lib/libc => libc}/stdtime/asctime.c (100%)
rename {lib/libc => libc}/stdtime/difftime.c (100%)
rename {lib/libc => libc}/stdtime/localtime.c (100%)
rename {lib/libc => libc}/stdtime/private.h (100%)
rename {lib/libc => libc}/stdtime/strftime.c (100%)
rename {lib/libc => libc}/stdtime/time2posix.3 (100%)
rename {lib/libc => libc}/stdtime/tzfile.5 (100%)
rename {lib/libc => libc}/stdtime/tzfile.h (100%)
rename {usr.sbin/zic => zic}/Makefile (100%)
rename {usr.sbin/zic => zic}/Music (100%)
rename {usr.sbin/zic => zic}/README (100%)
rename {usr.sbin/zic => zic}/Theory (100%)
rename {usr.sbin/zic => zic}/WWW (100%)
rename {usr.sbin/zic => zic}/ialloc.c (100%)
rename {usr.sbin/zic => zic}/private.h (100%)
rename {usr.sbin/zic => zic}/scheck.c (100%)
rename {usr.sbin/zic => zic}/tz-art.htm (100%)
rename {usr.sbin/zic => zic}/tz-link.htm (100%)
rename {usr.sbin/zic => zic}/zdump.8 (100%)
rename {usr.sbin/zic => zic}/zdump.c (100%)
rename {usr.sbin/zic => zic}/zic.8 (100%)
rename {usr.sbin/zic => zic}/zic.c (100%)
diff --git a/lib/libc/stdtime/asctime.c b/libc/stdtime/asctime.c
similarity index 100%
rename from lib/libc/stdtime/asctime.c
rename to libc/stdtime/asctime.c
diff --git a/lib/libc/stdtime/difftime.c b/libc/stdtime/difftime.c
similarity index 100%
rename from lib/libc/stdtime/difftime.c
rename to libc/stdtime/difftime.c
diff --git a/lib/libc/stdtime/localtime.c b/libc/stdtime/localtime.c
similarity index 100%
rename from lib/libc/stdtime/localtime.c
rename to libc/stdtime/localtime.c
diff --git a/lib/libc/stdtime/private.h b/libc/stdtime/private.h
similarity index 100%
rename from lib/libc/stdtime/private.h
rename to libc/stdtime/private.h
diff --git a/lib/libc/stdtime/strftime.c b/libc/stdtime/strftime.c
similarity index 100%
rename from lib/libc/stdtime/strftime.c
rename to libc/stdtime/strftime.c
diff --git a/lib/libc/stdtime/time2posix.3 b/libc/stdtime/time2posix.3
similarity index 100%
rename from lib/libc/stdtime/time2posix.3
rename to libc/stdtime/time2posix.3
diff --git a/lib/libc/stdtime/tzfile.5 b/libc/stdtime/tzfile.5
similarity index 100%
rename from lib/libc/stdtime/tzfile.5
rename to libc/stdtime/tzfile.5
diff --git a/lib/libc/stdtime/tzfile.h b/libc/stdtime/tzfile.h
similarity index 100%
rename from lib/libc/stdtime/tzfile.h
rename to libc/stdtime/tzfile.h
diff --git a/usr.sbin/zic/Makefile b/zic/Makefile
similarity index 100%
rename from usr.sbin/zic/Makefile
rename to zic/Makefile
diff --git a/usr.sbin/zic/Music b/zic/Music
similarity index 100%
rename from usr.sbin/zic/Music
rename to zic/Music
diff --git a/usr.sbin/zic/README b/zic/README
similarity index 100%
rename from usr.sbin/zic/README
rename to zic/README
diff --git a/usr.sbin/zic/Theory b/zic/Theory
similarity index 100%
rename from usr.sbin/zic/Theory
rename to zic/Theory
diff --git a/usr.sbin/zic/WWW b/zic/WWW
similarity index 100%
rename from usr.sbin/zic/WWW
rename to zic/WWW
diff --git a/usr.sbin/zic/ialloc.c b/zic/ialloc.c
similarity index 100%
rename from usr.sbin/zic/ialloc.c
rename to zic/ialloc.c
diff --git a/usr.sbin/zic/private.h b/zic/private.h
similarity index 100%
rename from usr.sbin/zic/private.h
rename to zic/private.h
diff --git a/usr.sbin/zic/scheck.c b/zic/scheck.c
similarity index 100%
rename from usr.sbin/zic/scheck.c
rename to zic/scheck.c
diff --git a/usr.sbin/zic/tz-art.htm b/zic/tz-art.htm
similarity index 100%
rename from usr.sbin/zic/tz-art.htm
rename to zic/tz-art.htm
diff --git a/usr.sbin/zic/tz-link.htm b/zic/tz-link.htm
similarity index 100%
rename from usr.sbin/zic/tz-link.htm
rename to zic/tz-link.htm
diff --git a/usr.sbin/zic/zdump.8 b/zic/zdump.8
similarity index 100%
rename from usr.sbin/zic/zdump.8
rename to zic/zdump.8
diff --git a/usr.sbin/zic/zdump.c b/zic/zdump.c
similarity index 100%
rename from usr.sbin/zic/zdump.c
rename to zic/zdump.c
diff --git a/usr.sbin/zic/zic.8 b/zic/zic.8
similarity index 100%
rename from usr.sbin/zic/zic.8
rename to zic/zic.8
diff --git a/usr.sbin/zic/zic.c b/zic/zic.c
similarity index 100%
rename from usr.sbin/zic/zic.c
rename to zic/zic.c
From 9556ff65cd40f2afcdbab50cd76fc44ed2d3dcc3 Mon Sep 17 00:00:00 2001
From: Edwin Groothuis
Date: Sat, 27 Sep 2008 12:24:26 +0000
Subject: [PATCH 003/453] Cleanup of vendor/tzcode/dist, these files don't
exist in the latest imported sources.
---
libc/stdtime/time2posix.3 | 119 -------------
libc/stdtime/tzfile.5 | 138 --------------
zic/Makefile | 365 --------------------------------------
zic/WWW | 71 --------
4 files changed, 693 deletions(-)
delete mode 100644 libc/stdtime/time2posix.3
delete mode 100644 libc/stdtime/tzfile.5
delete mode 100644 zic/Makefile
delete mode 100644 zic/WWW
diff --git a/libc/stdtime/time2posix.3 b/libc/stdtime/time2posix.3
deleted file mode 100644
index 846a52ed193..00000000000
--- a/libc/stdtime/time2posix.3
+++ /dev/null
@@ -1,119 +0,0 @@
-.TH TIME2POSIX 3
-.SH NAME
-time2posix, posix2time \- convert seconds since the Epoch
-.SH SYNOPSIS
-.nf
-.B #include
-.B #include
-.PP
-.B time_t time2posix(t)
-.B time_t t
-.PP
-.B time_t posix2time(t)
-.B time_t t
-.PP
-.B cc ... -lz
-.fi
-.SH DESCRIPTION
-IEEE Standard 1003.1
-(POSIX)
-legislates that a time_t value of
-536457599 shall correspond to "Wed Dec 31 23:59:59 GMT 1986."
-This effectively implies that POSIX time_t's cannot include leap
-seconds and,
-therefore,
-that the system time must be adjusted as each leap occurs.
-.PP
-If the time package is configured with leap-second support
-enabled,
-however,
-no such adjustment is needed and
-time_t values continue to increase over leap events
-(as a true `seconds since...' value).
-This means that these values will differ from those required by POSIX
-by the net number of leap seconds inserted since the Epoch.
-.PP
-Typically this is not a problem as the type time_t is intended
-to be
-(mostly)
-opaque\(emtime_t values should only be obtained-from and
-passed-to functions such as
-.IR time(2) ,
-.IR localtime(3) ,
-.IR mktime(3) ,
-and
-.IR difftime(3) .
-However,
-POSIX gives an arithmetic
-expression for directly computing a time_t value from a given date/time,
-and the same relationship is assumed by some
-(usually older)
-applications.
-Any programs creating/dissecting time_t's
-using such a relationship will typically not handle intervals
-over leap seconds correctly.
-.PP
-The
-.I time2posix
-and
-.I posix2time
-functions are provided to address this time_t mismatch by converting
-between local time_t values and their POSIX equivalents.
-This is done by accounting for the number of time-base changes that
-would have taken place on a POSIX system as leap seconds were inserted
-or deleted.
-These converted values can then be used in lieu of correcting the older
-applications,
-or when communicating with POSIX-compliant systems.
-.PP
-.I Time2posix
-is single-valued.
-That is,
-every local time_t
-corresponds to a single POSIX time_t.
-.I Posix2time
-is less well-behaved:
-for a positive leap second hit the result is not unique,
-and for a negative leap second hit the corresponding
-POSIX time_t doesn't exist so an adjacent value is returned.
-Both of these are good indicators of the inferiority of the
-POSIX representation.
-.PP
-The following table summarizes the relationship between a time
-T and it's conversion to,
-and back from,
-the POSIX representation over the leap second inserted at the end of June,
-1993.
-.nf
-.ta \w'93/06/30 'u +\w'23:59:59 'u +\w'A+0 'u +\w'X=time2posix(T) 'u
-DATE TIME T X=time2posix(T) posix2time(X)
-93/06/30 23:59:59 A+0 B+0 A+0
-93/06/30 23:59:60 A+1 B+1 A+1 or A+2
-93/07/01 00:00:00 A+2 B+1 A+1 or A+2
-93/07/01 00:00:01 A+3 B+2 A+3
-
-A leap second deletion would look like...
-
-DATE TIME T X=time2posix(T) posix2time(X)
-??/06/30 23:59:58 A+0 B+0 A+0
-??/07/01 00:00:00 A+1 B+2 A+1
-??/07/01 00:00:01 A+2 B+3 A+2
-.sp
-.ce
- [Note: posix2time(B+1) => A+0 or A+1]
-.fi
-.PP
-If leap-second support is not enabled,
-local time_t's and
-POSIX time_t's are equivalent,
-and both
-.I time2posix
-and
-.I posix2time
-degenerate to the identity function.
-.SH SEE ALSO
-difftime(3),
-localtime(3),
-mktime(3),
-time(2)
-.\" @(#)time2posix.3 7.3
diff --git a/libc/stdtime/tzfile.5 b/libc/stdtime/tzfile.5
deleted file mode 100644
index c7ef0b4ff47..00000000000
--- a/libc/stdtime/tzfile.5
+++ /dev/null
@@ -1,138 +0,0 @@
-.TH TZFILE 5
-.SH NAME
-tzfile \- time zone information
-.SH SYNOPSIS
-.B
-#include
-.SH DESCRIPTION
-The time zone information files used by
-.IR tzset (3)
-begin with the magic characters "TZif" to identify then as
-time zone information files,
-followed by sixteen bytes reserved for future use,
-followed by six four-byte values of type
-.BR long ,
-written in a ``standard'' byte order
-(the high-order byte of the value is written first).
-These values are,
-in order:
-.TP
-.I tzh_ttisgmtcnt
-The number of UTC/local indicators stored in the file.
-.TP
-.I tzh_ttisstdcnt
-The number of standard/wall indicators stored in the file.
-.TP
-.I tzh_leapcnt
-The number of leap seconds for which data is stored in the file.
-.TP
-.I tzh_timecnt
-The number of "transition times" for which data is stored
-in the file.
-.TP
-.I tzh_typecnt
-The number of "local time types" for which data is stored
-in the file (must not be zero).
-.TP
-.I tzh_charcnt
-The number of characters of "time zone abbreviation strings"
-stored in the file.
-.PP
-The above header is followed by
-.I tzh_timecnt
-four-byte values of type
-.BR long ,
-sorted in ascending order.
-These values are written in ``standard'' byte order.
-Each is used as a transition time (as returned by
-.IR time (2))
-at which the rules for computing local time change.
-Next come
-.I tzh_timecnt
-one-byte values of type
-.BR "unsigned char" ;
-each one tells which of the different types of ``local time'' types
-described in the file is associated with the same-indexed transition time.
-These values serve as indices into an array of
-.I ttinfo
-structures that appears next in the file;
-these structures are defined as follows:
-.in +.5i
-.sp
-.nf
-.ta .5i +\w'unsigned int\0\0'u
-struct ttinfo {
- long tt_gmtoff;
- int tt_isdst;
- unsigned int tt_abbrind;
-};
-.in -.5i
-.fi
-.sp
-Each structure is written as a four-byte value for
-.I tt_gmtoff
-of type
-.BR long ,
-in a standard byte order, followed by a one-byte value for
-.I tt_isdst
-and a one-byte value for
-.IR tt_abbrind .
-In each structure,
-.I tt_gmtoff
-gives the number of seconds to be added to UTC,
-.I tt_isdst
-tells whether
-.I tm_isdst
-should be set by
-.I localtime (3)
-and
-.I tt_abbrind
-serves as an index into the array of time zone abbreviation characters
-that follow the
-.I ttinfo
-structure(s) in the file.
-.PP
-Then there are
-.I tzh_leapcnt
-pairs of four-byte values, written in standard byte order;
-the first value of each pair gives the time
-(as returned by
-.IR time(2))
-at which a leap second occurs;
-the second gives the
-.I total
-number of leap seconds to be applied after the given time.
-The pairs of values are sorted in ascending order by time.
-.PP
-Then there are
-.I tzh_ttisstdcnt
-standard/wall indicators, each stored as a one-byte value;
-they tell whether the transition times associated with local time types
-were specified as standard time or wall clock time,
-and are used when a time zone file is used in handling POSIX-style
-time zone environment variables.
-.PP
-Finally there are
-.I tzh_ttisgmtcnt
-UTC/local indicators, each stored as a one-byte value;
-they tell whether the transition times associated with local time types
-were specified as UTC or local time,
-and are used when a time zone file is used in handling POSIX-style
-time zone environment variables.
-.PP
-.I Localtime
-uses the first standard-time
-.I ttinfo
-structure in the file
-(or simply the first
-.I ttinfo
-structure in the absence of a standard-time structure)
-if either
-.I tzh_timecnt
-is zero or the time argument is less than the first transition time recorded
-in the file.
-.SH SEE ALSO
-newctime(3)
-.\" @(#)tzfile.5 7.11
-.\" This file is in the public domain, so clarified as of
-.\" 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
diff --git a/zic/Makefile b/zic/Makefile
deleted file mode 100644
index 0aefc95e3d5..00000000000
--- a/zic/Makefile
+++ /dev/null
@@ -1,365 +0,0 @@
-# @(#)Makefile 7.67
-
-# Change the line below for your time zone (after finding the zone you want in
-# the time zone files, or adding it to a time zone file).
-# Alternately, if you discover you've got the wrong time zone, you can just
-# zic -l rightzone
-# to correct things.
-# Use the command
-# make zonenames
-# to get a list of the values you can use for LOCALTIME.
-
-LOCALTIME= Factory
-
-# If you want something other than Eastern United States time as a template
-# for handling POSIX-style time zone environment variables,
-# change the line below (after finding the zone you want in the
-# time zone files, or adding it to a time zone file).
-# (When a POSIX-style environment variable is handled, the rules in the
-# template file are used to determine "spring forward" and "fall back" days and
-# times; the environment variable itself specifies UTC offsets of standard and
-# summer time.)
-# Alternately, if you discover you've got the wrong time zone, you can just
-# zic -p rightzone
-# to correct things.
-# Use the command
-# make zonenames
-# to get a list of the values you can use for POSIXRULES.
-# If you want POSIX compatibility, use "America/New_York".
-
-POSIXRULES= America/New_York
-
-# Everything gets put in subdirectories of. . .
-
-TOPDIR= /usr/local
-
-# "Compiled" time zone information is placed in the "TZDIR" directory
-# (and subdirectories).
-# Use an absolute path name for TZDIR unless you're just testing the software.
-
-TZDIR= $(TOPDIR)/etc/zoneinfo
-
-# The "zic" and "zdump" commands get installed in. . .
-
-ETCDIR= $(TOPDIR)/etc
-
-# If you "make INSTALL", the "date" command gets installed in. . .
-
-BINDIR= $(TOPDIR)/bin
-
-# Manual pages go in subdirectories of. . .
-
-MANDIR= $(TOPDIR)/man
-
-# Library functions are put in an archive in LIBDIR.
-
-LIBDIR= $(TOPDIR)/lib
-TZLIB= $(LIBDIR)/libtz.a
-
-# If you always want time values interpreted as "seconds since the epoch
-# (not counting leap seconds)", use
-# REDO= posix_only
-# below. If you always want right time values interpreted as "seconds since
-# the epoch" (counting leap seconds)", use
-# REDO= right_only
-# below. If you want both sets of data available, with leap seconds not
-# counted normally, use
-# REDO= posix_right
-# below. If you want both sets of data available, with leap seconds counted
-# normally, use
-# REDO= right_posix
-# below.
-# POSIX mandates that leap seconds not be counted; for compatibility with it,
-# use either "posix_only" or "posix_right".
-
-REDO= posix_right
-
-# Since "." may not be in PATH...
-
-YEARISTYPE= ./yearistype
-
-# Non-default libraries needed to link.
-# Add -lintl if you want to use `gettext' on Solaris.
-LDLIBS=
-
-# Add the following to the end of the "CFLAGS=" line as needed.
-# -DHAVE_ADJTIME=0 if `adjtime' does not exist (SVR0?)
-# -DHAVE_GETTEXT=1 if `gettext' works (GNU, Linux, Solaris); also see LDLIBS
-# -DHAVE_LONG_DOUBLE=1 if your compiler supports the `long double' type
-# -DHAVE_SETTIMEOFDAY=0 if settimeofday does not exist (SVR0?)
-# -DHAVE_SETTIMEOFDAY=1 if settimeofday has just 1 arg (SVR4)
-# -DHAVE_SETTIMEOFDAY=2 if settimeofday uses 2nd arg (4.3BSD)
-# -DHAVE_SETTIMEOFDAY=3 if settimeofday ignores 2nd arg (4.4BSD)
-# -DHAVE_STRERROR=1 if `strerror' works
-# -DHAVE_SYMLINK=0 if your system lacks the symlink function
-# -DLOCALE_HOME=\"path\" if locales are in "path", not "/usr/lib/locale"
-# -DHAVE_UNISTD_H=0 if your compiler lacks a "unistd.h" (Microsoft C++ 7?)
-# -DHAVE_UTMPX_H=1 if your compiler has a "utmpx.h"
-# -DTZ_DOMAIN=\"foo\" to use "foo" for gettext domain name; default is "tz"
-# -TTZ_DOMAINDIR=\"/path\" to use "/path" for gettext directory;
-# the default is system-supplied, typically "/usr/lib/locale"
-# $(GCC_DEBUG_FLAGS) if you are using GCC and want lots of checking
-# -DNO_RUN_TIME_WARNINGS_ABOUT_YEAR_2000_PROBLEMS_THANK_YOU=1
-# if you do not want run time warnings about formats that may cause
-# year 2000 grief
-#
-GCC_DEBUG_FLAGS = -Dlint -g -O -fno-common \
- -Wall -Wcast-qual -Wconversion -Wmissing-prototypes \
- -Wnested-externs -Wpointer-arith -Wshadow \
- -Wtraditional # -Wstrict-prototypes -Wwrite-strings
-#
-# If you want to use System V compatibility code, add
-# -DUSG_COMPAT
-# to the end of the "CFLAGS=" line. This arrange for "timezone" and "daylight"
-# variables to be kept up-to-date by the time conversion functions. Neither
-# "timezone" nor "daylight" is described in X3J11's work.
-#
-# If your system has a "GMT offset" field in its "struct tm"s
-# (or if you decide to add such a field in your system's "time.h" file),
-# add the name to a define such as
-# -DTM_GMTOFF=tm_gmtoff
-# or
-# -DTM_GMTOFF=_tm_gmtoff
-# to the end of the "CFLAGS=" line.
-# Neither tm_gmtoff nor _tm_gmtoff is described in X3J11's work;
-# in its work, use of "tm_gmtoff" is described as non-conforming.
-# Both Linux and BSD have done the equivalent of defining TM_GMTOFF in
-# their recent releases.
-#
-# If your system has a "zone abbreviation" field in its "struct tm"s
-# (or if you decide to add such a field in your system's "time.h" file),
-# add the name to a define such as
-# -DTM_ZONE=tm_zone
-# or
-# -DTM_ZONE=_tm_zone
-# to the end of the "CFLAGS=" line.
-# Neither tm_zone nor _tm_zone is described in X3J11's work;
-# in its work, use of "tm_zone" is described as non-conforming.
-# Both UCB and Sun have done the equivalent of defining TM_ZONE in
-# their recent releases.
-#
-# If you want functions that were inspired by early versions of X3J11's work,
-# add
-# -DSTD_INSPIRED
-# to the end of the "CFLAGS=" line. This arranges for the functions
-# "tzsetwall", "offtime", "timelocal", "timegm", "timeoff",
-# "posix2time", and "time2posix" to be added to the time conversion library.
-# "tzsetwall" is like "tzset" except that it arranges for local wall clock
-# time (rather than the time specified in the TZ environment variable)
-# to be used.
-# "offtime" is like "gmtime" except that it accepts a second (long) argument
-# that gives an offset to add to the time_t when converting it.
-# "timelocal" is equivalent to "mktime".
-# "timegm" is like "timelocal" except that it turns a struct tm into
-# a time_t using UTC (rather than local time as "timelocal" does).
-# "timeoff" is like "timegm" except that it accepts a second (long) argument
-# that gives an offset to use when converting to a time_t.
-# "posix2time" and "time2posix" are described in an included manual page.
-# None of these functions are described in X3J11's current work.
-# Sun has provided "tzsetwall", "timelocal", and "timegm" in SunOS 4.0.
-# These functions may well disappear in future releases of the time
-# conversion package.
-#
-# If you want Source Code Control System ID's left out of object modules, add
-# -DNOID
-# to the end of the "CFLAGS=" line.
-#
-# If you'll never want to handle solar-time-based time zones, add
-# -DNOSOLAR
-# to the end of the "CFLAGS=" line
-# (and comment out the "SDATA=" line below).
-# This reduces (slightly) the run-time data-space requirements of
-# the time conversion functions; it may reduce the acceptability of your system
-# to folks in oil- and cash-rich places.
-#
-# If you want to allocate state structures in localtime, add
-# -DALL_STATE
-# to the end of the "CFLAGS=" line. Storage is obtained by calling malloc.
-#
-# If you want an "altzone" variable (a la System V Release 3.1), add
-# -DALTZONE
-# to the end of the "CFLAGS=" line.
-# This variable is not described in X3J11's work.
-#
-# If you want a "gtime" function (a la MACH), add
-# -DCMUCS
-# to the end of the "CFLAGS=" line
-# This function is not described in X3J11's work.
-#
-# NIST-PCTS:151-2, Version 1.4, (1993-12-03) is a test suite put
-# out by the National Institute of Standards and Technology
-# which claims to test C and Posix conformance. If you want to pass PCTS, add
-# -DPCTS
-# to the end of the "CFLAGS=" line.
-#
-# If you want strict compliance with XPG4 as of 1994-04-09, add
-# -DXPG4_1994_04_09
-# to the end of the "CFLAGS=" line. This causes "strftime" to always return
-# 53 as a week number (rather than 52 or 53) for those days in January that
-# before the first Monday in January when a "%V" format is used and January 1
-# falls on a Friday, Saturday, or Sunday.
-
-CFLAGS=
-
-# If you want zic's -s option used when installing, uncomment the next line
-# ZFLAGS= -s
-
-zic= ./zic
-ZIC= $(zic) $(ZFLAGS)
-
-# The name of a Posix-compliant `awk' on your system.
-AWK= awk
-
-###############################################################################
-
-cc= cc
-CC= $(cc) -DTZDIR=\"$(TZDIR)\"
-
-TZCSRCS= zic.c localtime.c asctime.c scheck.c ialloc.c
-TZCOBJS= zic.o localtime.o asctime.o scheck.o ialloc.o
-TZDSRCS= zdump.c localtime.c asctime.c ialloc.c
-TZDOBJS= zdump.o localtime.o asctime.o ialloc.o
-DATESRCS= date.c localtime.c logwtmp.c strftime.c asctime.c
-DATEOBJS= date.o localtime.o logwtmp.o strftime.o asctime.o
-LIBSRCS= localtime.c asctime.c difftime.c
-LIBOBJS= localtime.o asctime.o difftime.o
-HEADERS= tzfile.h private.h
-NONLIBSRCS= zic.c zdump.c scheck.c ialloc.c
-NEWUCBSRCS= date.c logwtmp.c strftime.c
-SOURCES= $(HEADERS) $(LIBSRCS) $(NONLIBSRCS) $(NEWUCBSRCS) tzselect.ksh
-MANS= newctime.3 newstrftime.3 newtzset.3 time2posix.3 \
- tzfile.5 tzselect.8 zic.8 zdump.8
-DOCS= README Theory $(MANS) date.1 Makefile
-PRIMARY_YDATA= africa antarctica asia australasia \
- europe northamerica southamerica
-YDATA= $(PRIMARY_YDATA) pacificnew etcetera factory backward
-NDATA= systemv
-SDATA= solar87 solar88 solar89
-TDATA= $(YDATA) $(NDATA) $(SDATA)
-TABDATA= iso3166.tab zone.tab
-DATA= $(YDATA) $(NDATA) $(SDATA) $(TABDATA) leapseconds yearistype.sh
-MISC= usno1988 usno1989 usno1989a usno1995 usno1997 usno1998 \
- Arts.htm WWW.htm gccdiffs checktab.awk
-ENCHILADA= $(DOCS) $(SOURCES) $(DATA) $(MISC)
-
-# And for the benefit of csh users on systems that assume the user
-# shell should be used to handle commands in Makefiles. . .
-
-SHELL= /bin/sh
-
-all: zic zdump $(LIBOBJS)
-
-ALL: all date tzselect
-
-install: all $(DATA) $(REDO) $(TZLIB) $(MANS) $(TABDATA)
- $(ZIC) -y $(YEARISTYPE) \
- -d $(TZDIR) -l $(LOCALTIME) -p $(POSIXRULES)
- -rm -f $(TZDIR)/iso3166.tab $(TZDIR)/zone.tab
- cp iso3166.tab zone.tab $(TZDIR)/.
- -mkdir $(TOPDIR) $(ETCDIR)
- cp zic zdump $(ETCDIR)/.
- -mkdir $(TOPDIR) $(MANDIR) \
- $(MANDIR)/man3 $(MANDIR)/man5 $(MANDIR)/man8
- -rm -f $(MANDIR)/man3/newctime.3 \
- $(MANDIR)/man3/newtzset.3 \
- $(MANDIR)/man5/tzfile.5 \
- $(MANDIR)/man8/tzselect.8 \
- $(MANDIR)/man8/zdump.8 \
- $(MANDIR)/man8/zic.8
- cp newctime.3 newtzset.3 $(MANDIR)/man3/.
- cp tzfile.5 $(MANDIR)/man5/.
- cp tzselect.8 zdump.8 zic.8 $(MANDIR)/man8/.
-
-INSTALL: ALL install date.1
- -mkdir $(TOPDIR) $(BINDIR)
- cp date $(BINDIR)/.
- -mkdir $(TOPDIR) $(MANDIR) $(MANDIR)/man1
- -rm -f $(MANDIR)/man1/date.1
- cp date.1 $(MANDIR)/man1/.
-
-zdump: $(TZDOBJS)
- $(CC) $(CFLAGS) $(LFLAGS) $(TZDOBJS) $(LDLIBS) -o $@
-
-zic: $(TZCOBJS) yearistype
- $(CC) $(CFLAGS) $(LFLAGS) $(TZCOBJS) $(LDLIBS) -o $@
-
-yearistype: yearistype.sh
- cp yearistype.sh yearistype
- chmod +x yearistype
-
-posix_only: zic $(TDATA)
- $(ZIC) -y $(YEARISTYPE) -d $(TZDIR) -L /dev/null $(TDATA)
-
-right_only: zic leapseconds $(TDATA)
- $(ZIC) -y $(YEARISTYPE) -d $(TZDIR) -L leapseconds $(TDATA)
-
-# In earlier versions of this makefile, the other two directories were
-# subdirectories of $(TZDIR). However, this led to configuration errors.
-# For example, with posix_right under the earlier scheme,
-# TZ='right/Australia/Adelaide' got you localtime with leap seconds,
-# but gmtime without leap seconds, which led to problems with applications
-# like sendmail that subtract gmtime from localtime.
-# Therefore, the other two directories are now siblings of $(TZDIR).
-# You must replace all of $(TZDIR) to switch from not using leap seconds
-# to using them, or vice versa.
-other_two: zic leapseconds $(TDATA)
- $(ZIC) -y $(YEARISTYPE) -d $(TZDIR)-posix -L /dev/null $(TDATA)
- $(ZIC) -y $(YEARISTYPE) \
- -d $(TZDIR)-leaps -L leapseconds $(TDATA)
-
-posix_right: posix_only other_two
-
-right_posix: right_only other_two
-
-zones: $(REDO)
-
-$(TZLIB): $(LIBOBJS)
- -mkdir $(TOPDIR) $(LIBDIR)
- ar ru $@ $(LIBOBJS)
- if [ -x /usr/ucb/ranlib -o -x /usr/bin/ranlib ] ; \
- then ranlib $@ ; fi
-
-# We use the system's logwtmp in preference to ours if available.
-
-date: $(DATEOBJS)
- ar r ,lib.a logwtmp.o
- if [ -x /usr/ucb/ranlib -o -x /usr/bin/ranlib ] ; \
- then ranlib ,lib.a ; fi
- $(CC) $(CFLAGS) date.o localtime.o asctime.o strftime.o \
- $(LDLIBS) -lc ,lib.a -o $@
- rm -f ,lib.a
-
-tzselect: tzselect.ksh
- sed \
- -e 's|AWK=[^}]*|AWK=$(AWK)|g' \
- -e 's|TZDIR=[^}]*|TZDIR=$(TZDIR)|' \
- <$? >$@
- chmod +x $@
-
-check_tables: checktab.awk $(PRIMARY_YDATA)
- $(AWK) -f checktab.awk $(PRIMARY_YDATA)
-
-clean:
- rm -f core *.o *.out tzselect zdump zic yearistype date \
- ,* *.tar.gz
-
-names:
- @echo $(ENCHILADA)
-
-public: $(ENCHILADA)
- tar cf - $(DOCS) $(SOURCES) $(MISC) | gzip -9 > tzcode.tar.gz
- tar cf - $(DATA) | gzip -9 > tzdata.tar.gz
-
-zonenames: $(TDATA)
- @awk '/^Zone/ { print $$2 } /^Link/ { print $$3 }' $(TDATA)
-
-asctime.o: private.h tzfile.h
-date.o: private.h
-difftime.o: private.h
-ialloc.o: private.h
-localtime.o: private.h tzfile.h
-scheck.o: private.h
-strftime.o: tzfile.h
-zic.o: private.h tzfile.h
-
-.KEEP_STATE:
diff --git a/zic/WWW b/zic/WWW
deleted file mode 100644
index d2fd6844819..00000000000
--- a/zic/WWW
+++ /dev/null
@@ -1,71 +0,0 @@
-# '@(#)WWW 7.3'
-
-# From Paul Eggert (1995-11-03)
-#
-# The Web has several other sources for time zone and daylight savings data.
-# Here are some recent links that may be of interest.
-#
-# Date and Time Gateway
-# http://www.bsdi.com/date
-# A text-based source for tables of current time throughout the world.
-# Its point-and-click interface accesses a recent version of the tz data.
-#
-# Local Times Around the World
-# http://www.hilink.com.au/times/
-# This text-based system contains links to local time servers
-# throughout the world, and though the coverage is limited,
-# the live data provide a nice way to check one's tables.
-#
-# World Time Zones
-# http://tycho.usno.navy.mil/tzones.html
-# US Naval Observatory data, used as the source for `usno1995'.
-#
-# Standard Time Zones of the World
-# http://www.odci.gov/cia/publications/95fact/802389.gif [54 kB]
-# http://www.odci.gov/cia/publications/95fact/802389h.gif [1317 kB]
-# A static time zone map, available in both low-resolution and
-# high-resolution versions. The quality is good, but the map does not
-# indicate summer time, and parts of the data are a few years out of date.
-#
-# VIBE's World Map
-# http://pathfinder.com/vibe/vibeworld
-# An active time zone map. You can point to the map and find out what
-# time it is at that location. The map and data are not as good as
-# other sources.
-
-###############################################################################
-
-# From Manavendra Thakur (1995-11-06)
-#
-# To Paul's list of time zone information on the web, I would add the
-# following URL:
-# http://www.dhl.com/dhl/dhlinfo/1bb.html
-# or more simply:
-# http://www.dhl.com/
-#
-# This is run by DHL (the courier company), and it presents a list of the
-# countries served by that company. If you then click on a particular
-# country, here's an example of what you'll see (graphics stripped out):
-#
-# United Kingdom
-#
-# HOLIDAYS: Jan 1, 2, Apr 14, 17, May 1, 29, Aug 28, Dec 25, 26
-#
-# INTERNATIONAL DIALING CODE: +44
-#
-# CURRENT LOCAL TIME: 09:41 Monday 6 November 1995
-#
-# I find this rather handy, and given that DHL covers 217 countries and
-# territories, it's pretty comprehensive coverage.
-#
-# (I have no idea what system DHL is using to calculate the local time, but
-# it's been accurate so far.)
-
-###############################################################################
-
-
-# From Arthur David Olson (1996-01-04)
-#
-# A good source of information about ISO 8601 seems to be
-# http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html
-# maintained by Markus Kuhn.
From 80ca36b52f4732dba27b6bb58743c0f1ab5bd8e3 Mon Sep 17 00:00:00 2001
From: Edwin Groothuis
Date: Wed, 20 May 2009 12:24:39 +0000
Subject: [PATCH 004/453] Vendor import of tzcode2009e. Obtained from:
ftp://elsie.nci.nih.gov/pub/
---
libc/stdtime/asctime.c | 106 +++-
libc/stdtime/difftime.c | 98 ++--
libc/stdtime/localtime.c | 809 ++++++++++++++++++-------
libc/stdtime/private.h | 194 +++---
libc/stdtime/strftime.c | 125 ++--
libc/stdtime/time2posix.3 | 121 ++++
libc/stdtime/tzfile.5 | 152 +++++
libc/stdtime/tzfile.h | 62 +-
unused/Makefile | 418 +++++++++++++
unused/checktab.awk | 159 +++++
unused/date.1 | 175 ++++++
unused/date.1.txt | 127 ++++
unused/date.c | 945 +++++++++++++++++++++++++++++
unused/itca.jpg | Bin 0 -> 55948 bytes
unused/newctime.3 | 239 ++++++++
unused/newctime.3.txt | 149 +++++
unused/newstrftime.3 | 230 ++++++++
unused/newstrftime.3.txt | 149 +++++
unused/newtzset.3 | 237 ++++++++
unused/newtzset.3.txt | 153 +++++
unused/time2posix.3.txt | 83 +++
{zic => unused}/tz-art.htm | 154 ++++-
unused/tz-link.htm | 648 ++++++++++++++++++++
unused/tzfile.5.txt | 106 ++++
unused/tzselect.8 | 41 ++
unused/tzselect.8.txt | 41 ++
unused/tzselect.ksh | 323 ++++++++++
unused/usno1988 | 111 ++++
unused/usno1989 | 452 ++++++++++++++
unused/usno1989a | 452 ++++++++++++++
unused/usno1995 | 326 +++++++++++
unused/usno1997 | 327 +++++++++++
unused/usno1998 | 327 +++++++++++
unused/workman.sh | 29 +
unused/zdump.8.txt | 43 ++
unused/zic.8.txt | 308 ++++++++++
unused/zoneinfo2tdf.pl | 54 ++
zic/Music | 81 ---
zic/README | 12 +-
zic/Theory | 109 ++--
zic/ialloc.c | 7 +-
zic/private.h | 194 +++---
zic/scheck.c | 14 +-
zic/tz-link.htm | 443 --------------
zic/zdump.8 | 20 +-
zic/zdump.c | 535 +++++++++++++----
zic/zic.8 | 91 ++-
zic/zic.c | 1141 +++++++++++++++++++++++++-----------
48 files changed, 9497 insertions(+), 1623 deletions(-)
create mode 100644 libc/stdtime/time2posix.3
create mode 100644 libc/stdtime/tzfile.5
create mode 100644 unused/Makefile
create mode 100644 unused/checktab.awk
create mode 100644 unused/date.1
create mode 100644 unused/date.1.txt
create mode 100644 unused/date.c
create mode 100644 unused/itca.jpg
create mode 100644 unused/newctime.3
create mode 100644 unused/newctime.3.txt
create mode 100644 unused/newstrftime.3
create mode 100644 unused/newstrftime.3.txt
create mode 100644 unused/newtzset.3
create mode 100644 unused/newtzset.3.txt
create mode 100644 unused/time2posix.3.txt
rename {zic => unused}/tz-art.htm (65%)
create mode 100644 unused/tz-link.htm
create mode 100644 unused/tzfile.5.txt
create mode 100644 unused/tzselect.8
create mode 100644 unused/tzselect.8.txt
create mode 100644 unused/tzselect.ksh
create mode 100644 unused/usno1988
create mode 100644 unused/usno1989
create mode 100644 unused/usno1989a
create mode 100644 unused/usno1995
create mode 100644 unused/usno1997
create mode 100644 unused/usno1998
create mode 100644 unused/workman.sh
create mode 100644 unused/zdump.8.txt
create mode 100644 unused/zic.8.txt
create mode 100755 unused/zoneinfo2tdf.pl
delete mode 100644 zic/Music
delete mode 100644 zic/tz-link.htm
diff --git a/libc/stdtime/asctime.c b/libc/stdtime/asctime.c
index 6578663c0d3..e0804f16f4d 100644
--- a/libc/stdtime/asctime.c
+++ b/libc/stdtime/asctime.c
@@ -1,11 +1,17 @@
/*
** 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.
+*/
+
+/*
+** Avoid the temptation to punt entirely to strftime;
+** the output of strftime is supposed to be locale specific
+** whereas the output of asctime is supposed to be constant.
*/
#ifndef lint
#ifndef NOID
-static char elsieid[] = "@(#)asctime.c 7.9";
+static char elsieid[] = "@(#)asctime.c 8.2";
#endif /* !defined NOID */
#endif /* !defined lint */
@@ -15,7 +21,57 @@ static char elsieid[] = "@(#)asctime.c 7.9";
#include "tzfile.h"
/*
-** A la ISO/IEC 9945-1, ANSI/IEEE Std 1003.1, Second Edition, 1996-07-12.
+** Some systems only handle "%.2d"; others only handle "%02d";
+** "%02.2d" makes (most) everybody happy.
+** At least some versions of gcc warn about the %02.2d;
+** we conditionalize below to avoid the warning.
+*/
+/*
+** All years associated with 32-bit time_t values are exactly four digits long;
+** some years associated with 64-bit time_t values are not.
+** Vintage programs are coded for years that are always four digits long
+** and may assume that the newline always lands in the same place.
+** For years that are less than four digits, we pad the output with
+** leading zeroes to get the newline in the traditional place.
+** The -4 ensures that we get four characters of output even if
+** we call a strftime variant that produces fewer characters for some years.
+** The ISO C 1999 and POSIX 1003.1-2004 standards prohibit padding the year,
+** but many implementations pad anyway; most likely the standards are buggy.
+*/
+#ifdef __GNUC__
+#define ASCTIME_FMT "%.3s %.3s%3d %2.2d:%2.2d:%2.2d %-4s\n"
+#else /* !defined __GNUC__ */
+#define ASCTIME_FMT "%.3s %.3s%3d %02.2d:%02.2d:%02.2d %-4s\n"
+#endif /* !defined __GNUC__ */
+/*
+** For years that are more than four digits we put extra spaces before the year
+** so that code trying to overwrite the newline won't end up overwriting
+** a digit within a year and truncating the year (operating on the assumption
+** that no output is better than wrong output).
+*/
+#ifdef __GNUC__
+#define ASCTIME_FMT_B "%.3s %.3s%3d %2.2d:%2.2d:%2.2d %s\n"
+#else /* !defined __GNUC__ */
+#define ASCTIME_FMT_B "%.3s %.3s%3d %02.2d:%02.2d:%02.2d %s\n"
+#endif /* !defined __GNUC__ */
+
+#define STD_ASCTIME_BUF_SIZE 26
+/*
+** Big enough for something such as
+** ??? ???-2147483648 -2147483648:-2147483648:-2147483648 -2147483648\n
+** (two three-character abbreviations, five strings denoting integers,
+** seven explicit spaces, two explicit colons, a newline,
+** and a trailing ASCII nul).
+** The values above are for systems where an int is 32 bits and are provided
+** as an example; the define below calculates the maximum for the system at
+** hand.
+*/
+#define MAX_ASCTIME_BUF_SIZE (2*3+5*INT_STRLEN_MAXIMUM(int)+7+2+1+1)
+
+static char buf_asctime[MAX_ASCTIME_BUF_SIZE];
+
+/*
+** A la ISO/IEC 9945-1, ANSI/IEEE Std 1003.1, 2004 Edition.
*/
char *
@@ -32,6 +88,8 @@ char * buf;
};
register const char * wn;
register const char * mn;
+ char year[INT_STRLEN_MAXIMUM(int) + 2];
+ char result[MAX_ASCTIME_BUF_SIZE];
if (timeptr->tm_wday < 0 || timeptr->tm_wday >= DAYSPERWEEK)
wn = "???";
@@ -40,35 +98,41 @@ char * buf;
mn = "???";
else mn = mon_name[timeptr->tm_mon];
/*
- ** The X3J11-suggested format is
- ** "%.3s %.3s%3d %02.2d:%02.2d:%02.2d %d\n"
- ** Since the .2 in 02.2d is ignored, we drop it.
+ ** Use strftime's %Y to generate the year, to avoid overflow problems
+ ** when computing timeptr->tm_year + TM_YEAR_BASE.
+ ** Assume that strftime is unaffected by other out-of-range members
+ ** (e.g., timeptr->tm_mday) when processing "%Y".
*/
- (void) sprintf(buf, "%.3s %.3s%3d %02d:%02d:%02d %d\n",
+ (void) strftime(year, sizeof year, "%Y", timeptr);
+ /*
+ ** We avoid using snprintf since it's not available on all systems.
+ */
+ (void) sprintf(result,
+ ((strlen(year) <= 4) ? ASCTIME_FMT : ASCTIME_FMT_B),
wn, mn,
timeptr->tm_mday, timeptr->tm_hour,
timeptr->tm_min, timeptr->tm_sec,
- TM_YEAR_BASE + timeptr->tm_year);
- return buf;
+ year);
+ if (strlen(result) < STD_ASCTIME_BUF_SIZE || buf == buf_asctime) {
+ (void) strcpy(buf, result);
+ return buf;
+ } else {
+#ifdef EOVERFLOW
+ errno = EOVERFLOW;
+#else /* !defined EOVERFLOW */
+ errno = EINVAL;
+#endif /* !defined EOVERFLOW */
+ return NULL;
+ }
}
/*
-** A la X3J11, with core dump avoidance.
+** A la ISO/IEC 9945-1, ANSI/IEEE Std 1003.1, 2004 Edition.
*/
char *
asctime(timeptr)
register const struct tm * timeptr;
{
- /*
- ** Big enough for something such as
- ** ??? ???-2147483648 -2147483648:-2147483648:-2147483648 -2147483648\n
- ** (two three-character abbreviations, five strings denoting integers,
- ** three explicit spaces, two explicit colons, a newline,
- ** and a trailing ASCII nul).
- */
- static char result[3 * 2 + 5 * INT_STRLEN_MAXIMUM(int) +
- 3 + 2 + 1 + 1];
-
- return asctime_r(timeptr, result);
+ return asctime_r(timeptr, buf_asctime);
}
diff --git a/libc/stdtime/difftime.c b/libc/stdtime/difftime.c
index 1d1519e1593..da779773bfd 100644
--- a/libc/stdtime/difftime.c
+++ b/libc/stdtime/difftime.c
@@ -1,83 +1,65 @@
/*
** This file is in the public domain, so clarified as of
-** June 5, 1996 by Arthur David Olson (arthur_david_olson@nih.gov).
+** 1996-06-05 by Arthur David Olson.
*/
#ifndef lint
#ifndef NOID
-static char elsieid[] = "@(#)difftime.c 7.9";
+static char elsieid[] = "@(#)difftime.c 8.1";
#endif /* !defined NOID */
#endif /* !defined lint */
/*LINTLIBRARY*/
-#include "private.h"
-
-/*
-** Algorithm courtesy Paul Eggert (eggert@twinsun.com).
-*/
-
-#ifdef HAVE_LONG_DOUBLE
-#define long_double long double
-#endif /* defined HAVE_LONG_DOUBLE */
-#ifndef HAVE_LONG_DOUBLE
-#define long_double double
-#endif /* !defined HAVE_LONG_DOUBLE */
+#include "private.h" /* for time_t, TYPE_INTEGRAL, and TYPE_SIGNED */
double
difftime(time1, time0)
const time_t time1;
const time_t time0;
{
- time_t delta;
- time_t hibit;
-
- {
- time_t tt;
- double d;
- long_double ld;
-
- if (sizeof tt < sizeof d)
- return (double) time1 - (double) time0;
- if (sizeof tt < sizeof ld)
- return (long_double) time1 - (long_double) time0;
+ /*
+ ** If (sizeof (double) > sizeof (time_t)) simply convert and subtract
+ ** (assuming that the larger type has more precision).
+ ** This is the common real-world case circa 2004.
+ */
+ if (sizeof (double) > sizeof (time_t))
+ return (double) time1 - (double) time0;
+ if (!TYPE_INTEGRAL(time_t)) {
+ /*
+ ** time_t is floating.
+ */
+ return time1 - time0;
+ }
+ if (!TYPE_SIGNED(time_t)) {
+ /*
+ ** time_t is integral and unsigned.
+ ** The difference of two unsigned values can't overflow
+ ** if the minuend is greater than or equal to the subtrahend.
+ */
+ if (time1 >= time0)
+ return time1 - time0;
+ else return -((double) (time0 - time1));
}
- if (time1 < time0)
- return -difftime(time0, time1);
/*
- ** As much as possible, avoid loss of precision
- ** by computing the difference before converting to double.
+ ** time_t is integral and signed.
+ ** Handle cases where both time1 and time0 have the same sign
+ ** (meaning that their difference cannot overflow).
*/
- delta = time1 - time0;
- if (delta >= 0)
- return delta;
+ if ((time1 < 0) == (time0 < 0))
+ return time1 - time0;
/*
- ** Repair delta overflow.
+ ** time1 and time0 have opposite signs.
+ ** Punt if unsigned long is too narrow.
*/
- hibit = (~ (time_t) 0) << (TYPE_BIT(time_t) - 1);
+ if (sizeof (unsigned long) < sizeof (time_t))
+ return (double) time1 - (double) time0;
/*
- ** The following expression rounds twice, which means
- ** the result may not be the closest to the true answer.
- ** For example, suppose time_t is 64-bit signed int,
- ** long_double is IEEE 754 double with default rounding,
- ** time1 = 9223372036854775807 and time0 = -1536.
- ** Then the true difference is 9223372036854777343,
- ** which rounds to 9223372036854777856
- ** with a total error of 513.
- ** But delta overflows to -9223372036854774273,
- ** which rounds to -9223372036854774784, and correcting
- ** this by subtracting 2 * (long_double) hibit
- ** (i.e. by adding 2**64 = 18446744073709551616)
- ** yields 9223372036854776832, which
- ** rounds to 9223372036854775808
- ** with a total error of 1535 instead.
- ** This problem occurs only with very large differences.
- ** It's too painful to fix this portably.
- ** We are not alone in this problem;
- ** some C compilers round twice when converting
- ** large unsigned types to small floating types,
- ** so if time_t is unsigned the "return delta" above
- ** has the same double-rounding problem with those compilers.
+ ** Stay calm...decent optimizers will eliminate the complexity below.
*/
- return delta - 2 * (long_double) hibit;
+ if (time1 >= 0 /* && time0 < 0 */)
+ return (unsigned long) time1 +
+ (unsigned long) (-(time0 + 1)) + 1;
+ return -(double) ((unsigned long) time0 +
+ (unsigned long) (-(time1 + 1)) + 1);
}
diff --git a/libc/stdtime/localtime.c b/libc/stdtime/localtime.c
index 33dcd5d052c..d186080bf35 100644
--- a/libc/stdtime/localtime.c
+++ b/libc/stdtime/localtime.c
@@ -1,18 +1,17 @@
/*
** 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.
*/
#ifndef lint
#ifndef NOID
-static char elsieid[] = "@(#)localtime.c 7.78";
+static char elsieid[] = "@(#)localtime.c 8.9";
#endif /* !defined NOID */
#endif /* !defined lint */
/*
-** Leap second handling from Bradley White (bww@k.gp.cs.cmu.edu).
-** POSIX-style TZ environment variable handling from Guy Harris
-** (guy@auspex.com).
+** Leap second handling from Bradley White.
+** POSIX-style TZ environment variable handling from Guy Harris.
*/
/*LINTLIBRARY*/
@@ -20,6 +19,20 @@ static char elsieid[] = "@(#)localtime.c 7.78";
#include "private.h"
#include "tzfile.h"
#include "fcntl.h"
+#include "float.h" /* for FLT_MAX and DBL_MAX */
+
+#ifndef TZ_ABBR_MAX_LEN
+#define TZ_ABBR_MAX_LEN 16
+#endif /* !defined TZ_ABBR_MAX_LEN */
+
+#ifndef TZ_ABBR_CHAR_SET
+#define TZ_ABBR_CHAR_SET \
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 :+-._"
+#endif /* !defined TZ_ABBR_CHAR_SET */
+
+#ifndef TZ_ABBR_ERR_CHAR
+#define TZ_ABBR_ERR_CHAR '_'
+#endif /* !defined TZ_ABBR_ERR_CHAR */
/*
** SunOS 4.1.1 headers lack O_BINARY.
@@ -46,16 +59,16 @@ static char elsieid[] = "@(#)localtime.c 7.78";
** 5. They might reference tm.TM_ZONE after calling offtime.
** What's best to do in the above cases is open to debate;
** for now, we just set things up so that in any of the five cases
-** WILDABBR is used. Another possibility: initialize tzname[0] to the
+** WILDABBR is used. Another possibility: initialize tzname[0] to the
** string "tzname[0] used before set", and similarly for the other cases.
-** And another: initialize tzname[0] to "ERA", with an explanation in the
+** And another: initialize tzname[0] to "ERA", with an explanation in the
** manual page of what this "time zone abbreviation" means (doing this so
** that tzname[0] has the "normal" length of three characters).
*/
#define WILDABBR " "
#endif /* !defined WILDABBR */
-static char wildabbr[] = "WILDABBR";
+static char wildabbr[] = WILDABBR;
static const char gmt[] = "GMT";
@@ -97,6 +110,8 @@ struct state {
int timecnt;
int typecnt;
int charcnt;
+ int goback;
+ int goahead;
time_t ats[TZ_MAX_TIMES];
unsigned char types[TZ_MAX_TIMES];
struct ttinfo ttis[TZ_MAX_TYPES];
@@ -121,43 +136,52 @@ struct rule {
** Prototypes for static functions.
*/
-static long detzcode P((const char * codep));
-static const char * getzname P((const char * strp));
-static const char * getnum P((const char * strp, int * nump, int min,
- int max));
-static const char * getsecs P((const char * strp, long * secsp));
-static const char * getoffset P((const char * strp, long * offsetp));
-static const char * getrule P((const char * strp, struct rule * rulep));
-static void gmtload P((struct state * sp));
-static void gmtsub P((const time_t * timep, long offset,
- struct tm * tmp));
-static void localsub P((const time_t * timep, long offset,
- struct tm * tmp));
-static int increment_overflow P((int * number, int delta));
-static int normalize_overflow P((int * tensptr, int * unitsptr,
- int base));
-static void settzname P((void));
-static time_t time1 P((struct tm * tmp,
- void(*funcp) P((const time_t *,
- long, struct tm *)),
- long offset));
-static time_t time2 P((struct tm *tmp,
- void(*funcp) P((const time_t *,
- long, struct tm*)),
- long offset, int * okayp));
-static time_t time2sub P((struct tm *tmp,
- void(*funcp) P((const time_t *,
- long, struct tm*)),
- long offset, int * okayp, int do_norm_secs));
-static void timesub P((const time_t * timep, long offset,
- const struct state * sp, struct tm * tmp));
-static int tmcomp P((const struct tm * atmp,
- const struct tm * btmp));
-static time_t transtime P((time_t janfirst, int year,
- const struct rule * rulep, long offset));
-static int tzload P((const char * name, struct state * sp));
-static int tzparse P((const char * name, struct state * sp,
- int lastditch));
+static long detzcode(const char * codep);
+static time_t detzcode64(const char * codep);
+static int differ_by_repeat(time_t t1, time_t t0);
+static const char * getzname(const char * strp);
+static const char * getqzname(const char * strp, const int delim);
+static const char * getnum(const char * strp, int * nump, int min,
+ int max);
+static const char * getsecs(const char * strp, long * secsp);
+static const char * getoffset(const char * strp, long * offsetp);
+static const char * getrule(const char * strp, struct rule * rulep);
+static void gmtload(struct state * sp);
+static struct tm * gmtsub(const time_t * timep, long offset,
+ struct tm * tmp);
+static struct tm * localsub(const time_t * timep, long offset,
+ struct tm * tmp);
+static int increment_overflow(int * number, int delta);
+static int leaps_thru_end_of(int y);
+static int long_increment_overflow(long * number, int delta);
+static int long_normalize_overflow(long * tensptr,
+ int * unitsptr, int base);
+static int normalize_overflow(int * tensptr, int * unitsptr,
+ int base);
+static void settzname(void);
+static time_t time1(struct tm * tmp,
+ struct tm * (*funcp)(const time_t *,
+ long, struct tm *),
+ long offset);
+static time_t time2(struct tm *tmp,
+ struct tm * (*funcp)(const time_t *,
+ long, struct tm*),
+ long offset, int * okayp);
+static time_t time2sub(struct tm *tmp,
+ struct tm * (*funcp)(const time_t *,
+ long, struct tm*),
+ long offset, int * okayp, int do_norm_secs);
+static struct tm * timesub(const time_t * timep, long offset,
+ const struct state * sp, struct tm * tmp);
+static int tmcomp(const struct tm * atmp,
+ const struct tm * btmp);
+static time_t transtime(time_t janfirst, int year,
+ const struct rule * rulep, long offset);
+static int typesequiv(const struct state * sp, int a, int b);
+static int tzload(const char * name, struct state * sp,
+ int doextend);
+static int tzparse(const char * name, struct state * sp,
+ int lastditch);
#ifdef ALL_STATE
static struct state * lclptr;
@@ -189,7 +213,7 @@ char * tzname[2] = {
** Except for the strftime function, these functions [asctime,
** ctime, gmtime, localtime] return values in one of two static
** objects: a broken-down time structure and an array of char.
-** Thanks to Paul Eggert (eggert@twinsun.com) for noting this.
+** Thanks to Paul Eggert for noting this.
*/
static struct tm tm;
@@ -210,14 +234,27 @@ const char * const codep;
register long result;
register int i;
- result = (codep[0] & 0x80) ? ~0L : 0L;
+ result = (codep[0] & 0x80) ? ~0L : 0;
for (i = 0; i < 4; ++i)
result = (result << 8) | (codep[i] & 0xff);
return result;
}
+static time_t
+detzcode64(codep)
+const char * const codep;
+{
+ register time_t result;
+ register int i;
+
+ result = (codep[0] & 0x80) ? (~(int_fast64_t) 0) : 0;
+ for (i = 0; i < 8; ++i)
+ result = result * 256 + (codep[i] & 0xff);
+ return result;
+}
+
static void
-settzname P((void))
+settzname(void)
{
register struct state * const sp = lclptr;
register int i;
@@ -264,16 +301,54 @@ settzname P((void))
tzname[ttisp->tt_isdst] =
&sp->chars[ttisp->tt_abbrind];
}
+ /*
+ ** Finally, scrub the abbreviations.
+ ** First, replace bogus characters.
+ */
+ for (i = 0; i < sp->charcnt; ++i)
+ if (strchr(TZ_ABBR_CHAR_SET, sp->chars[i]) == NULL)
+ sp->chars[i] = TZ_ABBR_ERR_CHAR;
+ /*
+ ** Second, truncate long abbreviations.
+ */
+ for (i = 0; i < sp->typecnt; ++i) {
+ register const struct ttinfo * const ttisp = &sp->ttis[i];
+ register char * cp = &sp->chars[ttisp->tt_abbrind];
+
+ if (strlen(cp) > TZ_ABBR_MAX_LEN &&
+ strcmp(cp, GRANDPARENTED) != 0)
+ *(cp + TZ_ABBR_MAX_LEN) = '\0';
+ }
}
static int
-tzload(name, sp)
+differ_by_repeat(t1, t0)
+const time_t t1;
+const time_t t0;
+{
+ if (TYPE_INTEGRAL(time_t) &&
+ TYPE_BIT(time_t) - TYPE_SIGNED(time_t) < SECSPERREPEAT_BITS)
+ return 0;
+ return t1 - t0 == SECSPERREPEAT;
+}
+
+static int
+tzload(name, sp, doextend)
register const char * name;
register struct state * const sp;
+register const int doextend;
{
- register const char * p;
- register int i;
- register int fid;
+ register const char * p;
+ register int i;
+ register int fid;
+ register int stored;
+ register int nread;
+ union {
+ struct tzhead tzhead;
+ char buf[2 * sizeof(struct tzhead) +
+ 2 * sizeof *sp +
+ 4 * TZ_MAX_TIMES];
+ } u;
if (name == NULL && (name = TZDEFAULT) == NULL)
return -1;
@@ -311,18 +386,13 @@ register struct state * const sp;
if ((fid = open(name, OPEN_MODE)) == -1)
return -1;
}
- {
- struct tzhead * tzhp;
- union {
- struct tzhead tzhead;
- char buf[sizeof *sp + sizeof *tzhp];
- } u;
+ nread = read(fid, u.buf, sizeof u.buf);
+ if (close(fid) < 0 || nread <= 0)
+ return -1;
+ for (stored = 4; stored <= 8; stored *= 2) {
int ttisstdcnt;
int ttisgmtcnt;
- i = read(fid, u.buf, sizeof u.buf);
- if (close(fid) != 0)
- return -1;
ttisstdcnt = (int) detzcode(u.tzhead.tzh_ttisstdcnt);
ttisgmtcnt = (int) detzcode(u.tzhead.tzh_ttisgmtcnt);
sp->leapcnt = (int) detzcode(u.tzhead.tzh_leapcnt);
@@ -337,17 +407,19 @@ register struct state * const sp;
(ttisstdcnt != sp->typecnt && ttisstdcnt != 0) ||
(ttisgmtcnt != sp->typecnt && ttisgmtcnt != 0))
return -1;
- if (i - (p - u.buf) < sp->timecnt * 4 + /* ats */
+ if (nread - (p - u.buf) <
+ sp->timecnt * stored + /* ats */
sp->timecnt + /* types */
- sp->typecnt * (4 + 2) + /* ttinfos */
+ sp->typecnt * 6 + /* ttinfos */
sp->charcnt + /* chars */
- sp->leapcnt * (4 + 4) + /* lsinfos */
+ sp->leapcnt * (stored + 4) + /* lsinfos */
ttisstdcnt + /* ttisstds */
ttisgmtcnt) /* ttisgmts */
return -1;
for (i = 0; i < sp->timecnt; ++i) {
- sp->ats[i] = detzcode(p);
- p += 4;
+ sp->ats[i] = (stored == 4) ?
+ detzcode(p) : detzcode64(p);
+ p += stored;
}
for (i = 0; i < sp->timecnt; ++i) {
sp->types[i] = (unsigned char) *p++;
@@ -375,8 +447,9 @@ register struct state * const sp;
register struct lsinfo * lsisp;
lsisp = &sp->lsis[i];
- lsisp->ls_trans = detzcode(p);
- p += 4;
+ lsisp->ls_trans = (stored == 4) ?
+ detzcode(p) : detzcode64(p);
+ p += stored;
lsisp->ls_corr = detzcode(p);
p += 4;
}
@@ -406,10 +479,127 @@ register struct state * const sp;
return -1;
}
}
+ /*
+ ** Out-of-sort ats should mean we're running on a
+ ** signed time_t system but using a data file with
+ ** unsigned values (or vice versa).
+ */
+ for (i = 0; i < sp->timecnt - 2; ++i)
+ if (sp->ats[i] > sp->ats[i + 1]) {
+ ++i;
+ if (TYPE_SIGNED(time_t)) {
+ /*
+ ** Ignore the end (easy).
+ */
+ sp->timecnt = i;
+ } else {
+ /*
+ ** Ignore the beginning (harder).
+ */
+ register int j;
+
+ for (j = 0; j + i < sp->timecnt; ++j) {
+ sp->ats[j] = sp->ats[j + i];
+ sp->types[j] = sp->types[j + i];
+ }
+ sp->timecnt = j;
+ }
+ break;
+ }
+ /*
+ ** If this is an old file, we're done.
+ */
+ if (u.tzhead.tzh_version[0] == '\0')
+ break;
+ nread -= p - u.buf;
+ for (i = 0; i < nread; ++i)
+ u.buf[i] = p[i];
+ /*
+ ** If this is a narrow integer time_t system, we're done.
+ */
+ if (stored >= (int) sizeof(time_t) && TYPE_INTEGRAL(time_t))
+ break;
+ }
+ if (doextend && nread > 2 &&
+ u.buf[0] == '\n' && u.buf[nread - 1] == '\n' &&
+ sp->typecnt + 2 <= TZ_MAX_TYPES) {
+ struct state ts;
+ register int result;
+
+ u.buf[nread - 1] = '\0';
+ result = tzparse(&u.buf[1], &ts, FALSE);
+ if (result == 0 && ts.typecnt == 2 &&
+ sp->charcnt + ts.charcnt <= TZ_MAX_CHARS) {
+ for (i = 0; i < 2; ++i)
+ ts.ttis[i].tt_abbrind +=
+ sp->charcnt;
+ for (i = 0; i < ts.charcnt; ++i)
+ sp->chars[sp->charcnt++] =
+ ts.chars[i];
+ i = 0;
+ while (i < ts.timecnt &&
+ ts.ats[i] <=
+ sp->ats[sp->timecnt - 1])
+ ++i;
+ while (i < ts.timecnt &&
+ sp->timecnt < TZ_MAX_TIMES) {
+ sp->ats[sp->timecnt] =
+ ts.ats[i];
+ sp->types[sp->timecnt] =
+ sp->typecnt +
+ ts.types[i];
+ ++sp->timecnt;
+ ++i;
+ }
+ sp->ttis[sp->typecnt++] = ts.ttis[0];
+ sp->ttis[sp->typecnt++] = ts.ttis[1];
+ }
+ }
+ sp->goback = sp->goahead = FALSE;
+ if (sp->timecnt > 1) {
+ for (i = 1; i < sp->timecnt; ++i)
+ if (typesequiv(sp, sp->types[i], sp->types[0]) &&
+ differ_by_repeat(sp->ats[i], sp->ats[0])) {
+ sp->goback = TRUE;
+ break;
+ }
+ for (i = sp->timecnt - 2; i >= 0; --i)
+ if (typesequiv(sp, sp->types[sp->timecnt - 1],
+ sp->types[i]) &&
+ differ_by_repeat(sp->ats[sp->timecnt - 1],
+ sp->ats[i])) {
+ sp->goahead = TRUE;
+ break;
+ }
}
return 0;
}
+static int
+typesequiv(sp, a, b)
+const struct state * const sp;
+const int a;
+const int b;
+{
+ register int result;
+
+ if (sp == NULL ||
+ a < 0 || a >= sp->typecnt ||
+ b < 0 || b >= sp->typecnt)
+ result = FALSE;
+ else {
+ register const struct ttinfo * ap = &sp->ttis[a];
+ register const struct ttinfo * bp = &sp->ttis[b];
+ result = ap->tt_gmtoff == bp->tt_gmtoff &&
+ ap->tt_isdst == bp->tt_isdst &&
+ ap->tt_ttisstd == bp->tt_ttisstd &&
+ ap->tt_ttisgmt == bp->tt_ttisgmt &&
+ strcmp(&sp->chars[ap->tt_abbrind],
+ &sp->chars[bp->tt_abbrind]) == 0;
+ }
+ return result;
+}
+
static const int mon_lengths[2][MONSPERYEAR] = {
{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
@@ -421,7 +611,7 @@ static const int year_lengths[2] = {
/*
** Given a pointer into a time zone string, scan until a character that is not
-** a valid character in a zone name is found. Return a pointer to that
+** a valid character in a zone name is found. Return a pointer to that
** character.
*/
@@ -437,6 +627,25 @@ register const char * strp;
return strp;
}
+/*
+** Given a pointer into an extended time zone string, scan until the ending
+** delimiter of the zone name is located. Return a pointer to the delimiter.
+**
+** As with getzname above, the legal character set is actually quite
+** restricted, with other characters producing undefined results.
+** We don't do any checking here; checking is done later in common-case code.
+*/
+
+static const char *
+getqzname(register const char *strp, const int delim)
+{
+ register int c;
+
+ while ((c = *strp) != '\0' && c != delim)
+ ++strp;
+ return strp;
+}
+
/*
** Given a pointer into a time zone string, extract a number from that string.
** Check that the number is within a specified range; if it is not, return
@@ -502,7 +711,7 @@ long * const secsp;
*secsp += num * SECSPERMIN;
if (*strp == ':') {
++strp;
- /* `SECSPERMIN' allows for leap seconds. */
+ /* `SECSPERMIN' allows for leap seconds. */
strp = getnum(strp, &num, 0, SECSPERMIN);
if (strp == NULL)
return NULL;
@@ -541,7 +750,7 @@ long * const offsetp;
/*
** Given a pointer into a time zone string, extract a rule in the form
-** date[/time]. See POSIX section 8 for the format of "date" and "time".
+** date[/time]. See POSIX section 8 for the format of "date" and "time".
** If a valid rule is not found, return NULL.
** Otherwise, return a pointer to the first character not part of the rule.
*/
@@ -660,7 +869,7 @@ const long offset;
dow += DAYSPERWEEK;
/*
- ** "dow" is the day-of-week of the first day of the month. Get
+ ** "dow" is the day-of-week of the first day of the month. Get
** the day-of-month (zero-origin) of the first "dow" day of the
** month.
*/
@@ -683,7 +892,7 @@ const long offset;
/*
** "value" is the Epoch-relative time of 00:00:00 UTC on the day in
- ** question. To get the Epoch-relative time of the specified local
+ ** question. To get the Epoch-relative time of the specified local
** time on that day, add the transition time and the current offset
** from UTC.
*/
@@ -721,25 +930,40 @@ const int lastditch;
stdlen = (sizeof sp->chars) - 1;
stdoffset = 0;
} else {
- name = getzname(name);
- stdlen = name - stdname;
- if (stdlen < 3)
- return -1;
+ if (*name == '<') {
+ name++;
+ stdname = name;
+ name = getqzname(name, '>');
+ if (*name != '>')
+ return (-1);
+ stdlen = name - stdname;
+ name++;
+ } else {
+ name = getzname(name);
+ stdlen = name - stdname;
+ }
if (*name == '\0')
return -1;
name = getoffset(name, &stdoffset);
if (name == NULL)
return -1;
}
- load_result = tzload(TZDEFRULES, sp);
+ load_result = tzload(TZDEFRULES, sp, FALSE);
if (load_result != 0)
sp->leapcnt = 0; /* so, we're off a little */
if (*name != '\0') {
- dstname = name;
- name = getzname(name);
- dstlen = name - dstname; /* length of DST zone name */
- if (dstlen < 3)
- return -1;
+ if (*name == '<') {
+ dstname = ++name;
+ name = getqzname(name, '>');
+ if (*name != '>')
+ return -1;
+ dstlen = name - dstname;
+ name++;
+ } else {
+ dstname = name;
+ name = getzname(name);
+ dstlen = name - dstname; /* length of DST zone name */
+ }
if (*name != '\0' && *name != ',' && *name != ';') {
name = getoffset(name, &dstoffset);
if (name == NULL)
@@ -766,11 +990,8 @@ const int lastditch;
return -1;
sp->typecnt = 2; /* standard time and DST */
/*
- ** Two transitions per year, from EPOCH_YEAR to 2037.
+ ** Two transitions per year, from EPOCH_YEAR forward.
*/
- sp->timecnt = 2 * (2037 - EPOCH_YEAR + 1);
- if (sp->timecnt > TZ_MAX_TIMES)
- return -1;
sp->ttis[0].tt_gmtoff = -dstoffset;
sp->ttis[0].tt_isdst = 1;
sp->ttis[0].tt_abbrind = stdlen + 1;
@@ -780,7 +1001,12 @@ const int lastditch;
atp = sp->ats;
typep = sp->types;
janfirst = 0;
- for (year = EPOCH_YEAR; year <= 2037; ++year) {
+ sp->timecnt = 0;
+ for (year = EPOCH_YEAR;
+ sp->timecnt + 2 <= TZ_MAX_TIMES;
+ ++year) {
+ time_t newfirst;
+
starttime = transtime(janfirst, year, &start,
stdoffset);
endtime = transtime(janfirst, year, &end,
@@ -796,8 +1022,13 @@ const int lastditch;
*atp++ = endtime;
*typep++ = 1; /* DST ends */
}
- janfirst += year_lengths[isleap(year)] *
+ sp->timecnt += 2;
+ newfirst = janfirst;
+ newfirst += year_lengths[isleap(year)] *
SECSPERDAY;
+ if (newfirst <= janfirst)
+ break;
+ janfirst = newfirst;
}
} else {
register long theirstdoffset;
@@ -912,7 +1143,7 @@ static void
gmtload(sp)
struct state * const sp;
{
- if (tzload(gmt, sp) != 0)
+ if (tzload(gmt, sp, TRUE) != 0)
(void) tzparse(gmt, sp, TRUE);
}
@@ -924,7 +1155,7 @@ struct state * const sp;
static
#endif /* !defined STD_INSPIRED */
void
-tzsetwall P((void))
+tzsetwall(void)
{
if (lcl_is_set < 0)
return;
@@ -939,13 +1170,13 @@ tzsetwall P((void))
}
}
#endif /* defined ALL_STATE */
- if (tzload((char *) NULL, lclptr) != 0)
+ if (tzload((char *) NULL, lclptr, TRUE) != 0)
gmtload(lclptr);
settzname();
}
void
-tzset P((void))
+tzset(void)
{
register const char * name;
@@ -981,7 +1212,7 @@ tzset P((void))
lclptr->ttis[0].tt_gmtoff = 0;
lclptr->ttis[0].tt_abbrind = 0;
(void) strcpy(lclptr->chars, gmt);
- } else if (tzload(name, lclptr) != 0)
+ } else if (tzload(name, lclptr, TRUE) != 0)
if (name[0] == ':' || tzparse(name, lclptr, FALSE) != 0)
(void) gmtload(lclptr);
settzname();
@@ -990,14 +1221,14 @@ tzset P((void))
/*
** The easy way to behave "as if no library function calls" localtime
** is to not call it--so we drop its guts into "localsub", which can be
-** freely called. (And no, the PANS doesn't require the above behavior--
+** freely called. (And no, the PANS doesn't require the above behavior--
** but it *is* desirable.)
**
** The unused offset argument is for the benefit of mktime variants.
*/
/*ARGSUSED*/
-static void
+static struct tm *
localsub(timep, offset, tmp)
const time_t * const timep;
const long offset;
@@ -1006,15 +1237,53 @@ struct tm * const tmp;
register struct state * sp;
register const struct ttinfo * ttisp;
register int i;
+ register struct tm * result;
const time_t t = *timep;
sp = lclptr;
#ifdef ALL_STATE
- if (sp == NULL) {
- gmtsub(timep, offset, tmp);
- return;
- }
+ if (sp == NULL)
+ return gmtsub(timep, offset, tmp);
#endif /* defined ALL_STATE */
+ if ((sp->goback && t < sp->ats[0]) ||
+ (sp->goahead && t > sp->ats[sp->timecnt - 1])) {
+ time_t newt = t;
+ register time_t seconds;
+ register time_t tcycles;
+ register int_fast64_t icycles;
+
+ if (t < sp->ats[0])
+ seconds = sp->ats[0] - t;
+ else seconds = t - sp->ats[sp->timecnt - 1];
+ --seconds;
+ tcycles = seconds / YEARSPERREPEAT / AVGSECSPERYEAR;
+ ++tcycles;
+ icycles = tcycles;
+ if (tcycles - icycles >= 1 || icycles - tcycles >= 1)
+ return NULL;
+ seconds = icycles;
+ seconds *= YEARSPERREPEAT;
+ seconds *= AVGSECSPERYEAR;
+ if (t < sp->ats[0])
+ newt += seconds;
+ else newt -= seconds;
+ if (newt < sp->ats[0] ||
+ newt > sp->ats[sp->timecnt - 1])
+ return NULL; /* "cannot happen" */
+ result = localsub(&newt, offset, tmp);
+ if (result == tmp) {
+ register time_t newy;
+
+ newy = tmp->tm_year;
+ if (t < sp->ats[0])
+ newy -= icycles * YEARSPERREPEAT;
+ else newy += icycles * YEARSPERREPEAT;
+ tmp->tm_year = newy;
+ if (tmp->tm_year != newy)
+ return NULL;
+ }
+ return result;
+ }
if (sp->timecnt == 0 || t < sp->ats[0]) {
i = 0;
while (sp->ttis[i].tt_isdst)
@@ -1023,10 +1292,17 @@ struct tm * const tmp;
break;
}
} else {
- for (i = 1; i < sp->timecnt; ++i)
- if (t < sp->ats[i])
- break;
- i = sp->types[i - 1];
+ register int lo = 1;
+ register int hi = sp->timecnt;
+
+ while (lo < hi) {
+ register int mid = (lo + hi) >> 1;
+
+ if (t < sp->ats[mid])
+ hi = mid;
+ else lo = mid + 1;
+ }
+ i = (int) sp->types[lo - 1];
}
ttisp = &sp->ttis[i];
/*
@@ -1035,12 +1311,13 @@ struct tm * const tmp;
** t += ttisp->tt_gmtoff;
** timesub(&t, 0L, sp, tmp);
*/
- timesub(&t, ttisp->tt_gmtoff, sp, tmp);
+ result = timesub(&t, ttisp->tt_gmtoff, sp, tmp);
tmp->tm_isdst = ttisp->tt_isdst;
tzname[tmp->tm_isdst] = &sp->chars[ttisp->tt_abbrind];
#ifdef TM_ZONE
tmp->TM_ZONE = &sp->chars[ttisp->tt_abbrind];
#endif /* defined TM_ZONE */
+ return result;
}
struct tm *
@@ -1048,8 +1325,7 @@ localtime(timep)
const time_t * const timep;
{
tzset();
- localsub(timep, 0L, &tm);
- return &tm;
+ return localsub(timep, 0L, &tm);
}
/*
@@ -1057,24 +1333,25 @@ const time_t * const timep;
*/
struct tm *
-localtime_r(timep, tm)
+localtime_r(timep, tmp)
const time_t * const timep;
-struct tm * tm;
+struct tm * tmp;
{
- localsub(timep, 0L, tm);
- return tm;
+ return localsub(timep, 0L, tmp);
}
/*
** gmtsub is to gmtime as localsub is to localtime.
*/
-static void
+static struct tm *
gmtsub(timep, offset, tmp)
const time_t * const timep;
const long offset;
struct tm * const tmp;
{
+ register struct tm * result;
+
if (!gmt_is_set) {
gmt_is_set = TRUE;
#ifdef ALL_STATE
@@ -1083,7 +1360,7 @@ struct tm * const tmp;
#endif /* defined ALL_STATE */
gmtload(gmtptr);
}
- timesub(timep, offset, gmtptr, tmp);
+ result = timesub(timep, offset, gmtptr, tmp);
#ifdef TM_ZONE
/*
** Could get fancy here and deliver something such as
@@ -1103,14 +1380,14 @@ struct tm * const tmp;
#endif /* State Farm */
}
#endif /* defined TM_ZONE */
+ return result;
}
struct tm *
gmtime(timep)
const time_t * const timep;
{
- gmtsub(timep, 0L, &tm);
- return &tm;
+ return gmtsub(timep, 0L, &tm);
}
/*
@@ -1118,12 +1395,11 @@ const time_t * const timep;
*/
struct tm *
-gmtime_r(timep, tm)
+gmtime_r(timep, tmp)
const time_t * const timep;
-struct tm * tm;
+struct tm * tmp;
{
- gmtsub(timep, 0L, tm);
- return tm;
+ return gmtsub(timep, 0L, tmp);
}
#ifdef STD_INSPIRED
@@ -1133,13 +1409,25 @@ offtime(timep, offset)
const time_t * const timep;
const long offset;
{
- gmtsub(timep, offset, &tm);
- return &tm;
+ return gmtsub(timep, offset, &tm);
}
#endif /* defined STD_INSPIRED */
-static void
+/*
+** Return the number of leap years through the end of the given year
+** where, to make the math easy, the answer for year zero is defined as zero.
+*/
+
+static int
+leaps_thru_end_of(y)
+register const int y;
+{
+ return (y >= 0) ? (y / 4 - y / 100 + y / 400) :
+ -(leaps_thru_end_of(-(y + 1)) + 1);
+}
+
+static struct tm *
timesub(timep, offset, sp, tmp)
const time_t * const timep;
const long offset;
@@ -1147,10 +1435,10 @@ register const struct state * const sp;
register struct tm * const tmp;
{
register const struct lsinfo * lp;
- register long days;
+ register time_t tdays;
+ register int idays; /* unsigned would be so 2003 */
register long rem;
- register int y;
- register int yleap;
+ int y;
register const int * ip;
register long corr;
register int hit;
@@ -1184,60 +1472,93 @@ register struct tm * const tmp;
break;
}
}
- days = *timep / SECSPERDAY;
- rem = *timep % SECSPERDAY;
-#ifdef mc68k
- if (*timep == 0x80000000) {
- /*
- ** A 3B1 muffs the division on the most negative number.
- */
- days = -24855;
- rem = -11648;
+ y = EPOCH_YEAR;
+ tdays = *timep / SECSPERDAY;
+ rem = *timep - tdays * SECSPERDAY;
+ while (tdays < 0 || tdays >= year_lengths[isleap(y)]) {
+ int newy;
+ register time_t tdelta;
+ register int idelta;
+ register int leapdays;
+
+ tdelta = tdays / DAYSPERLYEAR;
+ idelta = tdelta;
+ if (tdelta - idelta >= 1 || idelta - tdelta >= 1)
+ return NULL;
+ if (idelta == 0)
+ idelta = (tdays < 0) ? -1 : 1;
+ newy = y;
+ if (increment_overflow(&newy, idelta))
+ return NULL;
+ leapdays = leaps_thru_end_of(newy - 1) -
+ leaps_thru_end_of(y - 1);
+ tdays -= ((time_t) newy - y) * DAYSPERNYEAR;
+ tdays -= leapdays;
+ y = newy;
}
-#endif /* defined mc68k */
- rem += (offset - corr);
+ {
+ register long seconds;
+
+ seconds = tdays * SECSPERDAY + 0.5;
+ tdays = seconds / SECSPERDAY;
+ rem += seconds - tdays * SECSPERDAY;
+ }
+ /*
+ ** Given the range, we can now fearlessly cast...
+ */
+ idays = tdays;
+ rem += offset - corr;
while (rem < 0) {
rem += SECSPERDAY;
- --days;
+ --idays;
}
while (rem >= SECSPERDAY) {
rem -= SECSPERDAY;
- ++days;
+ ++idays;
}
+ while (idays < 0) {
+ if (increment_overflow(&y, -1))
+ return NULL;
+ idays += year_lengths[isleap(y)];
+ }
+ while (idays >= year_lengths[isleap(y)]) {
+ idays -= year_lengths[isleap(y)];
+ if (increment_overflow(&y, 1))
+ return NULL;
+ }
+ tmp->tm_year = y;
+ if (increment_overflow(&tmp->tm_year, -TM_YEAR_BASE))
+ return NULL;
+ tmp->tm_yday = idays;
+ /*
+ ** The "extra" mods below avoid overflow problems.
+ */
+ tmp->tm_wday = EPOCH_WDAY +
+ ((y - EPOCH_YEAR) % DAYSPERWEEK) *
+ (DAYSPERNYEAR % DAYSPERWEEK) +
+ leaps_thru_end_of(y - 1) -
+ leaps_thru_end_of(EPOCH_YEAR - 1) +
+ idays;
+ tmp->tm_wday %= DAYSPERWEEK;
+ if (tmp->tm_wday < 0)
+ tmp->tm_wday += DAYSPERWEEK;
tmp->tm_hour = (int) (rem / SECSPERHOUR);
- rem = rem % SECSPERHOUR;
+ rem %= SECSPERHOUR;
tmp->tm_min = (int) (rem / SECSPERMIN);
/*
** A positive leap second requires a special
- ** representation. This uses "... ??:59:60" et seq.
+ ** representation. This uses "... ??:59:60" et seq.
*/
tmp->tm_sec = (int) (rem % SECSPERMIN) + hit;
- tmp->tm_wday = (int) ((EPOCH_WDAY + days) % DAYSPERWEEK);
- if (tmp->tm_wday < 0)
- tmp->tm_wday += DAYSPERWEEK;
- y = EPOCH_YEAR;
-#define LEAPS_THRU_END_OF(y) ((y) / 4 - (y) / 100 + (y) / 400)
- while (days < 0 || days >= (long) year_lengths[yleap = isleap(y)]) {
- register int newy;
-
- newy = y + days / DAYSPERNYEAR;
- if (days < 0)
- --newy;
- days -= (newy - y) * DAYSPERNYEAR +
- LEAPS_THRU_END_OF(newy - 1) -
- LEAPS_THRU_END_OF(y - 1);
- y = newy;
- }
- tmp->tm_year = y - TM_YEAR_BASE;
- tmp->tm_yday = (int) days;
- ip = mon_lengths[yleap];
- for (tmp->tm_mon = 0; days >= (long) ip[tmp->tm_mon]; ++(tmp->tm_mon))
- days = days - (long) ip[tmp->tm_mon];
- tmp->tm_mday = (int) (days + 1);
+ ip = mon_lengths[isleap(y)];
+ for (tmp->tm_mon = 0; idays >= ip[tmp->tm_mon]; ++(tmp->tm_mon))
+ idays -= ip[tmp->tm_mon];
+ tmp->tm_mday = (int) (idays + 1);
tmp->tm_isdst = 0;
#ifdef TM_GMTOFF
tmp->TM_GMTOFF = offset;
#endif /* defined TM_GMTOFF */
+ return tmp;
}
char *
@@ -1247,7 +1568,7 @@ const time_t * const timep;
/*
** Section 4.12.3.2 of X3.159-1989 requires that
** The ctime function converts the calendar time pointed to by timer
-** to local time in the form of a string. It is equivalent to
+** to local time in the form of a string. It is equivalent to
** asctime(localtime(timer))
*/
return asctime(localtime(timep));
@@ -1258,17 +1579,16 @@ ctime_r(timep, buf)
const time_t * const timep;
char * buf;
{
- struct tm tm;
+ struct tm mytm;
- return asctime_r(localtime_r(timep, &tm), buf);
+ return asctime_r(localtime_r(timep, &mytm), buf);
}
/*
** Adapted from code provided by Robert Elz, who writes:
** The "best" way to do mktime I think is based on an idea of Bob
** Kridle's (so its said...) from a long time ago.
-** [kridle@xinet.com as of 1996-01-16.]
-** It does a binary search of the time_t space. Since time_t's are
+** It does a binary search of the time_t space. Since time_t's are
** just 32 bits, its a max of 32 iterations (even at 64 bits it
** would still be very reasonable).
*/
@@ -1278,7 +1598,7 @@ char * buf;
#endif /* !defined WRONG */
/*
-** Simplified normalize logic courtesy Paul Eggert (eggert@twinsun.com).
+** Simplified normalize logic courtesy Paul Eggert.
*/
static int
@@ -1293,6 +1613,18 @@ int delta;
return (*number < number0) != (delta < 0);
}
+static int
+long_increment_overflow(number, delta)
+long * number;
+int delta;
+{
+ long number0;
+
+ number0 = *number;
+ *number += delta;
+ return (*number < number0) != (delta < 0);
+}
+
static int
normalize_overflow(tensptr, unitsptr, base)
int * const tensptr;
@@ -1308,6 +1640,21 @@ const int base;
return increment_overflow(tensptr, tensdelta);
}
+static int
+long_normalize_overflow(tensptr, unitsptr, base)
+long * const tensptr;
+int * const unitsptr;
+const int base;
+{
+ register int tensdelta;
+
+ tensdelta = (*unitsptr >= 0) ?
+ (*unitsptr / base) :
+ (-1 - (-1 - *unitsptr) / base);
+ *unitsptr -= tensdelta * base;
+ return long_increment_overflow(tensptr, tensdelta);
+}
+
static int
tmcomp(atmp, btmp)
register const struct tm * const atmp;
@@ -1327,16 +1674,19 @@ register const struct tm * const btmp;
static time_t
time2sub(tmp, funcp, offset, okayp, do_norm_secs)
struct tm * const tmp;
-void (* const funcp) P((const time_t*, long, struct tm*));
+struct tm * (* const funcp)(const time_t*, long, struct tm*);
const long offset;
int * const okayp;
const int do_norm_secs;
{
register const struct state * sp;
register int dir;
- register int bits;
- register int i, j ;
+ register int i, j;
register int saved_seconds;
+ register long li;
+ register time_t lo;
+ register time_t hi;
+ long y;
time_t newt;
time_t t;
struct tm yourtm, mytm;
@@ -1352,42 +1702,46 @@ const int do_norm_secs;
return WRONG;
if (normalize_overflow(&yourtm.tm_mday, &yourtm.tm_hour, HOURSPERDAY))
return WRONG;
- if (normalize_overflow(&yourtm.tm_year, &yourtm.tm_mon, MONSPERYEAR))
+ y = yourtm.tm_year;
+ if (long_normalize_overflow(&y, &yourtm.tm_mon, MONSPERYEAR))
return WRONG;
/*
- ** Turn yourtm.tm_year into an actual year number for now.
+ ** Turn y into an actual year number for now.
** It is converted back to an offset from TM_YEAR_BASE later.
*/
- if (increment_overflow(&yourtm.tm_year, TM_YEAR_BASE))
+ if (long_increment_overflow(&y, TM_YEAR_BASE))
return WRONG;
while (yourtm.tm_mday <= 0) {
- if (increment_overflow(&yourtm.tm_year, -1))
+ if (long_increment_overflow(&y, -1))
return WRONG;
- i = yourtm.tm_year + (1 < yourtm.tm_mon);
- yourtm.tm_mday += year_lengths[isleap(i)];
+ li = y + (1 < yourtm.tm_mon);
+ yourtm.tm_mday += year_lengths[isleap(li)];
}
while (yourtm.tm_mday > DAYSPERLYEAR) {
- i = yourtm.tm_year + (1 < yourtm.tm_mon);
- yourtm.tm_mday -= year_lengths[isleap(i)];
- if (increment_overflow(&yourtm.tm_year, 1))
+ li = y + (1 < yourtm.tm_mon);
+ yourtm.tm_mday -= year_lengths[isleap(li)];
+ if (long_increment_overflow(&y, 1))
return WRONG;
}
for ( ; ; ) {
- i = mon_lengths[isleap(yourtm.tm_year)][yourtm.tm_mon];
+ i = mon_lengths[isleap(y)][yourtm.tm_mon];
if (yourtm.tm_mday <= i)
break;
yourtm.tm_mday -= i;
if (++yourtm.tm_mon >= MONSPERYEAR) {
yourtm.tm_mon = 0;
- if (increment_overflow(&yourtm.tm_year, 1))
+ if (long_increment_overflow(&y, 1))
return WRONG;
}
}
- if (increment_overflow(&yourtm.tm_year, -TM_YEAR_BASE))
+ if (long_increment_overflow(&y, -TM_YEAR_BASE))
+ return WRONG;
+ yourtm.tm_year = y;
+ if (yourtm.tm_year != y)
return WRONG;
if (yourtm.tm_sec >= 0 && yourtm.tm_sec < SECSPERMIN)
saved_seconds = 0;
- else if (yourtm.tm_year + TM_YEAR_BASE < EPOCH_YEAR) {
+ else if (y + TM_YEAR_BASE < EPOCH_YEAR) {
/*
** We can't set tm_sec to 0, because that might push the
** time below the minimum representable time.
@@ -1405,27 +1759,53 @@ const int do_norm_secs;
yourtm.tm_sec = 0;
}
/*
- ** Divide the search space in half
- ** (this works whether time_t is signed or unsigned).
+ ** Do a binary search (this works whatever time_t's type is).
*/
- bits = TYPE_BIT(time_t) - 1;
- /*
- ** If time_t is signed, then 0 is just above the median,
- ** assuming two's complement arithmetic.
- ** If time_t is unsigned, then (1 << bits) is just above the median.
- */
- t = TYPE_SIGNED(time_t) ? 0 : (((time_t) 1) << bits);
+ if (!TYPE_SIGNED(time_t)) {
+ lo = 0;
+ hi = lo - 1;
+ } else if (!TYPE_INTEGRAL(time_t)) {
+ if (sizeof(time_t) > sizeof(float))
+ hi = (time_t) DBL_MAX;
+ else hi = (time_t) FLT_MAX;
+ lo = -hi;
+ } else {
+ lo = 1;
+ for (i = 0; i < (int) TYPE_BIT(time_t) - 1; ++i)
+ lo *= 2;
+ hi = -(lo + 1);
+ }
for ( ; ; ) {
- (*funcp)(&t, offset, &mytm);
- dir = tmcomp(&mytm, &yourtm);
+ t = lo / 2 + hi / 2;
+ if (t < lo)
+ t = lo;
+ else if (t > hi)
+ t = hi;
+ if ((*funcp)(&t, offset, &mytm) == NULL) {
+ /*
+ ** Assume that t is too extreme to be represented in
+ ** a struct tm; arrange things so that it is less
+ ** extreme on the next pass.
+ */
+ dir = (t > 0) ? 1 : -1;
+ } else dir = tmcomp(&mytm, &yourtm);
if (dir != 0) {
- if (bits-- < 0)
+ if (t == lo) {
+ ++t;
+ if (t <= lo)
+ return WRONG;
+ ++lo;
+ } else if (t == hi) {
+ --t;
+ if (t >= hi)
+ return WRONG;
+ --hi;
+ }
+ if (lo > hi)
return WRONG;
- if (bits < 0)
- --t; /* may be needed if new t is minimal */
- else if (dir > 0)
- t -= ((time_t) 1) << bits;
- else t += ((time_t) 1) << bits;
+ if (dir > 0)
+ hi = t;
+ else lo = t;
continue;
}
if (yourtm.tm_isdst < 0 || mytm.tm_isdst == yourtm.tm_isdst)
@@ -1436,12 +1816,8 @@ const int do_norm_secs;
** It's okay to guess wrong since the guess
** gets checked.
*/
- /*
- ** The (void *) casts are the benefit of SunOS 3.3 on Sun 2's.
- */
sp = (const struct state *)
- (((void *) funcp == (void *) localsub) ?
- lclptr : gmtptr);
+ ((funcp == localsub) ? lclptr : gmtptr);
#ifdef ALL_STATE
if (sp == NULL)
return WRONG;
@@ -1454,7 +1830,8 @@ const int do_norm_secs;
continue;
newt = t + sp->ttis[j].tt_gmtoff -
sp->ttis[i].tt_gmtoff;
- (*funcp)(&newt, offset, &mytm);
+ if ((*funcp)(&newt, offset, &mytm) == NULL)
+ continue;
if (tmcomp(&mytm, &yourtm) != 0)
continue;
if (mytm.tm_isdst != yourtm.tm_isdst)
@@ -1473,15 +1850,15 @@ label:
if ((newt < t) != (saved_seconds < 0))
return WRONG;
t = newt;
- (*funcp)(&t, offset, tmp);
- *okayp = TRUE;
+ if ((*funcp)(&t, offset, tmp))
+ *okayp = TRUE;
return t;
}
static time_t
time2(tmp, funcp, offset, okayp)
struct tm * const tmp;
-void (* const funcp) P((const time_t*, long, struct tm*));
+struct tm * (* const funcp)(const time_t*, long, struct tm*);
const long offset;
int * const okayp;
{
@@ -1499,7 +1876,7 @@ int * const okayp;
static time_t
time1(tmp, funcp, offset)
struct tm * const tmp;
-void (* const funcp) P((const time_t *, long, struct tm *));
+struct tm * (* const funcp)(const time_t *, long, struct tm *);
const long offset;
{
register time_t t;
@@ -1517,7 +1894,7 @@ const long offset;
t = time2(tmp, funcp, offset, &okay);
#ifdef PCTS
/*
- ** PCTS code courtesy Grant Sullivan (grant@osf.org).
+ ** PCTS code courtesy Grant Sullivan.
*/
if (okay)
return t;
@@ -1534,11 +1911,7 @@ const long offset;
** We try to divine the type they started from and adjust to the
** type they need.
*/
- /*
- ** The (void *) casts are the benefit of SunOS 3.3 on Sun 2's.
- */
- sp = (const struct state *) (((void *) funcp == (void *) localsub) ?
- lclptr : gmtptr);
+ sp = (const struct state *) ((funcp == localsub) ? lclptr : gmtptr);
#ifdef ALL_STATE
if (sp == NULL)
return WRONG;
@@ -1680,7 +2053,7 @@ time_t t;
tzset();
/*
** For a positive leap second hit, the result
- ** is not unique. For a negative leap second
+ ** is not unique. For a negative leap second
** hit, the corresponding time doesn't exist,
** so we return an adjacent second.
*/
diff --git a/libc/stdtime/private.h b/libc/stdtime/private.h
index c8f45486837..008d468ac78 100644
--- a/libc/stdtime/private.h
+++ b/libc/stdtime/private.h
@@ -4,7 +4,7 @@
/*
** 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.
*/
/*
@@ -21,10 +21,12 @@
#ifndef lint
#ifndef NOID
-static char privatehid[] = "@(#)private.h 7.53";
+static char privatehid[] = "@(#)private.h 8.6";
#endif /* !defined NOID */
#endif /* !defined lint */
+#define GRANDPARENTED "Local time zone must be set--see zic manual page"
+
/*
** Defaults for preprocessor symbols.
** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'.
@@ -46,10 +48,6 @@ static char privatehid[] = "@(#)private.h 7.53";
#define HAVE_SETTIMEOFDAY 3
#endif /* !defined HAVE_SETTIMEOFDAY */
-#ifndef HAVE_STRERROR
-#define HAVE_STRERROR 1
-#endif /* !defined HAVE_STRERROR */
-
#ifndef HAVE_SYMLINK
#define HAVE_SYMLINK 1
#endif /* !defined HAVE_SYMLINK */
@@ -87,17 +85,17 @@ static char privatehid[] = "@(#)private.h 7.53";
#include "stdio.h"
#include "errno.h"
#include "string.h"
-#include "limits.h" /* for CHAR_BIT */
+#include "limits.h" /* for CHAR_BIT et al. */
#include "time.h"
#include "stdlib.h"
-#if HAVE_GETTEXT - 0
+#if HAVE_GETTEXT
#include "libintl.h"
-#endif /* HAVE_GETTEXT - 0 */
+#endif /* HAVE_GETTEXT */
-#if HAVE_SYS_WAIT_H - 0
+#if HAVE_SYS_WAIT_H
#include /* for WIFEXITED and WEXITSTATUS */
-#endif /* HAVE_SYS_WAIT_H - 0 */
+#endif /* HAVE_SYS_WAIT_H */
#ifndef WIFEXITED
#define WIFEXITED(status) (((status) & 0xff) == 0)
@@ -106,106 +104,82 @@ static char privatehid[] = "@(#)private.h 7.53";
#define WEXITSTATUS(status) (((status) >> 8) & 0xff)
#endif /* !defined WEXITSTATUS */
-#if HAVE_UNISTD_H - 0
-#include "unistd.h" /* for F_OK and R_OK */
-#endif /* HAVE_UNISTD_H - 0 */
+#if HAVE_UNISTD_H
+#include "unistd.h" /* for F_OK, R_OK, and other POSIX goodness */
+#endif /* HAVE_UNISTD_H */
-#if !(HAVE_UNISTD_H - 0)
#ifndef F_OK
#define F_OK 0
#endif /* !defined F_OK */
#ifndef R_OK
#define R_OK 4
#endif /* !defined R_OK */
-#endif /* !(HAVE_UNISTD_H - 0) */
-/* Unlike 's isdigit, this also works if c < 0 | c > UCHAR_MAX. */
+/* Unlike 's isdigit, this also works if c < 0 | c > UCHAR_MAX. */
#define is_digit(c) ((unsigned)(c) - '0' <= 9)
+/*
+** Define HAVE_STDINT_H's default value here, rather than at the
+** start, since __GLIBC__'s value depends on previously-included
+** files.
+** (glibc 2.1 and later have stdint.h, even with pre-C99 compilers.)
+*/
+#ifndef HAVE_STDINT_H
+#define HAVE_STDINT_H \
+ (199901 <= __STDC_VERSION__ || \
+ 2 < (__GLIBC__ + (0 < __GLIBC_MINOR__)))
+#endif /* !defined HAVE_STDINT_H */
+
+#if HAVE_STDINT_H
+#include "stdint.h"
+#endif /* !HAVE_STDINT_H */
+
+#ifndef INT_FAST64_MAX
+/* Pre-C99 GCC compilers define __LONG_LONG_MAX__ instead of LLONG_MAX. */
+#if defined LLONG_MAX || defined __LONG_LONG_MAX__
+typedef long long int_fast64_t;
+#else /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */
+#if (LONG_MAX >> 31) < 0xffffffff
+Please use a compiler that supports a 64-bit integer type (or wider);
+you may need to compile with "-DHAVE_STDINT_H".
+#endif /* (LONG_MAX >> 31) < 0xffffffff */
+typedef long int_fast64_t;
+#endif /* ! (defined LLONG_MAX || defined __LONG_LONG_MAX__) */
+#endif /* !defined INT_FAST64_MAX */
+
+#ifndef INT32_MAX
+#define INT32_MAX 0x7fffffff
+#endif /* !defined INT32_MAX */
+#ifndef INT32_MIN
+#define INT32_MIN (-1 - INT32_MAX)
+#endif /* !defined INT32_MIN */
+
/*
** Workarounds for compilers/systems.
*/
/*
-** SunOS 4.1.1 cc lacks prototypes.
-*/
-
-#ifndef P
-#ifdef __STDC__
-#define P(x) x
-#endif /* defined __STDC__ */
-#ifndef __STDC__
-#define P(x) ()
-#endif /* !defined __STDC__ */
-#endif /* !defined P */
-
-/*
-** SunOS 4.1.1 headers lack EXIT_SUCCESS.
-*/
-
-#ifndef EXIT_SUCCESS
-#define EXIT_SUCCESS 0
-#endif /* !defined EXIT_SUCCESS */
-
-/*
-** SunOS 4.1.1 headers lack EXIT_FAILURE.
-*/
-
-#ifndef EXIT_FAILURE
-#define EXIT_FAILURE 1
-#endif /* !defined EXIT_FAILURE */
-
-/*
-** SunOS 4.1.1 headers lack FILENAME_MAX.
-*/
-
-#ifndef FILENAME_MAX
-
-#ifndef MAXPATHLEN
-#ifdef unix
-#include "sys/param.h"
-#endif /* defined unix */
-#endif /* !defined MAXPATHLEN */
-
-#ifdef MAXPATHLEN
-#define FILENAME_MAX MAXPATHLEN
-#endif /* defined MAXPATHLEN */
-#ifndef MAXPATHLEN
-#define FILENAME_MAX 1024 /* Pure guesswork */
-#endif /* !defined MAXPATHLEN */
-
-#endif /* !defined FILENAME_MAX */
-
-/*
-** SunOS 4.1.1 libraries lack remove.
-*/
-
-#ifndef remove
-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.
+** Some time.h implementations don't declare asctime_r.
+** Others might define it as a macro.
** Fix the former without affecting the latter.
*/
-#ifndef errno
-extern int errno;
-#endif /* !defined errno */
+
+#ifndef asctime_r
+extern char * asctime_r(struct tm const *, char *);
+#endif
/*
** Private function declarations.
*/
-char * icalloc P((int nelem, int elsize));
-char * icatalloc P((char * old, const char * new));
-char * icpyalloc P((const char * string));
-char * imalloc P((int n));
-void * irealloc P((void * pointer, int size));
-void icfree P((char * pointer));
-void ifree P((char * pointer));
-char * scheck P((const char *string, const char *format));
+char * icalloc(int nelem, int elsize);
+char * icatalloc(char * old, const char * new);
+char * icpyalloc(const char * string);
+char * imalloc(int n);
+void * irealloc(void * pointer, int size);
+void icfree(char * pointer);
+void ifree(char * pointer);
+const char * scheck(const char * string, const char * format);
/*
** Finally, some convenience items.
@@ -227,6 +201,15 @@ char * scheck P((const char *string, const char *format));
#define TYPE_SIGNED(type) (((type) -1) < 0)
#endif /* !defined TYPE_SIGNED */
+/*
+** Since the definition of TYPE_INTEGRAL contains floating point numbers,
+** it cannot be used in preprocessor directives.
+*/
+
+#ifndef TYPE_INTEGRAL
+#define TYPE_INTEGRAL(type) (((type) 0.5) != 0.5)
+#endif /* !defined TYPE_INTEGRAL */
+
#ifndef INT_STRLEN_MAXIMUM
/*
** 302 / 1000 is log10(2.0) rounded up.
@@ -235,7 +218,8 @@ char * scheck P((const char *string, const char *format));
** add one more for a minus sign if the type is signed.
*/
#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 */
/*
@@ -269,11 +253,11 @@ char * scheck P((const char *string, const char *format));
*/
#ifndef _
-#if HAVE_GETTEXT - 0
+#if HAVE_GETTEXT
#define _(msgid) gettext(msgid)
-#else /* !(HAVE_GETTEXT - 0) */
+#else /* !HAVE_GETTEXT */
#define _(msgid) msgid
-#endif /* !(HAVE_GETTEXT - 0) */
+#endif /* !HAVE_GETTEXT */
#endif /* !defined _ */
#ifndef TZ_DOMAIN
@@ -283,10 +267,30 @@ char * scheck P((const char *string, const char *format));
#if HAVE_INCOMPATIBLE_CTIME_R
#undef asctime_r
#undef ctime_r
-char *asctime_r P((struct tm const *, char *));
-char *ctime_r P((time_t const *, char *));
+char *asctime_r(struct tm const *, char *);
+char *ctime_r(time_t const *, char *);
#endif /* HAVE_INCOMPATIBLE_CTIME_R */
+#ifndef YEARSPERREPEAT
+#define YEARSPERREPEAT 400 /* years before a Gregorian repeat */
+#endif /* !defined YEARSPERREPEAT */
+
+/*
+** The Gregorian year averages 365.2425 days, which is 31556952 seconds.
+*/
+
+#ifndef AVGSECSPERYEAR
+#define AVGSECSPERYEAR 31556952L
+#endif /* !defined AVGSECSPERYEAR */
+
+#ifndef SECSPERREPEAT
+#define SECSPERREPEAT ((int_fast64_t) YEARSPERREPEAT * (int_fast64_t) AVGSECSPERYEAR)
+#endif /* !defined SECSPERREPEAT */
+
+#ifndef SECSPERREPEAT_BITS
+#define SECSPERREPEAT_BITS 34 /* ceil(log2(SECSPERREPEAT)) */
+#endif /* !defined SECSPERREPEAT_BITS */
+
/*
** UNIX was a registered trademark of The Open Group in 2003.
*/
diff --git a/libc/stdtime/strftime.c b/libc/stdtime/strftime.c
index 365a42e12b8..d036d07690f 100644
--- a/libc/stdtime/strftime.c
+++ b/libc/stdtime/strftime.c
@@ -1,6 +1,6 @@
#ifndef lint
#ifndef NOID
-static char elsieid[] = "@(#)strftime.c 7.64";
+static char elsieid[] = "@(#)strftime.c 8.3";
/*
** Based on the UCB version with the ID appearing below.
** This is ANSIish only when "multibyte character == plain character".
@@ -19,7 +19,7 @@ static char elsieid[] = "@(#)strftime.c 7.64";
** duplicated in all such forms and that any documentation,
** advertising materials, and other materials related to such
** distribution and use acknowledge that the software was developed
-** by the University of California, Berkeley. The name of the
+** by the University of California, Berkeley. The name of the
** University may not be used to endorse or promote products derived
** from this software without specific prior written permission.
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
@@ -53,7 +53,7 @@ struct lc_time_T {
#ifdef LOCALE_HOME
#include "sys/stat.h"
static struct lc_time_T localebuf;
-static struct lc_time_T * _loc P((void));
+static struct lc_time_T * _loc(void);
#define Locale _loc()
#endif /* defined LOCALE_HOME */
#ifndef LOCALE_HOME
@@ -91,7 +91,7 @@ static const struct lc_time_T C_time_locale = {
** C99 requires this format.
** Previously this code used "%D %X", but we now conform to C99.
** Note that
- ** "%a %b %d %H:%M:%S %Y"
+ ** "%a %b %d %H:%M:%S %Y"
** is used by Solaris 2.3.
*/
"%a %b %e %T %Y",
@@ -106,11 +106,11 @@ static const struct lc_time_T C_time_locale = {
"%a %b %e %H:%M:%S %Z %Y"
};
-static char * _add P((const char *, char *, const char *));
-static char * _conv P((int, const char *, char *, const char *));
-static char * _fmt P((const char *, const struct tm *, char *, const char *, int *));
-
-size_t strftime P((char *, size_t, const char *, const struct tm *));
+static char * _add(const char *, char *, const char *);
+static char * _conv(int, const char *, char *, const char *);
+static char * _fmt(const char *, const struct tm *, char *, const char *,
+ int *);
+static char * _yconv(int, int, int, int, char *, const char *);
extern char * tzname[];
@@ -118,7 +118,6 @@ extern char * tzname[];
#define YEAR_2000_NAME "CHECK_STRFTIME_FORMATS_FOR_TWO_DIGIT_YEARS"
#endif /* !defined YEAR_2000_NAME */
-
#define IN_NONE 0
#define IN_SOME 1
#define IN_THIS 2
@@ -210,14 +209,14 @@ label:
** something completely different.
** (ado, 1993-05-24)
*/
- pt = _conv((t->tm_year + TM_YEAR_BASE) / 100,
- "%02d", pt, ptlim);
+ pt = _yconv(t->tm_year, TM_YEAR_BASE, 1, 0,
+ pt, ptlim);
continue;
case 'c':
{
int warn2 = IN_SOME;
- pt = _fmt(Locale->c_fmt, t, pt, ptlim, warnp);
+ pt = _fmt(Locale->c_fmt, t, pt, ptlim, &warn2);
if (warn2 == IN_ALL)
warn2 = IN_THIS;
if (warn2 > *warnp)
@@ -266,7 +265,7 @@ label:
** t->tm_hour % 12 : 12, 2, ' ');
** ...and has been changed to the below to
** match SunOS 4.1.1 and Arnold Robbins'
- ** strftime version 3.0. That is, "%k" and
+ ** strftime version 3.0. That is, "%k" and
** "%l" have been swapped.
** (ado, 1993-05-24)
*/
@@ -286,7 +285,7 @@ label:
** _conv(t->tm_hour, 2, ' ');
** ...and has been changed to the below to
** match SunOS 4.1.1 and Arnold Robbin's
- ** strftime version 3.0. That is, "%k" and
+ ** strftime version 3.0. That is, "%k" and
** "%l" have been swapped.
** (ado, 1993-05-24)
*/
@@ -361,7 +360,7 @@ label:
case 'G': /* ISO 8601 year (four digits) */
case 'g': /* ISO 8601 year (two digits) */
/*
-** From Arnold Robbins' strftime version 3.0: "the week number of the
+** From Arnold Robbins' strftime version 3.0: "the week number of the
** year (the first Monday as the first day of week 1) as a decimal number
** (01-53)."
** (ado, 1993-05-24)
@@ -374,17 +373,19 @@ label:
** might also contain days from the previous year and the week before week
** 01 of a year is the last week (52 or 53) of the previous year even if
** it contains days from the new year. A week starts with Monday (day 1)
-** and ends with Sunday (day 7). For example, the first week of the year
+** and ends with Sunday (day 7). For example, the first week of the year
** 1997 lasts from 1996-12-30 to 1997-01-05..."
** (ado, 1996-01-02)
*/
{
int year;
+ int base;
int yday;
int wday;
int w;
- year = t->tm_year + TM_YEAR_BASE;
+ year = t->tm_year;
+ base = TM_YEAR_BASE;
yday = t->tm_yday;
wday = t->tm_wday;
for ( ; ; ) {
@@ -392,7 +393,7 @@ label:
int bot;
int top;
- len = isleap(year) ?
+ len = isleap_sum(year, base) ?
DAYSPERLYEAR :
DAYSPERNYEAR;
/*
@@ -411,7 +412,7 @@ label:
top += DAYSPERWEEK;
top += len;
if (yday >= top) {
- ++year;
+ ++base;
w = 1;
break;
}
@@ -420,26 +421,26 @@ label:
DAYSPERWEEK);
break;
}
- --year;
- yday += isleap(year) ?
+ --base;
+ yday += isleap_sum(year, base) ?
DAYSPERLYEAR :
DAYSPERNYEAR;
}
#ifdef XPG4_1994_04_09
- if ((w == 52
- && t->tm_mon == TM_JANUARY)
- || (w == 1
- && t->tm_mon == TM_DECEMBER))
- w = 53;
+ if ((w == 52 &&
+ t->tm_mon == TM_JANUARY) ||
+ (w == 1 &&
+ t->tm_mon == TM_DECEMBER))
+ w = 53;
#endif /* defined XPG4_1994_04_09 */
if (*format == 'V')
pt = _conv(w, "%02d",
pt, ptlim);
else if (*format == 'g') {
*warnp = IN_ALL;
- pt = _conv(year % 100, "%02d",
+ pt = _yconv(year, base, 0, 1,
pt, ptlim);
- } else pt = _conv(year, "%04d",
+ } else pt = _yconv(year, base, 1, 1,
pt, ptlim);
}
continue;
@@ -477,11 +478,11 @@ label:
continue;
case 'y':
*warnp = IN_ALL;
- pt = _conv((t->tm_year + TM_YEAR_BASE) % 100,
- "%02d", pt, ptlim);
+ pt = _yconv(t->tm_year, TM_YEAR_BASE, 0, 1,
+ pt, ptlim);
continue;
case 'Y':
- pt = _conv(t->tm_year + TM_YEAR_BASE, "%04d",
+ pt = _yconv(t->tm_year, TM_YEAR_BASE, 1, 1,
pt, ptlim);
continue;
case 'Z':
@@ -512,12 +513,12 @@ label:
/*
** C99 says that the UTC offset must
** be computed by looking only at
- ** tm_isdst. This requirement is
+ ** tm_isdst. This requirement is
** incorrect, since it means the code
** must rely on magic (in this case
** altzone and timezone), and the
** magic might not have the correct
- ** offset. Doing things correctly is
+ ** offset. Doing things correctly is
** tricky and requires disobeying C99;
** see GNU C strftime for details.
** For now, punt and conform to the
@@ -546,9 +547,10 @@ label:
diff = -diff;
} else sign = "+";
pt = _add(sign, pt, ptlim);
- diff /= 60;
- pt = _conv((diff/60)*100 + diff%60,
- "%04d", pt, ptlim);
+ diff /= SECSPERMIN;
+ diff = (diff / MINSPERHOUR) * 100 +
+ (diff % MINSPERHOUR);
+ pt = _conv(diff, "%04d", pt, ptlim);
}
continue;
case '+':
@@ -558,7 +560,7 @@ label:
case '%':
/*
** X311J/88-090 (4.12.3.5): if conversion char is
- ** undefined, behavior is undefined. Print out the
+ ** undefined, behavior is undefined. Print out the
** character itself as printf(3) also does.
*/
default:
@@ -596,9 +598,50 @@ const char * const ptlim;
return pt;
}
+/*
+** POSIX and the C Standard are unclear or inconsistent about
+** what %C and %y do if the year is negative or exceeds 9999.
+** Use the convention that %C concatenated with %y yields the
+** same output as %Y, and that %Y contains at least 4 bytes,
+** with more only if necessary.
+*/
+
+static char *
+_yconv(a, b, convert_top, convert_yy, pt, ptlim)
+const int a;
+const int b;
+const int convert_top;
+const int convert_yy;
+char * pt;
+const char * const ptlim;
+{
+ register int lead;
+ register int trail;
+
+#define DIVISOR 100
+ trail = a % DIVISOR + b % DIVISOR;
+ lead = a / DIVISOR + b / DIVISOR + trail / DIVISOR;
+ trail %= DIVISOR;
+ if (trail < 0 && lead > 0) {
+ trail += DIVISOR;
+ --lead;
+ } else if (lead < 0 && trail > 0) {
+ trail -= DIVISOR;
+ ++lead;
+ }
+ if (convert_top) {
+ if (lead == 0 && trail < 0)
+ pt = _add("-0", pt, ptlim);
+ else pt = _conv(lead, "%02d", pt, ptlim);
+ }
+ if (convert_yy)
+ pt = _conv(((trail < 0) ? -trail : trail), "%02d", pt, ptlim);
+ return pt;
+}
+
#ifdef LOCALE_HOME
static struct lc_time_T *
-_loc P((void))
+_loc(void)
{
static const char locale_home[] = LOCALE_HOME;
static const char lc_time[] = "LC_TIME";
@@ -640,7 +683,7 @@ _loc P((void))
** Slurp the locale file into the cache.
*/
namesize = strlen(name) + 1;
- if (sizeof filename <
+ if (sizeof filename <
((sizeof locale_home) + namesize + (sizeof lc_time)))
goto no_locale;
oldsun = 0;
@@ -663,7 +706,7 @@ _loc P((void))
goto bad_locale;
bufsize = namesize + st.st_size;
locale_buf = NULL;
- lbuf = (lbuf == NULL) ? malloc(bufsize) : realloc(lbuf, bufsize);
+ lbuf = (lbuf == NULL) ? malloc(bufsize) : realloc(lbuf, bufsize);
if (lbuf == NULL)
goto bad_locale;
(void) strcpy(lbuf, name);
diff --git a/libc/stdtime/time2posix.3 b/libc/stdtime/time2posix.3
new file mode 100644
index 00000000000..96959c642ed
--- /dev/null
+++ b/libc/stdtime/time2posix.3
@@ -0,0 +1,121 @@
+.TH TIME2POSIX 3
+.SH NAME
+time2posix, posix2time \- convert seconds since the Epoch
+.SH SYNOPSIS
+.nf
+.B #include
+.B #include
+.PP
+.B time_t time2posix(t)
+.B time_t t
+.PP
+.B time_t posix2time(t)
+.B time_t t
+.PP
+.B cc ... -ltz
+.fi
+.SH DESCRIPTION
+IEEE Standard 1003.1
+(POSIX)
+legislates that a time_t value of
+536457599 shall correspond to "Wed Dec 31 23:59:59 UTC 1986."
+This effectively implies that POSIX time_t's cannot include leap
+seconds and,
+therefore,
+that the system time must be adjusted as each leap occurs.
+.PP
+If the time package is configured with leap-second support
+enabled,
+however,
+no such adjustment is needed and
+time_t values continue to increase over leap events
+(as a true `seconds since...' value).
+This means that these values will differ from those required by POSIX
+by the net number of leap seconds inserted since the Epoch.
+.PP
+Typically this is not a problem as the type time_t is intended
+to be
+(mostly)
+opaque\(emtime_t values should only be obtained-from and
+passed-to functions such as
+.IR time(2) ,
+.IR localtime(3) ,
+.IR mktime(3) ,
+and
+.IR difftime(3) .
+However,
+POSIX gives an arithmetic
+expression for directly computing a time_t value from a given date/time,
+and the same relationship is assumed by some
+(usually older)
+applications.
+Any programs creating/dissecting time_t's
+using such a relationship will typically not handle intervals
+over leap seconds correctly.
+.PP
+The
+.I time2posix
+and
+.I posix2time
+functions are provided to address this time_t mismatch by converting
+between local time_t values and their POSIX equivalents.
+This is done by accounting for the number of time-base changes that
+would have taken place on a POSIX system as leap seconds were inserted
+or deleted.
+These converted values can then be used in lieu of correcting the older
+applications,
+or when communicating with POSIX-compliant systems.
+.PP
+.I Time2posix
+is single-valued.
+That is,
+every local time_t
+corresponds to a single POSIX time_t.
+.I Posix2time
+is less well-behaved:
+for a positive leap second hit the result is not unique,
+and for a negative leap second hit the corresponding
+POSIX time_t doesn't exist so an adjacent value is returned.
+Both of these are good indicators of the inferiority of the
+POSIX representation.
+.PP
+The following table summarizes the relationship between a time
+T and it's conversion to,
+and back from,
+the POSIX representation over the leap second inserted at the end of June,
+1993.
+.nf
+.ta \w'93/06/30 'u +\w'23:59:59 'u +\w'A+0 'u +\w'X=time2posix(T) 'u
+DATE TIME T X=time2posix(T) posix2time(X)
+93/06/30 23:59:59 A+0 B+0 A+0
+93/06/30 23:59:60 A+1 B+1 A+1 or A+2
+93/07/01 00:00:00 A+2 B+1 A+1 or A+2
+93/07/01 00:00:01 A+3 B+2 A+3
+
+A leap second deletion would look like...
+
+DATE TIME T X=time2posix(T) posix2time(X)
+??/06/30 23:59:58 A+0 B+0 A+0
+??/07/01 00:00:00 A+1 B+2 A+1
+??/07/01 00:00:01 A+2 B+3 A+2
+.sp
+.ce
+ [Note: posix2time(B+1) => A+0 or A+1]
+.fi
+.PP
+If leap-second support is not enabled,
+local time_t's and
+POSIX time_t's are equivalent,
+and both
+.I time2posix
+and
+.I posix2time
+degenerate to the identity function.
+.SH SEE ALSO
+difftime(3),
+localtime(3),
+mktime(3),
+time(2)
+.\" @(#)time2posix.3 8.1
+.\" This file is in the public domain, so clarified as of
+.\" 1996-06-05 by Arthur David Olson.
diff --git a/libc/stdtime/tzfile.5 b/libc/stdtime/tzfile.5
new file mode 100644
index 00000000000..6b8768cc9fc
--- /dev/null
+++ b/libc/stdtime/tzfile.5
@@ -0,0 +1,152 @@
+.TH TZFILE 5
+.SH NAME
+tzfile \- time zone information
+.SH SYNOPSIS
+.B
+#include
+.SH DESCRIPTION
+The time zone information files used by
+.IR tzset (3)
+begin with the magic characters "TZif" to identify then as
+time zone information files,
+followed by a character identifying the version of the file's format
+(as of 2005, either an ASCII NUL or a '2')
+followed by fifteen bytes containing zeroes reserved for future use,
+followed by six four-byte values of type
+.BR long ,
+written in a ``standard'' byte order
+(the high-order byte of the value is written first).
+These values are,
+in order:
+.TP
+.I tzh_ttisgmtcnt
+The number of UTC/local indicators stored in the file.
+.TP
+.I tzh_ttisstdcnt
+The number of standard/wall indicators stored in the file.
+.TP
+.I tzh_leapcnt
+The number of leap seconds for which data is stored in the file.
+.TP
+.I tzh_timecnt
+The number of "transition times" for which data is stored
+in the file.
+.TP
+.I tzh_typecnt
+The number of "local time types" for which data is stored
+in the file (must not be zero).
+.TP
+.I tzh_charcnt
+The number of characters of "time zone abbreviation strings"
+stored in the file.
+.PP
+The above header is followed by
+.I tzh_timecnt
+four-byte values of type
+.BR long ,
+sorted in ascending order.
+These values are written in ``standard'' byte order.
+Each is used as a transition time (as returned by
+.IR time (2))
+at which the rules for computing local time change.
+Next come
+.I tzh_timecnt
+one-byte values of type
+.BR "unsigned char" ;
+each one tells which of the different types of ``local time'' types
+described in the file is associated with the same-indexed transition time.
+These values serve as indices into an array of
+.I ttinfo
+structures (with
+.I tzh_typecnt
+entries) that appears next in the file;
+these structures are defined as follows:
+.in +.5i
+.sp
+.nf
+.ta .5i +\w'unsigned int\0\0'u
+struct ttinfo {
+ long tt_gmtoff;
+ int tt_isdst;
+ unsigned int tt_abbrind;
+};
+.in -.5i
+.fi
+.sp
+Each structure is written as a four-byte value for
+.I tt_gmtoff
+of type
+.BR long ,
+in a standard byte order, followed by a one-byte value for
+.I tt_isdst
+and a one-byte value for
+.IR tt_abbrind .
+In each structure,
+.I tt_gmtoff
+gives the number of seconds to be added to UTC,
+.I tt_isdst
+tells whether
+.I tm_isdst
+should be set by
+.I localtime (3)
+and
+.I tt_abbrind
+serves as an index into the array of time zone abbreviation characters
+that follow the
+.I ttinfo
+structure(s) in the file.
+.PP
+Then there are
+.I tzh_leapcnt
+pairs of four-byte values, written in standard byte order;
+the first value of each pair gives the time
+(as returned by
+.IR time(2))
+at which a leap second occurs;
+the second gives the
+.I total
+number of leap seconds to be applied after the given time.
+The pairs of values are sorted in ascending order by time.
+.PP
+Then there are
+.I tzh_ttisstdcnt
+standard/wall indicators, each stored as a one-byte value;
+they tell whether the transition times associated with local time types
+were specified as standard time or wall clock time,
+and are used when a time zone file is used in handling POSIX-style
+time zone environment variables.
+.PP
+Finally there are
+.I tzh_ttisgmtcnt
+UTC/local indicators, each stored as a one-byte value;
+they tell whether the transition times associated with local time types
+were specified as UTC or local time,
+and are used when a time zone file is used in handling POSIX-style
+time zone environment variables.
+.PP
+.I Localtime
+uses the first standard-time
+.I ttinfo
+structure in the file
+(or simply the first
+.I ttinfo
+structure in the absence of a standard-time structure)
+if either
+.I tzh_timecnt
+is zero or the time argument is less than the first transition time recorded
+in the file.
+.PP
+For version-2-format time zone files,
+the above header and data is followed by a second header and data,
+identical in format except that
+eight bytes are used for each transition time or leap second time.
+After the second header and data comes a newline-enclosed,
+POSIX-TZ-environment-variable-style string for use in handling instants
+after the last transition time stored in the file
+(with nothing between the newlines if there is no POSIX representation for
+such instants).
+.SH SEE ALSO
+newctime(3)
+.\" @(#)tzfile.5 8.2
+.\" This file is in the public domain, so clarified as of
+.\" 1996-06-05 by Arthur David Olson.
diff --git a/libc/stdtime/tzfile.h b/libc/stdtime/tzfile.h
index 0921c3c3396..3a9eee305a5 100644
--- a/libc/stdtime/tzfile.h
+++ b/libc/stdtime/tzfile.h
@@ -4,7 +4,7 @@
/*
** 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.
*/
/*
@@ -21,7 +21,7 @@
#ifndef lint
#ifndef NOID
-static char tzfilehid[] = "@(#)tzfile.h 7.14";
+static char tzfilehid[] = "@(#)tzfile.h 8.1";
#endif /* !defined NOID */
#endif /* !defined lint */
@@ -48,8 +48,9 @@ static char tzfilehid[] = "@(#)tzfile.h 7.14";
#define TZ_MAGIC "TZif"
struct tzhead {
- char tzh_magic[4]; /* TZ_MAGIC */
- char tzh_reserved[16]; /* reserved for future use */
+ char tzh_magic[4]; /* TZ_MAGIC */
+ char tzh_version[1]; /* '\0' or '2' as of 2005 */
+ char tzh_reserved[15]; /* reserved--must be zero */
char tzh_ttisgmtcnt[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 */
@@ -83,19 +84,23 @@ struct tzhead {
** assumed to be local time
*/
+/*
+** If tzh_version is '2' or greater, the above is followed by a second instance
+** of tzhead and a second instance of the data in which each coded transition
+** time uses 8 rather than 4 chars,
+** then a POSIX-TZ-environment-variable-style string for use in handling
+** instants after the last transition time stored in the file
+** (with nothing between the newlines if there is no POSIX representation for
+** such instants).
+*/
+
/*
** In the current implementation, "tzset()" refuses to deal with files that
** exceed any of the limits below.
*/
#ifndef TZ_MAX_TIMES
-/*
-** 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
-** 138 years of Pacific Presidential Election time
-** (where there are three time zone transitions every fourth year).
-*/
-#define TZ_MAX_TIMES 370
+#define TZ_MAX_TIMES 1200
#endif /* !defined TZ_MAX_TIMES */
#ifndef TZ_MAX_TYPES
@@ -105,7 +110,7 @@ struct tzhead {
#ifdef NOSOLAR
/*
** Must be at least 14 for Europe/Riga as of Jan 12 1995,
-** as noted by Earl Chew .
+** as noted by Earl Chew.
*/
#define TZ_MAX_TYPES 20 /* Maximum number of local time types */
#endif /* !defined NOSOLAR */
@@ -156,33 +161,20 @@ struct tzhead {
#define EPOCH_YEAR 1970
#define EPOCH_WDAY TM_THURSDAY
-/*
-** Accurate only for the past couple of centuries;
-** that will probably do.
-*/
-
#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
-#ifndef USG
-
/*
-** Use of the underscored variants may cause problems if you move your code to
-** certain System-V-based systems; for maximum portability, use the
-** underscore-free variants. The underscored variants are provided for
-** backward compatibility only; they may disappear from future versions of
-** this file.
+** Since everything in isleap is modulo 400 (or a factor of 400), we know that
+** isleap(y) == isleap(y % 400)
+** and so
+** isleap(a + b) == isleap((a + b) % 400)
+** or
+** isleap(a + b) == isleap(a % 400 + b % 400)
+** This is true even if % means modulo rather than Fortran remainder
+** (which is allowed by C89 but not C99).
+** We use this to avoid addition overflow problems.
*/
-#define SECS_PER_MIN SECSPERMIN
-#define MINS_PER_HOUR MINSPERHOUR
-#define HOURS_PER_DAY HOURSPERDAY
-#define DAYS_PER_WEEK DAYSPERWEEK
-#define DAYS_PER_NYEAR DAYSPERNYEAR
-#define DAYS_PER_LYEAR DAYSPERLYEAR
-#define SECS_PER_HOUR SECSPERHOUR
-#define SECS_PER_DAY SECSPERDAY
-#define MONS_PER_YEAR MONSPERYEAR
-
-#endif /* !defined USG */
+#define isleap_sum(a, b) isleap((a) % 400 + (b) % 400)
#endif /* !defined TZFILE_H */
diff --git a/unused/Makefile b/unused/Makefile
new file mode 100644
index 00000000000..3865f23766e
--- /dev/null
+++ b/unused/Makefile
@@ -0,0 +1,418 @@
+# @(#)Makefile 8.7
+
+# Change the line below for your time zone (after finding the zone you want in
+# the time zone files, or adding it to a time zone file).
+# Alternately, if you discover you've got the wrong time zone, you can just
+# zic -l rightzone
+# to correct things.
+# Use the command
+# make zonenames
+# to get a list of the values you can use for LOCALTIME.
+
+LOCALTIME= Factory
+
+# If you want something other than Eastern United States time as a template
+# for handling POSIX-style time zone environment variables,
+# change the line below (after finding the zone you want in the
+# time zone files, or adding it to a time zone file).
+# (When a POSIX-style environment variable is handled, the rules in the
+# template file are used to determine "spring forward" and "fall back" days and
+# times; the environment variable itself specifies UTC offsets of standard and
+# summer time.)
+# Alternately, if you discover you've got the wrong time zone, you can just
+# zic -p rightzone
+# to correct things.
+# Use the command
+# make zonenames
+# to get a list of the values you can use for POSIXRULES.
+# If you want POSIX compatibility, use "America/New_York".
+
+POSIXRULES= America/New_York
+
+# Also see TZDEFRULESTRING below, which takes effect only
+# if the time zone files cannot be accessed.
+
+# Everything gets put in subdirectories of. . .
+
+TOPDIR= /usr/local
+
+# "Compiled" time zone information is placed in the "TZDIR" directory
+# (and subdirectories).
+# Use an absolute path name for TZDIR unless you're just testing the software.
+
+TZDIR= $(TOPDIR)/etc/zoneinfo
+
+# The "tzselect", "zic", and "zdump" commands get installed in. . .
+
+ETCDIR= $(TOPDIR)/etc
+
+# If you "make INSTALL", the "date" command gets installed in. . .
+
+BINDIR= $(TOPDIR)/bin
+
+# Manual pages go in subdirectories of. . .
+
+MANDIR= $(TOPDIR)/man
+
+# Library functions are put in an archive in LIBDIR.
+
+LIBDIR= $(TOPDIR)/lib
+TZLIB= $(LIBDIR)/libtz.a
+
+# If you always want time values interpreted as "seconds since the epoch
+# (not counting leap seconds)", use
+# REDO= posix_only
+# below. If you always want right time values interpreted as "seconds since
+# the epoch" (counting leap seconds)", use
+# REDO= right_only
+# below. If you want both sets of data available, with leap seconds not
+# counted normally, use
+# REDO= posix_right
+# below. If you want both sets of data available, with leap seconds counted
+# normally, use
+# REDO= right_posix
+# below.
+# POSIX mandates that leap seconds not be counted; for compatibility with it,
+# use either "posix_only" or "posix_right".
+
+REDO= posix_right
+
+# Since "." may not be in PATH...
+
+YEARISTYPE= ./yearistype
+
+# Non-default libraries needed to link.
+# Add -lintl if you want to use `gettext' on Solaris.
+LDLIBS=
+
+# Add the following to the end of the "CFLAGS=" line as needed.
+# -DHAVE_ADJTIME=0 if `adjtime' does not exist (SVR0?)
+# -DHAVE_GETTEXT=1 if `gettext' works (GNU, Linux, Solaris); also see LDLIBS
+# -DHAVE_INCOMPATIBLE_CTIME_R=1 if your system's time.h declares
+# ctime_r and asctime_r incompatibly with the POSIX standard (Solaris 8).
+# -DHAVE_SETTIMEOFDAY=0 if settimeofday does not exist (SVR0?)
+# -DHAVE_SETTIMEOFDAY=1 if settimeofday has just 1 arg (SVR4)
+# -DHAVE_SETTIMEOFDAY=2 if settimeofday uses 2nd arg (4.3BSD)
+# -DHAVE_SETTIMEOFDAY=3 if settimeofday ignores 2nd arg (4.4BSD)
+# -DHAVE_STDINT_H=1 if you have a pre-C99 compiler with "stdint.h"
+# -DHAVE_SYMLINK=0 if your system lacks the symlink function
+# -DHAVE_SYS_STAT_H=0 if your compiler lacks a "sys/stat.h"
+# -DHAVE_SYS_WAIT_H=0 if your compiler lacks a "sys/wait.h"
+# -DLOCALE_HOME=\"path\" if locales are in "path", not "/usr/lib/locale"
+# -DHAVE_UNISTD_H=0 if your compiler lacks a "unistd.h" (Microsoft C++ 7?)
+# -DHAVE_UTMPX_H=1 if your compiler has a "utmpx.h"
+# -DTZDEFRULESTRING=\",date/time,date/time\" to default to the specified
+# DST transitions if the time zone files cannot be accessed
+# -DTZ_DOMAIN=\"foo\" to use "foo" for gettext domain name; default is "tz"
+# -TTZ_DOMAINDIR=\"/path\" to use "/path" for gettext directory;
+# the default is system-supplied, typically "/usr/lib/locale"
+# $(GCC_DEBUG_FLAGS) if you are using GCC and want lots of checking
+# -DNO_RUN_TIME_WARNINGS_ABOUT_YEAR_2000_PROBLEMS_THANK_YOU=1
+# if you do not want run time warnings about formats that may cause
+# year 2000 grief
+# -DZIC_MAX_ABBR_LEN_WO_WARN=3
+# (or some other number) to set the maximum time zone abbreviation length
+# that zic will accept without a warning (the default is 6)
+GCC_DEBUG_FLAGS = -Dlint -g -O -fno-common \
+ -Wall -Wcast-qual -Wconversion -Wmissing-prototypes \
+ -Wnested-externs -Wpointer-arith -Wshadow \
+ -Wtraditional # -Wstrict-prototypes -Wwrite-strings
+#
+# If you want to use System V compatibility code, add
+# -DUSG_COMPAT
+# to the end of the "CFLAGS=" line. This arrange for "timezone" and "daylight"
+# variables to be kept up-to-date by the time conversion functions. Neither
+# "timezone" nor "daylight" is described in X3J11's work.
+#
+# If your system has a "GMT offset" field in its "struct tm"s
+# (or if you decide to add such a field in your system's "time.h" file),
+# add the name to a define such as
+# -DTM_GMTOFF=tm_gmtoff
+# or
+# -DTM_GMTOFF=_tm_gmtoff
+# to the end of the "CFLAGS=" line.
+# Neither tm_gmtoff nor _tm_gmtoff is described in X3J11's work;
+# in its work, use of "tm_gmtoff" is described as non-conforming.
+# Both Linux and BSD have done the equivalent of defining TM_GMTOFF in
+# their recent releases.
+#
+# If your system has a "zone abbreviation" field in its "struct tm"s
+# (or if you decide to add such a field in your system's "time.h" file),
+# add the name to a define such as
+# -DTM_ZONE=tm_zone
+# or
+# -DTM_ZONE=_tm_zone
+# to the end of the "CFLAGS=" line.
+# Neither tm_zone nor _tm_zone is described in X3J11's work;
+# in its work, use of "tm_zone" is described as non-conforming.
+# Both UCB and Sun have done the equivalent of defining TM_ZONE in
+# their recent releases.
+#
+# If you want functions that were inspired by early versions of X3J11's work,
+# add
+# -DSTD_INSPIRED
+# to the end of the "CFLAGS=" line. This arranges for the functions
+# "tzsetwall", "offtime", "timelocal", "timegm", "timeoff",
+# "posix2time", and "time2posix" to be added to the time conversion library.
+# "tzsetwall" is like "tzset" except that it arranges for local wall clock
+# time (rather than the time specified in the TZ environment variable)
+# to be used.
+# "offtime" is like "gmtime" except that it accepts a second (long) argument
+# that gives an offset to add to the time_t when converting it.
+# "timelocal" is equivalent to "mktime".
+# "timegm" is like "timelocal" except that it turns a struct tm into
+# a time_t using UTC (rather than local time as "timelocal" does).
+# "timeoff" is like "timegm" except that it accepts a second (long) argument
+# that gives an offset to use when converting to a time_t.
+# "posix2time" and "time2posix" are described in an included manual page.
+# X3J11's work does not describe any of these functions.
+# Sun has provided "tzsetwall", "timelocal", and "timegm" in SunOS 4.0.
+# These functions may well disappear in future releases of the time
+# conversion package.
+#
+# If you want Source Code Control System ID's left out of object modules, add
+# -DNOID
+# to the end of the "CFLAGS=" line.
+#
+# If you'll never want to handle solar-time-based time zones, add
+# -DNOSOLAR
+# to the end of the "CFLAGS=" line
+# (and comment out the "SDATA=" line below).
+# This reduces (slightly) the run-time data-space requirements of
+# the time conversion functions; it may reduce the acceptability of your system
+# to folks in oil- and cash-rich places.
+#
+# If you want to allocate state structures in localtime, add
+# -DALL_STATE
+# to the end of the "CFLAGS=" line. Storage is obtained by calling malloc.
+#
+# If you want an "altzone" variable (a la System V Release 3.1), add
+# -DALTZONE
+# to the end of the "CFLAGS=" line.
+# This variable is not described in X3J11's work.
+#
+# If you want a "gtime" function (a la MACH), add
+# -DCMUCS
+# to the end of the "CFLAGS=" line
+# This function is not described in X3J11's work.
+#
+# NIST-PCTS:151-2, Version 1.4, (1993-12-03) is a test suite put
+# out by the National Institute of Standards and Technology
+# which claims to test C and Posix conformance. If you want to pass PCTS, add
+# -DPCTS
+# to the end of the "CFLAGS=" line.
+#
+# If you want strict compliance with XPG4 as of 1994-04-09, add
+# -DXPG4_1994_04_09
+# to the end of the "CFLAGS=" line. This causes "strftime" to always return
+# 53 as a week number (rather than 52 or 53) for those days in January that
+# before the first Monday in January when a "%V" format is used and January 1
+# falls on a Friday, Saturday, or Sunday.
+
+CFLAGS=
+
+# If you want zic's -s option used when installing, uncomment the next line
+# ZFLAGS= -s
+
+zic= ./zic
+ZIC= $(zic) $(ZFLAGS)
+
+# The name of a Posix-compliant `awk' on your system.
+AWK= nawk
+
+# The path where SGML DTDs are kept.
+SGML_SEARCH_PATH= $(TOPDIR)/share/doc/sgml-lib/REC-html401-19991224/
+
+# The catalog file(s) to use when validating.
+SGML_CATALOG_FILES= HTML4.cat
+
+# The name, arguments and environment of a program to validate your web pages.
+# See for a validator, and
+# for a validation library.
+VALIDATE = nsgmls
+VALIDATE_FLAGS = -s -B -wall -wno-unused-param
+VALIDATE_ENV = \
+ SGML_CATALOG_FILES=$(SGML_CATALOG_FILES) \
+ SGML_SEARCH_PATH=$(SGML_SEARCH_PATH) \
+ SP_CHARSET_FIXED=YES \
+ SP_ENCODING=UTF-8
+
+###############################################################################
+
+cc= cc
+CC= $(cc) -DTZDIR=\"$(TZDIR)\"
+
+TZCSRCS= zic.c localtime.c asctime.c scheck.c ialloc.c
+TZCOBJS= zic.o localtime.o asctime.o scheck.o ialloc.o
+TZDSRCS= zdump.c localtime.c ialloc.c
+TZDOBJS= zdump.o localtime.o ialloc.o
+DATESRCS= date.c localtime.c strftime.c asctime.c
+DATEOBJS= date.o localtime.o strftime.o asctime.o
+LIBSRCS= localtime.c asctime.c difftime.c
+LIBOBJS= localtime.o asctime.o difftime.o
+HEADERS= tzfile.h private.h
+NONLIBSRCS= zic.c zdump.c scheck.c ialloc.c
+NEWUCBSRCS= date.c strftime.c
+SOURCES= $(HEADERS) $(LIBSRCS) $(NONLIBSRCS) $(NEWUCBSRCS) tzselect.ksh
+MANS= newctime.3 newstrftime.3 newtzset.3 time2posix.3 \
+ tzfile.5 tzselect.8 zic.8 zdump.8
+DOCS= README Theory $(MANS) date.1 Makefile
+PRIMARY_YDATA= africa antarctica asia australasia \
+ europe northamerica southamerica
+YDATA= $(PRIMARY_YDATA) pacificnew etcetera factory backward
+NDATA= systemv
+SDATA= solar87 solar88 solar89
+TDATA= $(YDATA) $(NDATA) $(SDATA)
+TABDATA= iso3166.tab zone.tab
+DATA= $(YDATA) $(NDATA) $(SDATA) $(TABDATA) leapseconds yearistype.sh
+WEB_PAGES= tz-art.htm tz-link.htm
+MISC= usno1988 usno1989 usno1989a usno1995 usno1997 usno1998 \
+ itca.jpg $(WEB_PAGES) checktab.awk workman.sh \
+ zoneinfo2tdf.pl
+ENCHILADA= $(DOCS) $(SOURCES) $(DATA) $(MISC)
+
+# And for the benefit of csh users on systems that assume the user
+# shell should be used to handle commands in Makefiles. . .
+
+SHELL= /bin/sh
+
+all: tzselect zic zdump $(LIBOBJS)
+
+ALL: all date
+
+install: all $(DATA) $(REDO) $(TZLIB) $(MANS) $(TABDATA)
+ $(ZIC) -y $(YEARISTYPE) \
+ -d $(TZDIR) -l $(LOCALTIME) -p $(POSIXRULES)
+ -rm -f $(TZDIR)/iso3166.tab $(TZDIR)/zone.tab
+ cp iso3166.tab zone.tab $(TZDIR)/.
+ -mkdir $(TOPDIR) $(ETCDIR)
+ cp tzselect zic zdump $(ETCDIR)/.
+ -mkdir $(TOPDIR) $(MANDIR) \
+ $(MANDIR)/man3 $(MANDIR)/man5 $(MANDIR)/man8
+ -rm -f $(MANDIR)/man3/newctime.3 \
+ $(MANDIR)/man3/newtzset.3 \
+ $(MANDIR)/man5/tzfile.5 \
+ $(MANDIR)/man8/tzselect.8 \
+ $(MANDIR)/man8/zdump.8 \
+ $(MANDIR)/man8/zic.8
+ cp newctime.3 newtzset.3 $(MANDIR)/man3/.
+ cp tzfile.5 $(MANDIR)/man5/.
+ cp tzselect.8 zdump.8 zic.8 $(MANDIR)/man8/.
+
+INSTALL: ALL install date.1
+ -mkdir $(TOPDIR) $(BINDIR)
+ cp date $(BINDIR)/.
+ -mkdir $(TOPDIR) $(MANDIR) $(MANDIR)/man1
+ -rm -f $(MANDIR)/man1/date.1
+ cp date.1 $(MANDIR)/man1/.
+
+zdump: $(TZDOBJS)
+ $(CC) $(CFLAGS) $(LFLAGS) $(TZDOBJS) $(LDLIBS) -o $@
+
+zic: $(TZCOBJS) yearistype
+ $(CC) $(CFLAGS) $(LFLAGS) $(TZCOBJS) $(LDLIBS) -o $@
+
+yearistype: yearistype.sh
+ cp yearistype.sh yearistype
+ chmod +x yearistype
+
+posix_only: zic $(TDATA)
+ $(ZIC) -y $(YEARISTYPE) -d $(TZDIR) -L /dev/null $(TDATA)
+
+right_only: zic leapseconds $(TDATA)
+ $(ZIC) -y $(YEARISTYPE) -d $(TZDIR) -L leapseconds $(TDATA)
+
+# In earlier versions of this makefile, the other two directories were
+# subdirectories of $(TZDIR). However, this led to configuration errors.
+# For example, with posix_right under the earlier scheme,
+# TZ='right/Australia/Adelaide' got you localtime with leap seconds,
+# but gmtime without leap seconds, which led to problems with applications
+# like sendmail that subtract gmtime from localtime.
+# Therefore, the other two directories are now siblings of $(TZDIR).
+# You must replace all of $(TZDIR) to switch from not using leap seconds
+# to using them, or vice versa.
+other_two: zic leapseconds $(TDATA)
+ $(ZIC) -y $(YEARISTYPE) -d $(TZDIR)-posix -L /dev/null $(TDATA)
+ $(ZIC) -y $(YEARISTYPE) \
+ -d $(TZDIR)-leaps -L leapseconds $(TDATA)
+
+posix_right: posix_only other_two
+
+right_posix: right_only other_two
+
+zones: $(REDO)
+
+$(TZLIB): $(LIBOBJS)
+ -mkdir $(TOPDIR) $(LIBDIR)
+ ar ru $@ $(LIBOBJS)
+ if [ -x /usr/ucb/ranlib -o -x /usr/bin/ranlib ] ; \
+ then ranlib $@ ; fi
+
+date: $(DATEOBJS)
+ $(CC) $(CFLAGS) date.o localtime.o asctime.o strftime.o \
+ $(LDLIBS) -lc -o $@
+
+tzselect: tzselect.ksh
+ sed \
+ -e 's|AWK=[^}]*|AWK=$(AWK)|g' \
+ -e 's|TZDIR=[^}]*|TZDIR=$(TZDIR)|' \
+ <$? >$@
+ chmod +x $@
+
+check: check_tables check_web
+
+check_tables: checktab.awk $(PRIMARY_YDATA)
+ $(AWK) -f checktab.awk $(PRIMARY_YDATA)
+
+check_web: $(WEB_PAGES)
+ $(VALIDATE_ENV) $(VALIDATE) $(VALIDATE_FLAGS) $(WEB_PAGES)
+
+clean:
+ rm -f core *.o *.out tzselect zdump zic yearistype date
+
+maintainer-clean: clean
+ @echo 'This command is intended for maintainers to use; it'
+ @echo 'deletes files that may need special tools to rebuild.'
+ rm -f *.[1-8].txt tzcode.tar.gz tzdata.tar.gz
+
+names:
+ @echo $(ENCHILADA)
+
+# The zics below ensure that each data file can stand on its own.
+# We also do an all-files run to catch links to links.
+
+public: $(ENCHILADA)
+ make maintainer-clean
+ make "CFLAGS=$(GCC_DEBUG_FLAGS)"
+ -mkdir /tmp/,tzpublic
+ -for i in $(TDATA) ; do zic -v -d /tmp/,tzpublic $$i 2>&1 | grep -v "starting year" ; done
+ for i in $(TDATA) ; do zic -d /tmp/,tzpublic $$i || exit; done
+ zic -v -d /tmp/,tzpublic $(TDATA) || exit
+ rm -f -r /tmp/,tzpublic
+ for i in *.[1-8] ; do sh workman.sh $$i > $$i.txt || exit; done
+ $(AWK) -f checktab.awk $(PRIMARY_YDATA)
+ tar cf - $(DOCS) $(SOURCES) $(MISC) *.[1-8].txt | gzip -9 > tzcode.tar.gz
+ tar cf - $(DATA) | gzip -9 > tzdata.tar.gz
+
+typecheck:
+ make clean
+ for i in "long long" unsigned double; \
+ do \
+ make CFLAGS="-DTYPECHECK -D_TIME_T \"-Dtime_t=$$i\"" ; \
+ ./zdump -v Europe/Rome ; \
+ make clean ; \
+ done
+
+zonenames: $(TDATA)
+ @$(AWK) '/^Zone/ { print $$2 } /^Link/ { print $$3 }' $(TDATA)
+
+asctime.o: private.h tzfile.h
+date.o: private.h
+difftime.o: private.h
+ialloc.o: private.h
+localtime.o: private.h tzfile.h
+scheck.o: private.h
+strftime.o: tzfile.h
+zic.o: private.h tzfile.h
+
+.KEEP_STATE:
diff --git a/unused/checktab.awk b/unused/checktab.awk
new file mode 100644
index 00000000000..80ad7d57015
--- /dev/null
+++ b/unused/checktab.awk
@@ -0,0 +1,159 @@
+# Check tz tables for consistency.
+
+# @(#)checktab.awk 8.1
+
+# Contributed by Paul Eggert.
+
+BEGIN {
+ FS = "\t"
+
+ if (!iso_table) iso_table = "iso3166.tab"
+ if (!zone_table) zone_table = "zone.tab"
+ if (!want_warnings) want_warnings = -1
+
+ while (getline >"/dev/stderr"
+ status = 1
+ }
+ cc = $1
+ name = $2
+ if (cc !~ /^[A-Z][A-Z]$/) {
+ printf "%s:%d: invalid country code `%s'\n", \
+ iso_table, iso_NR, cc >>"/dev/stderr"
+ status = 1
+ }
+ if (cc <= cc0) {
+ if (cc == cc0) {
+ s = "duplicate";
+ } else {
+ s = "out of order";
+ }
+
+ printf "%s:%d: country code `%s' is %s\n", \
+ iso_table, iso_NR, cc, s \
+ >>"/dev/stderr"
+ status = 1
+ }
+ cc0 = cc
+ if (name2cc[name]) {
+ printf "%s:%d: `%s' and `%s' have the sname name\n", \
+ iso_table, iso_NR, name2cc[name], cc \
+ >>"/dev/stderr"
+ status = 1
+ }
+ name2cc[name] = cc
+ cc2name[cc] = name
+ cc2NR[cc] = iso_NR
+ }
+
+ zone_table = "zone.tab"
+ cc0 = ""
+
+ while (getline >"/dev/stderr"
+ status = 1
+ }
+ cc = $1
+ coordinates = $2
+ tz = $3
+ comments = $4
+ if (cc < cc0) {
+ printf "%s:%d: country code `%s' is out of order\n", \
+ zone_table, zone_NR, cc >>"/dev/stderr"
+ status = 1
+ }
+ cc0 = cc
+ if (tz2cc[tz]) {
+ printf "%s:%d: %s: duplicate TZ column\n", \
+ zone_table, zone_NR, tz >>"/dev/stderr"
+ status = 1
+ }
+ tz2cc[tz] = cc
+ tz2comments[tz] = comments
+ tz2NR[tz] = zone_NR
+ if (cc2name[cc]) {
+ cc_used[cc]++
+ } else {
+ printf "%s:%d: %s: unknown country code\n", \
+ zone_table, zone_NR, cc >>"/dev/stderr"
+ status = 1
+ }
+ if (coordinates !~ /^[-+][0-9][0-9][0-5][0-9][-+][01][0-9][0-9][0-5][0-9]$/ \
+ && coordinates !~ /^[-+][0-9][0-9][0-5][0-9][0-5][0-9][-+][01][0-9][0-9][0-5][0-9][0-5][0-9]$/) {
+ printf "%s:%d: %s: invalid coordinates\n", \
+ zone_table, zone_NR, coordinates >>"/dev/stderr"
+ status = 1
+ }
+ }
+
+ for (tz in tz2cc) {
+ if (cc_used[tz2cc[tz]] == 1) {
+ if (tz2comments[tz]) {
+ printf "%s:%d: unnecessary comment `%s'\n", \
+ zone_table, tz2NR[tz], tz2comments[tz] \
+ >>"/dev/stderr"
+ status = 1
+ }
+ } else {
+ if (!tz2comments[tz]) {
+ printf "%s:%d: missing comment\n", \
+ zone_table, tz2NR[tz] >>"/dev/stderr"
+ status = 1
+ }
+ }
+ }
+
+ FS = " "
+}
+
+{
+ tz = ""
+ if ($1 == "Zone") tz = $2
+ if ($1 == "Link") {
+ # Ignore Link commands if source and destination basenames
+ # are identical, e.g. Europe/Istanbul versus Asia/Istanbul.
+ src = $2
+ dst = $3
+ while ((i = index(src, "/"))) src = substr(src, i+1)
+ while ((i = index(dst, "/"))) dst = substr(dst, i+1)
+ if (src != dst) tz = $3
+ }
+ if (tz && tz ~ /\//) {
+ if (!tz2cc[tz]) {
+ printf "%s: no data for `%s'\n", zone_table, tz \
+ >>"/dev/stderr"
+ status = 1
+ }
+ zoneSeen[tz] = 1
+ }
+}
+
+END {
+ for (tz in tz2cc) {
+ if (!zoneSeen[tz]) {
+ printf "%s:%d: no Zone table for `%s'\n", \
+ zone_table, tz2NR[tz], tz >>"/dev/stderr"
+ status = 1
+ }
+ }
+
+ if (0 < want_warnings) {
+ for (cc in cc2name) {
+ if (!cc_used[cc]) {
+ printf "%s:%d: warning: " \
+ "no Zone entries for %s (%s)\n", \
+ iso_table, cc2NR[cc], cc, cc2name[cc]
+ }
+ }
+ }
+
+ exit status
+}
diff --git a/unused/date.1 b/unused/date.1
new file mode 100644
index 00000000000..3c75ba4337c
--- /dev/null
+++ b/unused/date.1
@@ -0,0 +1,175 @@
+.TH DATE 1
+.SH NAME
+date \- show and set date and time
+.SH SYNOPSIS
+.if n .nh
+.if n .na
+.B date
+[
+.B \-u
+] [
+.B \-c
+] [
+.B \-n
+] [
+.B \-d
+dsttype
+] [
+.B \-t
+minutes-west
+] [
+\fB\-a \fR[\fB+\fR|\fB-]\fIsss\fB.\fIfff\fR
+] [
+.BI + format
+] [
+\fR[\fIyyyy\fR]\fImmddhhmm\fR[\fIyy\fR][\fB.\fIss\fR]
+]
+.SH DESCRIPTION
+.I Date
+without arguments writes the date and time to the standard output in
+the form
+.ce 1
+Wed Mar 8 14:54:40 EST 1989
+.br
+with
+.B EST
+replaced by the local time zone's abbreviation
+(or by the abbreviation for the time zone specified in the
+.B TZ
+environment variable if set).
+The exact output format depends on the locale.
+.PP
+If a command-line argument starts with a plus sign
+.RB (` + '),
+the rest of the argument is used as a
+.I format
+that controls what appears in the output.
+In the format, when a percent sign
+.RB (` % ')
+appears,
+it and the character after it are not output,
+but rather identify part of the date or time
+to be output in a particular way
+(or identify a special character to output):
+.nf
+.sp
+.if t .in +.5i
+.if n .in +2
+.ta \w'%M\0\0'u +\w'Wed Mar 8 14:54:40 EST 1989\0\0'u
+ Sample output Explanation
+%a Wed Abbreviated weekday name*
+%A Wednesday Full weekday name*
+%b Mar Abbreviated month name*
+%B March Full month name*
+%c Wed Mar 08 14:54:40 1989 Date and time*
+%C 19 Century
+%d 08 Day of month (always two digits)
+%D 03/08/89 Month/day/year (eight characters)
+%e 8 Day of month (leading zero blanked)
+%h Mar Abbreviated month name*
+%H 14 24-hour-clock hour (two digits)
+%I 02 12-hour-clock hour (two digits)
+%j 067 Julian day number (three digits)
+%k 2 12-hour-clock hour (leading zero blanked)
+%l 14 24-hour-clock hour (leading zero blanked)
+%m 03 Month number (two digits)
+%M 54 Minute (two digits)
+%n \\n newline character
+%p PM AM/PM designation
+%r 02:54:40 PM Hour:minute:second AM/PM designation
+%R 14:54 Hour:minute
+%S 40 Second (two digits)
+%t \\t tab character
+%T 14:54:40 Hour:minute:second
+%U 10 Sunday-based week number (two digits)
+%w 3 Day number (one digit, Sunday is 0)
+%W 10 Monday-based week number (two digits)
+%x 03/08/89 Date*
+%X 14:54:40 Time*
+%y 89 Last two digits of year
+%Y 1989 Year in full
+%Z EST Time zone abbreviation
+%+ Wed Mar 8 14:54:40 EST 1989 Default output format*
+.if t .in -.5i
+.if n .in -2
+* The exact output depends on the locale.
+.sp
+.fi
+If a character other than one of those shown above appears after
+a percent sign in the format,
+that following character is output.
+All other characters in the format are copied unchanged to the output;
+a newline character is always added at the end of the output.
+.PP
+In Sunday-based week numbering,
+the first Sunday of the year begins week 1;
+days preceding it are part of ``week 0.''
+In Monday-based week numbering,
+the first Monday of the year begins week 1.
+.PP
+To set the date, use a command line argument with one of the following forms:
+.nf
+.if t .in +.5i
+.if n .in +2
+.ta \w'198903081454\0'u
+1454 24-hour-clock hours (first two digits) and minutes
+081454 Month day (first two digits), hours, and minutes
+03081454 Month (two digits, January is 01), month day, hours, minutes
+8903081454 Year, month, month day, hours, minutes
+0308145489 Month, month day, hours, minutes, year
+ (on System V-compatible systems)
+030814541989 Month, month day, hours, minutes, four-digit year
+198903081454 Four-digit year, month, month day, hours, minutes
+.if t .in -.5i
+.if n .in -2
+.fi
+If the century, year, month, or month day is not given,
+the current value is used.
+Any of the above forms may be followed by a period and two digits that give
+the seconds part of the new time; if no seconds are given, zero is assumed.
+.PP
+These options are available:
+.TP
+.BR \-u " or " \-c
+Use UTC when setting and showing the date and time.
+.TP
+.B \-n
+Do not notify other networked systems of the time change.
+.TP
+.BI "\-d " dsttype
+Set the kernel-stored Daylight Saving Time type to the given value.
+(The kernel-stored DST type is used mostly by ``old'' binaries.)
+.TP
+.BI "\-t " minutes-west
+Set the kernel-stored ``minutes west of UTC'' value to the one given on the
+command line.
+(The kernel-stored DST type is used mostly by ``old'' binaries.)
+.TP
+.BI "\-a " adjustment
+Change the time forward (or backward) by the number of seconds
+(and fractions thereof) specified in the
+.I adjustment\^
+argument.
+Either the seconds part or the fractions part of the argument (but not both)
+may be omitted.
+On BSD-based systems,
+the adjustment is made by changing the rate at which time advances;
+on System-V-based systems, the adjustment is made by changing the time.
+.SH FILES
+.ta \w'/usr/local/etc/zoneinfo/posixrules\0\0'u
+/usr/lib/locale/\f2L\fP/LC_TIME description of time locale \f2L\fP
+.br
+/usr/local/etc/zoneinfo time zone information directory
+.br
+/usr/local/etc/zoneinfo/localtime local time zone file
+.br
+/usr/local/etc/zoneinfo/posixrules used with POSIX-style TZ's
+.br
+/usr/local/etc/zoneinfo/GMT for UTC leap seconds
+.sp
+If
+.B /usr/local/etc/zoneinfo/GMT
+is absent,
+UTC leap seconds are loaded from
+.BR /usr/local/etc/zoneinfo/posixrules .
+.\" @(#)date.1 8.1
diff --git a/unused/date.1.txt b/unused/date.1.txt
new file mode 100644
index 00000000000..2910aaac370
--- /dev/null
+++ b/unused/date.1.txt
@@ -0,0 +1,127 @@
+NAME
+
+ date - show and set date and time
+
+SYNOPSIS
+ date [ -u ] [ -c ] [ -n ] [ -d dsttype ] [ -t minutes-west ]
+ [ -a [+|-]sss.fff ] [ +format ] [ [yyyy]mmddhhmm[yy][.ss] ]
+
+DESCRIPTION
+ Date without arguments writes the date and time to the
+ standard output in the form
+ Wed Mar 8 14:54:40 EST 1989
+ with EST replaced by the local time zone's abbreviation (or
+ by the abbreviation for the time zone specified in the TZ
+ environment variable if set). The exact output format
+ depends on the locale.
+
+ If a command-line argument starts with a plus sign (`+'),
+ the rest of the argument is used as a format that controls
+ what appears in the output. In the format, when a percent
+ sign (`%') appears, it and the character after it are not
+ output, but rather identify part of the date or time to be
+ output in a particular way (or identify a special character
+ to output):
+
+ Sample output Explanation
+ %a Wed Abbreviated weekday name*
+ %A Wednesday Full weekday name*
+ %b Mar Abbreviated month name*
+ %B March Full month name*
+ %c Wed Mar 08 14:54:40 1989 Date and time*
+ %C 19 Century
+ %d 08 Day of month (always two digits)
+ %D 03/08/89 Month/day/year (eight characters)
+ %e 8 Day of month (leading zero blanked)
+ %h Mar Abbreviated month name*
+ %H 14 24-hour-clock hour (two digits)
+ %I 02 12-hour-clock hour (two digits)
+ %j 067 Julian day number (three digits)
+ %k 2 12-hour-clock hour (leading zero blanked)
+ %l 14 24-hour-clock hour (leading zero blanked)
+ %m 03 Month number (two digits)
+ %M 54 Minute (two digits)
+ %n \n newline character
+ %p PM AM/PM designation
+ %r 02:54:40 PM Hour:minute:second AM/PM designation
+ %R 14:54 Hour:minute
+ %S 40 Second (two digits)
+ %t \t tab character
+ %T 14:54:40 Hour:minute:second
+ %U 10 Sunday-based week number (two digits)
+ %w 3 Day number (one digit, Sunday is 0)
+ %W 10 Monday-based week number (two digits)
+ %x 03/08/89 Date*
+ %X 14:54:40 Time*
+ %y 89 Last two digits of year
+ %Y 1989 Year in full
+ %Z EST Time zone abbreviation
+ %+ Wed Mar 8 14:54:40 EST 1989 Default output format*
+ * The exact output depends on the locale.
+
+ If a character other than one of those shown above appears
+ after a percent sign in the format, that following character
+ is output. All other characters in the format are copied
+ unchanged to the output; a newline character is always added
+ at the end of the output.
+ In Sunday-based week numbering, the first Sunday of the year
+ begins week 1; days preceding it are part of ``week 0.'' In
+ Monday-based week numbering, the first Monday of the year
+ begins week 1.
+
+ To set the date, use a command line argument with one of the
+ following forms:
+ 1454 24-hour-clock hours (first two digits) and minutes
+ 081454 Month day (first two digits), hours, and minutes
+ 03081454 Month (two digits, January is 01), month day, hours, minutes
+ 8903081454 Year, month, month day, hours, minutes
+ 0308145489 Month, month day, hours, minutes, year
+ (on System V-compatible systems)
+ 030814541989 Month, month day, hours, minutes, four-digit year
+ 198903081454 Four-digit year, month, month day, hours, minutes
+ If the century, year, month, or month day is not given, the
+ current value is used. Any of the above forms may be
+ followed by a period and two digits that give the seconds
+ part of the new time; if no seconds are given, zero is
+ assumed.
+
+ These options are available:
+
+ -u or -c
+ Use UTC when setting and showing the date and time.
+
+ -n Do not notify other networked systems of the time
+ change.
+
+ -d dsttype
+ Set the kernel-stored Daylight Saving Time type to the
+ given value. (The kernel-stored DST type is used
+ mostly by ``old'' binaries.)
+
+ -t minutes-west
+ Set the kernel-stored ``minutes west of UTC'' value to
+ the one given on the command line. (The kernel-stored
+ DST type is used mostly by ``old'' binaries.)
+
+ -a adjustment
+ Change the time forward (or backward) by the number of
+ seconds (and fractions thereof) specified in the
+ adjustment argument. Either the seconds part or the
+ fractions part of the argument (but not both) may be
+ omitted. On BSD-based systems, the adjustment is made
+ by changing the rate at which time advances; on System-
+ V-based systems, the adjustment is made by changing the
+ time.
+
+FILES
+ /usr/lib/locale/L/LC_TIME description of time
+ locale L
+ /usr/local/etc/zoneinfo time zone information
+ directory
+ /usr/local/etc/zoneinfo/localtime local time zone file
+ /usr/local/etc/zoneinfo/posixrules used with POSIX-style
+ TZ's
+ /usr/local/etc/zoneinfo/GMT for UTC leap seconds
+
+ If /usr/local/etc/zoneinfo/GMT is absent, UTC leap seconds
+ are loaded from /usr/local/etc/zoneinfo/posixrules.
diff --git a/unused/date.c b/unused/date.c
new file mode 100644
index 00000000000..6a6d2cdaffc
--- /dev/null
+++ b/unused/date.c
@@ -0,0 +1,945 @@
+#ifndef lint
+#ifndef NOID
+static char elsieid[] = "@(#)date.c 8.4";
+/*
+** Modified from the UCB version with the SCCS ID appearing below.
+*/
+#endif /* !defined NOID */
+#endif /* !defined lint */
+
+/*
+ * Copyright (c) 1985, 1987, 1988 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANT[A]BILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+char copyright[] =
+"@(#) Copyright (c) 1985, 1987, 1988 The Regents of the University of California.\n\
+ All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)date.c 4.23 (Berkeley) 9/20/88";
+#endif /* not lint */
+
+#include "private.h"
+#if HAVE_ADJTIME || HAVE_SETTIMEOFDAY
+#include "sys/time.h" /* for struct timeval, struct timezone */
+#endif /* HAVE_ADJTIME || HAVE_SETTIMEOFDAY */
+#include "locale.h"
+#include "utmp.h" /* for OLD_TIME (or its absence) */
+#if HAVE_UTMPX_H
+#include "utmpx.h"
+#endif
+
+#ifndef OTIME_MSG
+#define OTIME_MSG "old time"
+#endif
+#ifndef NTIME_MSG
+#define NTIME_MSG "new time"
+#endif
+
+/*
+** The two things date knows about time are. . .
+*/
+
+#ifndef TM_YEAR_BASE
+#define TM_YEAR_BASE 1900
+#endif /* !defined TM_YEAR_BASE */
+
+#ifndef SECSPERMIN
+#define SECSPERMIN 60
+#endif /* !defined SECSPERMIN */
+
+extern double atof();
+extern char ** environ;
+extern char * getlogin();
+extern time_t mktime();
+extern char * optarg;
+extern int optind;
+extern char * strchr();
+extern time_t time();
+extern char * tzname[2];
+
+static int retval = EXIT_SUCCESS;
+
+static void checkfinal(const char *, int, time_t, time_t);
+static int comptm(const struct tm *, const struct tm *);
+static time_t convert(const char *, int, time_t);
+static void display(const char *);
+static void dogmt(void);
+static void errensure(void);
+static void iffy(time_t, time_t, const char *, const char *);
+int main(int, char**);
+static const char * nondigit(const char *);
+static void oops(const char *);
+static void reset(time_t, int);
+static void timeout(FILE *, const char *, const struct tm *);
+static void usage(void);
+static void wildinput(const char *, const char *,
+ const char *);
+
+int
+main(argc, argv)
+const int argc;
+char * argv[];
+{
+ register const char * format;
+ register const char * value;
+ register const char * cp;
+ register int ch;
+ register int dousg;
+ register int aflag = 0;
+ register int dflag = 0;
+ register int nflag = 0;
+ register int tflag = 0;
+ register int minuteswest;
+ register int dsttime;
+ register double adjust;
+ time_t now;
+ time_t t;
+
+ INITIALIZE(dousg);
+ INITIALIZE(minuteswest);
+ INITIALIZE(dsttime);
+ INITIALIZE(adjust);
+ INITIALIZE(t);
+#ifdef LC_ALL
+ (void) setlocale(LC_ALL, "");
+#endif /* defined(LC_ALL) */
+#if HAVE_GETTEXT
+#ifdef TZ_DOMAINDIR
+ (void) bindtextdomain(TZ_DOMAIN, TZ_DOMAINDIR);
+#endif /* defined(TEXTDOMAINDIR) */
+ (void) textdomain(TZ_DOMAIN);
+#endif /* HAVE_GETTEXT */
+ (void) time(&now);
+ format = value = NULL;
+ while ((ch = getopt(argc, argv, "ucnd:t:a:")) != EOF && ch != -1) {
+ switch (ch) {
+ default:
+ usage();
+ case 'u': /* do it in UTC */
+ case 'c':
+ dogmt();
+ break;
+ case 'n': /* don't set network */
+ nflag = 1;
+ break;
+ case 'd': /* daylight saving time */
+ if (dflag) {
+ (void) fprintf(stderr,
+ _("date: error: multiple -d's used"));
+ usage();
+ }
+ dflag = 1;
+ cp = optarg;
+ dsttime = atoi(cp);
+ if (*cp == '\0' || *nondigit(cp) != '\0')
+ wildinput(_("-t value"), optarg,
+ _("must be a non-negative number"));
+ break;
+ case 't': /* minutes west of UTC */
+ if (tflag) {
+ (void) fprintf(stderr,
+ _("date: error: multiple -t's used"));
+ usage();
+ }
+ tflag = 1;
+ cp = optarg;
+ minuteswest = atoi(cp);
+ if (*cp == '+' || *cp == '-')
+ ++cp;
+ if (*cp == '\0' || *nondigit(cp) != '\0')
+ wildinput(_("-d value"), optarg,
+ _("must be a number"));
+ break;
+ case 'a': /* adjustment */
+ if (aflag) {
+ (void) fprintf(stderr,
+ _("date: error: multiple -a's used"));
+ usage();
+ }
+ aflag = 1;
+ cp = optarg;
+ adjust = atof(cp);
+ if (*cp == '+' || *cp == '-')
+ ++cp;
+ if (*cp == '\0' || strcmp(cp, ".") == 0)
+ wildinput(_("-a value"), optarg,
+ _("must be a number"));
+ cp = nondigit(cp);
+ if (*cp == '.')
+ ++cp;
+ if (*nondigit(cp) != '\0')
+ wildinput(_("-a value"), optarg,
+ _("must be a number"));
+ break;
+ }
+ }
+ while (optind < argc) {
+ cp = argv[optind++];
+ if (*cp == '+')
+ if (format == NULL)
+ format = cp + 1;
+ else {
+ (void) fprintf(stderr,
+_("date: error: multiple formats in command line\n"));
+ usage();
+ }
+ else if (value == NULL)
+ value = cp;
+ else {
+ (void) fprintf(stderr,
+_("date: error: multiple values in command line\n"));
+ usage();
+ }
+ }
+ if (value != NULL) {
+ /*
+ ** This order ensures that "reasonable" twelve-digit inputs
+ ** (such as 120203042006) won't be misinterpreted
+ ** even if time_t's range all the way back to the thirteenth
+ ** century. Do not change the order.
+ */
+ t = convert(value, (dousg = TRUE), now);
+ if (t == -1)
+ t = convert(value, (dousg = FALSE), now);
+ if (t == -1) {
+ /*
+ ** Out of range values,
+ ** or time that falls in a DST transition hole?
+ */
+ if ((cp = strchr(value, '.')) != NULL) {
+ /*
+ ** Ensure that the failure of
+ ** TZ=America/New_York date 8712312359.60
+ ** doesn't get misdiagnosed. (It was
+ ** TZ=America/New_York date 8712311859.60
+ ** when the leap second was inserted.)
+ ** The normal check won't work since
+ ** the given time is valid in UTC.
+ */
+ if (atoi(cp + 1) >= SECSPERMIN)
+ wildinput(_("time"), value,
+ _("out of range seconds given"));
+ }
+ dogmt();
+ t = convert(value, FALSE, now);
+ if (t == -1)
+ t = convert(value, TRUE, now);
+ wildinput(_("time"), value,
+ (t == -1) ?
+ _("out of range value given") :
+ _("time skipped when clock springs forward"));
+ }
+ }
+ /*
+ ** Entire command line has now been checked.
+ */
+ if (aflag) {
+#if HAVE_ADJTIME
+ struct timeval tv;
+
+ tv.tv_sec = (int) adjust;
+ tv.tv_usec = (int) ((adjust - tv.tv_sec) * 1000000L);
+ if (adjtime(&tv, (struct timeval *) NULL) != 0)
+ oops("adjtime");
+#endif /* HAVE_ADJTIME */
+#if !HAVE_ADJTIME
+ reset((time_t) (now + adjust), nflag);
+#endif /* !HAVE_ADJTIME */
+ /*
+ ** Sun silently ignores everything else; we follow suit.
+ */
+ exit(retval);
+ }
+ if (dflag || tflag) {
+#if HAVE_SETTIMEOFDAY == 2
+ struct timezone tz;
+
+ if (!dflag || !tflag)
+ if (gettimeofday((struct timeval *) NULL, &tz) != 0)
+ oops("gettimeofday");
+ if (dflag)
+ tz.tz_dsttime = dsttime;
+ if (tflag)
+ tz.tz_minuteswest = minuteswest;
+ if (settimeofday((struct timeval *) NULL, &tz) != 0)
+ oops("settimeofday");
+#endif /* HAVE_SETTIMEOFDAY == 2 */
+#if HAVE_SETTIMEOFDAY != 2
+ (void) fprintf(stderr,
+_("date: warning: kernel doesn't keep -d/-t information, option ignored\n"));
+#endif /* HAVE_SETTIMEOFDAY != 2 */
+ }
+
+ if (value == NULL)
+ display(format);
+
+ reset(t, nflag);
+
+ checkfinal(value, dousg, t, now);
+
+#ifdef EBUG
+ {
+ struct tm tm;
+
+ tm = *localtime(&t);
+ timeout(stdout, "%c\n", &tm);
+ exit(retval);
+ }
+#endif /* defined EBUG */
+
+ display(format);
+
+ /* gcc -Wall pacifier */
+ for ( ; ; )
+ continue;
+}
+
+static void
+dogmt(void)
+{
+ static char ** fakeenv;
+
+ if (fakeenv == NULL) {
+ register int from;
+ register int to;
+ register int n;
+ static char tzegmt0[] = "TZ=GMT0";
+
+ for (n = 0; environ[n] != NULL; ++n)
+ continue;
+ fakeenv = (char **) malloc((size_t) (n + 2) * sizeof *fakeenv);
+ if (fakeenv == NULL) {
+ (void) perror(_("Memory exhausted"));
+ errensure();
+ exit(retval);
+ }
+ to = 0;
+ fakeenv[to++] = tzegmt0;
+ for (from = 1; environ[from] != NULL; ++from)
+ if (strncmp(environ[from], "TZ=", 3) != 0)
+ fakeenv[to++] = environ[from];
+ fakeenv[to] = NULL;
+ environ = fakeenv;
+ }
+}
+
+#ifdef OLD_TIME
+
+/*
+** We assume we're on a System-V-based system,
+** should use stime,
+** should write System-V-format utmp entries,
+** and don't have network notification to worry about.
+*/
+
+#include "fcntl.h" /* for O_WRONLY, O_APPEND */
+
+/*ARGSUSED*/
+static void
+reset(const time_t newt, const int nflag)
+{
+ register int fid;
+ time_t oldt;
+ static struct {
+ struct utmp before;
+ struct utmp after;
+ } s;
+#if HAVE_UTMPX_H
+ static struct {
+ struct utmpx before;
+ struct utmpx after;
+ } sx;
+#endif
+
+ /*
+ ** Wouldn't it be great if stime returned the old time?
+ */
+ (void) time(&oldt);
+ if (stime(&newt) != 0)
+ oops("stime");
+ s.before.ut_type = OLD_TIME;
+ s.before.ut_time = oldt;
+ (void) strcpy(s.before.ut_line, OTIME_MSG);
+ s.after.ut_type = NEW_TIME;
+ s.after.ut_time = newt;
+ (void) strcpy(s.after.ut_line, NTIME_MSG);
+ fid = open(WTMP_FILE, O_WRONLY | O_APPEND);
+ if (fid < 0)
+ oops(_("log file open"));
+ if (write(fid, (char *) &s, sizeof s) != sizeof s)
+ oops(_("log file write"));
+ if (close(fid) != 0)
+ oops(_("log file close"));
+#if !HAVE_UTMPX_H
+ pututline(&s.before);
+ pututline(&s.after);
+#endif /* !HAVE_UTMPX_H */
+#if HAVE_UTMPX_H
+ sx.before.ut_type = OLD_TIME;
+ sx.before.ut_tv.tv_sec = oldt;
+ (void) strcpy(sx.before.ut_line, OTIME_MSG);
+ sx.after.ut_type = NEW_TIME;
+ sx.after.ut_tv.tv_sec = newt;
+ (void) strcpy(sx.after.ut_line, NTIME_MSG);
+#if !SUPPRESS_WTMPX_FILE_UPDATE
+ /* In Solaris 2.5 (and presumably other systems),
+ `date' does not update /var/adm/wtmpx.
+ This must be a bug. If you'd like to reproduce the bug,
+ define SUPPRESS_WTMPX_FILE_UPDATE to be nonzero. */
+ fid = open(WTMPX_FILE, O_WRONLY | O_APPEND);
+ if (fid < 0)
+ oops(_("log file open"));
+ if (write(fid, (char *) &sx, sizeof sx) != sizeof sx)
+ oops(_("log file write"));
+ if (close(fid) != 0)
+ oops(_("log file close"));
+#endif /* !SUPPRESS_WTMPX_FILE_UPDATE */
+ pututxline(&sx.before);
+ pututxline(&sx.after);
+#endif /* HAVE_UTMPX_H */
+}
+
+#endif /* defined OLD_TIME */
+#ifndef OLD_TIME
+
+/*
+** We assume we're on a BSD-based system,
+** should use settimeofday,
+** should write BSD-format utmp entries (using logwtmp),
+** and may get to worry about network notification.
+** The "time name" changes between 4.3-tahoe and 4.4;
+** we include sys/param.h to determine which we should use.
+*/
+
+#ifndef TIME_NAME
+#include "sys/param.h"
+#ifdef BSD4_4
+#define TIME_NAME "date"
+#endif /* defined BSD4_4 */
+#ifndef BSD4_4
+#define TIME_NAME ""
+#endif /* !defined BSD4_4 */
+#endif /* !defined TIME_NAME */
+
+#include "syslog.h"
+#include "sys/socket.h"
+#include "netinet/in.h"
+#include "netdb.h"
+#define TSPTYPES
+#include "protocols/timed.h"
+
+extern int logwtmp();
+
+#if HAVE_SETTIMEOFDAY == 1
+#define settimeofday(t, tz) (settimeofday)(t)
+#endif /* HAVE_SETTIMEOFDAY == 1 */
+
+#ifndef TSP_SETDATE
+/*ARGSUSED*/
+#endif /* !defined TSP_SETDATE */
+static void
+reset(newt, nflag)
+const time_t newt;
+const int nflag;
+{
+ register const char * username;
+ static struct timeval tv; /* static so tv_usec is 0 */
+
+#ifdef EBUG
+ return;
+#endif /* defined EBUG */
+ username = getlogin();
+ if (username == NULL || *username == '\0') /* single-user or no tty */
+ username = "root";
+ tv.tv_sec = newt;
+#ifdef TSP_SETDATE
+ if (nflag || !netsettime(tv))
+#endif /* defined TSP_SETDATE */
+ {
+ /*
+ ** "old" entry is always written, for compatibility.
+ */
+ logwtmp("|", TIME_NAME, "");
+ if (settimeofday(&tv, (struct timezone *) NULL) == 0) {
+ logwtmp("{", TIME_NAME, ""); /* } */
+ syslog(LOG_AUTH | LOG_NOTICE, _("date set by %s"),
+ username);
+ } else oops("settimeofday");
+ }
+}
+
+#endif /* !defined OLD_TIME */
+
+static void
+wildinput(item, value, reason)
+const char * const item;
+const char * const value;
+const char * const reason;
+{
+ (void) fprintf(stderr,
+ _("date: error: bad command line %s \"%s\", %s\n"),
+ item, value, reason);
+ usage();
+}
+
+static void
+errensure(void)
+{
+ if (retval == EXIT_SUCCESS)
+ retval = EXIT_FAILURE;
+}
+
+static const char *
+nondigit(cp)
+register const char * cp;
+{
+ while (is_digit(*cp))
+ ++cp;
+ return cp;
+}
+
+static void
+usage(void)
+{
+ (void) fprintf(stderr, _("date: usage is date [-u] [-c] [-n] [-d dst] \
+[-t min-west] [-a sss.fff] [[yyyy]mmddhhmm[yyyy][.ss]] [+format]\n"));
+ errensure();
+ exit(retval);
+}
+
+static void
+oops(string)
+const char * const string;
+{
+ int e = errno;
+
+ (void) fprintf(stderr, _("date: error: "));
+ errno = e;
+ (void) perror(string);
+ errensure();
+ display((char *) NULL);
+}
+
+static void
+display(format)
+const char * const format;
+{
+ struct tm tm;
+ time_t now;
+
+ (void) time(&now);
+ tm = *localtime(&now);
+ timeout(stdout, format ? format : "%+", &tm);
+ (void) putchar('\n');
+ (void) fflush(stdout);
+ (void) fflush(stderr);
+ if (ferror(stdout) || ferror(stderr)) {
+ (void) fprintf(stderr,
+ _("date: error: couldn't write results\n"));
+ errensure();
+ }
+ exit(retval);
+}
+
+extern size_t strftime();
+
+#define INCR 1024
+
+static void
+timeout(fp, format, tmp)
+FILE * const fp;
+const char * const format;
+const struct tm * const tmp;
+{
+ char * cp;
+ size_t result;
+ size_t size;
+
+ if (*format == '\0')
+ return;
+ size = INCR;
+ cp = malloc((size_t) size);
+ for ( ; ; ) {
+ if (cp == NULL) {
+ (void) fprintf(stderr,
+ _("date: error: can't get memory\n"));
+ errensure();
+ exit(retval);
+ }
+ cp[0] = '\1';
+ result = strftime(cp, size, format, tmp);
+ if (result != 0 || cp[0] == '\0')
+ break;
+ size += INCR;
+ cp = realloc(cp, (size_t) size);
+ }
+ (void) fwrite(cp, 1, result, fp);
+ free(cp);
+}
+
+static int
+comptm(atmp, btmp)
+register const struct tm * const atmp;
+register const struct tm * const btmp;
+{
+ register int result;
+
+ if ((result = (atmp->tm_year - btmp->tm_year)) == 0 &&
+ (result = (atmp->tm_mon - btmp->tm_mon)) == 0 &&
+ (result = (atmp->tm_mday - btmp->tm_mday)) == 0 &&
+ (result = (atmp->tm_hour - btmp->tm_hour)) == 0 &&
+ (result = (atmp->tm_min - btmp->tm_min)) == 0)
+ result = atmp->tm_sec - btmp->tm_sec;
+ return result;
+}
+
+/*
+** convert --
+** convert user's input into a time_t.
+*/
+
+#define ATOI2(ar) (ar[0] - '0') * 10 + (ar[1] - '0'); ar += 2;
+
+static time_t
+convert(register const char * const value, const int dousg, const time_t t)
+{
+ register const char * cp;
+ register const char * dotp;
+ register int cent, year_in_cent, month, hour, day, mins, secs;
+ struct tm tm, outtm;
+ time_t outt;
+
+ tm = *localtime(&t);
+#define DIVISOR 100
+ year_in_cent = tm.tm_year % DIVISOR + TM_YEAR_BASE % DIVISOR;
+ cent = tm.tm_year / DIVISOR + TM_YEAR_BASE / DIVISOR +
+ year_in_cent / DIVISOR;
+ year_in_cent %= DIVISOR;
+ if (year_in_cent < 0) {
+ year_in_cent += DIVISOR;
+ --cent;
+ }
+ month = tm.tm_mon + 1;
+ day = tm.tm_mday;
+ hour = tm.tm_hour;
+ mins = tm.tm_min;
+ secs = 0;
+
+ dotp = strchr(value, '.');
+ for (cp = value; *cp != '\0'; ++cp)
+ if (!is_digit(*cp) && cp != dotp)
+ wildinput(_("time"), value, _("contains a nondigit"));
+
+ if (dotp == NULL)
+ dotp = strchr(value, '\0');
+ else {
+ cp = dotp + 1;
+ if (strlen(cp) != 2)
+ wildinput(_("time"), value,
+ _("seconds part is not two digits"));
+ secs = ATOI2(cp);
+ }
+
+ cp = value;
+ switch (dotp - cp) {
+ default:
+ wildinput(_("time"), value,
+ _("main part is wrong length"));
+ case 12:
+ if (!dousg) {
+ cent = ATOI2(cp);
+ year_in_cent = ATOI2(cp);
+ }
+ month = ATOI2(cp);
+ day = ATOI2(cp);
+ hour = ATOI2(cp);
+ mins = ATOI2(cp);
+ if (dousg) {
+ cent = ATOI2(cp);
+ year_in_cent = ATOI2(cp);
+ }
+ break;
+ case 8: /* mmddhhmm */
+ month = ATOI2(cp);
+ /* fall through to. . . */
+ case 6: /* ddhhmm */
+ day = ATOI2(cp);
+ /* fall through to. . . */
+ case 4: /* hhmm */
+ hour = ATOI2(cp);
+ mins = ATOI2(cp);
+ break;
+ case 10:
+ if (!dousg) {
+ year_in_cent = ATOI2(cp);
+ }
+ month = ATOI2(cp);
+ day = ATOI2(cp);
+ hour = ATOI2(cp);
+ mins = ATOI2(cp);
+ if (dousg) {
+ year_in_cent = ATOI2(cp);
+ }
+ break;
+ }
+
+ tm.tm_year = cent * 100 + year_in_cent - TM_YEAR_BASE;
+ tm.tm_mon = month - 1;
+ tm.tm_mday = day;
+ tm.tm_hour = hour;
+ tm.tm_min = mins;
+ tm.tm_sec = secs;
+ tm.tm_isdst = -1;
+ outtm = tm;
+ outt = mktime(&outtm);
+ return (comptm(&tm, &outtm) == 0) ? outt : -1;
+}
+
+/*
+** Code from here on out is either based on code provided by UCB
+** or is only called just before the program exits.
+*/
+
+/*
+** Check for iffy input.
+*/
+
+static void
+checkfinal(const char * const value,
+ const int didusg,
+ const time_t t,
+ const time_t oldnow)
+{
+ time_t othert;
+ struct tm tm;
+ struct tm othertm;
+ register int pass;
+ register long offset;
+
+ /*
+ ** See if there's both a USG and a BSD interpretation.
+ */
+ othert = convert(value, !didusg, oldnow);
+ if (othert != -1 && othert != t)
+ iffy(t, othert, value, _("year could be at start or end"));
+ /*
+ ** See if there's both a DST and a STD version.
+ */
+ tm = *localtime(&t);
+ othertm = tm;
+ othertm.tm_isdst = !tm.tm_isdst;
+ othert = mktime(&othertm);
+ if (othert != -1 && othertm.tm_isdst != tm.tm_isdst &&
+ comptm(&tm, &othertm) == 0)
+ iffy(t, othert, value,
+ _("both standard and summer time versions exist"));
+/*
+** Final check.
+**
+** If a jurisdiction shifts time *without* shifting whether time is
+** summer or standard (as Hawaii, the United Kingdom, and Saudi Arabia
+** have done), routine checks for iffy times may not work.
+** So we perform this final check, deferring it until after the time has
+** been set--it may take a while, and we don't want to introduce an unnecessary
+** lag between the time the user enters their command and the time that
+** stime/settimeofday is called.
+**
+** We just check nearby times to see if any have the same representation
+** as the time that convert returned. We work our way out from the center
+** for quick response in solar time situations. We only handle common cases--
+** offsets of at most a minute, and offsets of exact numbers of minutes
+** and at most an hour.
+*/
+ for (offset = 1; offset <= 60; ++offset)
+ for (pass = 1; pass <= 4; ++pass) {
+ if (pass == 1)
+ othert = t + offset;
+ else if (pass == 2)
+ othert = t - offset;
+ else if (pass == 3)
+ othert = t + 60 * offset;
+ else othert = t - 60 * offset;
+ othertm = *localtime(&othert);
+ if (comptm(&tm, &othertm) == 0)
+ iffy(t, othert, value,
+ _("multiple matching times exist"));
+ }
+}
+
+static void
+iffy(const time_t thist, const time_t thatt,
+ const char * const value, const char * const reason)
+{
+ struct tm tm;
+
+ (void) fprintf(stderr, _("date: warning: ambiguous time \"%s\", %s.\n"),
+ value, reason);
+ tm = *gmtime(&thist);
+ /*
+ ** Avoid running afoul of SCCS!
+ */
+ timeout(stderr, _("Time was set as if you used\n\tdate -u %m%d%H\
+%M\
+%Y.%S\n"), &tm);
+ tm = *localtime(&thist);
+ timeout(stderr, _("to get %c"), &tm);
+ (void) fprintf(stderr, _(" (%s). Use\n"),
+ tm.tm_isdst ? _("summer time") : _("standard time"));
+ tm = *gmtime(&thatt);
+ timeout(stderr, _("\tdate -u %m%d%H\
+%M\
+%Y.%S\n"), &tm);
+ tm = *localtime(&thatt);
+ timeout(stderr, _("to get %c"), &tm);
+ (void) fprintf(stderr, _(" (%s).\n"),
+ tm.tm_isdst ? _("summer time") : _("standard time"));
+ errensure();
+ exit(retval);
+}
+
+#ifdef TSP_SETDATE
+#define WAITACK 2 /* seconds */
+#define WAITDATEACK 5 /* seconds */
+
+/*
+ * Set the date in the machines controlled by timedaemons
+ * by communicating the new date to the local timedaemon.
+ * If the timedaemon is in the master state, it performs the
+ * correction on all slaves. If it is in the slave state, it
+ * notifies the master that a correction is needed.
+ * Returns 1 on success, 0 on failure.
+ */
+netsettime(ntv)
+ struct timeval ntv;
+{
+ int s, length, port, timed_ack, found, err;
+ long waittime;
+ fd_set ready;
+ char hostname[MAXHOSTNAMELEN];
+ struct timeval tout;
+ struct servent *sp;
+ struct tsp msg;
+ struct sockaddr_in sin, dest, from;
+
+ sp = getservbyname("timed", "udp");
+ if (sp == 0) {
+ fputs(_("udp/timed: unknown service\n"), stderr);
+ retval = 2;
+ return (0);
+ }
+ dest.sin_port = sp->s_port;
+ dest.sin_family = AF_INET;
+ dest.sin_addr.s_addr = htonl((u_long)INADDR_ANY);
+ s = socket(AF_INET, SOCK_DGRAM, 0);
+ if (s < 0) {
+ if (errno != EPROTONOSUPPORT)
+ perror("date: socket");
+ goto bad;
+ }
+ bzero((char *)&sin, sizeof (sin));
+ sin.sin_family = AF_INET;
+ for (port = IPPORT_RESERVED - 1; port > IPPORT_RESERVED / 2; port--) {
+ sin.sin_port = htons((u_short)port);
+ if (bind(s, (struct sockaddr *)&sin, sizeof (sin)) >= 0)
+ break;
+ if (errno != EADDRINUSE) {
+ if (errno != EADDRNOTAVAIL)
+ perror("date: bind");
+ goto bad;
+ }
+ }
+ if (port == IPPORT_RESERVED / 2) {
+ fputs(_("date: All ports in use\n"), stderr);
+ goto bad;
+ }
+ msg.tsp_type = TSP_SETDATE;
+ msg.tsp_vers = TSPVERSION;
+ if (gethostname(hostname, sizeof (hostname))) {
+ perror("gethostname");
+ goto bad;
+ }
+ (void) strncpy(msg.tsp_name, hostname, sizeof (hostname));
+ msg.tsp_seq = htons((u_short)0);
+ msg.tsp_time.tv_sec = htonl((u_long)ntv.tv_sec);
+ msg.tsp_time.tv_usec = htonl((u_long)ntv.tv_usec);
+ length = sizeof (struct sockaddr_in);
+ if (connect(s, &dest, length) < 0) {
+ perror("date: connect");
+ goto bad;
+ }
+ if (send(s, (char *)&msg, sizeof (struct tsp), 0) < 0) {
+ if (errno != ECONNREFUSED)
+ perror("date: send");
+ goto bad;
+ }
+ timed_ack = -1;
+ waittime = WAITACK;
+loop:
+ tout.tv_sec = waittime;
+ tout.tv_usec = 0;
+ FD_ZERO(&ready);
+ FD_SET(s, &ready);
+ found = select(FD_SETSIZE, &ready, (fd_set *)0, (fd_set *)0, &tout);
+ length = sizeof err;
+ if (getsockopt(s, SOL_SOCKET, SO_ERROR, (char *)&err, &length) == 0
+ && err) {
+ errno = err;
+ if (errno != ECONNREFUSED)
+ perror(_("date: send (delayed error)"));
+ goto bad;
+ }
+ if (found > 0 && FD_ISSET(s, &ready)) {
+ length = sizeof (struct sockaddr_in);
+ if (recvfrom(s, (char *)&msg, sizeof (struct tsp), 0, &from,
+ &length) < 0) {
+ if (errno != ECONNREFUSED)
+ perror("date: recvfrom");
+ goto bad;
+ }
+ msg.tsp_seq = ntohs(msg.tsp_seq);
+ msg.tsp_time.tv_sec = ntohl(msg.tsp_time.tv_sec);
+ msg.tsp_time.tv_usec = ntohl(msg.tsp_time.tv_usec);
+ switch (msg.tsp_type) {
+
+ case TSP_ACK:
+ timed_ack = TSP_ACK;
+ waittime = WAITDATEACK;
+ goto loop;
+
+ case TSP_DATEACK:
+ (void)close(s);
+ return (1);
+
+ default:
+ fprintf(stderr,
+ _("date: Wrong ack received from timed: %s\n"),
+ tsptype[msg.tsp_type]);
+ timed_ack = -1;
+ break;
+ }
+ }
+ if (timed_ack == -1)
+ fputs(_("date: Can't reach time daemon, time set locally.\n"),
+ stderr);
+bad:
+ (void)close(s);
+ retval = 2;
+ return (0);
+}
+#endif /* defined TSP_SETDATE */
diff --git a/unused/itca.jpg b/unused/itca.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..89a7119c0ccccf06d6686d0aaeea798137ade546
GIT binary patch
literal 55948
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