Commit 654e1f96 authored by Peter Eisentraut's avatar Peter Eisentraut

Clean up whitespace and indentation in parser and scanner files

These are not touched by pgindent, so clean them up a bit manually.
parent f3ebaad4
...@@ -47,13 +47,13 @@ static NDBOX * write_point_as_box(char *s, int dim); ...@@ -47,13 +47,13 @@ static NDBOX * write_point_as_box(char *s, int dim);
/* Grammar follows */ /* Grammar follows */
%% %%
box: box: O_BRACKET paren_list COMMA paren_list C_BRACKET
O_BRACKET paren_list COMMA paren_list C_BRACKET { {
int dim; int dim;
dim = delim_count($2, ',') + 1; dim = delim_count($2, ',') + 1;
if ( (delim_count($4, ',') + 1) != dim ) { if ((delim_count($4, ',') + 1) != dim)
{
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("bad cube representation"), errmsg("bad cube representation"),
...@@ -73,8 +73,9 @@ box: ...@@ -73,8 +73,9 @@ box:
*((void **)result) = write_box( dim, $2, $4 ); *((void **)result) = write_box( dim, $2, $4 );
} }
|
paren_list COMMA paren_list { | paren_list COMMA paren_list
{
int dim; int dim;
dim = delim_count($1, ',') + 1; dim = delim_count($1, ',') + 1;
...@@ -98,9 +99,9 @@ box: ...@@ -98,9 +99,9 @@ box:
*((void **)result) = write_box( dim, $1, $3 ); *((void **)result) = write_box( dim, $1, $3 );
} }
|
paren_list { | paren_list
{
int dim; int dim;
dim = delim_count($1, ',') + 1; dim = delim_count($1, ',') + 1;
...@@ -116,9 +117,8 @@ box: ...@@ -116,9 +117,8 @@ box:
*((void **)result) = write_point_as_box($1, dim); *((void **)result) = write_point_as_box($1, dim);
} }
| | list
{
list {
int dim; int dim;
dim = delim_count($1, ',') + 1; dim = delim_count($1, ',') + 1;
...@@ -134,20 +134,20 @@ box: ...@@ -134,20 +134,20 @@ box:
} }
; ;
paren_list: paren_list: O_PAREN list C_PAREN
O_PAREN list C_PAREN { {
$$ = $2; $$ = $2;
} }
; ;
list: list: CUBEFLOAT
CUBEFLOAT { {
/* alloc enough space to be sure whole list will fit */ /* alloc enough space to be sure whole list will fit */
$$ = palloc(scanbuflen + 1); $$ = palloc(scanbuflen + 1);
strcpy($$, $1); strcpy($$, $1);
} }
| | list COMMA CUBEFLOAT
list COMMA CUBEFLOAT { {
$$ = $1; $$ = $1;
strcat($$, ","); strcat($$, ",");
strcat($$, $3); strcat($$, $3);
...@@ -172,8 +172,8 @@ delim_count(char *s, char delim) ...@@ -172,8 +172,8 @@ delim_count(char *s, char delim)
static NDBOX * static NDBOX *
write_box(unsigned int dim, char *str1, char *str2) write_box(unsigned int dim, char *str1, char *str2)
{ {
NDBOX * bp; NDBOX *bp;
char * s; char *s;
int i; int i;
int size = offsetof(NDBOX, x[0]) + sizeof(double) * dim * 2; int size = offsetof(NDBOX, x[0]) + sizeof(double) * dim * 2;
...@@ -183,14 +183,16 @@ write_box(unsigned int dim, char *str1, char *str2) ...@@ -183,14 +183,16 @@ write_box(unsigned int dim, char *str1, char *str2)
s = str1; s = str1;
bp->x[i=0] = strtod(s, NULL); bp->x[i=0] = strtod(s, NULL);
while ((s = strchr(s, ',')) != NULL) { while ((s = strchr(s, ',')) != NULL)
{
s++; i++; s++; i++;
bp->x[i] = strtod(s, NULL); bp->x[i] = strtod(s, NULL);
} }
s = str2; s = str2;
bp->x[i=dim] = strtod(s, NULL); bp->x[i=dim] = strtod(s, NULL);
while ((s = strchr(s, ',')) != NULL) { while ((s = strchr(s, ',')) != NULL)
{
s++; i++; s++; i++;
bp->x[i] = strtod(s, NULL); bp->x[i] = strtod(s, NULL);
} }
...@@ -198,14 +200,14 @@ write_box(unsigned int dim, char *str1, char *str2) ...@@ -198,14 +200,14 @@ write_box(unsigned int dim, char *str1, char *str2)
return(bp); return(bp);
} }
static NDBOX * static NDBOX *
write_point_as_box(char *str, int dim) write_point_as_box(char *str, int dim)
{ {
NDBOX * bp; NDBOX *bp;
int i, size; int i,
size;
double x; double x;
char * s = str; char *s = str;
size = offsetof(NDBOX, x[0]) + sizeof(double) * dim * 2; size = offsetof(NDBOX, x[0]) + sizeof(double) * dim * 2;
...@@ -217,7 +219,8 @@ write_point_as_box(char *str, int dim) ...@@ -217,7 +219,8 @@ write_point_as_box(char *str, int dim)
x = strtod(s, NULL); x = strtod(s, NULL);
bp->x[0] = x; bp->x[0] = x;
bp->x[dim] = x; bp->x[dim] = x;
while ((s = strchr(s, ',')) != NULL) { while ((s = strchr(s, ',')) != NULL)
{
s++; i++; s++; i++;
x = strtod(s, NULL); x = strtod(s, NULL);
bp->x[i] = x; bp->x[i] = x;
......
...@@ -20,22 +20,22 @@ ...@@ -20,22 +20,22 @@
#define YYMALLOC palloc #define YYMALLOC palloc
#define YYFREE pfree #define YYFREE pfree
extern int seg_yylex(void); extern int seg_yylex(void);
extern int significant_digits(char *str); /* defined in seg.c */ extern int significant_digits(char *str); /* defined in seg.c */
void seg_yyerror(const char *message); void seg_yyerror(const char *message);
int seg_yyparse(void *result); int seg_yyparse(void *result);
static float seg_atof(char *value); static float seg_atof(char *value);
static char strbuf[25] = { static char strbuf[25] = {
'0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
'0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
'0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
'0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
'0', '0', '0', '0', '\0' '0', '0', '0', '0', '\0'
}; };
%} %}
...@@ -63,8 +63,8 @@ ...@@ -63,8 +63,8 @@
%% %%
range: range: boundary PLUMIN deviation
boundary PLUMIN deviation { {
((SEG *)result)->lower = $1.val - $3.val; ((SEG *)result)->lower = $1.val - $3.val;
((SEG *)result)->upper = $1.val + $3.val; ((SEG *)result)->upper = $1.val + $3.val;
sprintf(strbuf, "%g", ((SEG *)result)->lower); sprintf(strbuf, "%g", ((SEG *)result)->lower);
...@@ -74,8 +74,9 @@ range: ...@@ -74,8 +74,9 @@ range:
((SEG *)result)->l_ext = '\0'; ((SEG *)result)->l_ext = '\0';
((SEG *)result)->u_ext = '\0'; ((SEG *)result)->u_ext = '\0';
} }
|
boundary RANGE boundary { | boundary RANGE boundary
{
((SEG *)result)->lower = $1.val; ((SEG *)result)->lower = $1.val;
((SEG *)result)->upper = $3.val; ((SEG *)result)->upper = $3.val;
if ( ((SEG *)result)->lower > ((SEG *)result)->upper ) { if ( ((SEG *)result)->lower > ((SEG *)result)->upper ) {
...@@ -91,8 +92,9 @@ range: ...@@ -91,8 +92,9 @@ range:
((SEG *)result)->l_ext = ( $1.ext ? $1.ext : '\0' ); ((SEG *)result)->l_ext = ( $1.ext ? $1.ext : '\0' );
((SEG *)result)->u_ext = ( $3.ext ? $3.ext : '\0' ); ((SEG *)result)->u_ext = ( $3.ext ? $3.ext : '\0' );
} }
|
boundary RANGE { | boundary RANGE
{
((SEG *)result)->lower = $1.val; ((SEG *)result)->lower = $1.val;
((SEG *)result)->upper = HUGE_VAL; ((SEG *)result)->upper = HUGE_VAL;
((SEG *)result)->l_sigd = $1.sigd; ((SEG *)result)->l_sigd = $1.sigd;
...@@ -100,8 +102,9 @@ range: ...@@ -100,8 +102,9 @@ range:
((SEG *)result)->l_ext = ( $1.ext ? $1.ext : '\0' ); ((SEG *)result)->l_ext = ( $1.ext ? $1.ext : '\0' );
((SEG *)result)->u_ext = '-'; ((SEG *)result)->u_ext = '-';
} }
|
RANGE boundary { | RANGE boundary
{
((SEG *)result)->lower = -HUGE_VAL; ((SEG *)result)->lower = -HUGE_VAL;
((SEG *)result)->upper = $2.val; ((SEG *)result)->upper = $2.val;
((SEG *)result)->l_sigd = 0; ((SEG *)result)->l_sigd = 0;
...@@ -109,16 +112,17 @@ range: ...@@ -109,16 +112,17 @@ range:
((SEG *)result)->l_ext = '-'; ((SEG *)result)->l_ext = '-';
((SEG *)result)->u_ext = ( $2.ext ? $2.ext : '\0' ); ((SEG *)result)->u_ext = ( $2.ext ? $2.ext : '\0' );
} }
|
boundary { | boundary
{
((SEG *)result)->lower = ((SEG *)result)->upper = $1.val; ((SEG *)result)->lower = ((SEG *)result)->upper = $1.val;
((SEG *)result)->l_sigd = ((SEG *)result)->u_sigd = $1.sigd; ((SEG *)result)->l_sigd = ((SEG *)result)->u_sigd = $1.sigd;
((SEG *)result)->l_ext = ((SEG *)result)->u_ext = ( $1.ext ? $1.ext : '\0' ); ((SEG *)result)->l_ext = ((SEG *)result)->u_ext = ( $1.ext ? $1.ext : '\0' );
} }
; ;
boundary: boundary: SEGFLOAT
SEGFLOAT { {
/* temp variable avoids a gcc 3.3.x bug on Sparc64 */ /* temp variable avoids a gcc 3.3.x bug on Sparc64 */
float val = seg_atof($1); float val = seg_atof($1);
...@@ -126,8 +130,8 @@ boundary: ...@@ -126,8 +130,8 @@ boundary:
$$.sigd = significant_digits($1); $$.sigd = significant_digits($1);
$$.val = val; $$.val = val;
} }
| | EXTENSION SEGFLOAT
EXTENSION SEGFLOAT { {
/* temp variable avoids a gcc 3.3.x bug on Sparc64 */ /* temp variable avoids a gcc 3.3.x bug on Sparc64 */
float val = seg_atof($2); float val = seg_atof($2);
...@@ -137,8 +141,8 @@ boundary: ...@@ -137,8 +141,8 @@ boundary:
} }
; ;
deviation: deviation: SEGFLOAT
SEGFLOAT { {
/* temp variable avoids a gcc 3.3.x bug on Sparc64 */ /* temp variable avoids a gcc 3.3.x bug on Sparc64 */
float val = seg_atof($1); float val = seg_atof($1);
......
...@@ -261,53 +261,111 @@ adjust_outofscope_cursor_vars(struct cursor *cur) ...@@ -261,53 +261,111 @@ adjust_outofscope_cursor_vars(struct cursor *cur)
newvar = ptr->variable; newvar = ptr->variable;
skip_set_var = true; skip_set_var = true;
} }
else if ((ptr->variable->type->type == ECPGt_char_variable) && (!strncmp(ptr->variable->name, "ECPGprepared_statement", strlen("ECPGprepared_statement")))) else if ((ptr->variable->type->type == ECPGt_char_variable)
&& (!strncmp(ptr->variable->name, "ECPGprepared_statement", strlen("ECPGprepared_statement"))))
{ {
newvar = ptr->variable; newvar = ptr->variable;
skip_set_var = true; skip_set_var = true;
} }
else if ((ptr->variable->type->type != ECPGt_varchar && ptr->variable->type->type != ECPGt_char && ptr->variable->type->type != ECPGt_unsigned_char && ptr->variable->type->type != ECPGt_string) && atoi(ptr->variable->type->size) > 1) else if ((ptr->variable->type->type != ECPGt_varchar
&& ptr->variable->type->type != ECPGt_char
&& ptr->variable->type->type != ECPGt_unsigned_char
&& ptr->variable->type->type != ECPGt_string)
&& atoi(ptr->variable->type->size) > 1)
{ {
newvar = new_variable(cat_str(4, mm_strdup("("), mm_strdup(ecpg_type_name(ptr->variable->type->u.element->type)), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, mm_strdup("1"), ptr->variable->type->u.element->counter), ptr->variable->type->size), 0); newvar = new_variable(cat_str(4, mm_strdup("("),
mm_strdup(ecpg_type_name(ptr->variable->type->u.element->type)),
mm_strdup(" *)(ECPGget_var("),
mm_strdup(temp)),
ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type,
mm_strdup("1"),
ptr->variable->type->u.element->counter),
ptr->variable->type->size),
0);
sprintf(temp, "%d, (", ecpg_internal_var++); sprintf(temp, "%d, (", ecpg_internal_var++);
} }
else if ((ptr->variable->type->type == ECPGt_varchar || ptr->variable->type->type == ECPGt_char || ptr->variable->type->type == ECPGt_unsigned_char || ptr->variable->type->type == ECPGt_string) && atoi(ptr->variable->type->size) > 1) else if ((ptr->variable->type->type == ECPGt_varchar
|| ptr->variable->type->type == ECPGt_char
|| ptr->variable->type->type == ECPGt_unsigned_char
|| ptr->variable->type->type == ECPGt_string)
&& atoi(ptr->variable->type->size) > 1)
{ {
newvar = new_variable(cat_str(4, mm_strdup("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->counter), 0); newvar = new_variable(cat_str(4, mm_strdup("("),
mm_strdup(ecpg_type_name(ptr->variable->type->type)),
mm_strdup(" *)(ECPGget_var("),
mm_strdup(temp)),
ECPGmake_simple_type(ptr->variable->type->type,
ptr->variable->type->size,
ptr->variable->type->counter),
0);
if (ptr->variable->type->type == ECPGt_varchar) if (ptr->variable->type->type == ECPGt_varchar)
sprintf(temp, "%d, &(", ecpg_internal_var++); sprintf(temp, "%d, &(", ecpg_internal_var++);
else else
sprintf(temp, "%d, (", ecpg_internal_var++); sprintf(temp, "%d, (", ecpg_internal_var++);
} }
else if (ptr->variable->type->type == ECPGt_struct || ptr->variable->type->type == ECPGt_union) else if (ptr->variable->type->type == ECPGt_struct
|| ptr->variable->type->type == ECPGt_union)
{ {
sprintf(temp, "%d)))", ecpg_internal_var); sprintf(temp, "%d)))", ecpg_internal_var);
newvar = new_variable(cat_str(4, mm_strdup("(*("), mm_strdup(ptr->variable->type->type_name), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->variable->type->u.members, ptr->variable->type->type, ptr->variable->type->type_name, ptr->variable->type->struct_sizeof), 0); newvar = new_variable(cat_str(4, mm_strdup("(*("),
mm_strdup(ptr->variable->type->type_name),
mm_strdup(" *)(ECPGget_var("),
mm_strdup(temp)),
ECPGmake_struct_type(ptr->variable->type->u.members,
ptr->variable->type->type,
ptr->variable->type->type_name,
ptr->variable->type->struct_sizeof),
0);
sprintf(temp, "%d, &(", ecpg_internal_var++); sprintf(temp, "%d, &(", ecpg_internal_var++);
} }
else if (ptr->variable->type->type == ECPGt_array) else if (ptr->variable->type->type == ECPGt_array)
{ {
if (ptr->variable->type->u.element->type == ECPGt_struct || ptr->variable->type->u.element->type == ECPGt_union) if (ptr->variable->type->u.element->type == ECPGt_struct
|| ptr->variable->type->u.element->type == ECPGt_union)
{ {
sprintf(temp, "%d)))", ecpg_internal_var); sprintf(temp, "%d)))", ecpg_internal_var);
newvar = new_variable(cat_str(4, mm_strdup("(*("), mm_strdup(ptr->variable->type->u.element->type_name), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->variable->type->u.element->u.members, ptr->variable->type->u.element->type, ptr->variable->type->u.element->type_name, ptr->variable->type->u.element->struct_sizeof), 0); newvar = new_variable(cat_str(4, mm_strdup("(*("),
mm_strdup(ptr->variable->type->u.element->type_name),
mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)),
ECPGmake_struct_type(ptr->variable->type->u.element->u.members,
ptr->variable->type->u.element->type,
ptr->variable->type->u.element->type_name,
ptr->variable->type->u.element->struct_sizeof),
0);
sprintf(temp, "%d, (", ecpg_internal_var++); sprintf(temp, "%d, (", ecpg_internal_var++);
} }
else else
{ {
newvar = new_variable(cat_str(4, mm_strdup("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, ptr->variable->type->u.element->size, ptr->variable->type->u.element->counter), ptr->variable->type->size), 0); newvar = new_variable(cat_str(4, mm_strdup("("),
mm_strdup(ecpg_type_name(ptr->variable->type->type)),
mm_strdup(" *)(ECPGget_var("),
mm_strdup(temp)),
ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type,
ptr->variable->type->u.element->size,
ptr->variable->type->u.element->counter),
ptr->variable->type->size),
0);
sprintf(temp, "%d, &(", ecpg_internal_var++); sprintf(temp, "%d, &(", ecpg_internal_var++);
} }
} }
else else
{ {
newvar = new_variable(cat_str(4, mm_strdup("*("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->counter), 0); newvar = new_variable(cat_str(4, mm_strdup("*("),
mm_strdup(ecpg_type_name(ptr->variable->type->type)),
mm_strdup(" *)(ECPGget_var("),
mm_strdup(temp)),
ECPGmake_simple_type(ptr->variable->type->type,
ptr->variable->type->size,
ptr->variable->type->counter),
0);
sprintf(temp, "%d, &(", ecpg_internal_var++); sprintf(temp, "%d, &(", ecpg_internal_var++);
} }
/* create call to "ECPGset_var(<counter>, <pointer>. <line number>)" */ /* create call to "ECPGset_var(<counter>, <pointer>. <line number>)" */
if (!skip_set_var) if (!skip_set_var)
result = cat_str(5, result, mm_strdup("ECPGset_var("), mm_strdup(temp), mm_strdup(original_var), mm_strdup("), __LINE__);\n")); result = cat_str(5, result, mm_strdup("ECPGset_var("),
mm_strdup(temp), mm_strdup(original_var),
mm_strdup("), __LINE__);\n"));
/* now the indicator if there is one and it's not a global variable */ /* now the indicator if there is one and it's not a global variable */
if ((ptr->indicator->type->type == ECPGt_NO_INDICATOR) || (ptr->indicator->brace_level == 0)) if ((ptr->indicator->type->type == ECPGt_NO_INDICATOR) || (ptr->indicator->brace_level == 0))
...@@ -320,39 +378,79 @@ adjust_outofscope_cursor_vars(struct cursor *cur) ...@@ -320,39 +378,79 @@ adjust_outofscope_cursor_vars(struct cursor *cur)
original_var = ptr->indicator->name; original_var = ptr->indicator->name;
sprintf(temp, "%d))", ecpg_internal_var); sprintf(temp, "%d))", ecpg_internal_var);
if (ptr->indicator->type->type == ECPGt_struct || ptr->indicator->type->type == ECPGt_union) if (ptr->indicator->type->type == ECPGt_struct
|| ptr->indicator->type->type == ECPGt_union)
{ {
sprintf(temp, "%d)))", ecpg_internal_var); sprintf(temp, "%d)))", ecpg_internal_var);
newind = new_variable(cat_str(4, mm_strdup("(*("), mm_strdup(ptr->indicator->type->type_name), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->indicator->type->u.members, ptr->indicator->type->type, ptr->indicator->type->type_name, ptr->indicator->type->struct_sizeof), 0); newind = new_variable(cat_str(4, mm_strdup("(*("),
mm_strdup(ptr->indicator->type->type_name),
mm_strdup(" *)(ECPGget_var("),
mm_strdup(temp)),
ECPGmake_struct_type(ptr->indicator->type->u.members,
ptr->indicator->type->type,
ptr->indicator->type->type_name,
ptr->indicator->type->struct_sizeof),
0);
sprintf(temp, "%d, &(", ecpg_internal_var++); sprintf(temp, "%d, &(", ecpg_internal_var++);
} }
else if (ptr->indicator->type->type == ECPGt_array) else if (ptr->indicator->type->type == ECPGt_array)
{ {
if (ptr->indicator->type->u.element->type == ECPGt_struct || ptr->indicator->type->u.element->type == ECPGt_union) if (ptr->indicator->type->u.element->type == ECPGt_struct
|| ptr->indicator->type->u.element->type == ECPGt_union)
{ {
sprintf(temp, "%d)))", ecpg_internal_var); sprintf(temp, "%d)))", ecpg_internal_var);
newind = new_variable(cat_str(4, mm_strdup("(*("), mm_strdup(ptr->indicator->type->u.element->type_name), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->indicator->type->u.element->u.members, ptr->indicator->type->u.element->type, ptr->indicator->type->u.element->type_name, ptr->indicator->type->u.element->struct_sizeof), 0); newind = new_variable(cat_str(4, mm_strdup("(*("),
mm_strdup(ptr->indicator->type->u.element->type_name),
mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)),
ECPGmake_struct_type(ptr->indicator->type->u.element->u.members,
ptr->indicator->type->u.element->type,
ptr->indicator->type->u.element->type_name,
ptr->indicator->type->u.element->struct_sizeof),
0);
sprintf(temp, "%d, (", ecpg_internal_var++); sprintf(temp, "%d, (", ecpg_internal_var++);
} }
else else
{ {
newind = new_variable(cat_str(4, mm_strdup("("), mm_strdup(ecpg_type_name(ptr->indicator->type->u.element->type)), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->indicator->type->u.element->type, ptr->indicator->type->u.element->size, ptr->indicator->type->u.element->counter), ptr->indicator->type->size), 0); newind = new_variable(cat_str(4, mm_strdup("("),
mm_strdup(ecpg_type_name(ptr->indicator->type->u.element->type)),
mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)),
ECPGmake_array_type(ECPGmake_simple_type(ptr->indicator->type->u.element->type,
ptr->indicator->type->u.element->size,
ptr->indicator->type->u.element->counter),
ptr->indicator->type->size),
0);
sprintf(temp, "%d, &(", ecpg_internal_var++); sprintf(temp, "%d, &(", ecpg_internal_var++);
} }
} }
else if (atoi(ptr->indicator->type->size) > 1) else if (atoi(ptr->indicator->type->size) > 1)
{ {
newind = new_variable(cat_str(4, mm_strdup("("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->counter), 0); newind = new_variable(cat_str(4, mm_strdup("("),
mm_strdup(ecpg_type_name(ptr->indicator->type->type)),
mm_strdup(" *)(ECPGget_var("),
mm_strdup(temp)),
ECPGmake_simple_type(ptr->indicator->type->type,
ptr->indicator->type->size,
ptr->variable->type->counter),
0);
sprintf(temp, "%d, (", ecpg_internal_var++); sprintf(temp, "%d, (", ecpg_internal_var++);
} }
else else
{ {
newind = new_variable(cat_str(4, mm_strdup("*("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), mm_strdup(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->counter), 0); newind = new_variable(cat_str(4, mm_strdup("*("),
mm_strdup(ecpg_type_name(ptr->indicator->type->type)),
mm_strdup(" *)(ECPGget_var("),
mm_strdup(temp)),
ECPGmake_simple_type(ptr->indicator->type->type,
ptr->indicator->type->size,
ptr->variable->type->counter),
0);
sprintf(temp, "%d, &(", ecpg_internal_var++); sprintf(temp, "%d, &(", ecpg_internal_var++);
} }
/* create call to "ECPGset_var(<counter>, <pointer>. <line number>)" */ /* create call to "ECPGset_var(<counter>, <pointer>. <line number>)" */
result = cat_str(5, result, mm_strdup("ECPGset_var("), mm_strdup(temp), mm_strdup(original_var), mm_strdup("), __LINE__);\n")); result = cat_str(5, result, mm_strdup("ECPGset_var("),
mm_strdup(temp), mm_strdup(original_var),
mm_strdup("), __LINE__);\n"));
} }
add_variable_to_tail(&newlist, newvar, newind); add_variable_to_tail(&newlist, newvar, newind);
...@@ -407,7 +505,8 @@ add_additional_variables(char *name, bool insert) ...@@ -407,7 +505,8 @@ add_additional_variables(char *name, bool insert)
} }
static void static void
add_typedef(char *name, char * dimension, char * length, enum ECPGttype type_enum, char *type_dimension, char *type_index, int initializer, int array) add_typedef(char *name, char *dimension, char *length, enum ECPGttype type_enum,
char *type_dimension, char *type_index, int initializer, int array)
{ {
/* add entry to list */ /* add entry to list */
struct typedefs *ptr, *this; struct typedefs *ptr, *this;
......
...@@ -42,9 +42,8 @@ at: AT connection_object ...@@ -42,9 +42,8 @@ at: AT connection_object
{ {
connection = $2; connection = $2;
/* /*
* Do we have a variable as connection target? * Do we have a variable as connection target? Remove the variable
* Remove the variable from the variable * from the variable list or else it will be used twice.
* list or else it will be used twice
*/ */
if (argsinsert != NULL) if (argsinsert != NULL)
argsinsert = NULL; argsinsert = NULL;
...@@ -242,7 +241,9 @@ opt_options: Op connect_options ...@@ -242,7 +241,9 @@ opt_options: Op connect_options
; ;
connect_options: ColId opt_opt_value connect_options: ColId opt_opt_value
{ $$ = make2_str($1, $2); } {
$$ = make2_str($1, $2);
}
| ColId opt_opt_value Op connect_options | ColId opt_opt_value Op connect_options
{ {
if (strlen($3) == 0) if (strlen($3) == 0)
...@@ -265,7 +266,8 @@ opt_opt_value: /*EMPTY*/ ...@@ -265,7 +266,8 @@ opt_opt_value: /*EMPTY*/
{ $$ = make2_str(mm_strdup("="), $2); } { $$ = make2_str(mm_strdup("="), $2); }
; ;
prepared_name: name { prepared_name: name
{
if ($1[0] == '\"' && $1[strlen($1)-1] == '\"') /* already quoted? */ if ($1[0] == '\"' && $1[strlen($1)-1] == '\"') /* already quoted? */
$$ = $1; $$ = $1;
else /* not quoted => convert to lowercase */ else /* not quoted => convert to lowercase */
...@@ -767,7 +769,10 @@ s_struct_union: SQL_STRUCT ...@@ -767,7 +769,10 @@ s_struct_union: SQL_STRUCT
ECPGstruct_sizeof = mm_strdup(""); /* This must not be NULL to distinguish from simple types. */ ECPGstruct_sizeof = mm_strdup(""); /* This must not be NULL to distinguish from simple types. */
$$ = mm_strdup("struct"); $$ = mm_strdup("struct");
} }
| UNION { $$ = mm_strdup("union"); } | UNION
{
$$ = mm_strdup("union");
}
; ;
simple_type: unsigned_type { $$=$1; } simple_type: unsigned_type { $$=$1; }
...@@ -1163,7 +1168,10 @@ IntConstVar: Iconst ...@@ -1163,7 +1168,10 @@ IntConstVar: Iconst
new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0); new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
$$ = $1; $$ = $1;
} }
| cvariable { $$ = $1; } | cvariable
{
$$ = $1;
}
; ;
desc_header_item: SQL_COUNT { $$ = ECPGd_count; } desc_header_item: SQL_COUNT { $$ = ECPGd_count; }
...@@ -1206,7 +1214,12 @@ AllConstVar: ecpg_fconst ...@@ -1206,7 +1214,12 @@ AllConstVar: ecpg_fconst
new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0); new_variable($1, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
$$ = $1; $$ = $1;
} }
| IntConstVar { $$ = $1; }
| IntConstVar
{
$$ = $1;
}
| '-' ecpg_fconst | '-' ecpg_fconst
{ {
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3); char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
...@@ -1216,6 +1229,7 @@ AllConstVar: ecpg_fconst ...@@ -1216,6 +1229,7 @@ AllConstVar: ecpg_fconst
new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0); new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
$$ = var; $$ = var;
} }
| '-' Iconst | '-' Iconst
{ {
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3); char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
...@@ -1225,6 +1239,7 @@ AllConstVar: ecpg_fconst ...@@ -1225,6 +1239,7 @@ AllConstVar: ecpg_fconst
new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0); new_variable(var, ECPGmake_simple_type(ECPGt_const, length, 0), 0);
$$ = var; $$ = var;
} }
| ecpg_sconst | ecpg_sconst
{ {
char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3); char *length = mm_alloc(sizeof(int) * CHAR_BIT * 10 / 3);
......
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