33 * 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
44 *
55 * IDENTIFICATION
6- * $PostgreSQL: pgsql/src/timezone/localtime.c,v 1.10 2005/04/19 03:13:59 momjian Exp $
6+ * $PostgreSQL: pgsql/src/timezone/localtime.c,v 1.11 2005/06/20 08:00:51 neilc Exp $
77 */
88
99/*
@@ -81,15 +81,15 @@ static const char *getzname(const char *strp);
8181static const char * getnum (const char * strp ,int * nump ,int min ,int max );
8282static const char * getsecs (const char * strp ,long * secsp );
8383static const char * getoffset (const char * strp ,long * offsetp );
84- static const char * getrule (const char * strp ,struct rule * rulep );
85- static void gmtload (struct state * sp );
86- static void gmtsub (const pg_time_t * timep ,long offset ,struct pg_tm * tmp );
87- static void localsub (const pg_time_t * timep ,long offset ,struct pg_tm * tmp ,const pg_tz * tz );
84+ static const char * getrule (const char * strp ,struct rule * rulep );
85+ static void gmtload (struct state * sp );
86+ static void gmtsub (const pg_time_t * timep ,long offset ,struct pg_tm * tmp );
87+ static void localsub (const pg_time_t * timep ,long offset ,struct pg_tm * tmp ,const pg_tz * tz );
8888static void timesub (const pg_time_t * timep ,long offset ,
89- const struct state * sp ,struct pg_tm * tmp );
89+ const struct state * sp ,struct pg_tm * tmp );
9090static pg_time_t transtime (pg_time_t janfirst ,int year ,
91- const struct rule * rulep ,long offset );
92- int tzparse (const char * name ,struct state * sp ,int lastditch );
91+ const struct rule * rulep ,long offset );
92+ int tzparse (const char * name ,struct state * sp ,int lastditch );
9393
9494/* GMT timezone */
9595static struct state gmtmem ;
@@ -113,8 +113,8 @@ static struct pg_tm tm;
113113static long
114114detzcode (const char * codep )
115115{
116- register long result ;
117- register int i ;
116+ long result ;
117+ int i ;
118118
119119result = (codep [0 ]& 0x80 ) ? ~0L :0L ;
120120for (i = 0 ;i < 4 ;++ i )
@@ -123,16 +123,16 @@ detzcode(const char *codep)
123123}
124124
125125int
126- tzload (register const char * name ,register struct state * sp )
126+ tzload (const char * name ,struct state * sp )
127127{
128- register const char * p ;
129- register int i ;
130- register int fid ;
128+ const char * p ;
129+ int i ;
130+ int fid ;
131131
132132if (name == NULL && (name = TZDEFAULT )== NULL )
133133return -1 ;
134134{
135- register int doaccess ;
135+ int doaccess ;
136136char fullname [MAXPGPATH ];
137137
138138if (name [0 ]== ':' )
@@ -209,7 +209,7 @@ tzload(register const char *name, register struct state * sp)
209209}
210210for (i = 0 ;i < sp -> typecnt ;++ i )
211211{
212- register struct ttinfo * ttisp ;
212+ struct ttinfo * ttisp ;
213213
214214ttisp = & sp -> ttis [i ];
215215ttisp -> tt_gmtoff = detzcode (p );
@@ -227,7 +227,7 @@ tzload(register const char *name, register struct state * sp)
227227sp -> chars [i ]= '\0' ;/* ensure '\0' at end */
228228for (i = 0 ;i < sp -> leapcnt ;++ i )
229229{
230- register struct lsinfo * lsisp ;
230+ struct lsinfo * lsisp ;
231231
232232lsisp = & sp -> lsis [i ];
233233lsisp -> ls_trans = detzcode (p );
@@ -237,7 +237,7 @@ tzload(register const char *name, register struct state * sp)
237237}
238238for (i = 0 ;i < sp -> typecnt ;++ i )
239239{
240- register struct ttinfo * ttisp ;
240+ struct ttinfo * ttisp ;
241241
242242ttisp = & sp -> ttis [i ];
243243if (ttisstdcnt == 0 )
@@ -252,7 +252,7 @@ tzload(register const char *name, register struct state * sp)
252252}
253253for (i = 0 ;i < sp -> typecnt ;++ i )
254254{
255- register struct ttinfo * ttisp ;
255+ struct ttinfo * ttisp ;
256256
257257ttisp = & sp -> ttis [i ];
258258if (ttisgmtcnt == 0 )
@@ -284,9 +284,9 @@ static const int year_lengths[2] = {
284284 * character.
285285 */
286286static const char *
287- getzname (register const char * strp )
287+ getzname (const char * strp )
288288{
289- register char c ;
289+ char c ;
290290
291291while ((c = * strp )!= '\0' && !is_digit (c )&& c != ',' && c != '-' &&
292292c != '+' )
@@ -301,10 +301,10 @@ getzname(register const char *strp)
301301 * Otherwise, return a pointer to the first character not part of the number.
302302 */
303303static const char *
304- getnum (register const char * strp ,int * nump ,const int min ,const int max )
304+ getnum (const char * strp ,int * nump ,int min ,int max )
305305{
306- register char c ;
307- register int num ;
306+ char c ;
307+ int num ;
308308
309309if (strp == NULL || !is_digit (c = * strp ))
310310return NULL ;
@@ -330,7 +330,7 @@ getnum(register const char *strp, int *nump, const int min, const int max)
330330 * of seconds.
331331 */
332332static const char *
333- getsecs (register const char * strp ,long * secsp )
333+ getsecs (const char * strp ,long * secsp )
334334{
335335int num ;
336336
@@ -370,9 +370,9 @@ getsecs(register const char *strp, long *secsp)
370370 * Otherwise, return a pointer to the first character not part of the time.
371371 */
372372static const char *
373- getoffset (register const char * strp ,long * offsetp )
373+ getoffset (const char * strp ,long * offsetp )
374374{
375- register int neg = 0 ;
375+ int neg = 0 ;
376376
377377if (* strp == '-' )
378378{
@@ -396,7 +396,7 @@ getoffset(register const char *strp, long *offsetp)
396396 * Otherwise, return a pointer to the first character not part of the rule.
397397 */
398398static const char *
399- getrule (const char * strp ,register struct rule * rulep )
399+ getrule (const char * strp ,struct rule * rulep )
400400{
401401if (* strp == 'J' )
402402{
@@ -457,13 +457,13 @@ getrule(const char *strp, register struct rule * rulep)
457457 * calculate the Epoch-relative time that rule takes effect.
458458 */
459459static pg_time_t
460- transtime (const pg_time_t janfirst ,const int year ,
461- register const struct rule * rulep ,const long offset )
460+ transtime (const pg_time_t janfirst ,int year ,
461+ const struct rule * rulep ,long offset )
462462{
463- register int leapyear ;
464- register pg_time_t value = 0 ;
465- register int i ;
466- int d ,
463+ int leapyear ;
464+ pg_time_t value = 0 ;
465+ int i ,
466+ d ,
467467m1 ,
468468yy0 ,
469469yy1 ,
@@ -556,18 +556,18 @@ transtime(const pg_time_t janfirst, const int year,
556556 */
557557
558558int
559- tzparse (const char * name ,register struct state * sp ,const int lastditch )
559+ tzparse (const char * name ,struct state * sp ,int lastditch )
560560{
561561const char * stdname ;
562562const char * dstname = NULL ;
563563size_t stdlen ;
564564size_t dstlen ;
565565long stdoffset ;
566566long dstoffset ;
567- register pg_time_t * atp ;
568- register unsignedchar * typep ;
569- register char * cp ;
570- register int load_result ;
567+ pg_time_t * atp ;
568+ unsignedchar * typep ;
569+ char * cp ;
570+ int load_result ;
571571
572572stdname = name ;
573573if (lastditch )
@@ -614,8 +614,8 @@ tzparse(const char *name, register struct state * sp, const int lastditch)
614614{
615615struct rule start ;
616616struct rule end ;
617- register int year ;
618- register pg_time_t janfirst ;
617+ int year ;
618+ pg_time_t janfirst ;
619619pg_time_t starttime ;
620620pg_time_t endtime ;
621621
@@ -671,12 +671,12 @@ tzparse(const char *name, register struct state * sp, const int lastditch)
671671}
672672else
673673{
674- register long theirstdoffset ;
675- register long theirdstoffset ;
676- register long theiroffset ;
677- register int isdst ;
678- register int i ;
679- register int j ;
674+ long theirstdoffset ;
675+ long theirdstoffset ;
676+ long theiroffset ;
677+ int isdst ;
678+ int i ;
679+ int j ;
680680
681681if (* name != '\0' )
682682return -1 ;
@@ -798,7 +798,7 @@ tzparse(const char *name, register struct state * sp, const int lastditch)
798798}
799799
800800static void
801- gmtload (struct state * sp )
801+ gmtload (struct state * sp )
802802{
803803if (tzload (gmt ,sp )!= 0 )
804804(void )tzparse (gmt ,sp , TRUE);
@@ -814,11 +814,11 @@ gmtload(struct state * sp)
814814 * The unused offset argument is for the benefit of mktime variants.
815815 */
816816static void
817- localsub (const pg_time_t * timep ,const long offset ,struct pg_tm * tmp ,const pg_tz * tz )
817+ localsub (const pg_time_t * timep ,long offset ,struct pg_tm * tmp ,const pg_tz * tz )
818818{
819- register const struct state * sp ;
820- register const struct ttinfo * ttisp ;
821- register int i ;
819+ const struct state * sp ;
820+ const struct ttinfo * ttisp ;
821+ int i ;
822822const pg_time_t t = * timep ;
823823
824824sp = & tz -> state ;
@@ -859,7 +859,7 @@ pg_localtime(const pg_time_t *timep, const pg_tz *tz)
859859 * gmtsub is to gmtime as localsub is to localtime.
860860 */
861861static void
862- gmtsub (const pg_time_t * timep ,const long offset ,struct pg_tm * tmp )
862+ gmtsub (const pg_time_t * timep ,long offset ,struct pg_tm * tmp )
863863{
864864if (!gmt_is_set )
865865{
@@ -888,21 +888,21 @@ pg_gmtime(const pg_time_t *timep)
888888
889889
890890static void
891- timesub (const pg_time_t * timep ,const long offset ,
892- register const struct state * sp ,register struct pg_tm * tmp )
891+ timesub (const pg_time_t * timep ,long offset ,
892+ const struct state * sp ,struct pg_tm * tmp )
893893{
894- register const struct lsinfo * lp ;
894+ const struct lsinfo * lp ;
895895
896896/* expand days to 64 bits to support full Julian-day range */
897- register int64 days ;
898- register int idays ;
899- register long rem ;
900- register int y ;
901- register int yleap ;
902- register const int * ip ;
903- register long corr ;
904- register int hit ;
905- register int i ;
897+ int64 days ;
898+ int idays ;
899+ long rem ;
900+ int y ;
901+ int yleap ;
902+ const int * ip ;
903+ long corr ;
904+ int hit ;
905+ int i ;
906906
907907corr = 0 ;
908908hit = 0 ;
@@ -979,7 +979,7 @@ timesub(const pg_time_t *timep, const long offset,
979979#define LEAPS_THRU_END_OF (y )(((y) + 4800) / 4 - ((y) + 4800) / 100 + ((y) + 4800) / 400)
980980while (days < 0 || days >= (int64 )year_lengths [yleap = isleap (y )])
981981{
982- register int newy ;
982+ int newy ;
983983
984984newy = y + days /DAYSPERNYEAR ;
985985if (days < 0 )
@@ -1029,8 +1029,8 @@ pg_next_dst_boundary(const pg_time_t *timep,
10291029int * after_isdst ,
10301030const pg_tz * tz )
10311031{
1032- register const struct state * sp ;
1033- register const struct ttinfo * ttisp ;
1032+ const struct state * sp ;
1033+ const struct ttinfo * ttisp ;
10341034int i ;
10351035int j ;
10361036const pg_time_t t = * timep ;