PostgreSQL Source Code  git master
variable.c File Reference
#include "postgres_fe.h"
#include "preproc_extern.h"
Include dependency graph for variable.c:

Go to the source code of this file.

Functions

struct variablenew_variable (const char *name, struct ECPGtype *type, int brace_level)
 
static struct variablefind_struct_member (char *name, char *str, struct ECPGstruct_member *members, int brace_level)
 
static struct variablefind_struct (char *name, char *next, char *end)
 
static struct variablefind_simple (char *name)
 
struct variablefind_variable (char *name)
 
void remove_typedefs (int brace_level)
 
void remove_variables (int brace_level)
 
void reset_variables (void)
 
void add_variable_to_head (struct arguments **list, struct variable *var, struct variable *ind)
 
void add_variable_to_tail (struct arguments **list, struct variable *var, struct variable *ind)
 
void remove_variable_from_list (struct arguments **list, struct variable *var)
 
void dump_variables (struct arguments *list, int mode)
 
void check_indicator (struct ECPGtype *var)
 
struct typedefsget_typedef (const char *name, bool noerror)
 
void adjust_array (enum ECPGttype type_enum, char **dimension, char **length, char *type_dimension, char *type_index, int pointer_len, bool type_definition)
 

Variables

static struct variableallvariables = NULL
 
struct argumentsargsinsert = NULL
 
struct argumentsargsresult = NULL
 

Function Documentation

◆ add_variable_to_head()

void add_variable_to_head ( struct arguments **  list,
struct variable var,
struct variable ind 
)

Definition at line 378 of file variable.c.

379 {
380  struct arguments *p = (struct arguments *) mm_alloc(sizeof(struct arguments));
381 
382  p->variable = var;
383  p->indicator = ind;
384  p->next = *list;
385  *list = p;
386 }
void * mm_alloc(size_t size)
Definition: type.c:13
struct variable * indicator
Definition: type.h:187
struct arguments * next
Definition: type.h:188
struct variable * variable
Definition: type.h:186

References arguments::indicator, sort-test::list, mm_alloc(), arguments::next, and arguments::variable.

◆ add_variable_to_tail()

void add_variable_to_tail ( struct arguments **  list,
struct variable var,
struct variable ind 
)

Definition at line 390 of file variable.c.

391 {
392  struct arguments *p,
393  *new = (struct arguments *) mm_alloc(sizeof(struct arguments));
394 
395  for (p = *list; p && p->next; p = p->next);
396 
397  new->variable = var;
398  new->indicator = ind;
399  new->next = NULL;
400 
401  if (p)
402  p->next = new;
403  else
404  *list = new;
405 }

References sort-test::list, mm_alloc(), and arguments::next.

◆ adjust_array()

void adjust_array ( enum ECPGttype  type_enum,
char **  dimension,
char **  length,
char *  type_dimension,
char *  type_index,
int  pointer_len,
bool  type_definition 
)

Definition at line 516 of file variable.c.

517 {
518  if (atoi(type_index) >= 0)
519  {
520  if (atoi(*length) >= 0)
521  mmfatal(PARSE_ERROR, "multidimensional arrays are not supported");
522 
523  *length = type_index;
524  }
525 
526  if (atoi(type_dimension) >= 0)
527  {
528  if (atoi(*dimension) >= 0 && atoi(*length) >= 0)
529  mmfatal(PARSE_ERROR, "multidimensional arrays are not supported");
530 
531  if (atoi(*dimension) >= 0)
532  *length = *dimension;
533 
534  *dimension = type_dimension;
535  }
536 
537  if (pointer_len > 2)
538  mmfatal(PARSE_ERROR, ngettext("multilevel pointers (more than 2 levels) are not supported; found %d level",
539  "multilevel pointers (more than 2 levels) are not supported; found %d levels", pointer_len),
540  pointer_len);
541 
542  if (pointer_len > 1 && type_enum != ECPGt_char && type_enum != ECPGt_unsigned_char && type_enum != ECPGt_string)
543  mmfatal(PARSE_ERROR, "pointer to pointer is not supported for this data type");
544 
545  if (pointer_len > 1 && (atoi(*length) >= 0 || atoi(*dimension) >= 0))
546  mmfatal(PARSE_ERROR, "multidimensional arrays are not supported");
547 
548  if (atoi(*length) >= 0 && atoi(*dimension) >= 0 && pointer_len)
549  mmfatal(PARSE_ERROR, "multidimensional arrays are not supported");
550 
551  switch (type_enum)
552  {
553  case ECPGt_struct:
554  case ECPGt_union:
555  /* pointer has to get dimension 0 */
556  if (pointer_len)
557  {
558  *length = *dimension;
559  *dimension = mm_strdup("0");
560  }
561 
562  if (atoi(*length) >= 0)
563  mmfatal(PARSE_ERROR, "multidimensional arrays for structures are not supported");
564 
565  break;
566  case ECPGt_varchar:
567  case ECPGt_bytea:
568  /* pointer has to get dimension 0 */
569  if (pointer_len)
570  *dimension = mm_strdup("0");
571 
572  /* one index is the string length */
573  if (atoi(*length) < 0)
574  {
575  *length = *dimension;
576  *dimension = mm_strdup("-1");
577  }
578 
579  break;
580  case ECPGt_char:
581  case ECPGt_unsigned_char:
582  case ECPGt_string:
583  /* char ** */
584  if (pointer_len == 2)
585  {
586  *length = *dimension = mm_strdup("0");
587  break;
588  }
589 
590  /* pointer has to get length 0 */
591  if (pointer_len == 1)
592  *length = mm_strdup("0");
593 
594  /* one index is the string length */
595  if (atoi(*length) < 0)
596  {
597  /*
598  * make sure we return length = -1 for arrays without given
599  * bounds
600  */
601  if (atoi(*dimension) < 0 && !type_definition)
602 
603  /*
604  * do not change this for typedefs since it will be
605  * changed later on when the variable is defined
606  */
607  *length = mm_strdup("1");
608  else if (strcmp(*dimension, "0") == 0)
609  *length = mm_strdup("-1");
610  else
611  *length = *dimension;
612 
613  *dimension = mm_strdup("-1");
614  }
615  break;
616  default:
617  /* a pointer has dimension = 0 */
618  if (pointer_len)
619  {
620  *length = *dimension;
621  *dimension = mm_strdup("0");
622  }
623 
624  if (atoi(*length) >= 0)
625  mmfatal(PARSE_ERROR, "multidimensional arrays for simple data types are not supported");
626 
627  break;
628  }
629 }
#define ngettext(s, p, n)
Definition: c.h:1181
@ ECPGt_bytea
Definition: ecpgtype.h:67
@ ECPGt_union
Definition: ecpgtype.h:58
@ ECPGt_varchar
Definition: ecpgtype.h:48
@ ECPGt_struct
Definition: ecpgtype.h:57
@ ECPGt_unsigned_char
Definition: ecpgtype.h:43
@ ECPGt_char
Definition: ecpgtype.h:43
@ ECPGt_string
Definition: ecpgtype.h:65
char * mm_strdup(const char *string)
Definition: type.c:25
void void mmfatal(int error_code, const char *error,...) pg_attribute_printf(2
#define PARSE_ERROR

References ECPGt_bytea, ECPGt_char, ECPGt_string, ECPGt_struct, ECPGt_union, ECPGt_unsigned_char, ECPGt_varchar, mm_strdup(), mmfatal(), ngettext, and PARSE_ERROR.

◆ check_indicator()

void check_indicator ( struct ECPGtype var)

Definition at line 466 of file variable.c.

467 {
468  /* make sure this is a valid indicator variable */
469  switch (var->type)
470  {
471  struct ECPGstruct_member *p;
472 
473  case ECPGt_short:
474  case ECPGt_int:
475  case ECPGt_long:
476  case ECPGt_long_long:
478  case ECPGt_unsigned_int:
479  case ECPGt_unsigned_long:
481  break;
482 
483  case ECPGt_struct:
484  case ECPGt_union:
485  for (p = var->u.members; p; p = p->next)
486  check_indicator(p->type);
487  break;
488 
489  case ECPGt_array:
490  check_indicator(var->u.element);
491  break;
492  default:
493  mmerror(PARSE_ERROR, ET_ERROR, "indicator variable must have an integer type");
494  break;
495  }
496 }
@ ECPGt_long_long
Definition: ecpgtype.h:45
@ ECPGt_short
Definition: ecpgtype.h:43
@ ECPGt_unsigned_short
Definition: ecpgtype.h:43
@ ECPGt_int
Definition: ecpgtype.h:44
@ ECPGt_long
Definition: ecpgtype.h:44
@ ECPGt_array
Definition: ecpgtype.h:56
@ ECPGt_unsigned_long
Definition: ecpgtype.h:44
@ ECPGt_unsigned_long_long
Definition: ecpgtype.h:45
@ ECPGt_unsigned_int
Definition: ecpgtype.h:44
void check_indicator(struct ECPGtype *var)
Definition: variable.c:466
void mmerror(int error_code, enum errortype type, const char *error,...) pg_attribute_printf(3
struct ECPGtype * type
Definition: type.h:13
struct ECPGstruct_member * next
Definition: type.h:14
enum ECPGttype type
Definition: type.h:19
struct ECPGstruct_member * members
Definition: type.h:30
struct ECPGtype * element
Definition: type.h:28
union ECPGtype::@159 u
@ ET_ERROR
Definition: type.h:207

References check_indicator(), ECPGt_array, ECPGt_int, ECPGt_long, ECPGt_long_long, ECPGt_short, ECPGt_struct, ECPGt_union, ECPGt_unsigned_int, ECPGt_unsigned_long, ECPGt_unsigned_long_long, ECPGt_unsigned_short, ECPGtype::element, ET_ERROR, ECPGtype::members, mmerror(), ECPGstruct_member::next, PARSE_ERROR, ECPGstruct_member::type, ECPGtype::type, and ECPGtype::u.

Referenced by check_indicator().

◆ dump_variables()

void dump_variables ( struct arguments list,
int  mode 
)

Definition at line 437 of file variable.c.

438 {
439  char *str_zero;
440 
441  if (list == NULL)
442  return;
443 
444  str_zero = mm_strdup("0");
445 
446  /*
447  * The list is build up from the beginning so lets first dump the end of
448  * the list:
449  */
450 
451  dump_variables(list->next, mode);
452 
453  /* Then the current element and its indicator */
454  ECPGdump_a_type(base_yyout, list->variable->name, list->variable->type, list->variable->brace_level,
455  list->indicator->name, list->indicator->type, list->indicator->brace_level,
456  NULL, NULL, str_zero, NULL, NULL);
457 
458  /* Then release the list element. */
459  if (mode != 0)
460  free(list);
461 
462  free(str_zero);
463 }
#define free(a)
Definition: header.h:65
void dump_variables(struct arguments *list, int mode)
Definition: variable.c:437
static PgChecksumMode mode
Definition: pg_checksums.c:56
FILE * base_yyout
void ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype *type, const int brace_level, const char *ind_name, struct ECPGtype *ind_type, const int ind_brace_level, const char *prefix, const char *ind_prefix, char *arr_str_size, const char *struct_sizeof, const char *ind_struct_sizeof)
Definition: type.c:241

References base_yyout, dump_variables(), ECPGdump_a_type(), free, sort-test::list, mm_strdup(), and mode.

Referenced by dump_variables(), and output_statement().

◆ find_simple()

static struct variable* find_simple ( char *  name)
static

Definition at line 177 of file variable.c.

178 {
179  struct variable *p;
180 
181  for (p = allvariables; p; p = p->next)
182  {
183  if (strcmp(p->name, name) == 0)
184  return p;
185  }
186 
187  return NULL;
188 }
static struct variable * allvariables
Definition: variable.c:7
char * name
Definition: type.h:178
struct variable * next
const char * name

References allvariables, name, variable::name, and variable::next.

Referenced by find_variable().

◆ find_struct()

static struct variable* find_struct ( char *  name,
char *  next,
char *  end 
)
static

Definition at line 126 of file variable.c.

127 {
128  struct variable *p;
129  char c = *next;
130 
131  /* first get the mother structure entry */
132  *next = '\0';
133  p = find_variable(name);
134 
135  if (c == '-')
136  {
137  if (p->type->type != ECPGt_array)
138  mmfatal(PARSE_ERROR, "variable \"%s\" is not a pointer", name);
139 
140  if (p->type->u.element->type != ECPGt_struct && p->type->u.element->type != ECPGt_union)
141  mmfatal(PARSE_ERROR, "variable \"%s\" is not a pointer to a structure or a union", name);
142 
143  /* restore the name, we will need it later */
144  *next = c;
145 
146  return find_struct_member(name, ++end, p->type->u.element->u.members, p->brace_level);
147  }
148  else
149  {
150  if (next == end)
151  {
152  if (p->type->type != ECPGt_struct && p->type->type != ECPGt_union)
153  mmfatal(PARSE_ERROR, "variable \"%s\" is neither a structure nor a union", name);
154 
155  /* restore the name, we will need it later */
156  *next = c;
157 
158  return find_struct_member(name, end, p->type->u.members, p->brace_level);
159  }
160  else
161  {
162  if (p->type->type != ECPGt_array)
163  mmfatal(PARSE_ERROR, "variable \"%s\" is not an array", name);
164 
165  if (p->type->u.element->type != ECPGt_struct && p->type->u.element->type != ECPGt_union)
166  mmfatal(PARSE_ERROR, "variable \"%s\" is not a pointer to a structure or a union", name);
167 
168  /* restore the name, we will need it later */
169  *next = c;
170 
171  return find_struct_member(name, end, p->type->u.element->u.members, p->brace_level);
172  }
173  }
174 }
static int32 next
Definition: blutils.c:221
struct variable * find_variable(char *name)
Definition: variable.c:193
static struct variable * find_struct_member(char *name, char *str, struct ECPGstruct_member *members, int brace_level)
Definition: variable.c:25
char * c
enum ECPGttype type
int brace_level
Definition: type.h:180

References variable::brace_level, ECPGt_array, ECPGt_struct, ECPGt_union, find_struct_member(), find_variable(), mmfatal(), name, next, PARSE_ERROR, and variable::type.

Referenced by find_variable().

◆ find_struct_member()

static struct variable* find_struct_member ( char *  name,
char *  str,
struct ECPGstruct_member members,
int  brace_level 
)
static

Definition at line 25 of file variable.c.

26 {
27  char *next = strpbrk(++str, ".-["),
28  *end,
29  c = '\0';
30 
31  if (next != NULL)
32  {
33  c = *next;
34  *next = '\0';
35  }
36 
37  for (; members; members = members->next)
38  {
39  if (strcmp(members->name, str) == 0)
40  {
41  if (next == NULL)
42  {
43  /* found the end */
44  switch (members->type->type)
45  {
46  case ECPGt_array:
47  return new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->type, members->type->u.element->size, members->type->u.element->counter), members->type->size), brace_level);
48  case ECPGt_struct:
49  case ECPGt_union:
50  return new_variable(name, ECPGmake_struct_type(members->type->u.members, members->type->type, members->type->type_name, members->type->struct_sizeof), brace_level);
51  default:
52  return new_variable(name, ECPGmake_simple_type(members->type->type, members->type->size, members->type->counter), brace_level);
53  }
54  }
55  else
56  {
57  *next = c;
58  if (c == '[')
59  {
60  int count;
61 
62  /*
63  * We don't care about what's inside the array braces so
64  * just eat up the character
65  */
66  for (count = 1, end = next + 1; count; end++)
67  {
68  switch (*end)
69  {
70  case '[':
71  count++;
72  break;
73  case ']':
74  count--;
75  break;
76  default:
77  break;
78  }
79  }
80  }
81  else
82  end = next;
83 
84  switch (*end)
85  {
86  case '\0': /* found the end, but this time it has to be
87  * an array element */
88  if (members->type->type != ECPGt_array)
89  mmfatal(PARSE_ERROR, "incorrectly formed variable \"%s\"", name);
90 
91  switch (members->type->u.element->type)
92  {
93  case ECPGt_array:
94  return new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->u.element->type, members->type->u.element->u.element->size, members->type->u.element->u.element->counter), members->type->u.element->size), brace_level);
95  case ECPGt_struct:
96  case ECPGt_union:
97  return new_variable(name, ECPGmake_struct_type(members->type->u.element->u.members, members->type->u.element->type, members->type->u.element->type_name, members->type->u.element->struct_sizeof), brace_level);
98  default:
99  return new_variable(name, ECPGmake_simple_type(members->type->u.element->type, members->type->u.element->size, members->type->u.element->counter), brace_level);
100  }
101  break;
102  case '-':
103  if (members->type->type == ECPGt_array)
104  return find_struct_member(name, ++end, members->type->u.element->u.members, brace_level);
105  else
106  return find_struct_member(name, ++end, members->type->u.members, brace_level);
107  break;
108  case '.':
109  if (members->type->type == ECPGt_array)
110  return find_struct_member(name, end, members->type->u.element->u.members, brace_level);
111  else
112  return find_struct_member(name, end, members->type->u.members, brace_level);
113  break;
114  default:
115  mmfatal(PARSE_ERROR, "incorrectly formed variable \"%s\"", name);
116  break;
117  }
118  }
119  }
120  }
121 
122  return NULL;
123 }
const char * str
struct variable * new_variable(const char *name, struct ECPGtype *type, int brace_level)
Definition: variable.c:10
char * name
Definition: type.h:12
char * type_name
Definition: type.h:20
char * struct_sizeof
Definition: type.h:24
char * size
Definition: type.h:22
int counter
Definition: type.h:32
struct ECPGtype * ECPGmake_array_type(struct ECPGtype *type, char *size)
Definition: type.c:111
struct ECPGtype * ECPGmake_simple_type(enum ECPGttype type, char *size, int counter)
Definition: type.c:96
struct ECPGtype * ECPGmake_struct_type(struct ECPGstruct_member *rm, enum ECPGttype type, char *type_name, char *struct_sizeof)
Definition: type.c:121

References variable::brace_level, ECPGtype::counter, ECPGmake_array_type(), ECPGmake_simple_type(), ECPGmake_struct_type(), ECPGt_array, ECPGt_struct, ECPGt_union, ECPGtype::element, ECPGtype::members, mmfatal(), name, ECPGstruct_member::name, new_variable(), next, ECPGstruct_member::next, PARSE_ERROR, ECPGtype::size, str, ECPGtype::struct_sizeof, ECPGstruct_member::type, ECPGtype::type, ECPGtype::type_name, and ECPGtype::u.

Referenced by find_struct().

◆ find_variable()

struct variable* find_variable ( char *  name)

Definition at line 193 of file variable.c.

194 {
195  char *next,
196  *end;
197  struct variable *p;
198  int count;
199 
200  next = strpbrk(name, ".[-");
201  if (next)
202  {
203  if (*next == '[')
204  {
205  /*
206  * We don't care about what's inside the array braces so just eat
207  * up the characters
208  */
209  for (count = 1, end = next + 1; count; end++)
210  {
211  switch (*end)
212  {
213  case '[':
214  count++;
215  break;
216  case ']':
217  count--;
218  break;
219  default:
220  break;
221  }
222  }
223  if (*end == '.')
224  p = find_struct(name, next, end);
225  else
226  {
227  char c = *next;
228 
229  *next = '\0';
230  p = find_simple(name);
231  if (p == NULL)
232  mmfatal(PARSE_ERROR, "variable \"%s\" is not declared", name);
233 
234  *next = c;
235  switch (p->type->u.element->type)
236  {
237  case ECPGt_array:
238  return new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(p->type->u.element->u.element->type, p->type->u.element->u.element->size, p->type->u.element->u.element->counter), p->type->u.element->size), p->brace_level);
239  case ECPGt_struct:
240  case ECPGt_union:
241  return new_variable(name, ECPGmake_struct_type(p->type->u.element->u.members, p->type->u.element->type, p->type->u.element->type_name, p->type->u.element->struct_sizeof), p->brace_level);
242  default:
243  return new_variable(name, ECPGmake_simple_type(p->type->u.element->type, p->type->u.element->size, p->type->u.element->counter), p->brace_level);
244  }
245  }
246  }
247  else
248  p = find_struct(name, next, next);
249  }
250  else
251  p = find_simple(name);
252 
253  if (p == NULL)
254  mmfatal(PARSE_ERROR, "variable \"%s\" is not declared", name);
255 
256  return p;
257 }
static struct variable * find_struct(char *name, char *next, char *end)
Definition: variable.c:126
static struct variable * find_simple(char *name)
Definition: variable.c:177

References variable::brace_level, ECPGmake_array_type(), ECPGmake_simple_type(), ECPGmake_struct_type(), ECPGt_array, ECPGt_struct, ECPGt_union, find_simple(), find_struct(), mmfatal(), name, new_variable(), next, PARSE_ERROR, and variable::type.

Referenced by ECPGdump_a_type(), ECPGnumeric_lvalue(), find_struct(), output_get_descr(), and output_set_descr().

◆ get_typedef()

struct typedefs* get_typedef ( const char *  name,
bool  noerror 
)

Definition at line 499 of file variable.c.

500 {
501  struct typedefs *this;
502 
503  for (this = types; this != NULL; this = this->next)
504  {
505  if (strcmp(this->name, name) == 0)
506  return this;
507  }
508 
509  if (!noerror)
510  mmfatal(PARSE_ERROR, "unrecognized data type name \"%s\"", name);
511 
512  return NULL;
513 }
struct typedefs * types
Definition: ecpg.c:29
Definition: type.h:158

References mmfatal(), name, next, PARSE_ERROR, and types.

◆ new_variable()

struct variable* new_variable ( const char *  name,
struct ECPGtype type,
int  brace_level 
)

Definition at line 10 of file variable.c.

11 {
12  struct variable *p = (struct variable *) mm_alloc(sizeof(struct variable));
13 
14  p->name = mm_strdup(name);
15  p->type = type;
17 
18  p->next = allvariables;
19  allvariables = p;
20 
21  return p;
22 }
const char * type

References allvariables, variable::brace_level, mm_alloc(), mm_strdup(), name, variable::name, variable::next, type, and variable::type.

Referenced by find_struct_member(), and find_variable().

◆ remove_typedefs()

void remove_typedefs ( int  brace_level)

Definition at line 260 of file variable.c.

261 {
262  struct typedefs *p,
263  *prev;
264 
265  for (p = prev = types; p;)
266  {
267  if (p->brace_level >= brace_level)
268  {
269  /* remove it */
270  if (p == types)
271  prev = types = p->next;
272  else
273  prev->next = p->next;
274 
275  if (p->type->type_enum == ECPGt_struct || p->type->type_enum == ECPGt_union)
277  free(p->type);
278  free(p->name);
279  free(p);
280  if (prev == types)
281  p = types;
282  else
283  p = prev ? prev->next : NULL;
284  }
285  else
286  {
287  prev = p;
288  p = prev->next;
289  }
290  }
291 }
enum ECPGttype type_enum
Definition: type.h:123
int brace_level
Definition: type.h:162
char * name
Definition: type.h:159
struct ECPGstruct_member * struct_member_list
Definition: type.h:161
struct typedefs * next
Definition: type.h:163
struct this_type * type
Definition: type.h:160

References typedefs::brace_level, ECPGt_struct, ECPGt_union, free, typedefs::name, typedefs::next, typedefs::struct_member_list, typedefs::type, this_type::type_enum, and types.

◆ remove_variable_from_list()

void remove_variable_from_list ( struct arguments **  list,
struct variable var 
)

Definition at line 408 of file variable.c.

409 {
410  struct arguments *p,
411  *prev = NULL;
412  bool found = false;
413 
414  for (p = *list; p; p = p->next)
415  {
416  if (p->variable == var)
417  {
418  found = true;
419  break;
420  }
421  prev = p;
422  }
423  if (found)
424  {
425  if (prev)
426  prev->next = p->next;
427  else
428  *list = p->next;
429  }
430 }

References sort-test::list, arguments::next, and arguments::variable.

◆ remove_variables()

void remove_variables ( int  brace_level)

Definition at line 294 of file variable.c.

295 {
296  struct variable *p,
297  *prev;
298 
299  for (p = prev = allvariables; p;)
300  {
301  if (p->brace_level >= brace_level)
302  {
303  /* is it still referenced by a cursor? */
304  struct cursor *ptr;
305 
306  for (ptr = cur; ptr != NULL; ptr = ptr->next)
307  {
308  struct arguments *varptr,
309  *prevvar;
310 
311  for (varptr = prevvar = ptr->argsinsert; varptr != NULL; varptr = varptr->next)
312  {
313  if (p == varptr->variable)
314  {
315  /* remove from list */
316  if (varptr == ptr->argsinsert)
317  ptr->argsinsert = varptr->next;
318  else
319  prevvar->next = varptr->next;
320  }
321  }
322  for (varptr = prevvar = ptr->argsresult; varptr != NULL; varptr = varptr->next)
323  {
324  if (p == varptr->variable)
325  {
326  /* remove from list */
327  if (varptr == ptr->argsresult)
328  ptr->argsresult = varptr->next;
329  else
330  prevvar->next = varptr->next;
331  }
332  }
333  }
334 
335  /* remove it */
336  if (p == allvariables)
337  prev = allvariables = p->next;
338  else
339  prev->next = p->next;
340 
341  ECPGfree_type(p->type);
342  free(p->name);
343  free(p);
344  if (prev == allvariables)
345  p = allvariables;
346  else
347  p = prev ? prev->next : NULL;
348  }
349  else
350  {
351  prev = p;
352  p = prev->next;
353  }
354  }
355 }
struct cursor * cur
Definition: ecpg.c:28
Definition: type.h:137
struct arguments * argsinsert
Definition: type.h:143
struct cursor * next
Definition: type.h:147
struct arguments * argsresult
Definition: type.h:145
void ECPGfree_type(struct ECPGtype *type)
Definition: type.c:655

References allvariables, cursor::argsinsert, cursor::argsresult, variable::brace_level, cur, ECPGfree_type(), free, variable::name, variable::next, cursor::next, arguments::next, variable::type, and arguments::variable.

◆ reset_variables()

void reset_variables ( void  )

Definition at line 368 of file variable.c.

369 {
370  argsinsert = NULL;
371  argsresult = NULL;
372 }
struct arguments * argsresult
Definition: variable.c:365
struct arguments * argsinsert
Definition: variable.c:364

References argsinsert, and argsresult.

Referenced by output_statement().

Variable Documentation

◆ allvariables

struct variable* allvariables = NULL
static

Definition at line 7 of file variable.c.

Referenced by find_simple(), new_variable(), and remove_variables().

◆ argsinsert

struct arguments* argsinsert = NULL

Definition at line 364 of file variable.c.

Referenced by output_statement(), and reset_variables().

◆ argsresult

struct arguments* argsresult = NULL

Definition at line 365 of file variable.c.

Referenced by output_statement(), and reset_variables().