- copyFile (asmFile, code->oFile);
-
- if (port->genAssemblerEnd) {
- port->genAssemblerEnd(asmFile);
- }
- fclose (asmFile);
-
- rm_tmpfiles ();
-}
-
-
-/** Creates a temporary file with unique file name
- Scans, in order:
- - TMP, TEMP, TMPDIR env. variables
- - if Un*x system: /usr/tmp and /tmp
- - root directory using mkstemp() if available
- - default location using tempnam()
-*/
-static int
-tempfileandname(char *fname, size_t len)
-{
-#define TEMPLATE "sdccXXXXXX"
-#define TEMPLATE_LEN ((sizeof TEMPLATE) - 1)
-
- const char *tmpdir = NULL;
- int fd;
-
- if ((tmpdir = getenv ("TMP")) == NULL)
- if ((tmpdir = getenv ("TEMP")) == NULL)
- tmpdir = getenv ("TMPDIR");
-
-#if defined(_WIN32)
- {
- static int warning_emitted;
-
- if (tmpdir == NULL)
- {
- tmpdir = "c:\\";
- if (!warning_emitted)
- {
- fprintf (stderr, "TMP not defined in environment, using %s for temporary files\n.", tmpdir);
- warning_emitted = 1;
- }
- }
- }
-#else
- {
- /* try with /usr/tmp and /tmp on Un*x systems */
- struct stat statbuf;
-
- if (tmpdir == NULL) {
- if (stat("/usr/tmp", &statbuf) != -1)
- tmpdir = "/usr/tmp";
- else if (stat("/tmp", &statbuf) != -1)
- tmpdir = "/tmp";
- }
- }
-#endif
-
-#ifdef HAVE_MKSTEMP
- {
- char fnamebuf[PATH_MAX];
- size_t name_len;
-
- if (fname == NULL || len == 0) {
- fname = fnamebuf;
- len = sizeof fnamebuf;
- }
-
- if (tmpdir) {
- name_len = strlen(tmpdir) + 1 + TEMPLATE_LEN;
-
- assert(name_len < len);
- if (!(name_len < len)) /* in NDEBUG is defined */
- return -1; /* buffer too small, temporary file can not be created */
-
- sprintf(fname, "%s" DIR_SEPARATOR_STRING TEMPLATE, tmpdir);
- }
- else {
- name_len = TEMPLATE_LEN;
-
- assert(name_len < len);
- if (!(name_len < len)) /* in NDEBUG is defined */
- return -1; /* buffer too small, temporary file can not be created */
-
- strcpy(fname, TEMPLATE);
- }
-
- fd = mkstemp(fname);
- }
-#else
- {
- char *name = tempnam(tmpdir, "sdcc");
+ /* copy over code */
+ fprintf (asmFile, "%s", iComments2);
+ fprintf (asmFile, "; code\n");
+ fprintf (asmFile, "%s", iComments2);
+ tfprintf (asmFile, "\t!areacode\n", options.code_seg);
+ dbuf_write_and_destroy (&code->oBuf, asmFile);