Deleted Added
full compact
localtime.c (102885) localtime.c (107480)
1/*
2** This file is in the public domain, so clarified as of
3** June 5, 1996 by Arthur David Olson (arthur_david_olson@nih.gov).
4*/
5
6#ifndef lint
7#ifndef NOID
8static char elsieid[] = "@(#)localtime.c 7.57";
9#endif /* !defined NOID */
10#endif /* !defined lint */
11#include <sys/cdefs.h>
1/*
2** This file is in the public domain, so clarified as of
3** June 5, 1996 by Arthur David Olson (arthur_david_olson@nih.gov).
4*/
5
6#ifndef lint
7#ifndef NOID
8static char elsieid[] = "@(#)localtime.c 7.57";
9#endif /* !defined NOID */
10#endif /* !defined lint */
11#include <sys/cdefs.h>
12__FBSDID("$FreeBSD: head/lib/libc/stdtime/localtime.c 102885 2002-09-03 04:34:10Z peter $");
12__FBSDID("$FreeBSD: head/lib/libc/stdtime/localtime.c 107480 2002-12-02 01:05:08Z peter $");
13
14/*
15** Leap second handling from Bradley White (bww@k.gp.cs.cmu.edu).
16** POSIX-style TZ environment variable handling from Guy Harris
17** (guy@auspex.com).
18*/
19
20/*LINTLIBRARY*/

--- 1196 unchanged lines hidden (view full) ---

1217const time_t * const timep;
1218const long offset;
1219const struct state * const sp;
1220struct tm * const tmp;
1221{
1222 const struct lsinfo * lp;
1223 long days;
1224 long rem;
13
14/*
15** Leap second handling from Bradley White (bww@k.gp.cs.cmu.edu).
16** POSIX-style TZ environment variable handling from Guy Harris
17** (guy@auspex.com).
18*/
19
20/*LINTLIBRARY*/

--- 1196 unchanged lines hidden (view full) ---

1217const time_t * const timep;
1218const long offset;
1219const struct state * const sp;
1220struct tm * const tmp;
1221{
1222 const struct lsinfo * lp;
1223 long days;
1224 long rem;
1225 int y;
1225 long y;
1226 int yleap;
1227 const int * ip;
1228 long corr;
1229 int hit;
1230 int i;
1231
1232 corr = 0;
1233 hit = 0;

--- 52 unchanged lines hidden (view full) ---

1286 */
1287 tmp->tm_sec = (int) (rem % SECSPERMIN) + hit;
1288 tmp->tm_wday = (int) ((EPOCH_WDAY + days) % DAYSPERWEEK);
1289 if (tmp->tm_wday < 0)
1290 tmp->tm_wday += DAYSPERWEEK;
1291 y = EPOCH_YEAR;
1292#define LEAPS_THRU_END_OF(y) ((y) / 4 - (y) / 100 + (y) / 400)
1293 while (days < 0 || days >= (long) year_lengths[yleap = isleap(y)]) {
1226 int yleap;
1227 const int * ip;
1228 long corr;
1229 int hit;
1230 int i;
1231
1232 corr = 0;
1233 hit = 0;

--- 52 unchanged lines hidden (view full) ---

1286 */
1287 tmp->tm_sec = (int) (rem % SECSPERMIN) + hit;
1288 tmp->tm_wday = (int) ((EPOCH_WDAY + days) % DAYSPERWEEK);
1289 if (tmp->tm_wday < 0)
1290 tmp->tm_wday += DAYSPERWEEK;
1291 y = EPOCH_YEAR;
1292#define LEAPS_THRU_END_OF(y) ((y) / 4 - (y) / 100 + (y) / 400)
1293 while (days < 0 || days >= (long) year_lengths[yleap = isleap(y)]) {
1294 int newy;
1294 long newy;
1295
1296 newy = y + days / DAYSPERNYEAR;
1297 if (days < 0)
1298 --newy;
1299 days -= (newy - y) * DAYSPERNYEAR +
1300 LEAPS_THRU_END_OF(newy - 1) -
1301 LEAPS_THRU_END_OF(y - 1);
1302 y = newy;

--- 168 unchanged lines hidden (view full) ---

1471 yourtm.tm_sec = 0;
1472 }
1473 /*
1474 ** Divide the search space in half
1475 ** (this works whether time_t is signed or unsigned).
1476 */
1477 bits = TYPE_BIT(time_t) - 1;
1478 /*
1295
1296 newy = y + days / DAYSPERNYEAR;
1297 if (days < 0)
1298 --newy;
1299 days -= (newy - y) * DAYSPERNYEAR +
1300 LEAPS_THRU_END_OF(newy - 1) -
1301 LEAPS_THRU_END_OF(y - 1);
1302 y = newy;

--- 168 unchanged lines hidden (view full) ---

1471 yourtm.tm_sec = 0;
1472 }
1473 /*
1474 ** Divide the search space in half
1475 ** (this works whether time_t is signed or unsigned).
1476 */
1477 bits = TYPE_BIT(time_t) - 1;
1478 /*
1479 * Limit to 32 bits or the things go crazy
1480 * when it tries to figure out times near 2^62 etc.
1481 */
1482 if (bits > 31)
1483 bits = 31;
1484 /*
1485 ** If time_t is signed, then 0 is just above the median,
1486 ** assuming two's complement arithmetic.
1487 ** If time_t is unsigned, then (1 << bits) is just above the median.
1488 */
1489 t = TYPE_SIGNED(time_t) ? 0 : (((time_t) 1) << bits);
1490 for ( ; ; ) {
1491 (*funcp)(&t, offset, &mytm);
1492 dir = tmcomp(&mytm, &yourtm);

--- 258 unchanged lines hidden ---
1479 ** If time_t is signed, then 0 is just above the median,
1480 ** assuming two's complement arithmetic.
1481 ** If time_t is unsigned, then (1 << bits) is just above the median.
1482 */
1483 t = TYPE_SIGNED(time_t) ? 0 : (((time_t) 1) << bits);
1484 for ( ; ; ) {
1485 (*funcp)(&t, offset, &mytm);
1486 dir = tmcomp(&mytm, &yourtm);

--- 258 unchanged lines hidden ---