Commit 4e1ed3da authored by Michael Meskes's avatar Michael Meskes

- Added more compatibility functions.

	- Accept CPP defines for type definitions.
	- Do not parse system include files automatically for Informix mode
parent 78b08584
...@@ -1408,6 +1408,12 @@ Tue May 6 11:51:33 CEST 2003 ...@@ -1408,6 +1408,12 @@ Tue May 6 11:51:33 CEST 2003
Tue May 13 13:34:12 CEST 2003 Tue May 13 13:34:12 CEST 2003
- Fixed order of include search path. - Fixed order of include search path.
Wed May 14 13:05:49 CEST 2003
- Added more compatibility functions.
- Accept CPP defines for type definitions.
- Do not parse system include files automatically for Informix mode
- Set ecpg version to 2.12.0. - Set ecpg version to 2.12.0.
- Set ecpg library to 3.4.2. - Set ecpg library to 3.4.2.
- Set pgtypes library to 1.0.0 - Set pgtypes library to 1.0.0
......
...@@ -609,6 +609,28 @@ rfmtlong(long lng_val, char *fmt, char *outbuf) ...@@ -609,6 +609,28 @@ rfmtlong(long lng_val, char *fmt, char *outbuf)
return 0; return 0;
} }
void
rupshift(char *str)
{
for (; *str != '\0'; str++)
if (islower(*str)) *str = toupper(*str);
return;
}
int
byleng(char *str, int len)
{
for (len--; str[len] && str[len] == ' '; len--);
return (len+1);
}
void
ldchar(char *src, int len, char *dest)
{
memmove(dest, src, len);
dest[len]=0;
}
int int
rgetmsg(int msgnum, char *s, int maxsize) rgetmsg(int msgnum, char *s, int maxsize)
{ {
...@@ -639,13 +661,15 @@ rtypmsize(int type, int len) ...@@ -639,13 +661,15 @@ rtypmsize(int type, int len)
return 0; return 0;
} }
void int
rupshift(char *str) rtypwidth(int sqltype, int sqllen)
{ {
for (; *str != '\0'; str++) return 0;
if (islower(*str)) *str = toupper(*str);
return;
} }
int
dtcvfmtasc (char *inbuf, char *fmtstr, dtime_t *dtvalue)
{
return 0;
}
...@@ -15,4 +15,4 @@ extern int dtsub (dtime_t *, dtime_t *, intrvl_t *); ...@@ -15,4 +15,4 @@ extern int dtsub (dtime_t *, dtime_t *, intrvl_t *);
extern int dttoasc (dtime_t *, char *); extern int dttoasc (dtime_t *, char *);
extern int dttofmtasc (dtime_t *, char *, int, char *); extern int dttofmtasc (dtime_t *, char *, int, char *);
extern int intoasc(intrvl_t *, char *); extern int intoasc(intrvl_t *, char *);
extern int dtcvfmtasc(char *, char *, dtime_t *);
...@@ -26,6 +26,9 @@ extern int risnull(int, char *); ...@@ -26,6 +26,9 @@ extern int risnull(int, char *);
extern int rsetnull(int, char *); extern int rsetnull(int, char *);
extern int rtypalign(int, int); extern int rtypalign(int, int);
extern int rtypmsize(int, int); extern int rtypmsize(int, int);
extern int rtypwidth(int, int);
extern void rupshift(char *); extern void rupshift(char *);
extern int byleng(char *, int);
extern void ldchar(char *, int, char *);
...@@ -192,7 +192,7 @@ output_get_descr(char *desc_name, char *index) ...@@ -192,7 +192,7 @@ output_get_descr(char *desc_name, char *index)
break; break;
} }
fprintf(yyout, "%s,", get_dtype(results->value)); fprintf(yyout, "%s,", get_dtype(results->value));
ECPGdump_a_type(yyout, v->name, v->type, NULL, NULL, NULL, NULL, 0L, NULL, NULL); ECPGdump_a_type(yyout, v->name, v->type, NULL, NULL, NULL, NULL, make_str("0"), NULL, NULL);
} }
drop_assignments(); drop_assignments();
fputs("ECPGd_EODT);\n", yyout); fputs("ECPGd_EODT);\n", yyout);
......
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.69 2003/05/13 11:29:14 meskes Exp $ */ /* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.70 2003/05/14 14:37:35 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 */
...@@ -162,7 +162,7 @@ main(int argc, char *const argv[]) ...@@ -162,7 +162,7 @@ main(int argc, char *const argv[])
if (strcmp(optarg, "INFORMIX") == 0) if (strcmp(optarg, "INFORMIX") == 0)
{ {
compat = ECPG_COMPAT_INFORMIX; compat = ECPG_COMPAT_INFORMIX;
system_includes = true; /* system_includes = true; */
add_preprocessor_define("dec_t=Numeric"); add_preprocessor_define("dec_t=Numeric");
add_preprocessor_define("intrvl_t=Interval"); add_preprocessor_define("intrvl_t=Interval");
} }
......
...@@ -77,7 +77,7 @@ extern void add_variable(struct arguments **, struct variable *, struct variable ...@@ -77,7 +77,7 @@ extern void add_variable(struct arguments **, struct variable *, struct variable
extern void append_variable(struct arguments **, struct variable *, struct variable *); extern void append_variable(struct arguments **, struct variable *, struct variable *);
extern void dump_variables(struct arguments *, int); extern void dump_variables(struct arguments *, int);
extern struct typedefs *get_typedef(char *); extern struct typedefs *get_typedef(char *);
extern void adjust_array(enum ECPGttype, int *, int *, int, int, int); extern void adjust_array(enum ECPGttype, char **, char **, char *, char *, int);
extern void reset_variables(void); extern void reset_variables(void);
extern void check_indicator(struct ECPGtype *); extern void check_indicator(struct ECPGtype *);
extern void remove_variables(int); extern void remove_variables(int);
......
This diff is collapsed.
...@@ -83,7 +83,7 @@ ECPGmake_struct_member(char *name, struct ECPGtype * type, struct ECPGstruct_mem ...@@ -83,7 +83,7 @@ ECPGmake_struct_member(char *name, struct ECPGtype * type, struct ECPGstruct_mem
} }
struct ECPGtype * struct ECPGtype *
ECPGmake_simple_type(enum ECPGttype type, long size) ECPGmake_simple_type(enum ECPGttype type, char *size)
{ {
struct ECPGtype *ne = (struct ECPGtype *) mm_alloc(sizeof(struct ECPGtype)); struct ECPGtype *ne = (struct ECPGtype *) mm_alloc(sizeof(struct ECPGtype));
...@@ -96,7 +96,7 @@ ECPGmake_simple_type(enum ECPGttype type, long size) ...@@ -96,7 +96,7 @@ ECPGmake_simple_type(enum ECPGttype type, long size)
} }
struct ECPGtype * struct ECPGtype *
ECPGmake_array_type(struct ECPGtype * type, long size) ECPGmake_array_type(struct ECPGtype * type, char *size)
{ {
struct ECPGtype *ne = ECPGmake_simple_type(ECPGt_array, size); struct ECPGtype *ne = ECPGmake_simple_type(ECPGt_array, size);
...@@ -108,7 +108,7 @@ ECPGmake_array_type(struct ECPGtype * type, long size) ...@@ -108,7 +108,7 @@ ECPGmake_array_type(struct ECPGtype * type, long size)
struct ECPGtype * struct ECPGtype *
ECPGmake_struct_type(struct ECPGstruct_member * rm, enum ECPGttype type, char *struct_sizeof) ECPGmake_struct_type(struct ECPGstruct_member * rm, enum ECPGttype type, char *struct_sizeof)
{ {
struct ECPGtype *ne = ECPGmake_simple_type(type, 1); struct ECPGtype *ne = ECPGmake_simple_type(type, make_str("1"));
ne->u.members = ECPGstruct_member_dup(rm); ne->u.members = ECPGstruct_member_dup(rm);
ne->struct_sizeof = struct_sizeof; ne->struct_sizeof = struct_sizeof;
...@@ -207,13 +207,17 @@ get_type(enum ECPGttype type) ...@@ -207,13 +207,17 @@ get_type(enum ECPGttype type)
the variable (required to do array fetches of structs). the variable (required to do array fetches of structs).
*/ */
static void ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type, static void ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type,
long varcharsize, char *varcharsize,
long arrsiz, const char *siz, const char *prefix); char *arrsiz, const char *siz, const char *prefix);
static void ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, long arrsiz, static void ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, char *arrsiz,
struct ECPGtype * type, struct ECPGtype * ind_type, const char *offset, const char *prefix, const char *ind_prefix); struct ECPGtype * type, struct ECPGtype * ind_type, const char *offset, const char *prefix, const char *ind_prefix);
void void
ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const char *ind_name, struct ECPGtype * ind_type, const char *prefix, const char *ind_prefix, const long arr_str_siz, const char *struct_sizeof, const char *ind_struct_sizeof) ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type,
const char *ind_name, struct ECPGtype * ind_type,
const char *prefix, const char *ind_prefix,
char *arr_str_siz, const char *struct_sizeof,
const char *ind_struct_sizeof)
{ {
switch (type->type) switch (type->type)
{ {
...@@ -239,7 +243,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const char *i ...@@ -239,7 +243,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const char *i
if (ind_type != NULL) if (ind_type != NULL)
{ {
if (ind_type->type == ECPGt_NO_INDICATOR) if (ind_type->type == ECPGt_NO_INDICATOR)
ECPGdump_a_simple(o, ind_name, ind_type->type, ind_type->size, -1, NULL, ind_prefix); ECPGdump_a_simple(o, ind_name, ind_type->type, ind_type->size, make_str("-1"), NULL, ind_prefix);
else else
ECPGdump_a_simple(o, ind_name, ind_type->u.element->type, ECPGdump_a_simple(o, ind_name, ind_type->u.element->type,
ind_type->u.element->size, ind_type->size, NULL, prefix); ind_type->u.element->size, ind_type->size, NULL, prefix);
...@@ -250,7 +254,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const char *i ...@@ -250,7 +254,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const char *i
if (indicator_set && ind_type->type != ECPGt_struct) if (indicator_set && ind_type->type != ECPGt_struct)
mmerror(INDICATOR_NOT_STRUCT, ET_FATAL, "Indicator for struct has to be struct.\n"); mmerror(INDICATOR_NOT_STRUCT, ET_FATAL, "Indicator for struct has to be struct.\n");
ECPGdump_a_struct(o, name, ind_name, 1, type, ind_type, NULL, prefix, ind_prefix); ECPGdump_a_struct(o, name, ind_name, make_str("1"), type, ind_type, NULL, prefix, ind_prefix);
break; break;
case ECPGt_union: /* cannot dump a complete union */ case ECPGt_union: /* cannot dump a complete union */
yyerror("Type of union has to be specified"); yyerror("Type of union has to be specified");
...@@ -259,23 +263,23 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const char *i ...@@ -259,23 +263,23 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const char *i
if (indicator_set && (ind_type->type == ECPGt_struct || ind_type->type == ECPGt_array)) if (indicator_set && (ind_type->type == ECPGt_struct || ind_type->type == ECPGt_array))
mmerror(INDICATOR_NOT_SIMPLE, ET_FATAL, "Indicator for simple datatype has to be simple.\n"); mmerror(INDICATOR_NOT_SIMPLE, ET_FATAL, "Indicator for simple datatype has to be simple.\n");
ECPGdump_a_simple(o, name, type->type, 1, arr_str_siz ? arr_str_siz : 1, struct_sizeof, prefix); ECPGdump_a_simple(o, name, type->type, make_str("1"), (arr_str_siz && strcmp(arr_str_siz, "0") != 0) ? arr_str_siz : make_str("1"), struct_sizeof, prefix);
ECPGdump_a_simple(o, ind_name, ind_type->type, ind_type->size, arr_str_siz ? arr_str_siz : -1, ind_struct_sizeof, ind_prefix); ECPGdump_a_simple(o, ind_name, ind_type->type, ind_type->size, (arr_str_siz && strcmp(arr_str_siz, "0") != 0) ? arr_str_siz : make_str("-1"), ind_struct_sizeof, ind_prefix);
break; break;
case ECPGt_descriptor: case ECPGt_descriptor:
if (indicator_set && (ind_type->type == ECPGt_struct || ind_type->type == ECPGt_array)) if (indicator_set && (ind_type->type == ECPGt_struct || ind_type->type == ECPGt_array))
mmerror(INDICATOR_NOT_SIMPLE, ET_FATAL, "Indicator for simple datatype has to be simple.\n"); mmerror(INDICATOR_NOT_SIMPLE, ET_FATAL, "Indicator for simple datatype has to be simple.\n");
ECPGdump_a_simple(o, name, type->type, 0, -1, NULL, prefix); ECPGdump_a_simple(o, name, type->type, 0, make_str("-1"), NULL, prefix);
ECPGdump_a_simple(o, ind_name, ind_type->type, ind_type->size, -1, NULL, ind_prefix); ECPGdump_a_simple(o, ind_name, ind_type->type, ind_type->size, make_str("-1"), NULL, ind_prefix);
break; break;
default: default:
if (indicator_set && (ind_type->type == ECPGt_struct || ind_type->type == ECPGt_array)) if (indicator_set && (ind_type->type == ECPGt_struct || ind_type->type == ECPGt_array))
mmerror(INDICATOR_NOT_SIMPLE, ET_FATAL, "Indicator for simple datatype has to be simple.\n"); mmerror(INDICATOR_NOT_SIMPLE, ET_FATAL, "Indicator for simple datatype has to be simple.\n");
ECPGdump_a_simple(o, name, type->type, type->size, arr_str_siz ? arr_str_siz : -1, struct_sizeof, prefix); ECPGdump_a_simple(o, name, type->type, type->size, (arr_str_siz && strcmp(arr_str_siz, "0") != 0) ? arr_str_siz : make_str("-1"), struct_sizeof, prefix);
if (ind_type != NULL) if (ind_type != NULL)
ECPGdump_a_simple(o, ind_name, ind_type->type, ind_type->size, arr_str_siz ? arr_str_siz : -1, ind_struct_sizeof, ind_prefix); ECPGdump_a_simple(o, ind_name, ind_type->type, ind_type->size, (arr_str_siz && strcmp(arr_str_siz, "0") != 0) ? arr_str_siz : make_str("-1"), ind_struct_sizeof, ind_prefix);
break; break;
} }
} }
...@@ -285,8 +289,8 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const char *i ...@@ -285,8 +289,8 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const char *i
string, it represents the offset needed if we are in an array of structs. */ string, it represents the offset needed if we are in an array of structs. */
static void static void
ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type, ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type,
long varcharsize, char *varcharsize,
long arrsize, char *arrsize,
const char *siz, const char *siz,
const char *prefix const char *prefix
) )
...@@ -309,7 +313,9 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type, ...@@ -309,7 +313,9 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type,
* we have to use the pointer except for arrays with given * we have to use the pointer except for arrays with given
* bounds * bounds
*/ */
if (arrsize > 0 && siz == NULL) if (((atoi(arrsize) > 0) ||
(atoi(arrsize) == 0) && strcmp(arrsize, "0") != 0) &&
siz == NULL)
sprintf(variable, "(%s%s)", prefix ? prefix : "", name); sprintf(variable, "(%s%s)", prefix ? prefix : "", name);
else else
sprintf(variable, "&(%s%s)", prefix ? prefix : "", name); sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
...@@ -324,12 +330,16 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type, ...@@ -324,12 +330,16 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type,
* we have to use the pointer except for arrays with given * we have to use the pointer except for arrays with given
* bounds * bounds
*/ */
if ((varcharsize > 1 || arrsize > 0) && siz == NULL) if ((atoi(varcharsize) > 1 ||
(atoi(arrsize) > 0) ||
(atoi(varcharsize) == 0 && strcmp(varcharsize, "0") != 0) ||
(atoi(arrsize) == 0 && strcmp(arrsize, "0") != 0))
&& siz == NULL)
sprintf(variable, "(%s%s)", prefix ? prefix : "", name); sprintf(variable, "(%s%s)", prefix ? prefix : "", name);
else else
sprintf(variable, "&(%s%s)", prefix ? prefix : "", name); sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
sprintf(offset, "%ld*sizeof(char)", varcharsize == 0 ? 1 : varcharsize); sprintf(offset, "%s*sizeof(char)", strcmp(varcharsize, "0") == 0 ? "1" : varcharsize);
break; break;
case ECPGt_numeric: case ECPGt_numeric:
...@@ -369,7 +379,9 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type, ...@@ -369,7 +379,9 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type,
* we have to use the pointer except for arrays with given * we have to use the pointer except for arrays with given
* bounds * bounds
*/ */
if (arrsize > 0 && siz == NULL) if (((atoi(arrsize) > 0) ||
(atoi(arrsize) == 0) && strcmp(arrsize, "0") != 0) &&
siz == NULL)
sprintf(variable, "(%s%s)", prefix ? prefix : "", name); sprintf(variable, "(%s%s)", prefix ? prefix : "", name);
else else
sprintf(variable, "&(%s%s)", prefix ? prefix : "", name); sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
...@@ -378,13 +390,13 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type, ...@@ -378,13 +390,13 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type,
break; break;
} }
if (arrsize < 0) if (atoi(arrsize) < 0)
arrsize = 1; strcpy(arrsize, "1");
if (siz == NULL || arrsize <= 1) if (siz == NULL || strcmp(arrsize, "0") == 0 || strcmp(arrsize, "1") == 0)
fprintf(o, "\n\t%s,%s,%ldL,%ldL,%s, ", get_type(type), variable, varcharsize, arrsize, offset); fprintf(o, "\n\t%s,%s,(long)%s,(long)%s,%s, ", get_type(type), variable, varcharsize, arrsize, offset);
else else
fprintf(o, "\n\t%s,%s,%ldL,%ldL,%s, ", get_type(type), variable, varcharsize, arrsize, siz); fprintf(o, "\n\t%s,%s,(long)%s,(long)%s,%s, ", get_type(type), variable, varcharsize, arrsize, siz);
free(variable); free(variable);
free(offset); free(offset);
...@@ -394,7 +406,7 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type, ...@@ -394,7 +406,7 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype type,
/* Penetrate a struct and dump the contents. */ /* Penetrate a struct and dump the contents. */
static void static void
ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, long arrsiz, struct ECPGtype * type, struct ECPGtype * ind_type, const char *offsetarg, const char *prefix, const char *ind_prefix) ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, char *arrsiz, struct ECPGtype * type, struct ECPGtype * ind_type, const char *offsetarg, const char *prefix, const char *ind_prefix)
{ {
/* /*
* If offset is NULL, then this is the first recursive level. If not * If offset is NULL, then this is the first recursive level. If not
...@@ -416,7 +428,7 @@ ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, long arrsiz, ...@@ -416,7 +428,7 @@ ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, long arrsiz,
else else
offset = offsetarg; offset = offsetarg;
if (arrsiz == 1) if (atoi(arrsiz) == 1)
sprintf(pbuf, "%s%s.", prefix ? prefix : "", name); sprintf(pbuf, "%s%s.", prefix ? prefix : "", name);
else else
sprintf(pbuf, "%s%s->", prefix ? prefix : "", name); sprintf(pbuf, "%s%s->", prefix ? prefix : "", name);
...@@ -427,7 +439,7 @@ ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, long arrsiz, ...@@ -427,7 +439,7 @@ ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, long arrsiz,
ind_p = &struct_no_indicator; ind_p = &struct_no_indicator;
else if (ind_type != NULL) else if (ind_type != NULL)
{ {
if (arrsiz == 1) if (atoi(arrsiz) == 1)
sprintf(ind_pbuf, "%s%s.", ind_prefix ? ind_prefix : "", ind_name); sprintf(ind_pbuf, "%s%s.", ind_prefix ? ind_prefix : "", ind_name);
else else
sprintf(ind_pbuf, "%s%s->", ind_prefix ? ind_prefix : "", ind_name); sprintf(ind_pbuf, "%s%s->", ind_prefix ? ind_prefix : "", ind_name);
......
...@@ -14,7 +14,7 @@ struct ECPGstruct_member ...@@ -14,7 +14,7 @@ struct ECPGstruct_member
struct ECPGtype struct ECPGtype
{ {
enum ECPGttype type; enum ECPGttype type;
long size; /* For array it is the number of elements. char *size; /* For array it is the number of elements.
* For varchar it is the maxsize of the * For varchar it is the maxsize of the
* area. */ * area. */
char *struct_sizeof; /* For a struct this is the sizeof() type char *struct_sizeof; /* For a struct this is the sizeof() type
...@@ -23,17 +23,15 @@ struct ECPGtype ...@@ -23,17 +23,15 @@ struct ECPGtype
{ {
struct ECPGtype *element; /* For an array this is the type struct ECPGtype *element; /* For an array this is the type
* of the element */ * of the element */
struct ECPGstruct_member *members; /* A pointer to a list of members. */
struct ECPGstruct_member *members;
/* A pointer to a list of members. */
} u; } u;
}; };
/* Everything is malloced. */ /* Everything is malloced. */
void ECPGmake_struct_member(char *, struct ECPGtype *, struct ECPGstruct_member **); void ECPGmake_struct_member(char *, struct ECPGtype *, struct ECPGstruct_member **);
struct ECPGtype *ECPGmake_simple_type(enum ECPGttype, long); struct ECPGtype *ECPGmake_simple_type(enum ECPGttype, char *);
struct ECPGtype *ECPGmake_varchar_type(enum ECPGttype, long); struct ECPGtype *ECPGmake_varchar_type(enum ECPGttype, long);
struct ECPGtype *ECPGmake_array_type(struct ECPGtype *, long); struct ECPGtype *ECPGmake_array_type(struct ECPGtype *, char *);
struct ECPGtype *ECPGmake_struct_type(struct ECPGstruct_member *, enum ECPGttype, char *); struct ECPGtype *ECPGmake_struct_type(struct ECPGstruct_member *, enum ECPGttype, char *);
struct ECPGstruct_member *ECPGstruct_member_dup(struct ECPGstruct_member *); struct ECPGstruct_member *ECPGstruct_member_dup(struct ECPGstruct_member *);
...@@ -51,7 +49,9 @@ void ECPGfree_type(struct ECPGtype *); ...@@ -51,7 +49,9 @@ void ECPGfree_type(struct ECPGtype *);
size is the maxsize in case it is a varchar. Otherwise it is the size of size is the maxsize in case it is a varchar. Otherwise it is the size of
the variable (required to do array fetches of structs). the variable (required to do array fetches of structs).
*/ */
void ECPGdump_a_type(FILE *, const char *, struct ECPGtype *, const char *, struct ECPGtype *, const char *, const char *, const long, const char *, const char *); void ECPGdump_a_type(FILE *, const char *, struct ECPGtype *, const char *,
struct ECPGtype *, const char *, const char *, char *,
const char *, const char *);
/* A simple struct to keep a variable and its type. */ /* A simple struct to keep a variable and its type. */
struct ECPGtemp_type struct ECPGtemp_type
...@@ -83,8 +83,8 @@ struct when ...@@ -83,8 +83,8 @@ struct when
struct index struct index
{ {
int index1; char *index1;
int index2; char *index2;
char *str; char *str;
}; };
...@@ -92,8 +92,8 @@ struct this_type ...@@ -92,8 +92,8 @@ struct this_type
{ {
enum ECPGttype type_enum; enum ECPGttype type_enum;
char *type_str; char *type_str;
int type_dimension; char *type_dimension;
int type_index; char *type_index;
char *type_sizeof; char *type_sizeof;
}; };
......
...@@ -298,22 +298,22 @@ get_typedef(char *name) ...@@ -298,22 +298,22 @@ get_typedef(char *name)
} }
void void
adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dimension, int type_index, int pointer_len) adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *type_dimension, char *type_index, int pointer_len)
{ {
if (type_index >= 0) if (atoi(type_index) >= 0)
{ {
if (*length >= 0) if (atoi(*length) >= 0)
mmerror(PARSE_ERROR, ET_FATAL, "No multi-dimensional array support"); mmerror(PARSE_ERROR, ET_FATAL, "No multi-dimensional array support");
*length = type_index; *length = type_index;
} }
if (type_dimension >= 0) if (atoi(type_dimension) >= 0)
{ {
if (*dimension >= 0 && *length >= 0) if (atoi(*dimension) >= 0 && atoi(*length) >= 0)
mmerror(PARSE_ERROR, ET_FATAL, "No multi-dimensional array support"); mmerror(PARSE_ERROR, ET_FATAL, "No multi-dimensional array support");
if (*dimension >= 0) if (atoi(*dimension) >= 0)
*length = *dimension; *length = *dimension;
*dimension = type_dimension; *dimension = type_dimension;
...@@ -328,10 +328,10 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim ...@@ -328,10 +328,10 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
if (pointer_len > 1 && type_enum != ECPGt_char && type_enum != ECPGt_unsigned_char) if (pointer_len > 1 && type_enum != ECPGt_char && type_enum != ECPGt_unsigned_char)
mmerror(PARSE_ERROR, ET_FATAL, "No pointer to pointer supported for this type"); mmerror(PARSE_ERROR, ET_FATAL, "No pointer to pointer supported for this type");
if (pointer_len > 1 && (*length >= 0 || *dimension >= 0)) if (pointer_len > 1 && (atoi(*length) >= 0 || atoi(*dimension) >= 0))
mmerror(PARSE_ERROR, ET_FATAL, "No multi-dimensional array support"); mmerror(PARSE_ERROR, ET_FATAL, "No multi-dimensional array support");
if (*length >= 0 && *dimension >= 0 && pointer_len) if (atoi(*length) >= 0 && atoi(*dimension) >= 0 && pointer_len)
mmerror(PARSE_ERROR, ET_FATAL, "No multi-dimensional array support"); mmerror(PARSE_ERROR, ET_FATAL, "No multi-dimensional array support");
switch (type_enum) switch (type_enum)
...@@ -342,23 +342,23 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim ...@@ -342,23 +342,23 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
if (pointer_len) if (pointer_len)
{ {
*length = *dimension; *length = *dimension;
*dimension = 0; *dimension = make_str("0");
} }
if (*length >= 0) if (atoi(*length) >= 0)
mmerror(PARSE_ERROR, ET_FATAL, "No multi-dimensional array support for structures"); mmerror(PARSE_ERROR, ET_FATAL, "No multi-dimensional array support for structures");
break; break;
case ECPGt_varchar: case ECPGt_varchar:
/* pointer has to get dimension 0 */ /* pointer has to get dimension 0 */
if (pointer_len) if (pointer_len)
*dimension = 0; *dimension = make_str("0");
/* one index is the string length */ /* one index is the string length */
if (*length < 0) if (atoi(*length) < 0)
{ {
*length = *dimension; *length = *dimension;
*dimension = -1; *dimension = make_str("-1");
} }
break; break;
...@@ -367,19 +367,19 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim ...@@ -367,19 +367,19 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
/* char ** */ /* char ** */
if (pointer_len == 2) if (pointer_len == 2)
{ {
*length = *dimension = 0; *length = *dimension = make_str("0");
break; break;
} }
/* pointer has to get length 0 */ /* pointer has to get length 0 */
if (pointer_len == 1) if (pointer_len == 1)
*length = 0; *length = make_str("0");
/* one index is the string length */ /* one index is the string length */
if (*length < 0) if (atoi(*length) < 0)
{ {
*length = (*dimension < 0) ? 1 : *dimension; *length = (atoi(*dimension) < 0) ? make_str("1") : *dimension;
*dimension = -1; *dimension = make_str("-1");
} }
break; break;
default: default:
...@@ -387,10 +387,10 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim ...@@ -387,10 +387,10 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
if (pointer_len) if (pointer_len)
{ {
*length = *dimension; *length = *dimension;
*dimension = 0; *dimension = make_str("0");
} }
if (*length >= 0) if (atoi(*length) >= 0)
mmerror(PARSE_ERROR, ET_FATAL, "No multi-dimensional array support for simple data types"); mmerror(PARSE_ERROR, ET_FATAL, "No multi-dimensional array support for simple data types");
break; break;
......
...@@ -9,7 +9,8 @@ typedef char* c; ...@@ -9,7 +9,8 @@ typedef char* c;
exec sql type ind is union { int integer; short smallint; }; exec sql type ind is union { int integer; short smallint; };
typedef union { int integer; short smallint; } ind; typedef union { int integer; short smallint; } ind;
exec sql type str is varchar[8]; #define BUFSIZ 8
exec sql type str is varchar[BUFSIZ];
int int
main () main ()
......
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