@ -541,7 +541,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
<xb>{xbinside} {
<xb>{xbinside} {
addlit(yytext, yyleng);
addlit(yytext, yyleng);
}
}
<xb><<EOF>> { mmfatal(PARSE_ERROR, "unterminated bit string literal"); }
<xb><<EOF>> {
mmfatal(PARSE_ERROR, "unterminated bit string literal");
}
<SQL>{xhstart} {
<SQL>{xhstart} {
token_start = yytext;
token_start = yytext;
@ -549,7 +551,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
BEGIN(xh);
BEGIN(xh);
startlit();
startlit();
}
}
<xh><<EOF>> { mmfatal(PARSE_ERROR, "unterminated hexadecimal string literal"); }
<xh><<EOF>> {
mmfatal(PARSE_ERROR, "unterminated hexadecimal string literal");
}
<C>{xqstart} {
<C>{xqstart} {
token_start = yytext;
token_start = yytext;
@ -560,9 +564,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
<SQL>{
<SQL>{
{xnstart} {
{xnstart} {
/* National character.
/* National character. Transfer it as-is to the backend. */
* Transfer it as-is to the backend.
*/
token_start = yytext;
token_start = yytext;
state_before_str_start = YYSTATE;
state_before_str_start = YYSTATE;
BEGIN(xn);
BEGIN(xn);
@ -651,9 +653,15 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
}
}
}
}
<xq,xe,xn,xus>{xqdouble} { addlit(yytext, yyleng); }
<xq,xe,xn,xus>{xqdouble} {
<xqc>{xqcquote} { addlit(yytext, yyleng); }
addlit(yytext, yyleng);
<xq,xqc,xn,xus>{xqinside} { addlit(yytext, yyleng); }
}
<xqc>{xqcquote} {
addlit(yytext, yyleng);
}
<xq,xqc,xn,xus>{xqinside} {
addlit(yytext, yyleng);
}
<xe>{xeinside} {
<xe>{xeinside} {
addlit(yytext, yyleng);
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 */
/* This is only needed for \ just before EOF */
addlitchar(yytext[0]);
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>{
<SQL>{
{dolqdelim} {
{dolqdelim} {
@ -724,7 +734,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
/* single quote or dollar sign */
/* single quote or dollar sign */
addlitchar(yytext[0]);
addlitchar(yytext[0]);
}
}
<xdolq><<EOF>> { mmfatal(PARSE_ERROR, "unterminated dollar-quoted string"); }
<xdolq><<EOF>> {
mmfatal(PARSE_ERROR, "unterminated dollar-quoted string");
}
<SQL>{
<SQL>{
{xdstart} {
{xdstart} {
@ -743,6 +755,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
BEGIN(state_before_str_start);
BEGIN(state_before_str_start);
if (literallen == 0)
if (literallen == 0)
mmerror(PARSE_ERROR, ET_ERROR, "zero-length delimited identifier");
mmerror(PARSE_ERROR, ET_ERROR, "zero-length delimited identifier");
/*
/*
* The server will truncate the identifier here. We do
* The server will truncate the identifier here. We do
* not, as (1) it does not change the result; (2) we don't
* 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);
BEGIN(state_before_str_start);
if (literallen == 0)
if (literallen == 0)
mmerror(PARSE_ERROR, ET_ERROR, "zero-length delimited identifier");
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);
base_yylval.str = psprintf("U&\"%s\"", literalbuf);
return UIDENT;
return UIDENT;
}
}
@ -773,7 +790,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
<xd,xui>{xdinside} {
<xd,xui>{xdinside} {
addlit(yytext, yyleng);
addlit(yytext, yyleng);
}
}
<xd,xui><<EOF>> { mmfatal(PARSE_ERROR, "unterminated quoted identifier"); }
<xd,xui><<EOF>> {
mmfatal(PARSE_ERROR, "unterminated quoted identifier");
}
<C>{xdstart} {
<C>{xdstart} {
state_before_str_start = YYSTATE;
state_before_str_start = YYSTATE;
BEGIN(xdc);
BEGIN(xdc);
@ -782,7 +801,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
<xdc>{xdcinside} {
<xdc>{xdcinside} {
addlit(yytext, yyleng);
addlit(yytext, yyleng);
}
}
<xdc><<EOF>> { mmfatal(PARSE_ERROR, "unterminated quoted string"); }
<xdc><<EOF>> {
mmfatal(PARSE_ERROR, "unterminated quoted string");
}
<SQL>{
<SQL>{
{typecast} {
{typecast} {
@ -831,9 +852,8 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
{self} {
{self} {
/*
/*
* We may find a ';' inside a structure
* We may find a ';' inside a structure definition in a
* definition in a TYPE or VAR statement.
* TYPE or VAR statement. This is not an EOL marker.
* This is not an EOL marker.
*/
*/
if (yytext[0] == ';' && struct_level == 0)
if (yytext[0] == ';' && struct_level == 0)
BEGIN(C);
BEGIN(C);
@ -879,6 +899,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
for (ic = nchars - 2; ic >= 0; ic--)
for (ic = nchars - 2; ic >= 0; ic--)
{
{
char c = yytext[ic];
char c = yytext[ic];
if (c == '~' || c == '!' || c == '@' ||
if (c == '~' || c == '!' || c == '@' ||
c == '#' || c == '^' || c == '&' ||
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
* didn't find a qualifying character, so remove
* all trailing [+-]
* all trailing [+-]
*/
*/
do {
do
{
nchars--;
nchars--;
} while (nchars > 1 &&
} while (nchars > 1 &&
(yytext[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 */
/* Strip the unwanted chars from the token */
yyless(nchars);
yyless(nchars);
/*
/*
* If what we have left is only one char, and it's
* If what we have left is only one char, and it's
* one of the characters matching "self", then
* one of the characters matching "self", then
@ -912,6 +935,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
if (nchars == 1 &&
if (nchars == 1 &&
strchr(",()[].;:+-*/%^<>=", yytext[0]))
strchr(",()[].;:+-*/%^<>=", yytext[0]))
return yytext[0];
return yytext[0];
/*
/*
* Likewise, if what we have left is two chars, and
* Likewise, if what we have left is two chars, and
* those match the tokens ">=", "<=", "=>", "<>" or
* those match the tokens ">=", "<=", "=>", "<>" or
@ -1019,7 +1043,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
}
}
:{identifier}((("->"|\.){identifier})|(\[{array}\]))* {
:{identifier}((("->"|\.){identifier})|(\[{array}\]))* {
base_yylval.str = mm_strdup(yytext+1);
base_yylval.str = mm_strdup(yytext + 1);
return CVARIABLE;
return CVARIABLE;
}
}
@ -1053,8 +1077,8 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
*
*
* The backend will attempt to truncate and case-fold
* The backend will attempt to truncate and case-fold
* the identifier, but I see no good reason for ecpg
* the identifier, but I see no good reason for ecpg
* to do so; that's just another way that ecpg could get
* to do so; that's just another way that ecpg could
* out of step with the backend.
* get out of step with the backend.
*/
*/
base_yylval.str = mm_strdup(yytext);
base_yylval.str = mm_strdup(yytext);
return IDENT;
return IDENT;
@ -1070,7 +1094,10 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
* Begin ECPG-specific rules
* Begin ECPG-specific rules
*/
*/
<C>{exec_sql} { BEGIN(SQL); return SQL_START; }
<C>{exec_sql} {
BEGIN(SQL);
return SQL_START;
}
<C>{informix_special} {
<C>{informix_special} {
/* are we simulating Informix? */
/* are we simulating Informix? */
if (INFORMIX_MODE)
if (INFORMIX_MODE)
@ -1081,7 +1108,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
else
else
return S_ANYTHING;
return S_ANYTHING;
}
}
<C>{ccomment} { ECHO; }
<C>{ccomment} {
ECHO;
}
<C>{cppinclude} {
<C>{cppinclude} {
if (system_includes)
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 ';'; }
<C>";" { return ';'; }
<C>"," { return ','; }
<C>"," { return ','; }
@ -1185,7 +1216,9 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
return S_ANYTHING;
return S_ANYTHING;
}
}
}
}
<C>{exec_sql}{undef}{space}* { BEGIN(undef); }
<C>{exec_sql}{undef}{space}* {
BEGIN(undef);
}
<C>{informix_special}{undef}{space}* {
<C>{informix_special}{undef}{space}* {
/* are we simulating Informix? */
/* are we simulating Informix? */
if (INFORMIX_MODE)
if (INFORMIX_MODE)
@ -1199,19 +1232,19 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
}
}
}
}
<undef>{identifier}{space}*";" {
<undef>{identifier}{space}*";" {
struct _defines *ptr, *ptr2 = NULL;
struct _defines *ptr,
*ptr2 = NULL;
int i;
int i;
/*
/*
* Skip the ";" and trailing whitespace. Note that yytext
* Skip the ";" and trailing whitespace. Note that yytext
* contains at least one non-space character plus the ";"
* contains at least one non-space character plus the ";"
*/
*/
for (i = strlen(yytext)-2;
for (i = strlen(yytext) - 2;
i > 0 && ecpg_isspace(yytext[i]);
i > 0 && ecpg_isspace(yytext[i]);
i--)
i--)
;
;
yytext[i+1] = '\0';
yytext[i + 1] = '\0';
/* Find and unset any matching define; should be only 1 */
/* Find and unset any matching define; should be only 1 */
for (ptr = defines; ptr; ptr2 = ptr, ptr = ptr->next)
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");
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);
}
<C>{informix_special}{include}{space}* {
<C>{informix_special}{include}{space}* {
/* are we simulating Informix? */
/* are we simulating Informix? */
if (INFORMIX_MODE)
if (INFORMIX_MODE)
@ -1254,7 +1289,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
}
}
}
}
<C,xskip>{exec_sql}{ifdef}{space}* {
<C,xskip>{exec_sql}{ifdef}{space}* {
if (preproc_tos >= MAX_NESTED_IF-1)
if (preproc_tos >= MAX_NESTED_IF - 1)
mmfatal(PARSE_ERROR, "too many nested EXEC SQL IFDEF conditions");
mmfatal(PARSE_ERROR, "too many nested EXEC SQL IFDEF conditions");
preproc_tos++;
preproc_tos++;
stacked_if_value[preproc_tos].active = false;
stacked_if_value[preproc_tos].active = false;
@ -1267,7 +1302,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
/* are we simulating Informix? */
/* are we simulating Informix? */
if (INFORMIX_MODE)
if (INFORMIX_MODE)
{
{
if (preproc_tos >= MAX_NESTED_IF-1)
if (preproc_tos >= MAX_NESTED_IF - 1)
mmfatal(PARSE_ERROR, "too many nested EXEC SQL IFDEF conditions");
mmfatal(PARSE_ERROR, "too many nested EXEC SQL IFDEF conditions");
preproc_tos++;
preproc_tos++;
stacked_if_value[preproc_tos].active = false;
stacked_if_value[preproc_tos].active = false;
@ -1283,7 +1318,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
}
}
}
}
<C,xskip>{exec_sql}{ifndef}{space}* {
<C,xskip>{exec_sql}{ifndef}{space}* {
if (preproc_tos >= MAX_NESTED_IF-1)
if (preproc_tos >= MAX_NESTED_IF - 1)
mmfatal(PARSE_ERROR, "too many nested EXEC SQL IFDEF conditions");
mmfatal(PARSE_ERROR, "too many nested EXEC SQL IFDEF conditions");
preproc_tos++;
preproc_tos++;
stacked_if_value[preproc_tos].active = false;
stacked_if_value[preproc_tos].active = false;
@ -1296,7 +1331,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
/* are we simulating Informix? */
/* are we simulating Informix? */
if (INFORMIX_MODE)
if (INFORMIX_MODE)
{
{
if (preproc_tos >= MAX_NESTED_IF-1)
if (preproc_tos >= MAX_NESTED_IF - 1)
mmfatal(PARSE_ERROR, "too many nested EXEC SQL IFDEF conditions");
mmfatal(PARSE_ERROR, "too many nested EXEC SQL IFDEF conditions");
preproc_tos++;
preproc_tos++;
stacked_if_value[preproc_tos].active = false;
stacked_if_value[preproc_tos].active = false;
@ -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)
if (preproc_tos == 0)
mmfatal(PARSE_ERROR, "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)
@ -1346,7 +1382,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
{
{
stacked_if_value[preproc_tos].else_branch = true;
stacked_if_value[preproc_tos].else_branch = true;
stacked_if_value[preproc_tos].active =
stacked_if_value[preproc_tos].active =
(stacked_if_value[preproc_tos-1].active &&
(stacked_if_value[preproc_tos - 1].active &&
!stacked_if_value[preproc_tos].saw_active);
!stacked_if_value[preproc_tos].saw_active);
stacked_if_value[preproc_tos].saw_active = true;
stacked_if_value[preproc_tos].saw_active = true;
@ -1368,7 +1404,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
{
{
stacked_if_value[preproc_tos].else_branch = true;
stacked_if_value[preproc_tos].else_branch = true;
stacked_if_value[preproc_tos].active =
stacked_if_value[preproc_tos].active =
(stacked_if_value[preproc_tos-1].active &&
(stacked_if_value[preproc_tos - 1].active &&
!stacked_if_value[preproc_tos].saw_active);
!stacked_if_value[preproc_tos].saw_active);
stacked_if_value[preproc_tos].saw_active = true;
stacked_if_value[preproc_tos].saw_active = true;
@ -1425,14 +1461,15 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
bool this_active;
bool this_active;
/*
/*
* Skip the ";" and trailing whitespace. Note that yytext
* Skip the ";" and trailing whitespace. Note that
* contains at least one non-space character plus the ";"
* yytext contains at least one non-space character
* plus the ";"
*/
*/
for (i = strlen(yytext)-2;
for (i = strlen(yytext) - 2;
i > 0 && ecpg_isspace(yytext[i]);
i > 0 && ecpg_isspace(yytext[i]);
i--)
i--)
;
/* skip */ ;
yytext[i+1] = '\0';
yytext[i + 1] = '\0';
/* Does a definition exist? */
/* Does a definition exist? */
for (defptr = defines; defptr; defptr = defptr->next)
for (defptr = defines; defptr; defptr = defptr->next)
@ -1448,7 +1485,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
this_active = (defptr ? ifcond : !ifcond);
this_active = (defptr ? ifcond : !ifcond);
stacked_if_value[preproc_tos].active =
stacked_if_value[preproc_tos].active =
(stacked_if_value[preproc_tos-1].active &&
(stacked_if_value[preproc_tos - 1].active &&
!stacked_if_value[preproc_tos].saw_active &&
!stacked_if_value[preproc_tos].saw_active &&
this_active);
this_active);
stacked_if_value[preproc_tos].saw_active |= this_active;
stacked_if_value[preproc_tos].saw_active |= this_active;
@ -1559,11 +1596,12 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
if (i != 0)
if (i != 0)
output_line_number();
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);
}
%%
%%
@ -1599,15 +1637,15 @@ static void
addlit(char *ytext, int yleng)
addlit(char *ytext, int yleng)
{
{
/* enlarge buffer if needed */
/* enlarge buffer if needed */
if ((literallen+yleng) >= literalalloc)
if ((literallen + yleng) >= literalalloc)
{
{
do
do
literalalloc *= 2;
literalalloc *= 2;
while ((literallen+yleng) >= literalalloc);
while ((literallen + yleng) >= literalalloc);
literalbuf = (char *) realloc(literalbuf, literalalloc);
literalbuf = (char *) realloc(literalbuf, literalalloc);
}
}
/* append new data, add trailing null */
/* append new data, add trailing null */
memcpy(literalbuf+literallen, ytext, yleng);
memcpy(literalbuf + literallen, ytext, yleng);
literallen += yleng;
literallen += yleng;
literalbuf[literallen] = '\0';
literalbuf[literallen] = '\0';
}
}
@ -1616,7 +1654,7 @@ static void
addlitchar(unsigned char ychar)
addlitchar(unsigned char ychar)
{
{
/* enlarge buffer if needed */
/* enlarge buffer if needed */
if ((literallen+1) >= literalalloc)
if ((literallen + 1) >= literalalloc)
{
{
literalalloc *= 2;
literalalloc *= 2;
literalbuf = (char *) realloc(literalbuf, literalalloc);
literalbuf = (char *) realloc(literalbuf, literalalloc);
@ -1668,10 +1706,10 @@ parse_include(void)
yy_buffer = yb;
yy_buffer = yb;
/*
/*
* skip the ";" if there is one and trailing whitespace. Note that
* skip the ";" if there is one and trailing whitespace. Note that yytext
* yytext contains at least one non-space character plus the ";"
* contains at least one non-space character plus the ";"
*/
*/
for (i = strlen(yytext)-2;
for (i = strlen(yytext) - 2;
i > 0 && ecpg_isspace(yytext[i]);
i > 0 && ecpg_isspace(yytext[i]);
i--)
i--)
;
;
@ -1679,17 +1717,21 @@ parse_include(void)
if (yytext[i] == ';')
if (yytext[i] == ';')
i--;
i--;
yytext[i+1] = '\0';
yytext[i + 1] = '\0';
yyin = NULL;
yyin = NULL;
/* If file name is enclosed in '"' remove these and look only in '.' */
/* 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] == '"' &&
if (yytext[0] == '"' && yytext[i] == '"' &&
((compat != ECPG_COMPAT_INFORMIX && compat != ECPG_COMPAT_INFORMIX_SE) || yytext[1] == '/'))
((compat != ECPG_COMPAT_INFORMIX && compat != ECPG_COMPAT_INFORMIX_SE) || yytext[1] == '/'))
{
{
yytext[i] = '\0';
yytext[i] = '\0';
memmove(yytext, yytext+1, strlen(yytext));
memmove(yytext, yytext + 1, strlen(yytext));
strlcpy(inc_file, yytext, sizeof(inc_file));
strlcpy(inc_file, yytext, sizeof(inc_file));
yyin = fopen(inc_file, "r");
yyin = fopen(inc_file, "r");
@ -1708,7 +1750,7 @@ parse_include(void)
if ((yytext[0] == '"' && yytext[i] == '"') || (yytext[0] == '<' && yytext[i] == '>'))
if ((yytext[0] == '"' && yytext[i] == '"') || (yytext[0] == '<' && yytext[i] == '>'))
{
{
yytext[i] = '\0';
yytext[i] = '\0';
memmove(yytext, yytext+1, strlen(yytext));
memmove(yytext, yytext + 1, strlen(yytext));
}
}
for (ip = include_paths; yyin == NULL && ip != NULL; ip = ip->next)
for (ip = include_paths; yyin == NULL && ip != NULL; ip = ip->next)
@ -1718,7 +1760,7 @@ parse_include(void)
fprintf(stderr, _("Error: include path \"%s/%s\" is too long on line %d, skipping\n"), ip->path, yytext, yylineno);
fprintf(stderr, _("Error: include path \"%s/%s\" is too long on line %d, skipping\n"), ip->path, yytext, yylineno);
continue;
continue;
}
}
snprintf (inc_file, sizeof(inc_file), "%s/%s", ip->path, yytext);
snprintf(inc_file, sizeof(inc_file), "%s/%s", ip->path, yytext);
yyin = fopen(inc_file, "r");
yyin = fopen(inc_file, "r");
if (!yyin)
if (!yyin)
{
{
@ -1728,10 +1770,14 @@ parse_include(void)
yyin = fopen(inc_file, "r");
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)
if (yyin && include_next)
{
{
fclose (yyin);
fclose(yyin);
yyin = NULL;
yyin = NULL;
include_next = false;
include_next = false;
}
}
@ -1741,7 +1787,7 @@ parse_include(void)
mmfatal(NO_INCLUDE_FILE, "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));
yylineno = 1;
yylineno = 1;
output_line_number();
output_line_number();