|
1 | | -/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.62 2003/03/16 10:42:54 meskes Exp $ */ |
| 1 | +/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.63 2003/03/18 10:46:39 meskes Exp $ */ |
2 | 2 |
|
3 | 3 | /* New main for ecpg, the PostgreSQL embedded SQL precompiler. */ |
4 | 4 | /* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */ |
|
7 | 7 | #include"postgres_fe.h" |
8 | 8 |
|
9 | 9 | #include<unistd.h> |
| 10 | +#include<string.h> |
10 | 11 | #ifdefHAVE_GETOPT_H |
11 | 12 | #include<getopt.h> |
12 | 13 | #endif |
@@ -69,10 +70,27 @@ static void |
69 | 70 | add_preprocessor_define(char*define) |
70 | 71 | { |
71 | 72 | struct_defines*pd=defines; |
72 | | - |
| 73 | +char*ptr,*define_copy=mm_strdup(define); |
| 74 | + |
73 | 75 | defines=mm_alloc(sizeof(struct_defines)); |
74 | | -defines->old=strdup(define); |
75 | | -defines->new=strdup(""); |
| 76 | + |
| 77 | +/* look for = sign */ |
| 78 | +ptr=strchr(define_copy,'='); |
| 79 | +if (ptr!=NULL) |
| 80 | +{ |
| 81 | +char*tmp; |
| 82 | + |
| 83 | +/* symbol gets a value */ |
| 84 | +for (tmp=ptr-1;*tmp==' ';tmp--); |
| 85 | +tmp[1]='\0'; |
| 86 | +defines->old=define_copy; |
| 87 | +defines->new=ptr+1; |
| 88 | +} |
| 89 | +else |
| 90 | +{ |
| 91 | +defines->old=define_copy; |
| 92 | +defines->new=mm_strdup(""); |
| 93 | +} |
76 | 94 | defines->pertinent= true; |
77 | 95 | defines->next=pd; |
78 | 96 | } |
@@ -137,7 +155,10 @@ main(int argc, char *const argv[]) |
137 | 155 | break; |
138 | 156 | case'C': |
139 | 157 | if (strcmp(optarg,"INFORMIX")==0) |
| 158 | +{ |
140 | 159 | compat=ECPG_COMPAT_INFORMIX; |
| 160 | +add_preprocessor_define("dec_t=NumericVar"); |
| 161 | +} |
141 | 162 | else |
142 | 163 | { |
143 | 164 | fprintf(stderr,"Try '%s --help' for more information.\n",argv[0]); |
@@ -313,7 +334,7 @@ main(int argc, char *const argv[]) |
313 | 334 | lex_init(); |
314 | 335 |
|
315 | 336 | /* we need several includes */ |
316 | | -fprintf(yyout,"/* Processed by ecpg (%d.%d.%d) */\n/* These four include files are added by the preprocessor */\n#include <ecpgtype.h>\n#include <ecpglib.h>\n#include <ecpgerrno.h>\n#include <sqlca.h>\n#include <pgtypes_numeric.h>\n#line 1 \"%s\"\n",MAJOR_VERSION,MINOR_VERSION,PATCHLEVEL,input_filename); |
| 337 | +fprintf(yyout,"/* Processed by ecpg (%d.%d.%d) */\n/* These four include files are added by the preprocessor */\n#include <ecpgtype.h>\n#include <ecpglib.h>\n#include <ecpgerrno.h>\n#include <sqlca.h>\n#line 1 \"%s\"\n",MAJOR_VERSION,MINOR_VERSION,PATCHLEVEL,input_filename); |
317 | 338 |
|
318 | 339 | /* add some compatibility headers */ |
319 | 340 | if (compat==ECPG_COMPAT_INFORMIX) |
|