From: Michael Meskes Date: Sun, 18 Dec 2011 18:04:19 +0000 (+0100) Subject: Mark variables as const in pgtypeslib if they only carry a format string. X-Git-Tag: REL9_2_BETA1~677 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=59e242a4969d2efa6ce68dc7aab3cbd8cf975b08;p=postgresql Mark variables as const in pgtypeslib if they only carry a format string. --- diff --git a/src/interfaces/ecpg/include/pgtypes_date.h b/src/interfaces/ecpg/include/pgtypes_date.h index 7ab8046b7b..b8990bb072 100644 --- a/src/interfaces/ecpg/include/pgtypes_date.h +++ b/src/interfaces/ecpg/include/pgtypes_date.h @@ -21,8 +21,8 @@ extern void PGTYPESdate_julmdy(date, int *); extern void PGTYPESdate_mdyjul(int *, date *); extern int PGTYPESdate_dayofweek(date); extern void PGTYPESdate_today(date *); -extern int PGTYPESdate_defmt_asc(date *, char *, char *); -extern int PGTYPESdate_fmt_asc(date, char *, char *); +extern int PGTYPESdate_defmt_asc(date *, const char *, char *); +extern int PGTYPESdate_fmt_asc(date, const char *, char *); #ifdef __cplusplus } diff --git a/src/interfaces/ecpg/include/pgtypes_timestamp.h b/src/interfaces/ecpg/include/pgtypes_timestamp.h index 07e95294b3..537585ce21 100644 --- a/src/interfaces/ecpg/include/pgtypes_timestamp.h +++ b/src/interfaces/ecpg/include/pgtypes_timestamp.h @@ -22,9 +22,9 @@ extern "C" extern timestamp PGTYPEStimestamp_from_asc(char *, char **); extern char *PGTYPEStimestamp_to_asc(timestamp); extern int PGTYPEStimestamp_sub(timestamp *, timestamp *, interval *); -extern int PGTYPEStimestamp_fmt_asc(timestamp *, char *, int, char *); +extern int PGTYPEStimestamp_fmt_asc(timestamp *, char *, int, const char *); extern void PGTYPEStimestamp_current(timestamp *); -extern int PGTYPEStimestamp_defmt_asc(char *, char *, timestamp *); +extern int PGTYPEStimestamp_defmt_asc(char *, const char *, timestamp *); extern int PGTYPEStimestamp_add_interval(timestamp * tin, interval * span, timestamp * tout); extern int PGTYPEStimestamp_sub_interval(timestamp * tin, interval * span, timestamp * tout); diff --git a/src/interfaces/ecpg/pgtypeslib/common.c b/src/interfaces/ecpg/pgtypeslib/common.c index d800321a9d..9084fd06b4 100644 --- a/src/interfaces/ecpg/pgtypeslib/common.c +++ b/src/interfaces/ecpg/pgtypeslib/common.c @@ -16,7 +16,7 @@ pgtypes_alloc(long size) } char * -pgtypes_strdup(char *str) +pgtypes_strdup(const char *str) { char *new = (char *) strdup(str); diff --git a/src/interfaces/ecpg/pgtypeslib/datetime.c b/src/interfaces/ecpg/pgtypeslib/datetime.c index 41377a6861..823626fcf5 100644 --- a/src/interfaces/ecpg/pgtypeslib/datetime.c +++ b/src/interfaces/ecpg/pgtypeslib/datetime.c @@ -173,7 +173,7 @@ PGTYPESdate_today(date * d) #define PGTYPES_FMTDATE_YEAR_DIGITS_LONG 6 int -PGTYPESdate_fmt_asc(date dDate, char *fmtstring, char *outbuf) +PGTYPESdate_fmt_asc(date dDate, const char *fmtstring, char *outbuf) { static struct { @@ -335,7 +335,7 @@ PGTYPESdate_fmt_asc(date dDate, char *fmtstring, char *outbuf) #define PGTYPES_DATE_MONTH_MAXLENGTH 20 /* probably even less :-) */ int -PGTYPESdate_defmt_asc(date * d, char *fmt, char *str) +PGTYPESdate_defmt_asc(date * d, const char *fmt, char *str) { /* * token[2] = { 4,6 } means that token 2 starts at position 4 and ends at diff --git a/src/interfaces/ecpg/pgtypeslib/extern.h b/src/interfaces/ecpg/pgtypeslib/extern.h index c7c64b1578..88b2fb0775 100644 --- a/src/interfaces/ecpg/pgtypeslib/extern.h +++ b/src/interfaces/ecpg/pgtypeslib/extern.h @@ -37,7 +37,7 @@ union un_fmt_comb int pgtypes_fmt_replace(union un_fmt_comb, int, char **, int *); char *pgtypes_alloc(long); -char *pgtypes_strdup(char *); +char *pgtypes_strdup(const char *); #ifndef bool #define bool char diff --git a/src/interfaces/ecpg/pgtypeslib/timestamp.c b/src/interfaces/ecpg/pgtypeslib/timestamp.c index 8d787bbbe6..dc5ff72b60 100644 --- a/src/interfaces/ecpg/pgtypeslib/timestamp.c +++ b/src/interfaces/ecpg/pgtypeslib/timestamp.c @@ -18,7 +18,7 @@ #include "pgtypes_date.h" -int PGTYPEStimestamp_defmt_scan(char **, char *, timestamp *, int *, int *, int *, +int PGTYPEStimestamp_defmt_scan(char **, const char *, timestamp *, int *, int *, int *, int *, int *, int *, int *); #ifdef HAVE_INT64_TIMESTAMP @@ -384,12 +384,12 @@ PGTYPEStimestamp_current(timestamp * ts) static int dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm, - char *output, int *pstr_len, char *fmtstr) + char *output, int *pstr_len, const char *fmtstr) { union un_fmt_comb replace_val; int replace_type; int i; - char *p = fmtstr; + const char *p = fmtstr; char *q = output; while (*p) @@ -866,7 +866,7 @@ dttofmtasc_replace(timestamp * ts, date dDate, int dow, struct tm * tm, int -PGTYPEStimestamp_fmt_asc(timestamp * ts, char *output, int str_len, char *fmtstr) +PGTYPEStimestamp_fmt_asc(timestamp * ts, char *output, int str_len, const char *fmtstr) { struct tm tm; fsec_t fsec; @@ -894,7 +894,7 @@ PGTYPEStimestamp_sub(timestamp * ts1, timestamp * ts2, interval * iv) } int -PGTYPEStimestamp_defmt_asc(char *str, char *fmt, timestamp * d) +PGTYPEStimestamp_defmt_asc(char *str, const char *fmt, timestamp * d) { int year, month,