Clean up indentation and whitespace inconsistencies in ecpg.

ecpg's lexer and parser files aren't normally processed by
pgindent, and unsurprisingly there's a lot of code in there
that doesn't really match project style.  I spent some time
running pgindent over the fragments of these files that are
C code, and this is the result.  This is in the same spirit
as commit 30ed71e42, though apparently Peter used a different
method for that one, since it didn't find these problems.

Discussion: https://postgr.es/m/2011420.1713493114@sss.pgh.pa.us
This commit is contained in:
Tom Lane 2024-08-15 11:41:46 -04:00
parent 516b87502d
commit 97add39c03
4 changed files with 2602 additions and 2005 deletions

View File

@ -22,7 +22,9 @@ ECPG: stmtDeallocateStmt block
output_deallocate_prepare_statement($1);
}
ECPG: stmtDeclareCursorStmt block
{ output_simple_statement($1, (strncmp($1, "ECPGset_var", strlen("ECPGset_var")) == 0) ? 4 : 0); }
{
output_simple_statement($1, (strncmp($1, "ECPGset_var", strlen("ECPGset_var")) == 0) ? 4 : 0);
}
ECPG: stmtDiscardStmt block
ECPG: stmtFetchStmt block
{ output_statement($1, 1, ECPGst_normal); }
@ -47,7 +49,10 @@ ECPG: stmtExecuteStmt block
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
char *str = mm_strdup($1.name + 1);
/* It must be cut off double quotation because new_variable() double-quotes. */
/*
* It must be cut off double quotation because new_variable()
* double-quotes.
*/
str[strlen(str) - 1] = '\0';
sprintf(length, "%zu", strlen(str));
add_variable_to_tail(&argsinsert, new_variable(str, ECPGmake_simple_type(ECPGt_const, length, 0), 0), &no_indicator);
@ -63,6 +68,7 @@ ECPG: stmtPrepareStmt block
else if (strlen($1.type) == 0)
{
char *stmt = cat_str(3, mm_strdup("\""), $1.stmt, mm_strdup("\""));
output_prepare_statement($1.name, stmt);
}
else
@ -75,7 +81,10 @@ ECPG: stmtPrepareStmt block
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
char *str = mm_strdup($1.name + 1);
/* It must be cut off double quotation because new_variable() double-quotes. */
/*
* It must be cut off double quotation because new_variable()
* double-quotes.
*/
str[strlen(str) - 1] = '\0';
sprintf(length, "%zu", strlen(str));
add_variable_to_tail(&argsinsert, new_variable(str, ECPGmake_simple_type(ECPGt_const, length, 0), 0), &no_indicator);
@ -152,7 +161,10 @@ ECPG: stmtViewStmt rule
whenever_action(2);
free($1);
}
| ECPGExecuteImmediateStmt { output_statement($1, 0, ECPGst_exec_immediate); }
| ECPGExecuteImmediateStmt
{
output_statement($1, 0, ECPGst_exec_immediate);
}
| ECPGFree
{
const char *con = connection ? connection : "NULL";
@ -245,6 +257,7 @@ ECPG: stmtViewStmt rule
ECPG: where_or_current_clauseWHERECURRENT_POFcursor_name block
{
char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
$$ = cat_str(2, mm_strdup("where current of"), cursor_marker);
}
ECPG: CopyStmtCOPYopt_binaryqualified_nameopt_column_listcopy_fromopt_programcopy_file_namecopy_delimiteropt_withcopy_optionswhere_clause addon
@ -259,9 +272,9 @@ ECPG: var_valueNumericOnly addon
}
ECPG: fetch_argscursor_name addon
struct cursor *ptr = add_additional_variables($1, false);
if (ptr->connection)
connection = mm_strdup(ptr->connection);
if ($1[0] == ':')
{
free($1);
@ -269,9 +282,9 @@ ECPG: fetch_argscursor_name addon
}
ECPG: fetch_argsfrom_incursor_name addon
struct cursor *ptr = add_additional_variables($2, false);
if (ptr->connection)
connection = mm_strdup(ptr->connection);
if ($2[0] == ':')
{
free($2);
@ -283,9 +296,9 @@ ECPG: fetch_argsFIRST_Popt_from_incursor_name addon
ECPG: fetch_argsLAST_Popt_from_incursor_name addon
ECPG: fetch_argsALLopt_from_incursor_name addon
struct cursor *ptr = add_additional_variables($3, false);
if (ptr->connection)
connection = mm_strdup(ptr->connection);
if ($3[0] == ':')
{
free($3);
@ -293,9 +306,9 @@ ECPG: fetch_argsALLopt_from_incursor_name addon
}
ECPG: fetch_argsSignedIconstopt_from_incursor_name addon
struct cursor *ptr = add_additional_variables($3, false);
if (ptr->connection)
connection = mm_strdup(ptr->connection);
if ($3[0] == ':')
{
free($3);
@ -309,9 +322,9 @@ ECPG: fetch_argsSignedIconstopt_from_incursor_name addon
ECPG: fetch_argsFORWARDALLopt_from_incursor_name addon
ECPG: fetch_argsBACKWARDALLopt_from_incursor_name addon
struct cursor *ptr = add_additional_variables($4, false);
if (ptr->connection)
connection = mm_strdup(ptr->connection);
if ($4[0] == ':')
{
free($4);
@ -322,9 +335,9 @@ ECPG: fetch_argsRELATIVE_PSignedIconstopt_from_incursor_name addon
ECPG: fetch_argsFORWARDSignedIconstopt_from_incursor_name addon
ECPG: fetch_argsBACKWARDSignedIconstopt_from_incursor_name addon
struct cursor *ptr = add_additional_variables($4, false);
if (ptr->connection)
connection = mm_strdup(ptr->connection);
if ($4[0] == ':')
{
free($4);
@ -339,6 +352,7 @@ ECPG: cursor_namename rule
| char_civar
{
char *curname = mm_alloc(strlen($1) + 2);
sprintf(curname, ":%s", $1);
free($1);
$1 = curname;
@ -375,9 +389,12 @@ ECPG: ExecuteStmtCREATEOptTempTABLEIF_PNOTEXISTScreate_as_targetASEXECUTEprepare
}
ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectStmt block
{
struct cursor *ptr, *this;
struct cursor *ptr,
*this;
char *cursor_marker = $2[0] == ':' ? mm_strdup("$0") : mm_strdup($2);
char *comment, *c1, *c2;
char *comment,
*c1,
*c2;
int (*strcmp_fn) (const char *, const char *) = (($2[0] == ':' || $2[0] == '"') ? strcmp : pg_strcasecmp);
if (INFORMIX_MODE && pg_strcasecmp($2, "database") == 0)
@ -424,13 +441,13 @@ ECPG: ClosePortalStmtCLOSEcursor_name block
{
char *cursor_marker = $2[0] == ':' ? mm_strdup("$0") : $2;
struct cursor *ptr = NULL;
for (ptr = cur; ptr != NULL; ptr = ptr->next)
{
if (strcmp($2, ptr->name) == 0)
{
if (ptr->connection)
connection = mm_strdup(ptr->connection);
break;
}
}
@ -448,11 +465,18 @@ ECPG: into_clauseINTOOptTempTableName block
FoundInto = 1;
$$ = cat2_str(mm_strdup("into"), $2);
}
| ecpg_into { $$ = EMPTY; }
| ecpg_into
{
$$ = EMPTY;
}
ECPG: TypenameSimpleTypenameopt_array_bounds block
{ $$ = cat2_str($1, $2.str); }
{
$$ = cat2_str($1, $2.str);
}
ECPG: TypenameSETOFSimpleTypenameopt_array_bounds block
{ $$ = cat_str(3, mm_strdup("setof"), $2, $3.str); }
{
$$ = cat_str(3, mm_strdup("setof"), $2, $3.str);
}
ECPG: opt_array_boundsopt_array_bounds'['']' block
{
$$.index1 = $1.index1;
@ -480,7 +504,9 @@ ECPG: opt_array_bounds
$$.str = EMPTY;
}
ECPG: IconstICONST block
{ $$ = make_name(); }
{
$$ = make_name();
}
ECPG: AexprConstNULL_P rule
| civar { $$ = $1; }
| civarind { $$ = $1; }
@ -507,6 +533,7 @@ ECPG: FetchStmtMOVEfetch_args rule
{
char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
struct cursor *ptr = add_additional_variables($3, false);
if (ptr->connection)
connection = mm_strdup(ptr->connection);
@ -516,6 +543,7 @@ ECPG: FetchStmtMOVEfetch_args rule
{
char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
struct cursor *ptr = add_additional_variables($4, false);
if (ptr->connection)
connection = mm_strdup(ptr->connection);
@ -525,6 +553,7 @@ ECPG: FetchStmtMOVEfetch_args rule
{
char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
struct cursor *ptr = add_additional_variables($3, false);
if (ptr->connection)
connection = mm_strdup(ptr->connection);
@ -534,6 +563,7 @@ ECPG: FetchStmtMOVEfetch_args rule
{
char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
struct cursor *ptr = add_additional_variables($4, false);
if (ptr->connection)
connection = mm_strdup(ptr->connection);
@ -543,6 +573,7 @@ ECPG: FetchStmtMOVEfetch_args rule
{
char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
struct cursor *ptr = add_additional_variables($3, false);
if (ptr->connection)
connection = mm_strdup(ptr->connection);
@ -552,6 +583,7 @@ ECPG: FetchStmtMOVEfetch_args rule
{
char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
struct cursor *ptr = add_additional_variables($4, false);
if (ptr->connection)
connection = mm_strdup(ptr->connection);
@ -561,6 +593,7 @@ ECPG: FetchStmtMOVEfetch_args rule
{
char *cursor_marker = $3[0] == ':' ? mm_strdup("$0") : $3;
struct cursor *ptr = add_additional_variables($3, false);
if (ptr->connection)
connection = mm_strdup(ptr->connection);
@ -570,6 +603,7 @@ ECPG: FetchStmtMOVEfetch_args rule
{
char *cursor_marker = $4[0] == ':' ? mm_strdup("$0") : $4;
struct cursor *ptr = add_additional_variables($4, false);
if (ptr->connection)
connection = mm_strdup(ptr->connection);
@ -581,4 +615,7 @@ ECPG: limit_clauseLIMITselect_limit_value','select_offset_value block
$$ = cat_str(4, mm_strdup("limit"), $2, mm_strdup(","), $4);
}
ECPG: SignedIconstIconst rule
| civar { $$ = $1; }
| civar
{
$$ = $1;
}

View File

@ -47,7 +47,8 @@ char *input_filename = NULL;
static int FoundInto = 0;
static int initializer = 0;
static int pacounter = 1;
static char pacounter_buffer[sizeof(int) * CHAR_BIT * 10 / 3]; /* a rough guess at the size we need */
static char pacounter_buffer[sizeof(int) * CHAR_BIT * 10 / 3]; /* a rough guess at the
* size we need */
static struct this_type actual_type[STRUCT_DEPTH];
static char *actual_startline[STRUCT_DEPTH];
static int varchar_counter = 1;
@ -213,10 +214,15 @@ create_questionmarks(char *name, bool array)
int count;
char *result = EMPTY;
/* In case we have a struct, we have to print as many "?" as there are attributes in the struct
/*
* In case we have a struct, we have to print as many "?" as there are
* attributes in the struct
*
* An array is only allowed together with an element argument
* This is essentially only used for inserts, but using a struct as input parameter is an error anywhere else
* so we don't have to worry here. */
*
* This is essentially only used for inserts, but using a struct as input
* parameter is an error anywhere else so we don't have to worry here.
*/
if (p->type->type == ECPGt_struct || (array && p->type->type == ECPGt_array && p->type->u.element->type == ECPGt_struct))
{
@ -247,15 +253,17 @@ create_questionmarks(char *name, bool array)
static char *
adjust_outofscope_cursor_vars(struct cursor *cur)
{
/* Informix accepts DECLARE with variables that are out of scope when OPEN is called.
* For instance you can DECLARE a cursor in one function, and OPEN/FETCH/CLOSE
* it in another functions. This is very useful for e.g. event-driver programming,
* but may also lead to dangerous programming. The limitation when this is allowed
* and doesn't cause problems have to be documented, like the allocated variables
* must not be realloc()'ed.
/*
* Informix accepts DECLARE with variables that are out of scope when OPEN
* is called. For instance you can DECLARE a cursor in one function, and
* OPEN/FETCH/CLOSE it in another functions. This is very useful for e.g.
* event-driver programming, but may also lead to dangerous programming.
* The limitation when this is allowed and doesn't cause problems have to
* be documented, like the allocated variables must not be realloc()'ed.
*
* We have to change the variables to our own struct and just store the pointer
* instead of the variable. Do it only for local variables, not for globals.
* We have to change the variables to our own struct and just store the
* pointer instead of the variable. Do it only for local variables, not
* for globals.
*/
char *result = EMPTY;
@ -266,7 +274,8 @@ adjust_outofscope_cursor_vars(struct cursor *cur)
struct arguments *list;
struct arguments *ptr;
struct arguments *newlist = NULL;
struct variable *newvar, *newind;
struct variable *newvar,
*newind;
list = (insert ? cur->argsinsert : cur->argsresult);
@ -387,7 +396,10 @@ adjust_outofscope_cursor_vars(struct cursor *cur)
var_ptr = true;
}
/* create call to "ECPGset_var(<counter>, <connection>, <pointer>. <line number>)" */
/*
* create call to "ECPGset_var(<counter>, <connection>, <pointer>.
* <line number>)"
*/
if (!skip_set_var)
{
sprintf(var_text, "%d, %s", ecpg_internal_var++, var_ptr ? "&(" : "(");
@ -396,7 +408,10 @@ adjust_outofscope_cursor_vars(struct cursor *cur)
mm_strdup("), __LINE__);\n"));
}
/* now the indicator if there is one and it's not a global variable */
/*
* now the indicator if there is one and it's not a global
* variable
*/
if ((ptr->indicator->type->type == ECPGt_NO_INDICATOR) || (ptr->indicator->brace_level == 0))
{
newind = ptr->indicator;
@ -476,7 +491,10 @@ adjust_outofscope_cursor_vars(struct cursor *cur)
var_ptr = true;
}
/* create call to "ECPGset_var(<counter>, <pointer>. <line number>)" */
/*
* create call to "ECPGset_var(<counter>, <pointer>. <line
* number>)"
*/
sprintf(var_text, "%d, %s", ecpg_internal_var++, var_ptr ? "&(" : "(");
result = cat_str(5, result, mm_strdup("ECPGset_var("),
mm_strdup(var_text), mm_strdup(original_var),
@ -521,8 +539,12 @@ add_additional_variables(char *name, bool insert)
if (insert)
{
/* add all those input variables that were given earlier
* note that we have to append here but have to keep the existing order */
/*
* add all those input variables that were given earlier
*
* note that we have to append here but have to keep the existing
* order
*/
for (p = (SAMEFUNC(ptr) ? ptr->argsinsert : ptr->argsinsert_oos); p; p = p->next)
add_variable_to_tail(&argsinsert, p->variable, p->indicator);
}
@ -539,7 +561,8 @@ add_typedef(char *name, char *dimension, char *length, enum ECPGttype type_enum,
char *type_dimension, char *type_index, int initializer, int array)
{
/* add entry to list */
struct typedefs *ptr, *this;
struct typedefs *ptr,
*this;
if ((type_enum == ECPGt_struct ||
type_enum == ECPGt_union) &&
@ -593,6 +616,7 @@ static bool
check_declared_list(const char *name)
{
struct declared_list *ptr = NULL;
for (ptr = g_declared_list; ptr != NULL; ptr = ptr->next)
{
if (!ptr->connection)

File diff suppressed because it is too large Load Diff

View File

@ -541,7 +541,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
<xb>{xbinside} {
addlit(yytext, yyleng);
}
<xb><<EOF>> { mmfatal(PARSE_ERROR, "unterminated bit string literal"); }
<xb><<EOF>> {
mmfatal(PARSE_ERROR, "unterminated bit string literal");
}
<SQL>{xhstart} {
token_start = yytext;
@ -549,7 +551,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
BEGIN(xh);
startlit();
}
<xh><<EOF>> { mmfatal(PARSE_ERROR, "unterminated hexadecimal string literal"); }
<xh><<EOF>> {
mmfatal(PARSE_ERROR, "unterminated hexadecimal string literal");
}
<C>{xqstart} {
token_start = yytext;
@ -560,9 +564,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
<SQL>{
{xnstart} {
/* National character.
* Transfer it as-is to the backend.
*/
/* National character. Transfer it as-is to the backend. */
token_start = yytext;
state_before_str_start = YYSTATE;
BEGIN(xn);
@ -651,9 +653,15 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
}
}
<xq,xe,xn,xus>{xqdouble} { addlit(yytext, yyleng); }
<xqc>{xqcquote} { addlit(yytext, yyleng); }
<xq,xqc,xn,xus>{xqinside} { addlit(yytext, yyleng); }
<xq,xe,xn,xus>{xqdouble} {
addlit(yytext, yyleng);
}
<xqc>{xqcquote} {
addlit(yytext, yyleng);
}
<xq,xqc,xn,xus>{xqinside} {
addlit(yytext, yyleng);
}
<xe>{xeinside} {
addlit(yytext, yyleng);
}
@ -673,7 +681,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
/* This is only needed for \ just before EOF */
addlitchar(yytext[0]);
}
<xq,xqc,xe,xn,xus><<EOF>> { mmfatal(PARSE_ERROR, "unterminated quoted string"); }
<xq,xqc,xe,xn,xus><<EOF>> {
mmfatal(PARSE_ERROR, "unterminated quoted string");
}
<SQL>{
{dolqdelim} {
@ -724,7 +734,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
/* single quote or dollar sign */
addlitchar(yytext[0]);
}
<xdolq><<EOF>> { mmfatal(PARSE_ERROR, "unterminated dollar-quoted string"); }
<xdolq><<EOF>> {
mmfatal(PARSE_ERROR, "unterminated dollar-quoted string");
}
<SQL>{
{xdstart} {
@ -743,6 +755,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
BEGIN(state_before_str_start);
if (literallen == 0)
mmerror(PARSE_ERROR, ET_ERROR, "zero-length delimited identifier");
/*
* The server will truncate the identifier here. We do
* not, as (1) it does not change the result; (2) we don't
@ -763,7 +776,11 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
BEGIN(state_before_str_start);
if (literallen == 0)
mmerror(PARSE_ERROR, ET_ERROR, "zero-length delimited identifier");
/* The backend will truncate the identifier here. We do not as it does not change the result. */
/*
* The backend will truncate the identifier here. We do
* not as it does not change the result.
*/
base_yylval.str = psprintf("U&\"%s\"", literalbuf);
return UIDENT;
}
@ -773,7 +790,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
<xd,xui>{xdinside} {
addlit(yytext, yyleng);
}
<xd,xui><<EOF>> { mmfatal(PARSE_ERROR, "unterminated quoted identifier"); }
<xd,xui><<EOF>> {
mmfatal(PARSE_ERROR, "unterminated quoted identifier");
}
<C>{xdstart} {
state_before_str_start = YYSTATE;
BEGIN(xdc);
@ -782,7 +801,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
<xdc>{xdcinside} {
addlit(yytext, yyleng);
}
<xdc><<EOF>> { mmfatal(PARSE_ERROR, "unterminated quoted string"); }
<xdc><<EOF>> {
mmfatal(PARSE_ERROR, "unterminated quoted string");
}
<SQL>{
{typecast} {
@ -831,9 +852,8 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
{self} {
/*
* We may find a ';' inside a structure
* definition in a TYPE or VAR statement.
* This is not an EOL marker.
* We may find a ';' inside a structure definition in a
* TYPE or VAR statement. This is not an EOL marker.
*/
if (yytext[0] == ';' && struct_level == 0)
BEGIN(C);
@ -879,6 +899,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
for (ic = nchars - 2; ic >= 0; ic--)
{
char c = yytext[ic];
if (c == '~' || c == '!' || c == '@' ||
c == '#' || c == '^' || c == '&' ||
c == '|' || c == '`' || c == '?' ||
@ -891,7 +912,8 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
* didn't find a qualifying character, so remove
* all trailing [+-]
*/
do {
do
{
nchars--;
} while (nchars > 1 &&
(yytext[nchars - 1] == '+' ||
@ -903,6 +925,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
{
/* Strip the unwanted chars from the token */
yyless(nchars);
/*
* If what we have left is only one char, and it's
* one of the characters matching "self", then
@ -912,6 +935,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
if (nchars == 1 &&
strchr(",()[].;:+-*/%^<>=", yytext[0]))
return yytext[0];
/*
* Likewise, if what we have left is two chars, and
* those match the tokens ">=", "<=", "=>", "<>" or
@ -1053,8 +1077,8 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
*
* The backend will attempt to truncate and case-fold
* the identifier, but I see no good reason for ecpg
* to do so; that's just another way that ecpg could get
* out of step with the backend.
* to do so; that's just another way that ecpg could
* get out of step with the backend.
*/
base_yylval.str = mm_strdup(yytext);
return IDENT;
@ -1070,7 +1094,10 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
* Begin ECPG-specific rules
*/
<C>{exec_sql} { BEGIN(SQL); return SQL_START; }
<C>{exec_sql} {
BEGIN(SQL);
return SQL_START;
}
<C>{informix_special} {
/* are we simulating Informix? */
if (INFORMIX_MODE)
@ -1081,7 +1108,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
else
return S_ANYTHING;
}
<C>{ccomment} { ECHO; }
<C>{ccomment} {
ECHO;
}
<C>{cppinclude} {
if (system_includes)
{
@ -1138,7 +1167,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
}
}
}
<C>{xcstop} { mmerror(PARSE_ERROR, ET_ERROR, "nested /* ... */ comments"); }
<C>{xcstop} {
mmerror(PARSE_ERROR, ET_ERROR, "nested /* ... */ comments");
}
<C>":" { return ':'; }
<C>";" { return ';'; }
<C>"," { return ','; }
@ -1185,7 +1216,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
return S_ANYTHING;
}
}
<C>{exec_sql}{undef}{space}* { BEGIN(undef); }
<C>{exec_sql}{undef}{space}* {
BEGIN(undef);
}
<C>{informix_special}{undef}{space}* {
/* are we simulating Informix? */
if (INFORMIX_MODE)
@ -1199,7 +1232,8 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
}
}
<undef>{identifier}{space}*";" {
struct _defines *ptr, *ptr2 = NULL;
struct _defines *ptr,
*ptr2 = NULL;
int i;
/*
@ -1212,7 +1246,6 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
;
yytext[i + 1] = '\0';
/* Find and unset any matching define; should be only 1 */
for (ptr = defines; ptr; ptr2 = ptr, ptr = ptr->next)
{
@ -1240,7 +1273,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
mmfatal(PARSE_ERROR, "missing identifier in EXEC SQL UNDEF command");
yyterminate();
}
<C>{exec_sql}{include}{space}* { BEGIN(incl); }
<C>{exec_sql}{include}{space}* {
BEGIN(incl);
}
<C>{informix_special}{include}{space}* {
/* are we simulating Informix? */
if (INFORMIX_MODE)
@ -1337,7 +1372,8 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
}
}
<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 (preproc_tos == 0)
mmfatal(PARSE_ERROR, "missing matching \"EXEC SQL IFDEF\" / \"EXEC SQL IFNDEF\"");
else if (stacked_if_value[preproc_tos].else_branch)
@ -1425,13 +1461,14 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
bool this_active;
/*
* Skip the ";" and trailing whitespace. Note that yytext
* contains at least one non-space character plus the ";"
* Skip the ";" and trailing whitespace. Note that
* yytext contains at least one non-space character
* plus the ";"
*/
for (i = strlen(yytext) - 2;
i > 0 && ecpg_isspace(yytext[i]);
i--)
;
/* skip */ ;
yytext[i + 1] = '\0';
/* Does a definition exist? */
@ -1559,11 +1596,12 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
if (i != 0)
output_line_number();
}
}
<INITIAL>{other}|\n { mmfatal(PARSE_ERROR, "internal error: unreachable state; please report this to <%s>", PACKAGE_BUGREPORT); }
<INITIAL>{other}|\n {
mmfatal(PARSE_ERROR, "internal error: unreachable state; please report this to <%s>", PACKAGE_BUGREPORT);
}
%%
@ -1668,8 +1706,8 @@ parse_include(void)
yy_buffer = yb;
/*
* skip the ";" if there is one and trailing whitespace. Note that
* yytext contains at least one non-space character plus the ";"
* skip the ";" if there is one and trailing whitespace. Note that yytext
* contains at least one non-space character plus the ";"
*/
for (i = strlen(yytext) - 2;
i > 0 && ecpg_isspace(yytext[i]);
@ -1684,7 +1722,11 @@ parse_include(void)
yyin = NULL;
/* If file name is enclosed in '"' remove these and look only in '.' */
/* Informix does look into all include paths though, except filename starts with '/' */
/*
* Informix does look into all include paths though, except filename
* starts with '/'
*/
if (yytext[0] == '"' && yytext[i] == '"' &&
((compat != ECPG_COMPAT_INFORMIX && compat != ECPG_COMPAT_INFORMIX_SE) || yytext[1] == '/'))
{
@ -1728,7 +1770,11 @@ parse_include(void)
yyin = fopen(inc_file, "r");
}
}
/* if the command was "include_next" we have to disregard the first hit */
/*
* if the command was "include_next" we have to disregard the
* first hit
*/
if (yyin && include_next)
{
fclose(yyin);