Skip to content

Commit c80ba6a

Browse files
author
Michael Meskes
committed
*** empty log message ***
1 parent 4cd086c commit c80ba6a

File tree

14 files changed

+363
-196
lines changed

14 files changed

+363
-196
lines changed

src/interfaces/ecpg/ChangeLog

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,5 +758,22 @@ Thu Dec 23 13:25:05 CET 1999
758758
Thu Jan 6 09:52:27 CET 2000
759759

760760
- Synced preproc.y with gram.y.
761-
- Made sure Bruce's additions also make it into my source tree.
762761
- Set ecpg version to 2.6.14.
762+
763+
Wed Jan 12 15:50:39 CET 2000
764+
765+
- Made sure Rene Hogendoorn's patches make it into ecpg completely
766+
except for the FETCH syntax change.
767+
768+
Fri Jan 14 21:17:46 CET 2000
769+
770+
- Applied a minor patch to ecpglib.c.
771+
- Fixed initialization bugs.
772+
773+
Mon Jan 17 21:55:40 CET 2000
774+
775+
- Synced preproc.y with gram.y.
776+
- Changed FETCH syntax using Rene's final patch. Made it more
777+
standard compliant.
778+
- Set library version to 3.0.10.
779+
- Set ecpg version to 2.7.0.

src/interfaces/ecpg/TODO

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,17 @@ stderr. Instead it should be listed as a warning.
1313
The error handling has to be improved by adding additional error-rules to
1414
the parser.
1515

16-
it would be nice to be able to use :var[:index] as cvariable
16+
it would be nice to be able to use :var[:index] as cvariable for an array var
1717

18-
support for dynamic SQL with unknown number of variables with DESCRIPTORS
18+
How can one insert arrays from c variables?
1919

20-
The line numbering is not exact.
20+
support for dynamic SQL with unknown number of variables with DESCRIPTORS
2121

2222
What happens to the output variable during read if there was an
2323
indicator-error?
2424

2525
Add a semantic check level, e.g. check if a table really exists.
2626

27-
How can one insert arrays from c variables?
28-
2927
Missing statements:
3028
- exec sql ifdef
3129
- exec sql allocate

src/interfaces/ecpg/lib/Makefile.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
# Copyright (c) 1994, Regents of the University of California
77
#
88
# IDENTIFICATION
9-
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.55 2000/01/10 15:41:27 momjian Exp $
9+
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.56 2000/01/18 13:03:47 meskes Exp $
1010
#
1111
#-------------------------------------------------------------------------
1212

1313
NAME= ecpg
1414
SO_MAJOR_VERSION= 3
15-
SO_MINOR_VERSION= 1.0
15+
SO_MINOR_VERSION= 0.10
1616

1717
SRCDIR= @top_srcdir@
1818
include $(SRCDIR)/Makefile.global

src/interfaces/ecpg/lib/typename.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ECPGtype_name(enum ECPGttype typ)
88
{
99
switch (typ)
1010
{
11-
case ECPGt_char:
11+
case ECPGt_char:
1212
return "char";
1313
case ECPGt_unsigned_char:
1414
return "unsigned char";

src/interfaces/ecpg/preproc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ include $(SRCDIR)/Makefile.global
33

44
MAJOR_VERSION=2
55
MINOR_VERSION=7
6-
PATCHLEVEL=14
6+
PATCHLEVEL=0
77

88
CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION) \
99
-DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL) \

src/interfaces/ecpg/preproc/ecpg.c

Lines changed: 52 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ struct cursor *cur = NULL;
1717
struct typedefs *types = NULL;
1818
struct _defines *defines = NULL;
1919

20-
2120
static void
2221
usage(char *progname)
2322
{
2423
fprintf(stderr, "ecpg - the postgresql preprocessor, version: %d.%d.%d\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL);
25-
fprintf(stderr, "Usage: %s: [-v] [-t] [-I include path] [ -o output file name] file1 [file2] ...\n", progname);
24+
fprintf(stderr, "Usage: %s: [-v] [-t] [-I include path] [ -o output file name] [-D define name] file1 [file2] ...\n", progname);
2625
}
2726

2827
static void
@@ -35,6 +34,18 @@ add_include_path(char *path)
3534
include_paths->next = ip;
3635
}
3736

37+
static void
38+
add_preprocessor_define(char *define)
39+
{
40+
struct _defines *pd = defines;
41+
42+
defines = mm_alloc(sizeof(struct _defines));
43+
defines->old = strdup(define);
44+
defines->new = strdup("");
45+
defines->pertinent = true;
46+
defines->next = pd;
47+
}
48+
3849
int
3950
main(int argc, char *const argv[])
4051
{
@@ -49,7 +60,7 @@ main(int argc, char *const argv[])
4960
add_include_path("/usr/local/include");
5061
add_include_path(".");
5162

52-
while ((c = getopt(argc, argv, "vo:I:t")) != EOF)
63+
while ((c = getopt(argc, argv, "vo:I:tD:")) != EOF)
5364
{
5465
switch (c)
5566
{
@@ -73,6 +84,9 @@ main(int argc, char *const argv[])
7384
case 'v':
7485
verbose = true;
7586
break;
87+
case 'D':
88+
add_preprocessor_define(optarg);
89+
break;
7690
default:
7791
usage(argv[0]);
7892
return ILLEGAL_OPTION;
@@ -106,7 +120,10 @@ main(int argc, char *const argv[])
106120

107121
strcpy(input_filename, argv[fnr]);
108122

109-
ptr2ext = strrchr(input_filename, '.');
123+
/* take care of relative paths */
124+
ptr2ext = strrchr(input_filename, '/');
125+
ptr2ext = (ptr2ext ? strrchr(ptr2ext, '.') : strrchr(input_filename, '.'));
126+
110127
/* no extension? */
111128
if (ptr2ext == NULL)
112129
{
@@ -120,7 +137,7 @@ main(int argc, char *const argv[])
120137
ptr2ext[4] = '\0';
121138
}
122139

123-
if (out_option == 0)/* calculate the output name */
140+
if (out_option == 0) /* calculate the output name */
124141
{
125142
output_filename = strdup(input_filename);
126143

@@ -179,16 +196,29 @@ main(int argc, char *const argv[])
179196
ptr = ptr->next;
180197
free(this);
181198
}
199+
cur = NULL;
182200

183-
/* remove old defines as well */
184-
for (defptr = defines; defptr != NULL;)
201+
/* remove non-pertinent old defines as well */
202+
while ( defines && !defines->pertinent ) {
203+
defptr = defines;
204+
defines = defines->next;
205+
206+
free(defptr->new);
207+
free(defptr->old);
208+
free(defptr);
209+
}
210+
211+
for (defptr = defines; defptr != NULL; defptr = defptr->next )
185212
{
186-
struct _defines *this = defptr;
213+
struct _defines *this = defptr->next;
214+
215+
if ( this && !this->pertinent ) {
216+
defptr->next = this->next;
187217

188-
free(defptr->new);
189-
free(defptr->old);
190-
defptr = defptr->next;
218+
free(this->new);
219+
free(this->old);
191220
free(this);
221+
}
192222
}
193223

194224
/* and old typedefs */
@@ -197,17 +227,25 @@ main(int argc, char *const argv[])
197227
struct typedefs *this = typeptr;
198228

199229
free(typeptr->name);
200-
free(typeptr->type);
201230
ECPGfree_struct_member(typeptr->struct_member_list);
231+
free(typeptr->type);
202232
typeptr = typeptr->next;
203233
free(this);
204234
}
205-
235+
types = NULL;
236+
237+
/* initialize whenever structures */
238+
memset(&when_error, 0, sizeof(struct when));
239+
memset(&when_nf, 0, sizeof(struct when));
240+
memset(&when_warn, 0, sizeof(struct when));
241+
242+
/* and structure member lists */
243+
memset(struct_member_list, 0, sizeof(struct_member_list));
206244
/* initialize lex */
207245
lex_init();
208246

209247
/* we need two includes */
210-
fprintf(yyout, "/* Processed by ecpg (%d.%d.%d) */\n/* These two include files are added by the preprocessor */\n#include <ecpgtype.h>\n#include <ecpglib.h>\n\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL);
248+
fprintf(yyout, "/* Processed by ecpg (%d.%d.%d) */\n/* These two include files are added by the preprocessor */\n#include <ecpgtype.h>\n#include <ecpglib.h>\n#line 1 \"%s\"\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL, input_filename);
211249

212250
/* and parse the source */
213251
yyparse();

src/interfaces/ecpg/preproc/extern.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
#include "type.h"
33
#include <errno.h>
44

5+
/* defines */
6+
7+
#define STRUCT_DEPTH 128
8+
59
/* variables */
610

711
extern int braces_open,
@@ -23,6 +27,8 @@ extern struct ECPGtype ecpg_no_indicator;
2327
extern struct variable no_indicator;
2428
extern struct arguments *argsinsert;
2529
extern struct arguments *argsresult;
30+
extern struct when when_error, when_nf, when_warn;
31+
extern struct ECPGstruct_member *struct_member_list[STRUCT_DEPTH];
2632

2733
/* functions */
2834

@@ -39,9 +45,9 @@ extern void yyerror(char *);
3945
/* return codes */
4046

4147
#define OK 0
42-
#define PARSE_ERROR -1
48+
#define PARSE_ERROR -1
4349
#define ILLEGAL_OPTION -2
44-
#define INDICATOR_NOT_ARRAY -3
50+
#define INDICATOR_NOT_ARRAY -3
4551

46-
#define NO_INCLUDE_FILE ENOENT
47-
#define OUT_OF_MEMORY ENOMEM
52+
#define NO_INCLUDE_FILE ENOENT
53+
#define OUT_OF_MEMORY ENOMEM

0 commit comments

Comments
 (0)