*** empty log message ***
authorMichael Meskes <meskes@postgresql.org>
Thu, 23 Dec 1999 12:33:19 +0000 (12:33 +0000)
committerMichael Meskes <meskes@postgresql.org>
Thu, 23 Dec 1999 12:33:19 +0000 (12:33 +0000)
src/interfaces/ecpg/ChangeLog
src/interfaces/ecpg/TODO
src/interfaces/ecpg/preproc/Makefile
src/interfaces/ecpg/preproc/ecpg.c

index 415bde7d4e573728bc588708252cb1edb568b341..296b34d5cd282d937cb7a0ed1f16966b3b61e251 100644 (file)
@@ -749,3 +749,9 @@ Wed Dec 15 08:10:52 CET 1999
    - Some cleanup in libecpg.
    - Set library version to 3.0.9.
    - Set ecpg version to 2.6.12.
+
+Thu Dec 23 13:25:05 CET 1999
+
+   - Fixed command line parsing. 
+   - Set ecpg version to 2.6.13.
+
index 3b8b05eae00884b6a90950c411ad601cd5f8efc1..13b6e60a252b4bb7b5ed36935d391b8bd002edfc 100644 (file)
@@ -24,7 +24,7 @@ indicator-error?
 
 Add a semantic check level, e.g. check if a table really exists.
 
-How can on insert arrays from c variables?
+How can one insert arrays from c variables?
 
 Missing statements:
  - exec sql ifdef
index 1873d13ce978405d2811247bc9833cb8c4d6f20d..ad2af4804527895b327299d40e3085c03926023b 100644 (file)
@@ -3,7 +3,7 @@ include $(SRCDIR)/Makefile.global
 
 MAJOR_VERSION=2
 MINOR_VERSION=6
-PATCHLEVEL=12
+PATCHLEVEL=13
 
 CFLAGS+=-I../include -DMAJOR_VERSION=$(MAJOR_VERSION) \
    -DMINOR_VERSION=$(MINOR_VERSION) -DPATCHLEVEL=$(PATCHLEVEL) \
index a49cc6b60d536b643520a6c570f2131db26e94fc..a87c779f0addf165efc9ad0809d9625d6bcba180 100644 (file)
@@ -12,9 +12,7 @@
 #include "extern.h"
 
 struct _include_path *include_paths;
-struct _defines    *defines = NULL;
-int autocommit = 0;
-int ret_value = OK;
+int        ret_value = OK, autocommit = 0;
 struct cursor *cur = NULL;
 struct typedefs *types = NULL;
 
@@ -22,7 +20,7 @@ static void
 usage(char *progname)
 {
    fprintf(stderr, "ecpg - the postgresql preprocessor, version: %d.%d.%d\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL);
-   fprintf(stderr, "Usage: %s: [-v] [-t] [-I include path] [ -o output file name] [-D define name] file1 [file2] ...\n", progname);
+   fprintf(stderr, "Usage: %s: [-v] [-t] [-I include path] [ -o output file name] file1 [file2] ...\n", progname);
 }
 
 static void
@@ -35,23 +33,12 @@ add_include_path(char *path)
    include_paths->next = ip;
 }
 
-static void
-add_preprocessor_define(char *define)
-{
-   struct _defines *pd = defines;
-
-   defines = mm_alloc(sizeof(struct _defines));
-   defines->old = strdup(define);
-   defines->new = strdup("");
-   defines->pertinent = true;
-   defines->next = pd;
-}
-
 int
 main(int argc, char *const argv[])
 {
    int         fnr,
                c,
+               verbose = false,
                out_option = 0;
    struct _include_path *ip;
 
@@ -60,7 +47,7 @@ main(int argc, char *const argv[])
    add_include_path("/usr/local/include");
    add_include_path(".");
 
-   while ((c = getopt(argc, argv, "vo:I:tD:")) != EOF)
+   while ((c = getopt(argc, argv, "vo:I:t")) != EOF)
    {
        switch (c)
        {
@@ -82,14 +69,7 @@ main(int argc, char *const argv[])
                autocommit = 1;
                break;
            case 'v':
-               fprintf(stderr, "ecpg - the postgresql preprocessor, version: %d.%d.%d\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL);
-               fprintf(stderr, "exec sql include ... search starts here:\n");
-               for (ip = include_paths; ip != NULL; ip = ip->next)
-                   fprintf(stderr, " %s\n", ip->path);
-               fprintf(stderr, "End of search list.\n");
-               return OK;
-           case 'D':
-               add_preprocessor_define(optarg);
+               verbose = true;
                break;
            default:
                usage(argv[0]);
@@ -97,6 +77,16 @@ main(int argc, char *const argv[])
        }
    }
 
+   if (verbose)
+   {
+       fprintf(stderr, "ecpg - the postgresql preprocessor, version: %d.%d.%d\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL);
+       fprintf(stderr, "exec sql include ... search starts here:\n");
+       for (ip = include_paths; ip != NULL; ip = ip->next)
+           fprintf(stderr, " %s\n", ip->path);
+       fprintf(stderr, "End of search list.\n");
+       return OK;
+   }
+   
    if (optind >= argc)         /* no files specified */
    {
        usage(argv[0]);
@@ -114,9 +104,7 @@ main(int argc, char *const argv[])
 
            strcpy(input_filename, argv[fnr]);
 
-           /* take care of relative paths */
-           ptr2ext = strrchr(input_filename, '/');
-           ptr2ext = (ptr2ext ? strrchr(ptr2ext, '.') : strrchr(input_filename, '.'));
+           ptr2ext = strrchr(input_filename, '.');
            /* no extension? */
            if (ptr2ext == NULL)
            {
@@ -189,29 +177,16 @@ main(int argc, char *const argv[])
                    ptr = ptr->next;
                    free(this);
                }
-               cur = NULL;
-
-               /* remove non-pertinent old defines as well */
-               while ( defines && !defines->pertinent ) {
-                   defptr = defines;
-                   defines = defines->next;
-
-                   free(defptr->new);
-                   free(defptr->old);
-                   free(defptr);
-               }
 
-               for (defptr = defines; defptr != NULL; defptr = defptr->next )
+               /* remove old defines as well */
+               for (defptr = defines; defptr != NULL;)
                {
-                   struct _defines *this = defptr->next;
-                   
-                   if ( this && !this->pertinent ) {
-                   defptr->next = this->next;
+                   struct _defines *this = defptr;
 
-                   free(this->new);
-                   free(this->old);
+                   free(defptr->new);
+                   free(defptr->old);
+                   defptr = defptr->next;
                    free(this);
-                   }
                }
 
                /* and old typedefs */
@@ -225,13 +200,12 @@ main(int argc, char *const argv[])
                    typeptr = typeptr->next;
                    free(this);
                }
-               types = NULL;
 
                /* initialize lex */
                lex_init();
 
                /* we need two includes */
-               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);
+               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);
 
                /* and parse the source */
                yyparse();