Commit 73b92d10 authored by Michael Meskes's avatar Michael Meskes

Added typedef patches and a new option '-c' to automatically create C typedefs from SQL ones.

parent a13ddd36
...@@ -1225,6 +1225,12 @@ Wed Mar 6 10:40:28 CET 2002 ...@@ -1225,6 +1225,12 @@ Wed Mar 6 10:40:28 CET 2002
Sun Mar 10 13:08:22 CET 2002 Sun Mar 10 13:08:22 CET 2002
- Fixed two bugs in define command in lexer. - Fixed two bugs in define command in lexer.
Thu Mar 21 08:25:08 CET 2002
- Applied patch by Nicolas Bazin <nbazin@ingenico.com.au> for improved
typedef handling.
- Added option '-c' to automatically create C typedef from SQL one.
- Set ecpg version to 2.10.0. - Set ecpg version to 2.10.0.
- Set library version to 3.4.0. - Set library version to 3.4.0.
...@@ -36,6 +36,7 @@ static ScanKeyword ScanKeywords[] = { ...@@ -36,6 +36,7 @@ static ScanKeyword ScanKeywords[] = {
{"signed", SQL_SIGNED}, {"signed", SQL_SIGNED},
{"static", S_STATIC}, {"static", S_STATIC},
{"struct", SQL_STRUCT}, {"struct", SQL_STRUCT},
{"typedef", S_TYPEDEF},
{"union", UNION}, {"union", UNION},
{"unsigned", SQL_UNSIGNED}, {"unsigned", SQL_UNSIGNED},
{"varchar", VARCHAR}, {"varchar", VARCHAR},
......
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.53 2002/01/10 10:42:54 meskes Exp $ */ /* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.54 2002/03/21 09:42:50 meskes Exp $ */
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */ /* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
/* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */ /* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */
...@@ -17,7 +17,8 @@ extern char *optarg; ...@@ -17,7 +17,8 @@ extern char *optarg;
#include "extern.h" #include "extern.h"
int ret_value = 0, int ret_value = 0,
autocommit = 0; autocommit = false;
auto_create_c = false;
struct _include_path *include_paths = NULL; struct _include_path *include_paths = NULL;
struct cursor *cur = NULL; struct cursor *cur = NULL;
struct typedefs *types = NULL; struct typedefs *types = NULL;
...@@ -31,11 +32,11 @@ help(const char *progname) ...@@ -31,11 +32,11 @@ help(const char *progname)
/* printf is a macro some places; don't #ifdef inside its arguments */ /* printf is a macro some places; don't #ifdef inside its arguments */
#ifdef YYDEBUG #ifdef YYDEBUG
printf("Usage:\n" printf("Usage:\n"
" %s [-d] [-I DIRECTORY] [-o OUTFILE] [-t] file1 [file2...]\n\n", " %s [-d] [-I DIRECTORY] [-o OUTFILE] [-t] [-c] [-D symbol] file1 [file2...]\n\n",
progname); progname);
#else #else
printf("Usage:\n" printf("Usage:\n"
" %s [-I DIRECTORY] [-o OUTFILE] [-t] file1 [file2...]\n\n", " %s [-I DIRECTORY] [-o OUTFILE] [-t] [-c] [-D symbol] file1 [file2...]\n\n",
progname); progname);
#endif #endif
printf("Options:\n"); printf("Options:\n");
...@@ -45,6 +46,8 @@ help(const char *progname) ...@@ -45,6 +46,8 @@ help(const char *progname)
printf(" -I DIRECTORY search DIRECTORY for include files\n"); printf(" -I DIRECTORY search DIRECTORY for include files\n");
printf(" -o OUTFILE write result to OUTFILE\n"); printf(" -o OUTFILE write result to OUTFILE\n");
printf(" -t turn on autocommit of transactions\n"); printf(" -t turn on autocommit of transactions\n");
printf(" -c automatically generate C code from embedded SQL code\n currently this works for EXEC SQL TYPE\n");
printf(" -D symbol define symbo\n");
printf("\nIf no output file is specified, the name is formed by adding .c\n" printf("\nIf no output file is specified, the name is formed by adding .c\n"
"to the input file name, after stripping off .pgc if present.\n"); "to the input file name, after stripping off .pgc if present.\n");
printf("\nReport bugs to <pgsql-bugs@postgresql.org>.\n"); printf("\nReport bugs to <pgsql-bugs@postgresql.org>.\n");
...@@ -58,6 +61,7 @@ add_include_path(char *path) ...@@ -58,6 +61,7 @@ add_include_path(char *path)
include_paths = mm_alloc(sizeof(struct _include_path)); include_paths = mm_alloc(sizeof(struct _include_path));
include_paths->path = path; include_paths->path = path;
include_paths->next = ip; include_paths->next = ip;
} }
static void static void
...@@ -107,7 +111,7 @@ main(int argc, char *const argv[]) ...@@ -107,7 +111,7 @@ main(int argc, char *const argv[])
add_include_path("/usr/local/include"); add_include_path("/usr/local/include");
add_include_path("."); add_include_path(".");
while ((c = getopt(argc, argv, "vo:I:tD:d")) != -1) while ((c = getopt(argc, argv, "vco:I:tD:d")) != -1)
{ {
switch (c) switch (c)
{ {
...@@ -122,13 +126,15 @@ main(int argc, char *const argv[]) ...@@ -122,13 +126,15 @@ main(int argc, char *const argv[])
add_include_path(optarg); add_include_path(optarg);
break; break;
case 't': case 't':
autocommit = 1; autocommit = true;
break; break;
case 'v': case 'v':
verbose = true; verbose = true;
break; break;
case 'c':
auto_create_c = true;
break;
case 'D': case 'D':
/* XXX not documented */
add_preprocessor_define(optarg); add_preprocessor_define(optarg);
break; break;
case 'd': case 'd':
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
extern int braces_open, extern int braces_open,
autocommit, autocommit,
auto_create_c,
ret_value, ret_value,
struct_level; struct_level;
extern char *descriptor_index; extern char *descriptor_index;
......
This diff is collapsed.
...@@ -11,9 +11,8 @@ exec sql type str is varchar[10]; ...@@ -11,9 +11,8 @@ exec sql type str is varchar[10];
int int
main () main ()
{ {
typedef struct { long born; short age; } birthinfo;
exec sql type birthinfo is struct { long born; short age; };
exec sql begin declare section; exec sql begin declare section;
typedef struct { long born; short age; } birthinfo;
struct personal_struct { str name; struct personal_struct { str name;
birthinfo birth; birthinfo birth;
} personal; } personal;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment