Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1fbb06d

Browse files
author
Michael Meskes
committed
Zoltan beautified his hidden-variable-patch for ecpg. This also makes sure we get an error message instead of a warning if the variable have different types.
1 parentb2bddc2 commit1fbb06d

File tree

4 files changed

+25
-26
lines changed

4 files changed

+25
-26
lines changed

‎src/interfaces/ecpg/preproc/descriptor.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* functions needed for descriptor handling
33
*
4-
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/descriptor.c,v 1.33 2010/04/0108:41:01 meskes Exp $
4+
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/descriptor.c,v 1.34 2010/04/0110:30:53 meskes Exp $
55
*
66
* since descriptor might be either a string constant or a string var
77
* we need to check for a constant if we expect a constant
@@ -188,7 +188,7 @@ output_get_descr(char *desc_name, char *index)
188188
break;
189189
}
190190
fprintf(yyout,"%s,",get_dtype(results->value));
191-
ECPGdump_a_type(yyout,v->name,v->type,NULL,NULL,NULL,NULL,make_str("0"),NULL,NULL,v->brace_level,-1);
191+
ECPGdump_a_type(yyout,v->name,v->type,v->brace_level,NULL,NULL,-1,NULL,NULL,make_str("0"),NULL,NULL);
192192
}
193193
drop_assignments();
194194
fputs("ECPGd_EODT);\n",yyout);
@@ -293,7 +293,7 @@ output_set_descr(char *desc_name, char *index)
293293
caseECPGd_length:
294294
caseECPGd_type:
295295
fprintf(yyout,"%s,",get_dtype(results->value));
296-
ECPGdump_a_type(yyout,v->name,v->type,NULL,NULL,NULL,NULL,make_str("0"),NULL,NULL,v->brace_level,-1);
296+
ECPGdump_a_type(yyout,v->name,v->type,v->brace_level,NULL,NULL,-1,NULL,NULL,make_str("0"),NULL,NULL);
297297
break;
298298

299299
default:

‎src/interfaces/ecpg/preproc/type.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.c,v 1.89 2010/04/0108:41:01 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.c,v 1.90 2010/04/0110:30:53 meskes Exp $ */
22

33
#include"postgres_fe.h"
44

@@ -236,12 +236,11 @@ static void ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, c
236236
structECPGtype*type,structECPGtype*ind_type,constchar*prefix,constchar*ind_prefix);
237237

238238
void
239-
ECPGdump_a_type(FILE*o,constchar*name,structECPGtype*type,
240-
constchar*ind_name,structECPGtype*ind_type,
239+
ECPGdump_a_type(FILE*o,constchar*name,structECPGtype*type,constintbrace_level,
240+
constchar*ind_name,structECPGtype*ind_type,constintind_brace_level,
241241
constchar*prefix,constchar*ind_prefix,
242242
char*arr_str_siz,constchar*struct_sizeof,
243-
constchar*ind_struct_sizeof,
244-
constintbrace_level,constintind_brace_level)
243+
constchar*ind_struct_sizeof)
245244
{
246245
structvariable*var;
247246

@@ -251,28 +250,29 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type,
251250
{
252251
char*str;
253252

254-
str=strdup(name);
253+
str=mm_strdup(name);
255254
var=find_variable(str);
256255
free(str);
257256

258257
if ((var->type->type!=type->type)||
259258
(var->type->type_name&& !type->type_name)||
260259
(!var->type->type_name&&type->type_name)||
261260
(var->type->type_name&&type->type_name&&strcmp(var->type->type_name,type->type_name)))
262-
mmerror(PARSE_ERROR,ET_WARNING,"variable (%s) is hidden by a local variable of a different type",name);
261+
mmerror(PARSE_ERROR,ET_FATAL,"variable (%s) is hidden by a local variable of a different type",name);
263262
elseif (var->brace_level!=brace_level)
264263
mmerror(PARSE_ERROR,ET_WARNING,"variable (%s) is hidden by a local variable",name);
265264

266265
if (ind_name&&ind_type&&ind_type->type!=ECPGt_NO_INDICATOR&&ind_brace_level >=0)
267266
{
268-
str=strdup(ind_name);
267+
str=mm_strdup(ind_name);
269268
var=find_variable(str);
270269
free(str);
270+
271271
if ((var->type->type!=ind_type->type)||
272272
(var->type->type_name&& !ind_type->type_name)||
273273
(!var->type->type_name&&ind_type->type_name)||
274274
(var->type->type_name&&ind_type->type_name&&strcmp(var->type->type_name,ind_type->type_name)))
275-
mmerror(PARSE_ERROR,ET_WARNING,"indicator variable (%s) is hidden by a local variable of a different type",ind_name);
275+
mmerror(PARSE_ERROR,ET_FATAL,"indicator variable (%s) is hidden by a local variable of a different type",ind_name);
276276
elseif (var->brace_level!=ind_brace_level)
277277
mmerror(PARSE_ERROR,ET_WARNING,"indicator variable (%s) is hidden by a local variable",ind_name);
278278
}
@@ -535,12 +535,12 @@ ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, char *arrsiz,
535535

536536
for (p=type->u.members;p;p=p->next)
537537
{
538-
ECPGdump_a_type(o,p->name,p->type,
538+
ECPGdump_a_type(o,p->name,p->type,-1,
539539
(ind_p!=NULL) ?ind_p->name :NULL,
540540
(ind_p!=NULL) ?ind_p->type :NULL,
541+
-1,
541542
prefix,ind_prefix,arrsiz,type->struct_sizeof,
542-
(ind_p!=NULL) ?ind_type->struct_sizeof :NULL,
543-
-1,-1);
543+
(ind_p!=NULL) ?ind_type->struct_sizeof :NULL);
544544
if (ind_p!=NULL&&ind_p!=&struct_no_indicator)
545545
ind_p=ind_p->next;
546546
}

‎src/interfaces/ecpg/preproc/type.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.h,v 1.55 2010/04/0108:41:01 meskes Exp $
2+
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.h,v 1.56 2010/04/0110:30:53 meskes Exp $
33
*/
44
#ifndef_ECPG_PREPROC_TYPE_H
55
#define_ECPG_PREPROC_TYPE_H
@@ -55,10 +55,10 @@ voidECPGfree_type(struct ECPGtype *);
5555
size is the maxsize in case it is a varchar. Otherwise it is the size of
5656
the variable (required to do array fetches of structs).
5757
*/
58-
voidECPGdump_a_type(FILE*,constchar*,structECPGtype*,
59-
constchar*,structECPGtype*,constchar*,
60-
constchar*,char*,constchar*,constchar*,
61-
constint,constint);
58+
voidECPGdump_a_type(FILE*,constchar*,structECPGtype*,constint,
59+
constchar*,structECPGtype*,constint,
60+
constchar*,constchar*,char*,
61+
constchar*,constchar*);
6262

6363
/* A simple struct to keep a variable and its type. */
6464
structECPGtemp_type

‎src/interfaces/ecpg/preproc/variable.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/variable.c,v 1.55 2010/04/0108:41:01 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/variable.c,v 1.56 2010/04/0110:30:53 meskes Exp $ */
22

33
#include"postgres_fe.h"
44

@@ -22,7 +22,7 @@ new_variable(const char *name, struct ECPGtype * type, int brace_level)
2222
}
2323

2424
staticstructvariable*
25-
find_struct_member(constchar*name,char*str,structECPGstruct_member*members,intbrace_level)
25+
find_struct_member(char*name,char*str,structECPGstruct_member*members,intbrace_level)
2626
{
2727
char*next=strpbrk(++str,".-["),
2828
*end,
@@ -444,10 +444,9 @@ dump_variables(struct arguments * list, int mode)
444444
dump_variables(list->next,mode);
445445

446446
/* Then the current element and its indicator */
447-
ECPGdump_a_type(yyout,list->variable->name,list->variable->type,
448-
list->indicator->name,list->indicator->type,
449-
NULL,NULL,make_str("0"),NULL,NULL,
450-
list->variable->brace_level,list->indicator->brace_level);
447+
ECPGdump_a_type(yyout,list->variable->name,list->variable->type,list->variable->brace_level,
448+
list->indicator->name,list->indicator->type,list->indicator->brace_level,
449+
NULL,NULL,make_str("0"),NULL,NULL);
451450

452451
/* Then release the list element. */
453452
if (mode!=0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp