summaryrefslogtreecommitdiff
path: root/src/interfaces/ecpg/preproc/pgc.l
diff options
context:
space:
mode:
authorMichael Meskes <meskes@postgresql.org>2003-02-14 13:17:13 +0000
committerMichael Meskes <meskes@postgresql.org>2003-02-14 13:17:13 +0000
commit3a335375a961f28053195b2fda15dbe4d40ffc4a (patch)
tree4c32edb2cc0735eecc10ed4d33b90fc35666269e /src/interfaces/ecpg/preproc/pgc.l
parentaa874ee0d7fcf57257f1c405d81e99503fe0d593 (diff)
downloadpostgresql-3a335375a961f28053195b2fda15dbe4d40ffc4a.tar.gz
- Synced parser and keyword file.
- More work on Informix compatibility.
Diffstat (limited to 'src/interfaces/ecpg/preproc/pgc.l')
-rw-r--r--src/interfaces/ecpg/preproc/pgc.l61
1 files changed, 40 insertions, 21 deletions
diff --git a/src/interfaces/ecpg/preproc/pgc.l b/src/interfaces/ecpg/preproc/pgc.l
index 44e22f5cc0..a89ef3b1a0 100644
--- a/src/interfaces/ecpg/preproc/pgc.l
+++ b/src/interfaces/ecpg/preproc/pgc.l
@@ -12,7 +12,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.103 2003/02/13 20:37:28 meskes Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.104 2003/02/14 13:17:13 meskes Exp $
*
*-------------------------------------------------------------------------
*/
@@ -423,7 +423,6 @@ cppline {space}*#(.*\\{space})*.*
/* are we simulating Informix? */
if (compat == ECPG_COMPAT_INFORMIX)
{
- printf ("unput $\n");
unput(':');
}
else
@@ -560,6 +559,12 @@ cppline {space}*#(.*\\{space})*.*
if (keyword != NULL)
return keyword->value;
+ /* Is it a C keyword? */
+ keyword = ScanCKeywordLookup(yytext);
+ if (keyword != NULL)
+ return keyword->value;
+
+
/* How about a DEFINE? */
for (ptr = defines; ptr; ptr = ptr->next)
{
@@ -697,6 +702,7 @@ cppline {space}*#(.*\\{space})*.*
<C>{exec_sql}{define}{space}* { BEGIN(def_ident); }
<C>{exec_sql}{include}{space}* { BEGIN(incl); }
+<C>{informix_special}{include}{space}* { BEGIN(incl); }
<C,xskip>{exec_sql}{ifdef}{space}* { ifcond = TRUE; BEGIN(xcond); }
<C,xskip>{exec_sql}{ifndef}{space}* { ifcond = FALSE; BEGIN(xcond); }
@@ -832,32 +838,45 @@ cppline {space}*#(.*\\{space})*.*
i-- )
{}
- /* Remove trailing '"' if it exists */
- if (yytext[i] == '"')
- yytext[i] = '\0';
- else
- yytext[i+1] = '\0';
+ yytext[i+1] = '\0';
+ yyin = NULL;
- /* also remove starting '"' */
- if (yytext[0] == '"')
+ /* If file name is enclosed in '"' remove these and look only in '.' */
+ if (yytext[0] == '"' && yytext[i] == '"')
+ {
+ yytext[i] = '\0';
memmove(yytext, yytext+1, strlen(yytext));
-
- yyin = NULL;
- for (ip = include_paths; yyin == NULL && ip != NULL; ip = ip->next)
- {
- if (strlen(ip->path) + strlen(yytext) + 3 > MAXPGPATH)
- {
- fprintf(stderr, "Error: Path %s/%s is too long in line %d, skipping.\n", ip->path, yytext, yylineno);
- continue;
- }
- snprintf (inc_file, sizeof(inc_file), "%s/%s", ip->path, yytext);
- yyin = fopen( inc_file, "r" );
+
+ strncpy(inc_file, yytext, sizeof(inc_file));
+ yyin = fopen(inc_file, "r");
if (!yyin)
{
if (strcmp(inc_file + strlen(inc_file) - 2, ".h"))
{
strcat(inc_file, ".h");
- yyin = fopen( inc_file, "r" );
+ yyin = fopen(inc_file, "r");
+ }
+ }
+
+ }
+ else
+ {
+ for (ip = include_paths; yyin == NULL && ip != NULL; ip = ip->next)
+ {
+ if (strlen(ip->path) + strlen(yytext) + 3 > MAXPGPATH)
+ {
+ fprintf(stderr, "Error: Path %s/%s is too long in line %d, skipping.\n", ip->path, yytext, yylineno);
+ continue;
+ }
+ snprintf (inc_file, sizeof(inc_file), "%s/%s", ip->path, yytext);
+ yyin = fopen(inc_file, "r");
+ if (!yyin)
+ {
+ if (strcmp(inc_file + strlen(inc_file) - 2, ".h"))
+ {
+ strcat(inc_file, ".h");
+ yyin = fopen( inc_file, "r" );
+ }
}
}
}