$NetBSD: patch-ad,v 1.3 2005/02/25 18:31:43 drochner Exp $ --- miscutil.cpp.orig 2001-12-30 21:35:25.000000000 +0100 +++ miscutil.cpp @@ -26,8 +26,12 @@ // #ifdef _MSC_VER // for getcwd ( at least for Visual C++) -#if defined(unix) || defined(__unix__) || defined(_unix) || defined(__unix) || defined(__EMX__) || defined (NetBSD) +#if defined(unix) || defined(__unix__) || defined(_unix) || defined(__unix) || defined(__EMX__) || defined (__NetBSD__) #include +#include +#if defined(BSD) && BSD >= 199306 +#define HAVE_MKSTEMP +#endif #ifdef __hpux // HP-UX does not define getcwd in unistd.h @@ -134,6 +138,17 @@ char *tempnam(const char *, const char * char *full_qualified_tempnam(const char *pref) { +#ifdef HAVE_MKSTEMP + char buf[80]; + int fd; + + /* safer than tempnam(), probably, but, .... */ + sprintf(buf, "/tmp/%sXXXXXX", pref); + if ((fd = mkstemp(buf)) < 0) + return NULL; + close(fd); + return strdup(buf); +#else #if defined (__BCPLUSPLUS__) || defined (__TCPLUSPLUS__) /* borland has a prototype that expects a char * as second arg */ char *filename = tempnam(0, (char *) pref); @@ -161,6 +176,7 @@ char *full_qualified_tempnam(const char return filename; } #endif +#endif } unsigned short hextoint(const char hexchar) @@ -374,7 +390,11 @@ ostream & operator << (ostream & out, co TempFile::TempFile() { +#if 1 + tempFileName = full_qualified_tempnam("pstmp"); +#else tempFileName = tempnam(0, "pstmp"); +#endif // cout << "constructed " << tempFileName << endl; }