ghostscript/ghostscript-mkstemp64.patch
2007-09-27 11:23:56 +00:00

167 lines
5.1 KiB
Diff

From: alexcher <alexcher@a1074d23-0009-0410-80fe-cf8c14f379e6>
Date: Sat, 8 Sep 2007 22:31:20 +0000 (+0000)
Subject: Declare Ghostscript as _LARGEFILE64_SOURCE program, i.e. request transitional
X-Git-Url: http://git.infradead.org/?p=ghostscript.git;a=commitdiff_plain;h=0513d1b9542d37e7134d36e49222b12ef469b722
Declare Ghostscript as _LARGEFILE64_SOURCE program, i.e. request transitional
interface to large file support. Check for mkstemp64() availability specially.
git-svn-id: http://svn.ghostscript.com/ghostscript/trunk/gs@8232 a1074d23-0009-0410-80fe-cf8c14f379e6
---
diff --git a/src/Makefile.in b/src/Makefile.in
index c1e3c3b..5590f9a 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -120,8 +120,11 @@ GENOPT=
#
# -DHAVE_FILE64
# use marked versions of the stdio FILE calls, fopen64() et al.
+#
+# -DHAVE_MKSTEMP64
+# use non-standard function mkstemp64()
-CAPOPT= @HAVE_MKSTEMP@ @HAVE_HYPOT@ @HAVE_FILE64@ @HAVE_FONTCONFIG@
+CAPOPT= @HAVE_MKSTEMP@ @HAVE_HYPOT@ @HAVE_FILE64@ @HAVE_MKSTEMP64@ @HAVE_FONTCONFIG@
# Define the name of the executable file.
diff --git a/src/configure.ac b/src/configure.ac
index 10658c5..ffde250 100644
--- a/src/configure.ac
+++ b/src/configure.ac
@@ -924,6 +924,9 @@ AC_SUBST(HAVE_HYPOT)
AC_CHECK_FUNCS([fopen64], [HAVE_FILE64=-DHAVE_FILE64])
AC_SUBST(HAVE_FILE64)
+AC_CHECK_FUNCS([mkstemp64], [HAVE_MKSTEMP64=-DHAVE_MKSTEMP64])
+AC_SUBST(HAVE_MKSTEMP64)
+
AC_PROG_GCC_TRADITIONAL
dnl NB: We don't actually provide autoconf-switched fallbacks for any
diff --git a/src/gp_unifs.c b/src/gp_unifs.c
index 6b6a85c..ac555b5 100644
--- a/src/gp_unifs.c
+++ b/src/gp_unifs.c
@@ -88,18 +88,22 @@ gp_open_scratch_file_generic(const char *prefix, char fname[gp_file_name_sizeof]
/* save the old filename template in case mkstemp fails */
memcpy(ofname, fname, gp_file_name_sizeof);
-#if defined(HAVE_FILE64) && !defined(_LARGEFILE64_SOURCE)
- if (b64)
- file = mkstemp64(fname);
- else
+#ifdef HAVE_MKSTEMP64
+ file = (b64 ? mkstemp64 : mkstemp)(fname);
+#else
+ file = mkstemp(fname);
#endif
- file = mkstemp(fname);
-
- /* Fixme : what to do with b64 and 32-bit mkstemp? Unimplemented. */
if (file < -1) {
eprintf1("**** Could not open temporary file %s\n", ofname);
return NULL;
}
+#if defined(O_LARGEFILE) && defined(__hpux)
+ if (b64)
+ fcntl(file, F_SETFD, fcntl(file, F_GETFD) | O_LARGEFILE);
+#else
+ /* Fixme : what to do with b64 and 32-bit mkstemp? Unimplemented. */
+#endif
+
fp = fdopen(file, mode);
if (fp == NULL)
close(file);
@@ -479,10 +483,10 @@ gp_enumerate_files_close(file_enum * pfen)
FILE *gp_fopen_64(const char *filename, const char *mode)
{
-#if defined(_LARGEFILE64_SOURCE) || !defined(HAVE_FILE64)
- return fopen(filename, mode);
-#else
+#if defined(HAVE_FILE64)
return fopen64(filename, mode);
+#else
+ return fopen(filename, mode);
#endif
}
@@ -497,22 +501,22 @@ FILE *gp_open_scratch_file_64(const char *prefix,
int64_t gp_ftell_64(FILE *strm)
{
-#if defined(_LARGEFILE64_SOURCE) || !defined(HAVE_FILE64)
- return ftello(strm);
-#else
+#if defined(HAVE_FILE64)
return ftello64(strm);
+#else
+ return ftello(strm);
#endif
}
int gp_fseek_64(FILE *strm, int64_t offset, int origin)
{
-#if defined(_LARGEFILE64_SOURCE) || !defined(HAVE_FILE64)
+#if defined(HAVE_FILE64)
+ return fseeko64(strm, offset, origin);
+#else
off_t offset1 = (off_t)offset;
if (offset != offset1)
return -1;
return fseeko(strm, offset1, origin);
-#else
- return fseeko64(strm, offset, origin);
#endif
}
diff --git a/src/stdpre.h b/src/stdpre.h
index acb61c1..c17cdbf 100644
--- a/src/stdpre.h
+++ b/src/stdpre.h
@@ -17,6 +17,9 @@
#ifndef stdpre_INCLUDED
# define stdpre_INCLUDED
+/* Ghostscript uses transitional LFS functions. */
+#define _LARGEFILE64_SOURCE 1
+
/*
* Here we deal with the vagaries of various C compilers. We assume that:
* ANSI-standard Unix compilers define __STDC__.
From: alexcher <alexcher@a1074d23-0009-0410-80fe-cf8c14f379e6>
Date: Wed, 5 Sep 2007 19:21:05 +0000 (+0000)
Subject: Replace non-standard function call fdopen64() with fdopen(). The former
X-Git-Url: http://git.infradead.org/?p=ghostscript.git;a=commitdiff_plain;h=dc01761c07d210974d829c35c33a8886c33b0488
Replace non-standard function call fdopen64() with fdopen(). The former
is not available on most platforms and not needed anyway because O_LARGEFILE
flag is set earlier in the code. Bug 689175.
DIFFERENCES:
None
git-svn-id: http://svn.ghostscript.com/ghostscript/trunk/gs@8229 a1074d23-0009-0410-80fe-cf8c14f379e6
---
diff --git a/src/gpmisc.c b/src/gpmisc.c
index f963d82..303fac2 100644
--- a/src/gpmisc.c
+++ b/src/gpmisc.c
@@ -93,11 +93,7 @@ gp_fopentemp_generic(const char *fname, const char *mode, bool b64)
* fdopen as (char *), rather than following the POSIX.1 standard,
* which defines it as (const char *). Patch this here.
*/
-#if defined (O_LARGEFILE)
- file = (b64 ? fdopen64 : fdopen)(fildes, (char *)mode); /* still really const */
-#else
file = fdopen(fildes, (char *)mode); /* still really const */
-#endif
if (file == 0)
close(fildes);
return file;