summaryrefslogtreecommitdiff
path: root/legacy/embryo
diff options
context:
space:
mode:
authortsauerbeck <tsauerbeck>2005-03-26 16:37:25 +0000
committertsauerbeck <tsauerbeck@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>2005-03-26 16:37:25 +0000
commitb02572979aa46ecdc9f7d918dd211d4b502c2f78 (patch)
treef596ba155e1e756176b16d70d5c32924ad1c1f4d /legacy/embryo
parent0ba866f5cf0e4e6bc18beb8181d9b53065302d70 (diff)
use a temporary file for the intermediate asm output
SVN revision: 13924
Diffstat (limited to 'legacy/embryo')
-rw-r--r--legacy/embryo/src/bin/embryo_cc_sc.h2
-rw-r--r--legacy/embryo/src/bin/embryo_cc_sc1.c25
2 files changed, 17 insertions, 10 deletions
diff --git a/legacy/embryo/src/bin/embryo_cc_sc.h b/legacy/embryo/src/bin/embryo_cc_sc.h
index d8db1fa826..024c8adb62 100644
--- a/legacy/embryo/src/bin/embryo_cc_sc.h
+++ b/legacy/embryo/src/bin/embryo_cc_sc.h
@@ -411,7 +411,7 @@ typedef struct __s_stringpair
411 int sc_eofsrc(void *handle); 411 int sc_eofsrc(void *handle);
412 412
413/* output to intermediate (.ASM) file */ 413/* output to intermediate (.ASM) file */
414 void *sc_openasm(char *filename); /* read/write */ 414 void *sc_openasm(int fd); /* read/write */
415 void sc_closeasm(void *handle, int deletefile); 415 void sc_closeasm(void *handle, int deletefile);
416 void sc_resetasm(void *handle); 416 void sc_resetasm(void *handle);
417 int sc_writeasm(void *handle, char *str); 417 int sc_writeasm(void *handle, char *str);
diff --git a/legacy/embryo/src/bin/embryo_cc_sc1.c b/legacy/embryo/src/bin/embryo_cc_sc1.c
index e6b82743c1..75c3b712e3 100644
--- a/legacy/embryo/src/bin/embryo_cc_sc1.c
+++ b/legacy/embryo/src/bin/embryo_cc_sc1.c
@@ -214,9 +214,9 @@ sc_eofsrc(void *handle)
214} 214}
215 215
216void * 216void *
217sc_openasm(char *filename) 217sc_openasm(int fd)
218{ 218{
219 return fopen(filename, "w+"); 219 return fdopen(fd, "w+");
220} 220}
221 221
222void 222void
@@ -285,7 +285,7 @@ sc_lengthbin(void *handle)
285int 285int
286sc_compile(int argc, char *argv[]) 286sc_compile(int argc, char *argv[])
287{ 287{
288 int entry, i, jmpcode; 288 int entry, i, jmpcode, fd_out;
289 int retcode; 289 int retcode;
290 char incfname[_MAX_PATH]; 290 char incfname[_MAX_PATH];
291 char reportname[_MAX_PATH]; 291 char reportname[_MAX_PATH];
@@ -293,6 +293,7 @@ sc_compile(int argc, char *argv[])
293 void *inpfmark; 293 void *inpfmark;
294 char lcl_ctrlchar; 294 char lcl_ctrlchar;
295 int lcl_packstr, lcl_needsemicolon, lcl_tabsize; 295 int lcl_packstr, lcl_needsemicolon, lcl_tabsize;
296 char *tmpdir;
296 297
297 /* set global variables to their initial value */ 298 /* set global variables to their initial value */
298 binf = NULL; 299 binf = NULL;
@@ -314,11 +315,17 @@ sc_compile(int argc, char *argv[])
314 if (!phopt_init()) 315 if (!phopt_init())
315 error(103); /* insufficient memory */ 316 error(103); /* insufficient memory */
316 317
317 setopt(argc, argv, inpfname, outfname, incfname, reportname); 318 setopt(argc, argv, inpfname, binfname, incfname, reportname);
318 /* set output names that depend on the input name */ 319
319 set_extension(outfname, ".asm", TRUE); 320 /* open the output file */
320 strcpy(binfname, outfname); 321 tmpdir = getenv("TMPDIR");
321 set_extension(binfname, ".amx", TRUE); 322 if (!tmpdir) tmpdir = "/tmp";
323
324 snprintf(outfname, _MAX_PATH, "%s/embryo_cc.asm-tmp-XXXXXX", tmpdir);
325 fd_out = mkstemp(outfname);
326 if (fd_out < 0)
327 error(101, outfname);
328
322 setconfig(argv[0]); /* the path to the include files */ 329 setconfig(argv[0]); /* the path to the include files */
323 lcl_ctrlchar = sc_ctrlchar; 330 lcl_ctrlchar = sc_ctrlchar;
324 lcl_packstr = sc_packstr; 331 lcl_packstr = sc_packstr;
@@ -328,7 +335,7 @@ sc_compile(int argc, char *argv[])
328 if (inpf == NULL) 335 if (inpf == NULL)
329 error(100, inpfname); 336 error(100, inpfname);
330 freading = TRUE; 337 freading = TRUE;
331 outf = (FILE *) sc_openasm(outfname); /* first write to assembler 338 outf = (FILE *) sc_openasm(fd_out); /* first write to assembler
332 * file (may be temporary) */ 339 * file (may be temporary) */
333 if (outf == NULL) 340 if (outf == NULL)
334 error(101, outfname); 341 error(101, outfname);