|
Lines 278-283
Link Here
|
| 278 |
|
278 |
|
| 279 |
#if !(defined(Lynx) || defined(__Lynx__) || (defined(SVR4) && !defined(sun))) && !defined (__CYGWIN__) |
279 |
#if !(defined(Lynx) || defined(__Lynx__) || (defined(SVR4) && !defined(sun))) && !defined (__CYGWIN__) |
| 280 |
#define HAS_MKSTEMP |
280 |
#define HAS_MKSTEMP |
|
|
281 |
#include <error.h> |
| 282 |
extern const char *__progname; |
| 281 |
#endif |
283 |
#endif |
| 282 |
|
284 |
|
| 283 |
typedef unsigned char boolean; |
285 |
typedef unsigned char boolean; |
|
Lines 426-431
Link Here
|
| 426 |
} else { |
428 |
} else { |
| 427 |
#ifdef HAS_MKSTEMP |
429 |
#ifdef HAS_MKSTEMP |
| 428 |
int fd; |
430 |
int fd; |
|
|
431 |
const char suffix[] = ".XXXXXX"; |
| 432 |
const char *tmp_dir = getenv("TMPDIR")?:"/tmp"; |
| 433 |
unsigned tmp_len = strlen( tmp_dir ); |
| 434 |
unsigned prog_len = strlen( __progname ); |
| 435 |
char tmpbuf[ tmp_len + prog_len + sizeof(suffix) + 1 ]; |
| 436 |
|
| 437 |
memcpy( tmpbuf, tmp_dir, tmp_len ); |
| 438 |
tmpbuf[ tmp_len ] = '/'; |
| 439 |
memcpy( tmpbuf + tmp_len + 1, __progname, prog_len ); |
| 440 |
memcpy( tmpbuf + tmp_len + prog_len + 1, suffix, sizeof(suffix) ); |
| 441 |
|
| 429 |
#endif |
442 |
#endif |
| 430 |
tmpMakefile = Strdup(tmpMakefile); |
443 |
tmpMakefile = Strdup(tmpMakefile); |
| 431 |
#ifndef HAS_MKSTEMP |
444 |
#ifndef HAS_MKSTEMP |
|
Lines 434-440
Link Here
|
| 434 |
LogFatal("Cannot create temporary file %s.", tmpMakefile); |
447 |
LogFatal("Cannot create temporary file %s.", tmpMakefile); |
| 435 |
} |
448 |
} |
| 436 |
#else |
449 |
#else |
| 437 |
fd = mkstemp(tmpMakefile); |
450 |
fd = mkstemp(tmpbuf); |
|
|
451 |
tmpMakefile = strdup(tmpbuf); |
| 438 |
if (fd == -1 || (tmpfd = fdopen(fd, "w+")) == NULL) { |
452 |
if (fd == -1 || (tmpfd = fdopen(fd, "w+")) == NULL) { |
| 439 |
if (fd != -1) { |
453 |
if (fd != -1) { |
| 440 |
unlink(tmpMakefile); close(fd); |
454 |
unlink(tmpMakefile); close(fd); |
|
Lines 1786-1791
Link Here
|
| 1786 |
if (outFile == NULL) { |
1800 |
if (outFile == NULL) { |
| 1787 |
#ifdef HAS_MKSTEMP |
1801 |
#ifdef HAS_MKSTEMP |
| 1788 |
int fd; |
1802 |
int fd; |
|
|
1803 |
const char suffix[] = ".XXXXXX"; |
| 1804 |
const char *tmp_dir = getenv("TMPDIR")?:"/tmp"; |
| 1805 |
unsigned tmp_len = strlen( tmp_dir ); |
| 1806 |
unsigned prog_len = strlen( __progname ); |
| 1807 |
char tmpbuf[ tmp_len + prog_len + sizeof(suffix) + 1 ]; |
| 1808 |
|
| 1809 |
memcpy( tmpbuf, tmp_dir, tmp_len ); |
| 1810 |
tmpbuf[ tmp_len ] = '/'; |
| 1811 |
memcpy( tmpbuf + tmp_len + 1, __progname, prog_len ); |
| 1812 |
memcpy( tmpbuf + tmp_len + prog_len + 1, suffix, sizeof(suffix) ); |
| 1813 |
|
| 1789 |
#endif |
1814 |
#endif |
| 1790 |
tmpImakefile = Strdup(tmpImakefile); |
1815 |
tmpImakefile = Strdup(tmpImakefile); |
| 1791 |
#ifndef HAS_MKSTEMP |
1816 |
#ifndef HAS_MKSTEMP |
|
Lines 1795-1801
Link Here
|
| 1795 |
tmpImakefile); |
1820 |
tmpImakefile); |
| 1796 |
} |
1821 |
} |
| 1797 |
#else |
1822 |
#else |
| 1798 |
fd=mkstemp(tmpImakefile); |
1823 |
fd=mkstemp(tmpbuf); |
|
|
1824 |
tmpImakefile = strdup(tmpbuf); |
| 1799 |
if (fd != -1) |
1825 |
if (fd != -1) |
| 1800 |
outFile = fdopen(fd, "w"); |
1826 |
outFile = fdopen(fd, "w"); |
| 1801 |
if (outFile == NULL) { |
1827 |
if (outFile == NULL) { |