Enlightenment CVS committal Author : tsauerbeck Project : e17 Module : libs/embryo
Dir : e17/libs/embryo/src/bin Modified Files: embryo_cc_sc.h embryo_cc_sc1.c Log Message: use a temporary file for the intermediate asm output =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/embryo/src/bin/embryo_cc_sc.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- embryo_cc_sc.h 26 Mar 2005 15:21:02 -0000 1.7 +++ embryo_cc_sc.h 26 Mar 2005 16:37:25 -0000 1.8 @@ -9,7 +9,7 @@ * Copyright J.E. Hendrix, 1982, 1983 * Copyright T. Riemersma, 1997-2003 * - * Version: $Id: embryo_cc_sc.h,v 1.7 2005/03/26 15:21:02 tsauerbeck Exp $ + * Version: $Id: embryo_cc_sc.h,v 1.8 2005/03/26 16:37:25 tsauerbeck Exp $ * * This software is provided "as-is", without any express or implied warranty. * In no event will the authors be held liable for any damages arising from @@ -411,7 +411,7 @@ int sc_eofsrc(void *handle); /* output to intermediate (.ASM) file */ - void *sc_openasm(char *filename); /* read/write */ + void *sc_openasm(int fd); /* read/write */ void sc_closeasm(void *handle, int deletefile); void sc_resetasm(void *handle); int sc_writeasm(void *handle, char *str); =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/embryo/src/bin/embryo_cc_sc1.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -3 -r1.22 -r1.23 --- embryo_cc_sc1.c 26 Mar 2005 15:27:14 -0000 1.22 +++ embryo_cc_sc1.c 26 Mar 2005 16:37:25 -0000 1.23 @@ -21,7 +21,7 @@ * must not be misrepresented as being the original software. * 3. This notice may not be removed or altered from any source * distribution. - * Version: $Id: embryo_cc_sc1.c,v 1.22 2005/03/26 15:27:14 tsauerbeck Exp $ + * Version: $Id: embryo_cc_sc1.c,v 1.23 2005/03/26 16:37:25 tsauerbeck Exp $ */ #include <assert.h> #include <ctype.h> @@ -214,9 +214,9 @@ } void * -sc_openasm(char *filename) +sc_openasm(int fd) { - return fopen(filename, "w+"); + return fdopen(fd, "w+"); } void @@ -285,7 +285,7 @@ int sc_compile(int argc, char *argv[]) { - int entry, i, jmpcode; + int entry, i, jmpcode, fd_out; int retcode; char incfname[_MAX_PATH]; char reportname[_MAX_PATH]; @@ -293,6 +293,7 @@ void *inpfmark; char lcl_ctrlchar; int lcl_packstr, lcl_needsemicolon, lcl_tabsize; + char *tmpdir; /* set global variables to their initial value */ binf = NULL; @@ -314,11 +315,17 @@ if (!phopt_init()) error(103); /* insufficient memory */ - setopt(argc, argv, inpfname, outfname, incfname, reportname); - /* set output names that depend on the input name */ - set_extension(outfname, ".asm", TRUE); - strcpy(binfname, outfname); - set_extension(binfname, ".amx", TRUE); + setopt(argc, argv, inpfname, binfname, incfname, reportname); + + /* open the output file */ + tmpdir = getenv("TMPDIR"); + if (!tmpdir) tmpdir = "/tmp"; + + snprintf(outfname, _MAX_PATH, "%s/embryo_cc.asm-tmp-XXXXXX", tmpdir); + fd_out = mkstemp(outfname); + if (fd_out < 0) + error(101, outfname); + setconfig(argv[0]); /* the path to the include files */ lcl_ctrlchar = sc_ctrlchar; lcl_packstr = sc_packstr; @@ -328,7 +335,7 @@ if (inpf == NULL) error(100, inpfname); freading = TRUE; - outf = (FILE *) sc_openasm(outfname); /* first write to assembler + outf = (FILE *) sc_openasm(fd_out); /* first write to assembler * file (may be temporary) */ if (outf == NULL) error(101, outfname); ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs