Commit b21de4e7 authored by Peter Eisentraut's avatar Peter Eisentraut

ecpg: Split off mmfatal() from mmerror()

This allows decorating mmfatal() with noreturn compiler hints, leading
to better diagnostics.
parent 22967d80
...@@ -274,7 +274,7 @@ output_set_descr(char *desc_name, char *index) ...@@ -274,7 +274,7 @@ output_set_descr(char *desc_name, char *index)
case ECPGd_di_precision: case ECPGd_di_precision:
case ECPGd_precision: case ECPGd_precision:
case ECPGd_scale: case ECPGd_scale:
mmerror(PARSE_ERROR, ET_FATAL, "descriptor item \"%s\" is not implemented", mmfatal(PARSE_ERROR, "descriptor item \"%s\" is not implemented",
descriptor_item_name(results->value)); descriptor_item_name(results->value));
break; break;
...@@ -284,7 +284,7 @@ output_set_descr(char *desc_name, char *index) ...@@ -284,7 +284,7 @@ output_set_descr(char *desc_name, char *index)
case ECPGd_octet: case ECPGd_octet:
case ECPGd_ret_length: case ECPGd_ret_length:
case ECPGd_ret_octet: case ECPGd_ret_octet:
mmerror(PARSE_ERROR, ET_FATAL, "descriptor item \"%s\" cannot be set", mmfatal(PARSE_ERROR, "descriptor item \"%s\" cannot be set",
descriptor_item_name(results->value)); descriptor_item_name(results->value));
break; break;
......
...@@ -64,11 +64,9 @@ struct ECPGtype ecpg_query = {ECPGt_char_variable, NULL, NULL, NULL, {NULL}, 0}; ...@@ -64,11 +64,9 @@ struct ECPGtype ecpg_query = {ECPGt_char_variable, NULL, NULL, NULL, {NULL}, 0};
/* /*
* Handle parsing errors and warnings * Handle parsing errors and warnings
*/ */
void static void __attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 0)))
mmerror(int error_code, enum errortype type, const char *error, ...) vmmerror(int error_code, enum errortype type, const char *error, va_list ap)
{ {
va_list ap;
/* internationalize the error message string */ /* internationalize the error message string */
error = _(error); error = _(error);
...@@ -80,14 +78,11 @@ mmerror(int error_code, enum errortype type, const char *error, ...) ...@@ -80,14 +78,11 @@ mmerror(int error_code, enum errortype type, const char *error, ...)
fprintf(stderr, _("WARNING: ")); fprintf(stderr, _("WARNING: "));
break; break;
case ET_ERROR: case ET_ERROR:
case ET_FATAL:
fprintf(stderr, _("ERROR: ")); fprintf(stderr, _("ERROR: "));
break; break;
} }
va_start(ap, error);
vfprintf(stderr, error, ap); vfprintf(stderr, error, ap);
va_end(ap);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
...@@ -98,18 +93,38 @@ mmerror(int error_code, enum errortype type, const char *error, ...) ...@@ -98,18 +93,38 @@ mmerror(int error_code, enum errortype type, const char *error, ...)
case ET_ERROR: case ET_ERROR:
ret_value = error_code; ret_value = error_code;
break; break;
case ET_FATAL:
if (yyin)
fclose(yyin);
if (yyout)
fclose(yyout);
if (strcmp(output_filename, "-") != 0 && unlink(output_filename) != 0)
fprintf(stderr, _("could not remove output file \"%s\"\n"), output_filename);
exit(error_code);
} }
} }
void
mmerror(int error_code, enum errortype type, const char *error, ...)
{
va_list ap;
va_start(ap, error);
vmmerror(error_code, type, error, ap);
va_end(ap);
}
void
mmfatal(int error_code, const char *error, ...)
{
va_list ap;
va_start(ap, error);
vmmerror(error_code, ET_ERROR, error, ap);
va_end(ap);
if (yyin)
fclose(yyin);
if (yyout)
fclose(yyout);
if (strcmp(output_filename, "-") != 0 && unlink(output_filename) != 0)
fprintf(stderr, _("could not remove output file \"%s\"\n"), output_filename);
exit(error_code);
}
/* /*
* string concatenation * string concatenation
*/ */
......
...@@ -1687,7 +1687,7 @@ cvariable: CVARIABLE ...@@ -1687,7 +1687,7 @@ cvariable: CVARIABLE
{ {
case '[': case '[':
if (brace) if (brace)
mmerror(PARSE_ERROR, ET_FATAL, "multidimensional arrays for simple data types are not supported"); mmfatal(PARSE_ERROR, "multidimensional arrays for simple data types are not supported");
brace_open++; brace_open++;
break; break;
case ']': case ']':
......
...@@ -73,10 +73,8 @@ extern int base_yylex(void); ...@@ -73,10 +73,8 @@ extern int base_yylex(void);
extern void base_yyerror(const char *); extern void base_yyerror(const char *);
extern void *mm_alloc(size_t), *mm_realloc(void *, size_t); extern void *mm_alloc(size_t), *mm_realloc(void *, size_t);
extern char *mm_strdup(const char *); extern char *mm_strdup(const char *);
extern void extern void mmerror(int errorcode, enum errortype type, const char *error, ...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4)));
mmerror(int, enum errortype, const char *,...) extern void mmfatal(int errorcode, const char *error, ...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3),noreturn));
/* This extension allows gcc to check the format string */
__attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4)));
extern void output_get_descr_header(char *); extern void output_get_descr_header(char *);
extern void output_get_descr(char *, char *); extern void output_get_descr(char *, char *);
extern void output_set_descr_header(char *); extern void output_set_descr_header(char *);
......
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
CATALOG_NAME = ecpg CATALOG_NAME = ecpg
AVAIL_LANGUAGES = cs de es fr it ja ko pl pt_BR ru tr zh_CN zh_TW AVAIL_LANGUAGES = cs de es fr it ja ko pl pt_BR ru tr zh_CN zh_TW
GETTEXT_FILES = descriptor.c ecpg.c pgc.c preproc.c type.c variable.c GETTEXT_FILES = descriptor.c ecpg.c pgc.c preproc.c type.c variable.c
GETTEXT_TRIGGERS = mmerror:3 GETTEXT_TRIGGERS = mmerror:3 mmfatal:2
GETTEXT_FLAGS = mmerror:3:c-format GETTEXT_FLAGS = mmerror:3:c-format mmfatal:2:c-format
...@@ -400,7 +400,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -400,7 +400,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
<xc>{op_chars} { ECHO; } <xc>{op_chars} { ECHO; }
<xc>\*+ { ECHO; } <xc>\*+ { ECHO; }
<xc><<EOF>> { mmerror(PARSE_ERROR, ET_FATAL, "unterminated /* comment"); } <xc><<EOF>> { mmfatal(PARSE_ERROR, "unterminated /* comment"); }
<SQL>{xbstart} { <SQL>{xbstart} {
token_start = yytext; token_start = yytext;
...@@ -422,7 +422,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -422,7 +422,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
<xb>{xbinside} { addlit(yytext, yyleng); } <xb>{xbinside} { addlit(yytext, yyleng); }
<xh>{quotecontinue} | <xh>{quotecontinue} |
<xb>{quotecontinue} { /* ignore */ } <xb>{quotecontinue} { /* ignore */ }
<xb><<EOF>> { mmerror(PARSE_ERROR, ET_FATAL, "unterminated bit string literal"); } <xb><<EOF>> { mmfatal(PARSE_ERROR, "unterminated bit string literal"); }
<SQL>{xhstart} { <SQL>{xhstart} {
token_start = yytext; token_start = yytext;
...@@ -438,7 +438,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -438,7 +438,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
return XCONST; return XCONST;
} }
<xh><<EOF>> { mmerror(PARSE_ERROR, ET_FATAL, "unterminated hexadecimal string literal"); } <xh><<EOF>> { mmfatal(PARSE_ERROR, "unterminated hexadecimal string literal"); }
<SQL>{xnstart} { <SQL>{xnstart} {
/* National character. /* National character.
* Transfer it as-is to the backend. * Transfer it as-is to the backend.
...@@ -516,7 +516,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -516,7 +516,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
/* This is only needed for \ just before EOF */ /* This is only needed for \ just before EOF */
addlitchar(yytext[0]); addlitchar(yytext[0]);
} }
<xq,xqc,xe,xn,xus><<EOF>> { mmerror(PARSE_ERROR, ET_FATAL, "unterminated quoted string"); } <xq,xqc,xe,xn,xus><<EOF>> { mmfatal(PARSE_ERROR, "unterminated quoted string"); }
<SQL>{dolqfailed} { <SQL>{dolqfailed} {
/* throw back all but the initial "$" */ /* throw back all but the initial "$" */
yyless(1); yyless(1);
...@@ -592,7 +592,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -592,7 +592,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
} }
<xd,xui>{xddouble} { addlitchar('"'); } <xd,xui>{xddouble} { addlitchar('"'); }
<xd,xui>{xdinside} { addlit(yytext, yyleng); } <xd,xui>{xdinside} { addlit(yytext, yyleng); }
<xd,xdc,xui><<EOF>> { mmerror(PARSE_ERROR, ET_FATAL, "unterminated quoted identifier"); } <xd,xdc,xui><<EOF>> { mmfatal(PARSE_ERROR, "unterminated quoted identifier"); }
<C,SQL>{xdstart} { <C,SQL>{xdstart} {
state_before = YYSTATE; state_before = YYSTATE;
BEGIN(xdc); BEGIN(xdc);
...@@ -938,7 +938,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -938,7 +938,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
BEGIN(C); BEGIN(C);
} }
<undef>{other}|\n { <undef>{other}|\n {
mmerror(PARSE_ERROR, ET_FATAL, "missing identifier in EXEC SQL UNDEF command"); mmfatal(PARSE_ERROR, "missing identifier in EXEC SQL UNDEF command");
yyterminate(); yyterminate();
} }
<C>{exec_sql}{include}{space}* { BEGIN(incl); } <C>{exec_sql}{include}{space}* { BEGIN(incl); }
...@@ -984,10 +984,10 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -984,10 +984,10 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
} }
<C,xskip>{exec_sql}{elif}{space}* { /* pop stack */ <C,xskip>{exec_sql}{elif}{space}* { /* pop stack */
if ( preproc_tos == 0 ) { if ( preproc_tos == 0 ) {
mmerror(PARSE_ERROR, ET_FATAL, "missing matching \"EXEC SQL IFDEF\" / \"EXEC SQL IFNDEF\""); mmfatal(PARSE_ERROR, "missing matching \"EXEC SQL IFDEF\" / \"EXEC SQL IFNDEF\"");
} }
else if ( stacked_if_value[preproc_tos].else_branch ) else if ( stacked_if_value[preproc_tos].else_branch )
mmerror(PARSE_ERROR, ET_FATAL, "missing \"EXEC SQL ENDIF;\""); mmfatal(PARSE_ERROR, "missing \"EXEC SQL ENDIF;\"");
else else
preproc_tos--; preproc_tos--;
...@@ -998,9 +998,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -998,9 +998,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
if (INFORMIX_MODE) if (INFORMIX_MODE)
{ {
if (preproc_tos == 0) if (preproc_tos == 0)
mmerror(PARSE_ERROR, ET_FATAL, "missing matching \"EXEC SQL IFDEF\" / \"EXEC SQL IFNDEF\""); mmfatal(PARSE_ERROR, "missing matching \"EXEC SQL IFDEF\" / \"EXEC SQL IFNDEF\"");
else if (stacked_if_value[preproc_tos].else_branch) else if (stacked_if_value[preproc_tos].else_branch)
mmerror(PARSE_ERROR, ET_FATAL, "missing \"EXEC SQL ENDIF;\""); mmfatal(PARSE_ERROR, "missing \"EXEC SQL ENDIF;\"");
else else
preproc_tos--; preproc_tos--;
...@@ -1016,7 +1016,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -1016,7 +1016,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
<C,xskip>{exec_sql}{else}{space}*";" { /* only exec sql endif pops the stack, so take care of duplicated 'else' */ <C,xskip>{exec_sql}{else}{space}*";" { /* only exec sql endif pops the stack, so take care of duplicated 'else' */
if (stacked_if_value[preproc_tos].else_branch) if (stacked_if_value[preproc_tos].else_branch)
mmerror(PARSE_ERROR, ET_FATAL, "more than one EXEC SQL ELSE"); mmfatal(PARSE_ERROR, "more than one EXEC SQL ELSE");
else else
{ {
stacked_if_value[preproc_tos].else_branch = TRUE; stacked_if_value[preproc_tos].else_branch = TRUE;
...@@ -1035,7 +1035,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -1035,7 +1035,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
if (INFORMIX_MODE) if (INFORMIX_MODE)
{ {
if (stacked_if_value[preproc_tos].else_branch) if (stacked_if_value[preproc_tos].else_branch)
mmerror(PARSE_ERROR, ET_FATAL, "more than one EXEC SQL ELSE"); mmfatal(PARSE_ERROR, "more than one EXEC SQL ELSE");
else else
{ {
stacked_if_value[preproc_tos].else_branch = TRUE; stacked_if_value[preproc_tos].else_branch = TRUE;
...@@ -1057,7 +1057,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -1057,7 +1057,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
} }
<C,xskip>{exec_sql}{endif}{space}*";" { <C,xskip>{exec_sql}{endif}{space}*";" {
if (preproc_tos == 0) if (preproc_tos == 0)
mmerror(PARSE_ERROR, ET_FATAL, "unmatched EXEC SQL ENDIF"); mmfatal(PARSE_ERROR, "unmatched EXEC SQL ENDIF");
else else
preproc_tos--; preproc_tos--;
...@@ -1071,7 +1071,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -1071,7 +1071,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
if (INFORMIX_MODE) if (INFORMIX_MODE)
{ {
if (preproc_tos == 0) if (preproc_tos == 0)
mmerror(PARSE_ERROR, ET_FATAL, "unmatched EXEC SQL ENDIF"); mmfatal(PARSE_ERROR, "unmatched EXEC SQL ENDIF");
else else
preproc_tos--; preproc_tos--;
...@@ -1091,7 +1091,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -1091,7 +1091,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
<xcond>{identifier}{space}*";" { <xcond>{identifier}{space}*";" {
if (preproc_tos >= MAX_NESTED_IF-1) if (preproc_tos >= MAX_NESTED_IF-1)
mmerror(PARSE_ERROR, ET_FATAL, "too many nested EXEC SQL IFDEF conditions"); mmfatal(PARSE_ERROR, "too many nested EXEC SQL IFDEF conditions");
else else
{ {
struct _defines *defptr; struct _defines *defptr;
...@@ -1124,7 +1124,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -1124,7 +1124,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
} }
<xcond>{other}|\n { <xcond>{other}|\n {
mmerror(PARSE_ERROR, ET_FATAL, "missing identifier in EXEC SQL IFDEF command"); mmfatal(PARSE_ERROR, "missing identifier in EXEC SQL IFDEF command");
yyterminate(); yyterminate();
} }
<def_ident>{identifier} { <def_ident>{identifier} {
...@@ -1133,7 +1133,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -1133,7 +1133,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
startlit(); startlit();
} }
<def_ident>{other}|\n { <def_ident>{other}|\n {
mmerror(PARSE_ERROR, ET_FATAL, "missing identifier in EXEC SQL DEFINE command"); mmfatal(PARSE_ERROR, "missing identifier in EXEC SQL DEFINE command");
yyterminate(); yyterminate();
} }
<def>{space}*";" { <def>{space}*";" {
...@@ -1166,7 +1166,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -1166,7 +1166,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
<incl>{dquote}{xdinside}{dquote}{space}*";"? { parse_include(); } <incl>{dquote}{xdinside}{dquote}{space}*";"? { parse_include(); }
<incl>[^;\<\>\"]+";" { parse_include(); } <incl>[^;\<\>\"]+";" { parse_include(); }
<incl>{other}|\n { <incl>{other}|\n {
mmerror(PARSE_ERROR, ET_FATAL, "syntax error in EXEC SQL INCLUDE command"); mmfatal(PARSE_ERROR, "syntax error in EXEC SQL INCLUDE command");
yyterminate(); yyterminate();
} }
...@@ -1176,7 +1176,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -1176,7 +1176,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
if ( preproc_tos > 0 ) if ( preproc_tos > 0 )
{ {
preproc_tos = 0; preproc_tos = 0;
mmerror(PARSE_ERROR, ET_FATAL, "missing \"EXEC SQL ENDIF;\""); mmfatal(PARSE_ERROR, "missing \"EXEC SQL ENDIF;\"");
} }
yyterminate(); yyterminate();
} }
...@@ -1215,7 +1215,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. ...@@ -1215,7 +1215,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*.
} }
} }
<INITIAL>{other}|\n { mmerror(PARSE_ERROR, ET_FATAL, "internal error: unreachable state; please report this to <pgsql-bugs@postgresql.org>"); } <INITIAL>{other}|\n { mmfatal(PARSE_ERROR, "internal error: unreachable state; please report this to <pgsql-bugs@postgresql.org>"); }
%% %%
void void
lex_init(void) lex_init(void)
...@@ -1362,7 +1362,7 @@ parse_include(void) ...@@ -1362,7 +1362,7 @@ parse_include(void)
} }
} }
if (!yyin) if (!yyin)
mmerror(NO_INCLUDE_FILE, ET_FATAL, "could not open include file \"%s\" on line %d", yytext, yylineno); mmfatal(NO_INCLUDE_FILE, "could not open include file \"%s\" on line %d", yytext, yylineno);
input_filename = mm_strdup(inc_file); input_filename = mm_strdup(inc_file);
yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE )); yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE ));
......
...@@ -15,7 +15,7 @@ mm_alloc(size_t size) ...@@ -15,7 +15,7 @@ mm_alloc(size_t size)
void *ptr = malloc(size); void *ptr = malloc(size);
if (ptr == NULL) if (ptr == NULL)
mmerror(OUT_OF_MEMORY, ET_FATAL, "out of memory"); mmfatal(OUT_OF_MEMORY, "out of memory");
return ptr; return ptr;
} }
...@@ -27,7 +27,7 @@ mm_strdup(const char *string) ...@@ -27,7 +27,7 @@ mm_strdup(const char *string)
char *new = strdup(string); char *new = strdup(string);
if (new == NULL) if (new == NULL)
mmerror(OUT_OF_MEMORY, ET_FATAL, "out of memory"); mmfatal(OUT_OF_MEMORY, "out of memory");
return new; return new;
} }
...@@ -282,7 +282,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const int bra ...@@ -282,7 +282,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const int bra
{ {
case ECPGt_array: case ECPGt_array:
if (indicator_set && ind_type->type != ECPGt_array) if (indicator_set && ind_type->type != ECPGt_array)
mmerror(INDICATOR_NOT_ARRAY, ET_FATAL, "indicator for array/pointer has to be array/pointer"); mmfatal(INDICATOR_NOT_ARRAY, "indicator for array/pointer has to be array/pointer");
switch (type->u.element->type) switch (type->u.element->type)
{ {
case ECPGt_array: case ECPGt_array:
...@@ -319,7 +319,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const int bra ...@@ -319,7 +319,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const int bra
break; break;
case ECPGt_struct: case ECPGt_struct:
if (indicator_set && ind_type->type != ECPGt_struct) if (indicator_set && ind_type->type != ECPGt_struct)
mmerror(INDICATOR_NOT_STRUCT, ET_FATAL, "indicator for struct has to be a struct"); mmfatal(INDICATOR_NOT_STRUCT, "indicator for struct has to be a struct");
ECPGdump_a_struct(o, name, ind_name, mm_strdup("1"), type, ind_type, prefix, ind_prefix); ECPGdump_a_struct(o, name, ind_name, mm_strdup("1"), type, ind_type, prefix, ind_prefix);
break; break;
...@@ -328,7 +328,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const int bra ...@@ -328,7 +328,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const int bra
break; break;
case ECPGt_char_variable: case ECPGt_char_variable:
if (indicator_set && (ind_type->type == ECPGt_struct || ind_type->type == ECPGt_array)) if (indicator_set && (ind_type->type == ECPGt_struct || ind_type->type == ECPGt_array))
mmerror(INDICATOR_NOT_SIMPLE, ET_FATAL, "indicator for simple data type has to be simple"); mmfatal(INDICATOR_NOT_SIMPLE, "indicator for simple data type has to be simple");
ECPGdump_a_simple(o, name, type->type, mm_strdup("1"), (arr_str_siz && strcmp(arr_str_siz, "0") != 0) ? arr_str_siz : mm_strdup("1"), struct_sizeof, prefix, 0); ECPGdump_a_simple(o, name, type->type, mm_strdup("1"), (arr_str_siz && strcmp(arr_str_siz, "0") != 0) ? arr_str_siz : mm_strdup("1"), struct_sizeof, prefix, 0);
if (ind_type != NULL) if (ind_type != NULL)
...@@ -336,7 +336,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const int bra ...@@ -336,7 +336,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const int bra
break; break;
case ECPGt_descriptor: case ECPGt_descriptor:
if (indicator_set && (ind_type->type == ECPGt_struct || ind_type->type == ECPGt_array)) if (indicator_set && (ind_type->type == ECPGt_struct || ind_type->type == ECPGt_array))
mmerror(INDICATOR_NOT_SIMPLE, ET_FATAL, "indicator for simple data type has to be simple"); mmfatal(INDICATOR_NOT_SIMPLE, "indicator for simple data type has to be simple");
ECPGdump_a_simple(o, name, type->type, NULL, mm_strdup("-1"), NULL, prefix, 0); ECPGdump_a_simple(o, name, type->type, NULL, mm_strdup("-1"), NULL, prefix, 0);
if (ind_type != NULL) if (ind_type != NULL)
...@@ -344,7 +344,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const int bra ...@@ -344,7 +344,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const int bra
break; break;
default: default:
if (indicator_set && (ind_type->type == ECPGt_struct || ind_type->type == ECPGt_array)) if (indicator_set && (ind_type->type == ECPGt_struct || ind_type->type == ECPGt_array))
mmerror(INDICATOR_NOT_SIMPLE, ET_FATAL, "indicator for simple data type has to be simple"); mmfatal(INDICATOR_NOT_SIMPLE, "indicator for simple data type has to be simple");
ECPGdump_a_simple(o, name, type->type, type->size, (arr_str_siz && strcmp(arr_str_siz, "0") != 0) ? arr_str_siz : mm_strdup("-1"), struct_sizeof, prefix, type->counter); ECPGdump_a_simple(o, name, type->type, type->size, (arr_str_siz && strcmp(arr_str_siz, "0") != 0) ? arr_str_siz : mm_strdup("-1"), struct_sizeof, prefix, type->counter);
if (ind_type != NULL) if (ind_type != NULL)
......
...@@ -186,7 +186,7 @@ struct assignment ...@@ -186,7 +186,7 @@ struct assignment
enum errortype enum errortype
{ {
ET_WARNING, ET_ERROR, ET_FATAL ET_WARNING, ET_ERROR
}; };
struct fetch_desc struct fetch_desc
......
...@@ -86,7 +86,7 @@ find_struct_member(char *name, char *str, struct ECPGstruct_member * members, in ...@@ -86,7 +86,7 @@ find_struct_member(char *name, char *str, struct ECPGstruct_member * members, in
case '\0': /* found the end, but this time it has to be case '\0': /* found the end, but this time it has to be
* an array element */ * an array element */
if (members->type->type != ECPGt_array) if (members->type->type != ECPGt_array)
mmerror(PARSE_ERROR, ET_FATAL, "incorrectly formed variable \"%s\"", name); mmfatal(PARSE_ERROR, "incorrectly formed variable \"%s\"", name);
switch (members->type->u.element->type) switch (members->type->u.element->type)
{ {
...@@ -113,7 +113,7 @@ find_struct_member(char *name, char *str, struct ECPGstruct_member * members, in ...@@ -113,7 +113,7 @@ find_struct_member(char *name, char *str, struct ECPGstruct_member * members, in
return (find_struct_member(name, end, members->type->u.members, brace_level)); return (find_struct_member(name, end, members->type->u.members, brace_level));
break; break;
default: default:
mmerror(PARSE_ERROR, ET_FATAL, "incorrectly formed variable \"%s\"", name); mmfatal(PARSE_ERROR, "incorrectly formed variable \"%s\"", name);
break; break;
} }
} }
...@@ -136,10 +136,10 @@ find_struct(char *name, char *next, char *end) ...@@ -136,10 +136,10 @@ find_struct(char *name, char *next, char *end)
if (c == '-') if (c == '-')
{ {
if (p->type->type != ECPGt_array) if (p->type->type != ECPGt_array)
mmerror(PARSE_ERROR, ET_FATAL, "variable \"%s\" is not a pointer", name); mmfatal(PARSE_ERROR, "variable \"%s\" is not a pointer", name);
if (p->type->u.element->type != ECPGt_struct && p->type->u.element->type != ECPGt_union) if (p->type->u.element->type != ECPGt_struct && p->type->u.element->type != ECPGt_union)
mmerror(PARSE_ERROR, ET_FATAL, "variable \"%s\" is not a pointer to a structure or a union", name); mmfatal(PARSE_ERROR, "variable \"%s\" is not a pointer to a structure or a union", name);
/* restore the name, we will need it later */ /* restore the name, we will need it later */
*next = c; *next = c;
...@@ -151,7 +151,7 @@ find_struct(char *name, char *next, char *end) ...@@ -151,7 +151,7 @@ find_struct(char *name, char *next, char *end)
if (next == end) if (next == end)
{ {
if (p->type->type != ECPGt_struct && p->type->type != ECPGt_union) if (p->type->type != ECPGt_struct && p->type->type != ECPGt_union)
mmerror(PARSE_ERROR, ET_FATAL, "variable \"%s\" is neither a structure nor a union", name); mmfatal(PARSE_ERROR, "variable \"%s\" is neither a structure nor a union", name);
/* restore the name, we will need it later */ /* restore the name, we will need it later */
*next = c; *next = c;
...@@ -161,10 +161,10 @@ find_struct(char *name, char *next, char *end) ...@@ -161,10 +161,10 @@ find_struct(char *name, char *next, char *end)
else else
{ {
if (p->type->type != ECPGt_array) if (p->type->type != ECPGt_array)
mmerror(PARSE_ERROR, ET_FATAL, "variable \"%s\" is not an array", name); mmfatal(PARSE_ERROR, "variable \"%s\" is not an array", name);
if (p->type->u.element->type != ECPGt_struct && p->type->u.element->type != ECPGt_union) if (p->type->u.element->type != ECPGt_struct && p->type->u.element->type != ECPGt_union)
mmerror(PARSE_ERROR, ET_FATAL, "variable \"%s\" is not a pointer to a structure or a union", name); mmfatal(PARSE_ERROR, "variable \"%s\" is not a pointer to a structure or a union", name);
/* restore the name, we will need it later */ /* restore the name, we will need it later */
*next = c; *next = c;
...@@ -230,7 +230,7 @@ find_variable(char *name) ...@@ -230,7 +230,7 @@ find_variable(char *name)
*next = '\0'; *next = '\0';
p = find_simple(name); p = find_simple(name);
if (p == NULL) if (p == NULL)
mmerror(PARSE_ERROR, ET_FATAL, "variable \"%s\" is not declared", name); mmfatal(PARSE_ERROR, "variable \"%s\" is not declared", name);
*next = c; *next = c;
switch (p->type->u.element->type) switch (p->type->u.element->type)
...@@ -252,7 +252,7 @@ find_variable(char *name) ...@@ -252,7 +252,7 @@ find_variable(char *name)
p = find_simple(name); p = find_simple(name);
if (p == NULL) if (p == NULL)
mmerror(PARSE_ERROR, ET_FATAL, "variable \"%s\" is not declared", name); mmfatal(PARSE_ERROR, "variable \"%s\" is not declared", name);
return (p); return (p);
} }
...@@ -497,7 +497,7 @@ get_typedef(char *name) ...@@ -497,7 +497,7 @@ get_typedef(char *name)
for (this = types; this && strcmp(this->name, name) != 0; this = this->next); for (this = types; this && strcmp(this->name, name) != 0; this = this->next);
if (!this) if (!this)
mmerror(PARSE_ERROR, ET_FATAL, "unrecognized data type name \"%s\"", name); mmfatal(PARSE_ERROR, "unrecognized data type name \"%s\"", name);
return (this); return (this);
} }
...@@ -508,7 +508,7 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty ...@@ -508,7 +508,7 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
if (atoi(type_index) >= 0) if (atoi(type_index) >= 0)
{ {
if (atoi(*length) >= 0) if (atoi(*length) >= 0)
mmerror(PARSE_ERROR, ET_FATAL, "multidimensional arrays are not supported"); mmfatal(PARSE_ERROR, "multidimensional arrays are not supported");
*length = type_index; *length = type_index;
} }
...@@ -516,7 +516,7 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty ...@@ -516,7 +516,7 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
if (atoi(type_dimension) >= 0) if (atoi(type_dimension) >= 0)
{ {
if (atoi(*dimension) >= 0 && atoi(*length) >= 0) if (atoi(*dimension) >= 0 && atoi(*length) >= 0)
mmerror(PARSE_ERROR, ET_FATAL, "multidimensional arrays are not supported"); mmfatal(PARSE_ERROR, "multidimensional arrays are not supported");
if (atoi(*dimension) >= 0) if (atoi(*dimension) >= 0)
*length = *dimension; *length = *dimension;
...@@ -525,18 +525,18 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty ...@@ -525,18 +525,18 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
} }
if (pointer_len > 2) if (pointer_len > 2)
mmerror(PARSE_ERROR, ET_FATAL, ngettext("multilevel pointers (more than 2 levels) are not supported; found %d level", mmfatal(PARSE_ERROR, ngettext("multilevel pointers (more than 2 levels) are not supported; found %d level",
"multilevel pointers (more than 2 levels) are not supported; found %d levels", pointer_len), "multilevel pointers (more than 2 levels) are not supported; found %d levels", pointer_len),
pointer_len); pointer_len);
if (pointer_len > 1 && type_enum != ECPGt_char && type_enum != ECPGt_unsigned_char && type_enum != ECPGt_string) if (pointer_len > 1 && type_enum != ECPGt_char && type_enum != ECPGt_unsigned_char && type_enum != ECPGt_string)
mmerror(PARSE_ERROR, ET_FATAL, "pointer to pointer is not supported for this data type"); mmfatal(PARSE_ERROR, "pointer to pointer is not supported for this data type");
if (pointer_len > 1 && (atoi(*length) >= 0 || atoi(*dimension) >= 0)) if (pointer_len > 1 && (atoi(*length) >= 0 || atoi(*dimension) >= 0))
mmerror(PARSE_ERROR, ET_FATAL, "multidimensional arrays are not supported"); mmfatal(PARSE_ERROR, "multidimensional arrays are not supported");
if (atoi(*length) >= 0 && atoi(*dimension) >= 0 && pointer_len) if (atoi(*length) >= 0 && atoi(*dimension) >= 0 && pointer_len)
mmerror(PARSE_ERROR, ET_FATAL, "multidimensional arrays are not supported"); mmfatal(PARSE_ERROR, "multidimensional arrays are not supported");
switch (type_enum) switch (type_enum)
{ {
...@@ -550,7 +550,7 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty ...@@ -550,7 +550,7 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
} }
if (atoi(*length) >= 0) if (atoi(*length) >= 0)
mmerror(PARSE_ERROR, ET_FATAL, "multidimensional arrays for structures are not supported"); mmfatal(PARSE_ERROR, "multidimensional arrays for structures are not supported");
break; break;
case ECPGt_varchar: case ECPGt_varchar:
...@@ -611,7 +611,7 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty ...@@ -611,7 +611,7 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
} }
if (atoi(*length) >= 0) if (atoi(*length) >= 0)
mmerror(PARSE_ERROR, ET_FATAL, "multidimensional arrays for simple data types are not supported"); mmfatal(PARSE_ERROR, "multidimensional arrays for simple data types are not supported");
break; break;
} }
......
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