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

and errors from pickier compilers.
This commit is contained in:
Tom Lane 2000-04-18 00:24:30 +00:00
parent 3b192c232d
commit 6216e84df6
2 changed files with 8 additions and 6 deletions

View File

@ -34,7 +34,7 @@ extern "C"
const char *descriptor, const char *query);
bool ECPGdeallocate_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(int, char *, int,...);

View File

@ -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),