summaryrefslogtreecommitdiff
path: root/Build/source/texk/dviljk/dvi2xx.c
diff options
context:
space:
mode:
authorJoachim Schrod <jschrod@acm.org>2008-02-17 13:34:01 +0000
committerJoachim Schrod <jschrod@acm.org>2008-02-17 13:34:01 +0000
commit5dbcc08b662131c3b8e01e5209456d1f102a4dbc (patch)
treee4ee823d72d08c6240b51457c8ef1e8effeabf3c /Build/source/texk/dviljk/dvi2xx.c
parent6e6be95c64689979c542c342d71b57d77038d7aa (diff)
Better implementation of mkdtemp() if it's not available: Use mktemp()
if it's there; no implicit declaration of mkdir(); no compiler warnings because they don't grok 0 being a pointer. git-svn-id: svn://tug.org/texlive/trunk@6658 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/dviljk/dvi2xx.c')
-rw-r--r--Build/source/texk/dviljk/dvi2xx.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/Build/source/texk/dviljk/dvi2xx.c b/Build/source/texk/dviljk/dvi2xx.c
index f54c5058740..962d7ca7d05 100644
--- a/Build/source/texk/dviljk/dvi2xx.c
+++ b/Build/source/texk/dviljk/dvi2xx.c
@@ -3913,6 +3913,28 @@ char *str;
#endif /* __riscos */
+#ifndef HAVE_MKDTEMP
+/* If mkdtemp() is not available, supply an (unsecure) version of it. We try
+ to use mktemp() to get the temporary directory name, since that maps best
+ to mkdtemp() behavior. But if mktemp() is also not available, we resort
+ to tmpnam() which is supposed to be there from the C standard. */
+#ifndef HAVE_MKTEMP
+#define mktemp tmpnam
+#endif
+char * mkdtemp ( char * template )
+{
+ if ( mktemp(template) == NULL ) {
+ if ( errno == 0 ) errno = EINVAL; /* if it's tmpnam() */
+ return NULL;
+ }
+ if ( mkdir(template, 0700) == -1 ) {
+ return NULL;
+ }
+ return template;
+}
+#endif
+
+
/* interpret a \special command, made up of keyword=value pairs */
#if NeedFunctionPrototypes
void DoSpecial(char *str, int n)
@@ -3925,7 +3947,7 @@ int n;
bool first_keyword = _TRUE;
char xs[STRSIZE], ys[STRSIZE];
char *include_file = NULL;
- enum { None, VerbFile, HPFile, PSFile } file_type;
+ enum { None, VerbFile, HPFile, PSFile } file_type = None;
float x,y;
long4 x_pos, y_pos;
KeyWord k;