From 6e8fe3b03d179f65ca87e0cf744907903e150c5b Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Mon, 25 Mar 2013 18:44:21 +0900 Subject: [PATCH] embryo: use eina_file_mkstemp. --- ChangeLog | 1 + NEWS | 1 + src/bin/embryo/embryo_cc_sc.h | 1 - src/bin/embryo/embryo_cc_sc1.c | 16 ++++------------ src/bin/embryo/embryo_cc_scvars.c | 1 - 5 files changed, 6 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 35443bbca4..2442e7beaf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2013-03-25 Cedric Bail * Eina: add portable eina_file_mkstemp(). + * Embryo: use eina_file_mkstemp(). 2013-03-22 Jiyoun Park (Jypark) diff --git a/NEWS b/NEWS index 655ba53d49..c1931abe60 100644 --- a/NEWS +++ b/NEWS @@ -131,6 +131,7 @@ Improvements: * Evas textblock: Added proper size adjustments for "high" shaped texts. * Use the right macro to disable fcntl. * Edje: use Eina_Cow to reduce memory usage. + * Embryo: use eina_file_mkstemp(). Fixes: * Fix a memory leak in ecore_con_dns when using ecore_con_server_connect diff --git a/src/bin/embryo/embryo_cc_sc.h b/src/bin/embryo/embryo_cc_sc.h index 9eaf6b86e0..965e580942 100644 --- a/src/bin/embryo/embryo_cc_sc.h +++ b/src/bin/embryo/embryo_cc_sc.h @@ -620,7 +620,6 @@ extern constvalue libname_tab; /* library table (#pragma library "..." syntax) * extern constvalue *curlibrary; /* current library */ extern symbol *curfunc; /* pointer to current function */ extern char *inpfname; /* name of the file currently read from */ -extern char outfname[]; /* output file name */ extern char sc_ctrlchar; /* the control character (or escape character) */ extern int litidx; /* index to literal table */ extern int litmax; /* current size of the literal table */ diff --git a/src/bin/embryo/embryo_cc_sc1.c b/src/bin/embryo/embryo_cc_sc1.c index 14b6b1cbc1..dfef9472cd 100644 --- a/src/bin/embryo/embryo_cc_sc1.c +++ b/src/bin/embryo/embryo_cc_sc1.c @@ -267,6 +267,7 @@ sc_compile(int argc, char *argv[]) char lcl_ctrlchar; int lcl_packstr, lcl_needsemicolon, lcl_tabsize; char *tmpdir; + Eina_Tmpstr *outfname; /* set global variables to their initial value */ binf = NULL; @@ -291,16 +292,7 @@ sc_compile(int argc, char *argv[]) setopt(argc, argv, inpfname, binfname, incfname, reportname); /* open the output file */ - -#ifndef HAVE_EVIL - tmpdir = getenv("TMPDIR"); - if (!tmpdir) tmpdir = "/tmp"; -#else - tmpdir = (char *)evil_tmpdir_get(); -#endif /* ! HAVE_EVIL */ - - snprintf(outfname, PATH_MAX, "%s/embryo_cc.asm-tmp-XXXXXX", tmpdir); - fd_out = mkstemp(outfname); + fd_out = eina_file_mkstemp("embryo_cc.asm-tmp-XXXXXX", &outfname); if (fd_out < 0) error(101, outfname); @@ -407,7 +399,8 @@ sc_compile(int argc, char *argv[]) } /* if */ if (outf) sc_closeasm(outf); - unlink (outfname); + unlink(outfname); + eina_tmpstr_del(outfname); if (binf) sc_closebin(binf, errnum != 0); @@ -550,7 +543,6 @@ initglobals(void) sc_rationaltag = 0; /* assume no support for rational numbers */ rational_digits = 0; /* number of fractional digits */ - outfname[0] = '\0'; /* output file name */ inpf = NULL; /* file read from */ inpfname = NULL; /* pointer to name of the file currently * read from */ diff --git a/src/bin/embryo/embryo_cc_scvars.c b/src/bin/embryo/embryo_cc_scvars.c index f369b9b928..0609a9bc33 100644 --- a/src/bin/embryo/embryo_cc_scvars.c +++ b/src/bin/embryo/embryo_cc_scvars.c @@ -45,7 +45,6 @@ constvalue libname_tab = { NULL, "", 0, 0 }; /* library table (#pragma library " constvalue *curlibrary = NULL; /* current library */ symbol *curfunc; /* pointer to current function */ char *inpfname; /* pointer to name of the file currently read from */ -char outfname[PATH_MAX]; /* output file name */ char sc_ctrlchar = CTRL_CHAR; /* the control character (or escape character) */ int litidx = 0; /* index to literal table */ int litmax = sDEF_LITMAX; /* current size of the literal table */