Skip to content

Commit 0b62bbe

Browse files
author
Neil Conway
committed
Cosmetic improvements to the timezone code: remove the use of the
'register' qualifier, make some function declarations more consistent, and so on.
1 parent ec490f5 commit 0b62bbe

File tree

6 files changed

+200
-201
lines changed

6 files changed

+200
-201
lines changed

src/timezone/ialloc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
44
*
55
* IDENTIFICATION
6-
* $PostgreSQL: pgsql/src/timezone/ialloc.c,v 1.5 2004/05/21 20:59:10 tgl Exp $
6+
* $PostgreSQL: pgsql/src/timezone/ialloc.c,v 1.6 2005/06/20 08:00:51 neilc Exp $
77
*/
88

99
#include "postgres.h"
@@ -38,9 +38,9 @@ irealloc(void *pointer, const int size)
3838
char *
3939
icatalloc(char *old, const char *new)
4040
{
41-
register char *result;
42-
register int oldsize,
43-
newsize;
41+
char *result;
42+
int oldsize,
43+
newsize;
4444

4545
newsize = (new == NULL) ? 0 : strlen(new);
4646
if (old == NULL)

src/timezone/localtime.c

Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
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);
8181
static const char *getnum(const char *strp, int *nump, int min, int max);
8282
static const char *getsecs(const char *strp, long *secsp);
8383
static 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);
8888
static 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);
9090
static 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 */
9595
static struct state gmtmem;
@@ -113,8 +113,8 @@ static struct pg_tm tm;
113113
static long
114114
detzcode(const char *codep)
115115
{
116-
register long result;
117-
register int i;
116+
long result;
117+
int i;
118118

119119
result = (codep[0] & 0x80) ? ~0L : 0L;
120120
for (i = 0; i < 4; ++i)
@@ -123,16 +123,16 @@ detzcode(const char *codep)
123123
}
124124

125125
int
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

132132
if (name == NULL && (name = TZDEFAULT) == NULL)
133133
return -1;
134134
{
135-
register int doaccess;
135+
int doaccess;
136136
char fullname[MAXPGPATH];
137137

138138
if (name[0] == ':')
@@ -209,7 +209,7 @@ tzload(register const char *name, register struct state * sp)
209209
}
210210
for (i = 0; i < sp->typecnt; ++i)
211211
{
212-
register struct ttinfo *ttisp;
212+
struct ttinfo *ttisp;
213213

214214
ttisp = &sp->ttis[i];
215215
ttisp->tt_gmtoff = detzcode(p);
@@ -227,7 +227,7 @@ tzload(register const char *name, register struct state * sp)
227227
sp->chars[i] = '\0'; /* ensure '\0' at end */
228228
for (i = 0; i < sp->leapcnt; ++i)
229229
{
230-
register struct lsinfo *lsisp;
230+
struct lsinfo *lsisp;
231231

232232
lsisp = &sp->lsis[i];
233233
lsisp->ls_trans = detzcode(p);
@@ -237,7 +237,7 @@ tzload(register const char *name, register struct state * sp)
237237
}
238238
for (i = 0; i < sp->typecnt; ++i)
239239
{
240-
register struct ttinfo *ttisp;
240+
struct ttinfo *ttisp;
241241

242242
ttisp = &sp->ttis[i];
243243
if (ttisstdcnt == 0)
@@ -252,7 +252,7 @@ tzload(register const char *name, register struct state * sp)
252252
}
253253
for (i = 0; i < sp->typecnt; ++i)
254254
{
255-
register struct ttinfo *ttisp;
255+
struct ttinfo *ttisp;
256256

257257
ttisp = &sp->ttis[i];
258258
if (ttisgmtcnt == 0)
@@ -284,9 +284,9 @@ static const int year_lengths[2] = {
284284
* character.
285285
*/
286286
static const char *
287-
getzname(register const char *strp)
287+
getzname(const char *strp)
288288
{
289-
register char c;
289+
char c;
290290

291291
while ((c = *strp) != '\0' && !is_digit(c) && c != ',' && c != '-' &&
292292
c != '+')
@@ -301,10 +301,10 @@ getzname(register const char *strp)
301301
* Otherwise, return a pointer to the first character not part of the number.
302302
*/
303303
static 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

309309
if (strp == NULL || !is_digit(c = *strp))
310310
return NULL;
@@ -330,7 +330,7 @@ getnum(register const char *strp, int *nump, const int min, const int max)
330330
* of seconds.
331331
*/
332332
static const char *
333-
getsecs(register const char *strp, long *secsp)
333+
getsecs(const char *strp, long *secsp)
334334
{
335335
int 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
*/
372372
static 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

377377
if (*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
*/
398398
static const char *
399-
getrule(const char *strp, register struct rule * rulep)
399+
getrule(const char *strp, struct rule *rulep)
400400
{
401401
if (*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
*/
459459
static 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,
467467
m1,
468468
yy0,
469469
yy1,
@@ -556,18 +556,18 @@ transtime(const pg_time_t janfirst, const int year,
556556
*/
557557

558558
int
559-
tzparse(const char *name, register struct state * sp, const int lastditch)
559+
tzparse(const char *name, struct state *sp, int lastditch)
560560
{
561561
const char *stdname;
562562
const char *dstname = NULL;
563563
size_t stdlen;
564564
size_t dstlen;
565565
long stdoffset;
566566
long dstoffset;
567-
register pg_time_t *atp;
568-
register unsigned char *typep;
569-
register char *cp;
570-
register int load_result;
567+
pg_time_t *atp;
568+
unsigned char *typep;
569+
char *cp;
570+
int load_result;
571571

572572
stdname = name;
573573
if (lastditch)
@@ -614,8 +614,8 @@ tzparse(const char *name, register struct state * sp, const int lastditch)
614614
{
615615
struct rule start;
616616
struct rule end;
617-
register int year;
618-
register pg_time_t janfirst;
617+
int year;
618+
pg_time_t janfirst;
619619
pg_time_t starttime;
620620
pg_time_t endtime;
621621

@@ -671,12 +671,12 @@ tzparse(const char *name, register struct state * sp, const int lastditch)
671671
}
672672
else
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

681681
if (*name != '\0')
682682
return -1;
@@ -798,7 +798,7 @@ tzparse(const char *name, register struct state * sp, const int lastditch)
798798
}
799799

800800
static void
801-
gmtload(struct state * sp)
801+
gmtload(struct state *sp)
802802
{
803803
if (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
*/
816816
static 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;
822822
const pg_time_t t = *timep;
823823

824824
sp = &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
*/
861861
static 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
{
864864
if (!gmt_is_set)
865865
{
@@ -888,21 +888,21 @@ pg_gmtime(const pg_time_t *timep)
888888

889889

890890
static 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

907907
corr = 0;
908908
hit = 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)
980980
while (days < 0 || days >= (int64) year_lengths[yleap = isleap(y)])
981981
{
982-
register int newy;
982+
int newy;
983983

984984
newy = y + days / DAYSPERNYEAR;
985985
if (days < 0)
@@ -1029,8 +1029,8 @@ pg_next_dst_boundary(const pg_time_t *timep,
10291029
int *after_isdst,
10301030
const 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;
10341034
int i;
10351035
int j;
10361036
const pg_time_t t = *timep;

src/timezone/pgtz.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
77
*
88
* IDENTIFICATION
9-
* $PostgreSQL: pgsql/src/timezone/pgtz.c,v 1.34 2005/06/19 21:34:03 tgl Exp $
9+
* $PostgreSQL: pgsql/src/timezone/pgtz.c,v 1.35 2005/06/20 08:00:51 neilc Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -97,7 +97,7 @@ static void scan_available_timezones(char *tzdir, char *tzdirsub,
9797
* Get GMT offset from a system struct tm
9898
*/
9999
static int
100-
get_timezone_offset(struct tm * tm)
100+
get_timezone_offset(struct tm *tm)
101101
{
102102
#if defined(HAVE_STRUCT_TM_TM_ZONE)
103103
return tm->tm_gmtoff;
@@ -128,7 +128,7 @@ build_time_t(int year, int month, int day)
128128
* Does a system tm value match one we computed ourselves?
129129
*/
130130
static bool
131-
compare_tm(struct tm * s, struct pg_tm * p)
131+
compare_tm(struct tm *s, struct pg_tm *p)
132132
{
133133
if (s->tm_sec != p->tm_sec ||
134134
s->tm_min != p->tm_min ||
@@ -155,7 +155,7 @@ compare_tm(struct tm * s, struct pg_tm * p)
155155
* test time.
156156
*/
157157
static int
158-
score_timezone(const char *tzname, struct tztry * tt)
158+
score_timezone(const char *tzname, struct tztry *tt)
159159
{
160160
int i;
161161
pg_time_t pgtt;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy