From c2dad2660ffa4e03d48d1ae33cbf04c09fd43ae8 Mon Sep 17 00:00:00 2001 From: Michael Meskes Date: Sun, 17 Feb 2008 18:42:23 +0000 Subject: [PATCH] Changed INFORMIX mode symbol definition yet again because the old way didn't work on NetBSD. --- src/interfaces/ecpg/ChangeLog | 5 +++ src/interfaces/ecpg/include/datetime.h | 7 +++-- src/interfaces/ecpg/include/decimal.h | 5 +-- src/interfaces/ecpg/include/ecpg_informix.h | 5 --- src/interfaces/ecpg/preproc/pgc.l | 35 ++++++++++++++++++++- 5 files changed, 46 insertions(+), 11 deletions(-) diff --git a/src/interfaces/ecpg/ChangeLog b/src/interfaces/ecpg/ChangeLog index 7a2f8346a6..b73664a4ae 100644 --- a/src/interfaces/ecpg/ChangeLog +++ b/src/interfaces/ecpg/ChangeLog @@ -2317,3 +2317,8 @@ Fri, 15 Feb 2008 12:01:13 +0100 - Changed the way symbols are defined in C in INFORMIX mode. +Sun, 17 Feb 2008 18:45:39 +0100 + + - Removed duplicate include of ecpgtype.h. + - Changed INFORMIX mode symbol definition yet again because the old + way didn't work on NetBSD. diff --git a/src/interfaces/ecpg/include/datetime.h b/src/interfaces/ecpg/include/datetime.h index 03f2091db4..c7d37cb60f 100644 --- a/src/interfaces/ecpg/include/datetime.h +++ b/src/interfaces/ecpg/include/datetime.h @@ -5,8 +5,9 @@ #include -/* brought in by ecpg_informix.h nowadays - * typedef timestamp dtime_t; - * typedef interval intrvl_t; */ +#ifndef _ECPGLIB_H /* source created by ecpg which defines these symbols */ +typedef timestamp dtime_t; +typedef interval intrvl_t; +#endif /* ndef _ECPGLIB_H */ #endif /* ndef _ECPG_DATETIME_H */ diff --git a/src/interfaces/ecpg/include/decimal.h b/src/interfaces/ecpg/include/decimal.h index ae185a99c0..a4d4967fa3 100644 --- a/src/interfaces/ecpg/include/decimal.h +++ b/src/interfaces/ecpg/include/decimal.h @@ -5,7 +5,8 @@ #include -/* brought in by ecpg_informix.h nowadays - * typedef decimal dec_t; */ +#ifndef _ECPGLIB_H /* source created by ecpg which defines this symbol */ +typedef decimal dec_t; +#endif /* ndef _ECPGLIB_H */ #endif /* ndef _ECPG_DECIMAL_H */ diff --git a/src/interfaces/ecpg/include/ecpg_informix.h b/src/interfaces/ecpg/include/ecpg_informix.h index 4153896c33..c00914338d 100644 --- a/src/interfaces/ecpg/include/ecpg_informix.h +++ b/src/interfaces/ecpg/include/ecpg_informix.h @@ -82,11 +82,6 @@ extern int dttofmtasc(timestamp *, char *, int, char *); extern int intoasc(interval *, char *); extern int dtcvfmtasc(char *, char *, timestamp *); -/* we also define Informix datatypes here */ -typedef timestamp dtime_t; -typedef interval intrvl_t; -typedef decimal dec_t; - #ifdef __cplusplus } #endif diff --git a/src/interfaces/ecpg/preproc/pgc.l b/src/interfaces/ecpg/preproc/pgc.l index 97edc420fb..bd0a7d265e 100644 --- a/src/interfaces/ecpg/preproc/pgc.l +++ b/src/interfaces/ecpg/preproc/pgc.l @@ -47,6 +47,7 @@ static void addlitchar (unsigned char); static void parse_include (void); static bool ecpg_isspace(char ch); static bool isdefine(void); +static bool isinformixdefine(void); char *token_start; int state_before; @@ -743,7 +744,9 @@ cppline {space}*#(.*\\{space})*.*{newline} {identifier} { const ScanKeyword *keyword; - if (!isdefine()) + /* Informix uses SQL defines only in SQL space */ + /* however, some defines have to be taken care of for compatibility */ + if ((!INFORMIX_MODE || !isinformixdefine()) && !isdefine()) { keyword = ScanCKeywordLookup(yytext); if (keyword != NULL) @@ -1315,6 +1318,36 @@ static bool isdefine(void) return false; } +static bool isinformixdefine(void) +{ + const char *new = NULL; + + if (strcmp(yytext, "dec_t") == 0) + new = "decimal"; + else if (strcmp(yytext, "intrvl_t") == 0) + new = "interval"; + else if (strcmp(yytext, "dtime_t") == 0) + new = "timestamp"; + + if (new) + { + struct _yy_buffer *yb; + + yb = mm_alloc(sizeof(struct _yy_buffer)); + + yb->buffer = YY_CURRENT_BUFFER; + yb->lineno = yylineno; + yb->filename = mm_strdup(input_filename); + yb->next = yy_buffer; + yy_buffer = yb; + + yy_scan_string(new); + return true; + } + + return false; +} + /* * Called before any actual parsing is done */ -- 2.39.5