Skip to content

Commit 59e242a

Browse files
author
Michael Meskes
committed
Mark variables as const in pgtypeslib if they only carry a format string.
1 parent 2223283 commit 59e242a

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

src/interfaces/ecpg/include/pgtypes_date.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ extern void PGTYPESdate_julmdy(date, int *);
2121
extern void PGTYPESdate_mdyjul(int *, date *);
2222
extern int PGTYPESdate_dayofweek(date);
2323
extern void PGTYPESdate_today(date *);
24-
extern int PGTYPESdate_defmt_asc(date *, char *, char *);
25-
extern int PGTYPESdate_fmt_asc(date, char *, char *);
24+
extern int PGTYPESdate_defmt_asc(date *, const char *, char *);
25+
extern int PGTYPESdate_fmt_asc(date, const char *, char *);
2626

2727
#ifdef __cplusplus
2828
}

src/interfaces/ecpg/include/pgtypes_timestamp.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ extern "C"
2222
extern timestamp PGTYPEStimestamp_from_asc(char *, char **);
2323
extern char *PGTYPEStimestamp_to_asc(timestamp);
2424
extern int PGTYPEStimestamp_sub(timestamp *, timestamp *, interval *);
25-
extern int PGTYPEStimestamp_fmt_asc(timestamp *, char *, int, char *);
25+
extern int PGTYPEStimestamp_fmt_asc(timestamp *, char *, int, const char *);
2626
extern void PGTYPEStimestamp_current(timestamp *);
27-
extern int PGTYPEStimestamp_defmt_asc(char *, char *, timestamp *);
27+
extern int PGTYPEStimestamp_defmt_asc(char *, const char *, timestamp *);
2828
extern int PGTYPEStimestamp_add_interval(timestamp * tin, interval * span, timestamp * tout);
2929
extern int PGTYPEStimestamp_sub_interval(timestamp * tin, interval * span, timestamp * tout);
3030

src/interfaces/ecpg/pgtypeslib/common.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pgtypes_alloc(long size)
1616
}
1717

1818
char *
19-
pgtypes_strdup(char *str)
19+
pgtypes_strdup(const char *str)
2020
{
2121
char *new = (char *) strdup(str);
2222

src/interfaces/ecpg/pgtypeslib/datetime.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ PGTYPESdate_today(date * d)
173173
#define PGTYPES_FMTDATE_YEAR_DIGITS_LONG 6
174174

175175
int
176-
PGTYPESdate_fmt_asc(date dDate, char *fmtstring, char *outbuf)
176+
PGTYPESdate_fmt_asc(date dDate, const char *fmtstring, char *outbuf)
177177
{
178178
static struct
179179
{
@@ -335,7 +335,7 @@ PGTYPESdate_fmt_asc(date dDate, char *fmtstring, char *outbuf)
335335

336336
#define PGTYPES_DATE_MONTH_MAXLENGTH 20 /* probably even less :-) */
337337
int
338-
PGTYPESdate_defmt_asc(date * d, char *fmt, char *str)
338+
PGTYPESdate_defmt_asc(date * d, const char *fmt, char *str)
339339
{
340340
/*
341341
* token[2] = { 4,6 } means that token 2 starts at position 4 and ends at

src/interfaces/ecpg/pgtypeslib/extern.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ union un_fmt_comb
3737
int pgtypes_fmt_replace(union un_fmt_comb, int, char **, int *);
3838

3939
char *pgtypes_alloc(long);
40-
char *pgtypes_strdup(char *);
40+
char *pgtypes_strdup(const char *);
4141

4242
#ifndef bool
4343
#define bool char

src/interfaces/ecpg/pgtypeslib/timestamp.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "pgtypes_date.h"
1919

2020

21-
int PGTYPEStimestamp_defmt_scan(char **, char *, timestamp *, int *, int *, int *,
21+
int PGTYPEStimestamp_defmt_scan(char **, const char *, timestamp *, int *, int *, int *,
2222
int *, int *, int *, int *);
2323

2424
#ifdef HAVE_INT64_TIMESTAMP
@@ -384,12 +384,12 @@ PGTYPEStimestamp_current(timestamp * ts)
384384

385385
static int
386386
dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
387-
char *output, int *pstr_len, char *fmtstr)
387+
char *output, int *pstr_len, const char *fmtstr)
388388
{
389389
union un_fmt_comb replace_val;
390390
int replace_type;
391391
int i;
392-
char *p = fmtstr;
392+
const char *p = fmtstr;
393393
char *q = output;
394394

395395
while (*p)
@@ -866,7 +866,7 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm,
866866

867867

868868
int
869-
PGTYPEStimestamp_fmt_asc(timestamp * ts, char *output, int str_len, char *fmtstr)
869+
PGTYPEStimestamp_fmt_asc(timestamp * ts, char *output, int str_len, const char *fmtstr)
870870
{
871871
struct tm tm;
872872
fsec_t fsec;
@@ -894,7 +894,7 @@ PGTYPEStimestamp_sub(timestamp * ts1, timestamp * ts2, interval * iv)
894894
}
895895

896896
int
897-
PGTYPEStimestamp_defmt_asc(char *str, char *fmt, timestamp * d)
897+
PGTYPEStimestamp_defmt_asc(char *str, const char *fmt, timestamp * d)
898898
{
899899
int year,
900900
month,

0 commit comments

Comments
 (0)