Commit 6216e84d authored by Tom Lane's avatar Tom Lane

Make ECPGraise's str parameter const to suppress warnings from gcc

and errors from pickier compilers.
parent 3b192c23
...@@ -34,7 +34,7 @@ extern "C" ...@@ -34,7 +34,7 @@ extern "C"
const char *descriptor, const char *query); const char *descriptor, const char *query);
bool ECPGdeallocate_desc(int line, const char *name); bool ECPGdeallocate_desc(int line, const char *name);
bool ECPGallocate_desc(int line, const char *name); bool ECPGallocate_desc(int line, const char *name);
void ECPGraise(int line, int code, char *str); void ECPGraise(int line, int code, const char *str);
bool ECPGget_desc_header(int, char *, int *); bool ECPGget_desc_header(int, char *, int *);
bool ECPGget_desc(int, char *, int,...); bool ECPGget_desc(int, char *, int,...);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include <sqlca.h> #include <sqlca.h>
void void
ECPGraise(int line, int code, char *str) ECPGraise(int line, int code, const char *str)
{ {
sqlca.sqlcode = code; sqlca.sqlcode = code;
...@@ -119,13 +119,15 @@ ECPGraise(int line, int code, char *str) ...@@ -119,13 +119,15 @@ ECPGraise(int line, int code, char *str)
break; break;
case ECPG_PGSQL: case ECPG_PGSQL:
{
int slen = strlen(str);
/* strip trailing newline */ /* strip trailing newline */
if (str[strlen(str) - 1] == '\n') if (slen > 0 && str[slen - 1] == '\n')
str[strlen(str) - 1] = '\0'; slen--;
snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc), snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
"'%s' in line %d.", str, line); "'%.*s' in line %d.", slen, str, line);
break; break;
}
case ECPG_TRANS: case ECPG_TRANS:
snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc), snprintf(sqlca.sqlerrm.sqlerrmc, sizeof(sqlca.sqlerrm.sqlerrmc),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment