aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/ecpg/preproc
diff options
context:
space:
mode:
Diffstat (limited to 'src/interfaces/ecpg/preproc')
-rw-r--r--src/interfaces/ecpg/preproc/ecpg.c6
-rw-r--r--src/interfaces/ecpg/preproc/type.c76
-rw-r--r--src/interfaces/ecpg/preproc/variable.c5
3 files changed, 66 insertions, 21 deletions
diff --git a/src/interfaces/ecpg/preproc/ecpg.c b/src/interfaces/ecpg/preproc/ecpg.c
index cd110f6b488..339ca8821ab 100644
--- a/src/interfaces/ecpg/preproc/ecpg.c
+++ b/src/interfaces/ecpg/preproc/ecpg.c
@@ -138,7 +138,11 @@ main(int argc, char *const argv[])
progname = get_progname(argv[0]);
- find_my_exec(argv[0], my_exec_path);
+ if (find_my_exec(argv[0], my_exec_path) < 0)
+ {
+ fprintf(stderr, _("%s: could not locate my own executable path\n"), argv[0]);
+ return (ILLEGAL_OPTION);
+ }
output_filename = NULL;
while ((c = getopt_long(argc, argv, "vcio:I:tD:dC:r:h?", ecpg_options, NULL)) != -1)
diff --git a/src/interfaces/ecpg/preproc/type.c b/src/interfaces/ecpg/preproc/type.c
index c24b4c2fbcd..2982cb62049 100644
--- a/src/interfaces/ecpg/preproc/type.c
+++ b/src/interfaces/ecpg/preproc/type.c
@@ -308,7 +308,11 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const int bra
if (ind_type != NULL)
{
if (ind_type->type == ECPGt_NO_INDICATOR)
- ECPGdump_a_simple(o, ind_name, ind_type->type, ind_type->size, mm_strdup("-1"), NULL, ind_prefix, 0);
+ {
+ char *str_neg_one = mm_strdup("-1");
+ ECPGdump_a_simple(o, ind_name, ind_type->type, ind_type->size, str_neg_one, NULL, ind_prefix, 0);
+ free(str_neg_one);
+ }
else
{
ECPGdump_a_simple(o, ind_name, ind_type->u.element->type,
@@ -318,37 +322,71 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, const int bra
}
break;
case ECPGt_struct:
- if (indicator_set && ind_type->type != ECPGt_struct)
- mmfatal(INDICATOR_NOT_STRUCT, "indicator for struct has to be a struct");
+ {
+ char *str_one = mm_strdup("1");
- ECPGdump_a_struct(o, name, ind_name, mm_strdup("1"), type, ind_type, prefix, ind_prefix);
+ if (indicator_set && ind_type->type != ECPGt_struct)
+ mmfatal(INDICATOR_NOT_STRUCT, "indicator for struct has to be a struct");
+
+ ECPGdump_a_struct(o, name, ind_name, str_one, type, ind_type, prefix, ind_prefix);
+ free(str_one);
+ }
break;
case ECPGt_union: /* cannot dump a complete union */
base_yyerror("type of union has to be specified");
break;
case ECPGt_char_variable:
- if (indicator_set && (ind_type->type == ECPGt_struct || ind_type->type == ECPGt_array))
- mmfatal(INDICATOR_NOT_SIMPLE, "indicator for simple data type has to be simple");
+ {
+ /* Allocate for each, as there are code-paths where the values get stomped on. */
+ char *str_varchar_one = mm_strdup("1");
+ char *str_arr_one = mm_strdup("1");
+ char *str_neg_one = mm_strdup("-1");
+
+ if (indicator_set && (ind_type->type == ECPGt_struct || ind_type->type == ECPGt_array))
+ mmfatal(INDICATOR_NOT_SIMPLE, "indicator for simple data type has to be simple");
- ECPGdump_a_simple(o, name, type->type, mm_strdup("1"), (arr_str_siz && strcmp(arr_str_siz, "0") != 0) ? arr_str_siz : mm_strdup("1"), struct_sizeof, prefix, 0);
- if (ind_type != NULL)
- ECPGdump_a_simple(o, ind_name, ind_type->type, ind_type->size, (arr_str_siz && strcmp(arr_str_siz, "0") != 0) ? arr_str_siz : mm_strdup("-1"), ind_struct_sizeof, ind_prefix, 0);
+ ECPGdump_a_simple(o, name, type->type, str_varchar_one, (arr_str_siz && strcmp(arr_str_siz, "0") != 0) ? arr_str_siz : str_arr_one, struct_sizeof, prefix, 0);
+ if (ind_type != NULL)
+ ECPGdump_a_simple(o, ind_name, ind_type->type, ind_type->size, (arr_str_siz && strcmp(arr_str_siz, "0") != 0) ? arr_str_siz : str_neg_one, ind_struct_sizeof, ind_prefix, 0);
+
+ free(str_varchar_one);
+ free(str_arr_one);
+ free(str_neg_one);
+ }
break;
case ECPGt_descriptor:
- if (indicator_set && (ind_type->type == ECPGt_struct || ind_type->type == ECPGt_array))
- mmfatal(INDICATOR_NOT_SIMPLE, "indicator for simple data type has to be simple");
+ {
+ /* Allocate for each, as there are code-paths where the values get stomped on. */
+ char *str_neg_one = mm_strdup("-1");
+ char *ind_type_neg_one = mm_strdup("-1");
+
+ if (indicator_set && (ind_type->type == ECPGt_struct || ind_type->type == ECPGt_array))
+ mmfatal(INDICATOR_NOT_SIMPLE, "indicator for simple data type has to be simple");
- ECPGdump_a_simple(o, name, type->type, NULL, mm_strdup("-1"), NULL, prefix, 0);
- if (ind_type != NULL)
- ECPGdump_a_simple(o, ind_name, ind_type->type, ind_type->size, mm_strdup("-1"), NULL, ind_prefix, 0);
+ ECPGdump_a_simple(o, name, type->type, NULL, str_neg_one, NULL, prefix, 0);
+ if (ind_type != NULL)
+ ECPGdump_a_simple(o, ind_name, ind_type->type, ind_type->size, ind_type_neg_one, NULL, ind_prefix, 0);
+
+ free(str_neg_one);
+ free(ind_type_neg_one);
+ }
break;
default:
- if (indicator_set && (ind_type->type == ECPGt_struct || ind_type->type == ECPGt_array))
- mmfatal(INDICATOR_NOT_SIMPLE, "indicator for simple data type has to be simple");
+ {
+ /* Allocate for each, as there are code-paths where the values get stomped on. */
+ char *str_neg_one = mm_strdup("-1");
+ char *ind_type_neg_one = mm_strdup("-1");
+
+ if (indicator_set && (ind_type->type == ECPGt_struct || ind_type->type == ECPGt_array))
+ mmfatal(INDICATOR_NOT_SIMPLE, "indicator for simple data type has to be simple");
- ECPGdump_a_simple(o, name, type->type, type->size, (arr_str_siz && strcmp(arr_str_siz, "0") != 0) ? arr_str_siz : mm_strdup("-1"), struct_sizeof, prefix, type->counter);
- if (ind_type != NULL)
- ECPGdump_a_simple(o, ind_name, ind_type->type, ind_type->size, (arr_str_siz && strcmp(arr_str_siz, "0") != 0) ? arr_str_siz : mm_strdup("-1"), ind_struct_sizeof, ind_prefix, 0);
+ ECPGdump_a_simple(o, name, type->type, type->size, (arr_str_siz && strcmp(arr_str_siz, "0") != 0) ? arr_str_siz : str_neg_one, struct_sizeof, prefix, type->counter);
+ if (ind_type != NULL)
+ ECPGdump_a_simple(o, ind_name, ind_type->type, ind_type->size, (arr_str_siz && strcmp(arr_str_siz, "0") != 0) ? arr_str_siz : ind_type_neg_one, ind_struct_sizeof, ind_prefix, 0);
+
+ free(str_neg_one);
+ free(ind_type_neg_one);
+ }
break;
}
}
diff --git a/src/interfaces/ecpg/preproc/variable.c b/src/interfaces/ecpg/preproc/variable.c
index cc923a797bc..d762286b94f 100644
--- a/src/interfaces/ecpg/preproc/variable.c
+++ b/src/interfaces/ecpg/preproc/variable.c
@@ -437,6 +437,7 @@ remove_variable_from_list(struct arguments ** list, struct variable * var)
void
dump_variables(struct arguments * list, int mode)
{
+ char *str_zero = mm_strdup("0");
if (list == NULL)
return;
@@ -450,11 +451,13 @@ dump_variables(struct arguments * list, int mode)
/* Then the current element and its indicator */
ECPGdump_a_type(yyout, list->variable->name, list->variable->type, list->variable->brace_level,
list->indicator->name, list->indicator->type, list->indicator->brace_level,
- NULL, NULL, mm_strdup("0"), NULL, NULL);
+ NULL, NULL, str_zero, NULL, NULL);
/* Then release the list element. */
if (mode != 0)
free(list);
+
+ free(str_zero);
}
void