aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/ecpg/preproc/ecpg.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/interfaces/ecpg/preproc/ecpg.c')
-rw-r--r--src/interfaces/ecpg/preproc/ecpg.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/interfaces/ecpg/preproc/ecpg.c b/src/interfaces/ecpg/preproc/ecpg.c
index a97b74e748b..e156468f2b8 100644
--- a/src/interfaces/ecpg/preproc/ecpg.c
+++ b/src/interfaces/ecpg/preproc/ecpg.c
@@ -91,7 +91,7 @@ main(int argc, char *const argv[])
/* after the options there must not be anything but filenames */
for (fnr = optind; fnr < argc; fnr++)
{
- char *ptr2ext;
+ char *output_filename = NULL, *ptr2ext;
input_filename = mm_alloc(strlen(argv[fnr]) + 5);
@@ -113,7 +113,7 @@ main(int argc, char *const argv[])
if (out_option == 0)/* calculate the output name */
{
- char *output_filename = strdup(input_filename);
+ output_filename = strdup(input_filename);
ptr2ext = strrchr(output_filename, '.');
/* make extension = .c */
@@ -128,7 +128,6 @@ main(int argc, char *const argv[])
free(input_filename);
continue;
}
- free(output_filename);
}
yyin = fopen(input_filename, "r");
@@ -136,9 +135,25 @@ main(int argc, char *const argv[])
perror(argv[fnr]);
else
{
+ struct cursor *ptr;
+
/* initialize lex */
lex_init();
-
+
+ /* initialize cursor list */
+ for (ptr = cur; ptr != NULL;)
+ {
+ struct cursor *c;
+
+ free(ptr->name);
+ free(ptr->command);
+ c = ptr;
+ ptr = ptr->next;
+ free(c);
+ }
+
+ cur = NULL;
+
/* we need two includes */
fprintf(yyout, "/* Processed by ecpg (%d.%d.%d) */\n/*These two include files are added by the preprocessor */\n#include <ecpgtype.h>\n#include <ecpglib.h>\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL);
@@ -150,6 +165,10 @@ main(int argc, char *const argv[])
if (out_option == 0)
fclose(yyout);
}
+
+ if (output_filename)
+ free(output_filename);
+
free(input_filename);
}
}