Skip to content

Commit 48d818e

Browse files
committed
Const-ify a few more large static tables.
Per research by Andres. Discussion: https://postgr.es/m/20181015200754.7y7zfuzsoux2c4ya@alap3.anarazel.de
1 parent 9958b2b commit 48d818e

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

src/backend/utils/adt/datetime.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static const datetkn datetktbl[] = {
165165
{YESTERDAY, RESERV, DTK_YESTERDAY} /* yesterday midnight */
166166
};
167167

168-
static int szdatetktbl = sizeof datetktbl / sizeof datetktbl[0];
168+
static const int szdatetktbl = sizeof datetktbl / sizeof datetktbl[0];
169169

170170
/*
171171
* deltatktbl: same format as datetktbl, but holds keywords used to represent
@@ -238,7 +238,7 @@ static const datetkn deltatktbl[] = {
238238
{"yrs", UNITS, DTK_YEAR} /* "years" relative */
239239
};
240240

241-
static int szdeltatktbl = sizeof deltatktbl / sizeof deltatktbl[0];
241+
static const int szdeltatktbl = sizeof deltatktbl / sizeof deltatktbl[0];
242242

243243
static TimeZoneAbbrevTable *zoneabbrevtbl = NULL;
244244

src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/sjis.map

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
static struct
1+
static const struct
22
{
33
unsigned short int nec; /* SJIS UDC (NEC selection IBM kanji) */
44
unsigned short int sjis; /* SJIS UDC (IBM kanji) */

src/interfaces/ecpg/pgtypeslib/dt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,6 @@ extern char *pgtypes_date_weekdays_short[];
336336
extern char *pgtypes_date_months[];
337337
extern char *months[];
338338
extern char *days[];
339-
extern int day_tab[2][13];
339+
extern const int day_tab[2][13];
340340

341341
#endif /* DT_H */

src/interfaces/ecpg/pgtypeslib/dt_common.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
#include "dt.h"
1111
#include "pgtypes_timestamp.h"
1212

13-
int day_tab[2][13] = {
13+
const int day_tab[2][13] = {
1414
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0},
1515
{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0}};
1616

1717
typedef long AbsoluteTime;
1818

19-
static datetkn datetktbl[] = {
19+
static const datetkn datetktbl[] = {
2020
/* text, token, lexval */
2121
{EARLY, RESERV, DTK_EARLY}, /* "-infinity" reserved for "early time" */
2222
{"acsst", DTZ, 37800}, /* Cent. Australia */
@@ -420,7 +420,7 @@ static datetkn datetktbl[] = {
420420
{ZULU, TZ, 0}, /* UTC */
421421
};
422422

423-
static datetkn deltatktbl[] = {
423+
static const datetkn deltatktbl[] = {
424424
/* text, token, lexval */
425425
{"@", IGNORE_DTF, 0}, /* postgres relative prefix */
426426
{DAGO, AGO, 0}, /* "ago" indicates negative time offset */
@@ -490,9 +490,9 @@ static datetkn deltatktbl[] = {
490490
static const unsigned int szdatetktbl = lengthof(datetktbl);
491491
static const unsigned int szdeltatktbl = lengthof(deltatktbl);
492492

493-
static datetkn *datecache[MAXDATEFIELDS] = {NULL};
493+
static const datetkn *datecache[MAXDATEFIELDS] = {NULL};
494494

495-
static datetkn *deltacache[MAXDATEFIELDS] = {NULL};
495+
static const datetkn *deltacache[MAXDATEFIELDS] = {NULL};
496496

497497
char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL};
498498

@@ -502,12 +502,12 @@ char *pgtypes_date_weekdays_short[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fr
502502

503503
char *pgtypes_date_months[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", NULL};
504504

505-
static datetkn *
506-
datebsearch(char *key, datetkn *base, unsigned int nel)
505+
static const datetkn *
506+
datebsearch(const char *key, const datetkn *base, unsigned int nel)
507507
{
508508
if (nel > 0)
509509
{
510-
datetkn *last = base + nel - 1,
510+
const datetkn *last = base + nel - 1,
511511
*position;
512512
int result;
513513

@@ -540,7 +540,7 @@ int
540540
DecodeUnits(int field, char *lowtoken, int *val)
541541
{
542542
int type;
543-
datetkn *tp;
543+
const datetkn *tp;
544544

545545
/* use strncmp so that we match truncated tokens */
546546
if (deltacache[field] != NULL &&
@@ -641,7 +641,7 @@ static int
641641
DecodeSpecial(int field, char *lowtoken, int *val)
642642
{
643643
int type;
644-
datetkn *tp;
644+
const datetkn *tp;
645645

646646
/* use strncmp so that we match truncated tokens */
647647
if (datecache[field] != NULL &&

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