diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-04-18 00:24:30 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-04-18 00:24:30 +0000 |
commit | 6216e84df611759f626107180f47087260e36ca9 (patch) | |
tree | f900733237ddcef05a407c7227b6beac16136e67 /src/interfaces/ecpg/lib/error.c | |
parent | 3b192c232d64fce4b968c3238746957c9bee32f1 (diff) | |
download | postgresql-6216e84df611759f626107180f47087260e36ca9.tar.gz postgresql-6216e84df611759f626107180f47087260e36ca9.zip |
Make ECPGraise's str parameter const to suppress warnings from gcc
and errors from pickier compilers.
Diffstat (limited to 'src/interfaces/ecpg/lib/error.c')
-rw-r--r-- | src/interfaces/ecpg/lib/error.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/interfaces/ecpg/lib/error.c b/src/interfaces/ecpg/lib/error.c index e2da331757a..369972687cd 100644 --- a/src/interfaces/ecpg/lib/error.c +++ b/src/interfaces/ecpg/lib/error.c @@ -7,7 +7,7 @@ #include <sqlca.h> void -ECPGraise(int line, int code, char *str) +ECPGraise(int line, int code, const char *str) { sqlca.sqlcode = code; @@ -119,13 +119,15 @@ ECPGraise(int line, int code, char *str) break; case ECPG_PGSQL: + { + int slen = strlen(str); /* strip trailing newline */ - if (str[strlen(str) - 1] == '\n') - str[strlen(str) - 1] = '\0'; - + if (slen > 0 && str[slen - 1] == '\n') + slen--; snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc), - "'%s' in line %d.", str, line); + "'%.*s' in line %d.", slen, str, line); break; + } case ECPG_TRANS: snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc), |