Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0ab0607

Browse files
author
Michael Meskes
committed
Changed INFORMIX mode symbol definition yet again because the old way didn't work on NetBSD.
1 parent a50a313 commit 0ab0607

File tree

5 files changed

+50
-15
lines changed

5 files changed

+50
-15
lines changed

src/interfaces/ecpg/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2317,3 +2317,8 @@ Fri, 15 Feb 2008 12:01:13 +0100
23172317

23182318
- Changed the way symbols are defined in C in INFORMIX mode.
23192319

2320+
Sun, 17 Feb 2008 18:45:39 +0100
2321+
2322+
- Removed duplicate include of ecpgtype.h.
2323+
- Changed INFORMIX mode symbol definition yet again because the old
2324+
way didn't work on NetBSD.
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/datetime.h,v 1.12.4.1 2008/02/15 12:11:02 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/datetime.h,v 1.12.4.2 2008/02/17 18:42:23 meskes Exp $ */
22

33
#ifndef _ECPG_DATETIME_H
44
#define _ECPG_DATETIME_H
55

66
#include <ecpg_informix.h>
77

8-
/* brought in by ecpg_informix.h nowadays
9-
* typedef timestamp dtime_t;
10-
* typedef interval intrvl_t; */
8+
#ifndef _ECPGLIB_H /* source created by ecpg which defines these symbols */
9+
typedef timestamp dtime_t;
10+
typedef interval intrvl_t;
11+
#endif /* ndef _ECPGLIB_H */
1112

1213
#endif /* ndef _ECPG_DATETIME_H */

src/interfaces/ecpg/include/decimal.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/decimal.h,v 1.14.4.1 2008/02/15 12:11:02 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/decimal.h,v 1.14.4.2 2008/02/17 18:42:23 meskes Exp $ */
22

33
#ifndef _ECPG_DECIMAL_H
44
#define _ECPG_DECIMAL_H
55

66
#include <ecpg_informix.h>
77

8-
/* brought in by ecpg_informix.h nowadays
9-
* typedef decimal dec_t; */
8+
#ifndef _ECPGLIB_H /* source created by ecpg which defines this symbol */
9+
typedef decimal dec_t;
10+
#endif /* ndef _ECPGLIB_H */
1011

1112
#endif /* ndef _ECPG_DECIMAL_H */

src/interfaces/ecpg/include/ecpg_informix.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* This file contains stuff needed to be as compatible to Informix as possible.
3-
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpg_informix.h,v 1.18.4.1 2008/02/15 12:11:02 meskes Exp $
3+
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpg_informix.h,v 1.18.4.2 2008/02/17 18:42:23 meskes Exp $
44
*/
55
#ifndef _ECPG_INFORMIX_H
66
#define _ECPG_INFORMIX_H
@@ -82,11 +82,6 @@ extern int dttofmtasc(timestamp *, char *, int, char *);
8282
extern int intoasc(interval *, char *);
8383
extern int dtcvfmtasc(char *, char *, timestamp *);
8484

85-
/* we also define Informix datatypes here */
86-
typedef timestamp dtime_t;
87-
typedef interval intrvl_t;
88-
typedef decimal dec_t;
89-
9085
#ifdef __cplusplus
9186
}
9287
#endif

src/interfaces/ecpg/preproc/pgc.l

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.159.2.2 2008/02/15 16:28:47 meskes Exp $
15+
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.159.2.3 2008/02/17 18:42:23 meskes Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -47,6 +47,7 @@ static void addlitchar (unsigned char);
4747
static void parse_include (void);
4848
static bool ecpg_isspace(char ch);
4949
static bool isdefine(void);
50+
static bool isinformixdefine(void);
5051

5152
char *token_start;
5253
int state_before;
@@ -743,7 +744,9 @@ cppline {space}*#(.*\\{space})*.*{newline}
743744
<C>{identifier} {
744745
const ScanKeyword *keyword;
745746

746-
if (!isdefine())
747+
/* Informix uses SQL defines only in SQL space */
748+
/* however, some defines have to be taken care of for compatibility */
749+
if ((!INFORMIX_MODE || !isinformixdefine()) && !isdefine())
747750
{
748751
keyword = ScanCKeywordLookup(yytext);
749752
if (keyword != NULL)
@@ -1315,6 +1318,36 @@ static bool isdefine(void)
13151318
return false;
13161319
}
13171320

1321+
static bool isinformixdefine(void)
1322+
{
1323+
const char *new = NULL;
1324+
1325+
if (strcmp(yytext, "dec_t") == 0)
1326+
new = "decimal";
1327+
else if (strcmp(yytext, "intrvl_t") == 0)
1328+
new = "interval";
1329+
else if (strcmp(yytext, "dtime_t") == 0)
1330+
new = "timestamp";
1331+
1332+
if (new)
1333+
{
1334+
struct _yy_buffer *yb;
1335+
1336+
yb = mm_alloc(sizeof(struct _yy_buffer));
1337+
1338+
yb->buffer = YY_CURRENT_BUFFER;
1339+
yb->lineno = yylineno;
1340+
yb->filename = mm_strdup(input_filename);
1341+
yb->next = yy_buffer;
1342+
yy_buffer = yb;
1343+
1344+
yy_scan_string(new);
1345+
return true;
1346+
}
1347+
1348+
return false;
1349+
}
1350+
13181351
/*
13191352
* Called before any actual parsing is done
13201353
*/

0 commit comments

Comments
 (0)