From eae74c7acfa484868f5374f8f0ebff1eb39d1c61 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Sun, 12 Feb 2012 20:44:37 +0000 Subject: redo conditional compilation of Windows stuff to use MSVCRT, based on _WIN32, instead of WIN32 git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1644 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- converter/other/cameratopam/cameratopam.c | 6 +++-- converter/other/exif.c | 3 ++- converter/other/exif.h | 2 +- converter/other/fiasco/getopt.c | 3 +-- .../other/jpeg2000/libjasper/base/jas_stream.c | 5 ++-- converter/other/pamtotiff.c | 2 +- doc/HISTORY | 3 +++ lib/libpm.c | 6 ++--- lib/pm.h | 2 +- lib/pmfileio.c | 4 +-- lib/util/nsleep.c | 6 +++-- pm_config.in.h | 29 ++++++++++++++++++++-- urt/rle_config.h | 2 +- 13 files changed, 53 insertions(+), 20 deletions(-) diff --git a/converter/other/cameratopam/cameratopam.c b/converter/other/cameratopam/cameratopam.c index 87bde3ce..aa9c49cd 100644 --- a/converter/other/cameratopam/cameratopam.c +++ b/converter/other/cameratopam/cameratopam.c @@ -10,6 +10,8 @@ #define _BSD_SOURCE 1 /* Make sure string.h contains strcasecmp() */ #define _XOPEN_SOURCE /* Make sure unistd.h contains swab() */ +#include "pm_config.h" + #include #include #include @@ -26,7 +28,7 @@ #ifdef __CYGWIN__ #include #endif -#if !defined(WIN32) || defined(__CYGWIN__) +#if !MSVCRT #include #endif @@ -207,7 +209,7 @@ static void CLASS bad_pixels() free (fname); if (errno != ERANGE) return; } -#ifdef WIN32 +#if MSVCRT if (fname[1] == ':') memmove (fname, fname+2, len-2); for (cp=fname; *cp; cp++) diff --git a/converter/other/exif.c b/converter/other/exif.c index 6178d9a2..b94c1ef4 100644 --- a/converter/other/exif.c +++ b/converter/other/exif.c @@ -21,6 +21,7 @@ See the EXIF specs at http://exif.org (2001.09.01). --------------------------------------------------------------------------*/ +#include "pm_config.h" #include #include #include @@ -30,7 +31,7 @@ #include #include -#ifdef _WIN32 +#if MSVCRT #include #else #include diff --git a/converter/other/exif.h b/converter/other/exif.h index e5825e12..bae16726 100644 --- a/converter/other/exif.h +++ b/converter/other/exif.h @@ -3,7 +3,7 @@ #define MAX_COMMENT 2000 -#ifdef _WIN32 +#if MSVCRT #define PATH_MAX _MAX_PATH #endif diff --git a/converter/other/fiasco/getopt.c b/converter/other/fiasco/getopt.c index f5baf7d3..2f45c7cc 100644 --- a/converter/other/fiasco/getopt.c +++ b/converter/other/fiasco/getopt.c @@ -73,8 +73,7 @@ #include #endif /* GNU C library. */ -#if defined (WIN32) && !defined (__CYGWIN32__) -/* It's not Unix, really. See? Capital letters. */ +#if MSVCRT #include #define getpid() GetCurrentProcessId() #endif diff --git a/converter/other/jpeg2000/libjasper/base/jas_stream.c b/converter/other/jpeg2000/libjasper/base/jas_stream.c index 7af161d2..7c6050fb 100644 --- a/converter/other/jpeg2000/libjasper/base/jas_stream.c +++ b/converter/other/jpeg2000/libjasper/base/jas_stream.c @@ -117,6 +117,7 @@ */ #define _XOPEN_SOURCE 500 /* Make sure P_tmpdir is defined */ +#include "pm_config.h" #include #include #include @@ -126,7 +127,7 @@ #if defined(HAVE_UNISTD_H) #include #endif -#if defined(WIN32) || defined(HAVE_IO_H) +#if MSVCRT #include #endif @@ -440,7 +441,7 @@ jas_stream_t *jas_stream_fdopen(int fd, const char *mode) /* Parse the mode string. */ stream->openmode_ = jas_strtoopenmode(mode); -#if defined(WIN32) +#if defined(HAVE_SETMODE) && defined(O_BINARY) /* Argh!!! Someone ought to banish text mode (i.e., O_TEXT) to the greatest depths of purgatory! */ /* Ensure that the file descriptor is in binary mode, if the caller diff --git a/converter/other/pamtotiff.c b/converter/other/pamtotiff.c index 24558b58..2082b3bd 100644 --- a/converter/other/pamtotiff.c +++ b/converter/other/pamtotiff.c @@ -1026,7 +1026,7 @@ validateReadableStdout(void) { error message about a file I/O error. We, on the other hand, produce a helpful error message. -----------------------------------------------------------------------------*/ -#if !defined(WIN32) || defined(__CYGWIN__) +#if !MSVCRT int flags; diff --git a/doc/HISTORY b/doc/HISTORY index 2864732e..84c9344d 100644 --- a/doc/HISTORY +++ b/doc/HISTORY @@ -21,6 +21,9 @@ not yet BJH Release 10.58.00 Windows: compute program name correctly. + Build: redo conditional compilation of Windows to use + MSVCRT, based on _WIN32, instead of WIN32. + Build: use Pkgconfig to find libxml2 if it works (fall back to xml2-config). diff --git a/lib/libpm.c b/lib/libpm.c index 3c69c105..f6578a59 100644 --- a/lib/libpm.c +++ b/lib/libpm.c @@ -708,7 +708,7 @@ extractAfterLastSlash(const char * const fullPath, -#ifdef WIN32 +#if MSVCRT static void splitpath(const char * const fullPath, char * const retval, @@ -737,8 +737,8 @@ pm_arg0toprogname(const char arg0[]) { but truncated at 64 characters. -----------------------------------------------------------------------------*/ static char retval[64+1]; -#ifdef WIN32 - splitPath(arg0, retval, sizeof(retval)); +#if MSVCRT + splitpath(arg0, retval, sizeof(retval)); #else extractAfterLastSlash(arg0, retval, sizeof(retval)); #endif diff --git a/lib/pm.h b/lib/pm.h index 88f61522..72ecc919 100644 --- a/lib/pm.h +++ b/lib/pm.h @@ -86,7 +86,7 @@ extern "C" { We're ignoring S_IREAD now to see if anyone misses it. If there are still users that need it, we can handle it here. */ -#ifdef WIN32 +#if MSVCRT #define PM_S_IWUSR _S_IWRITE #define PM_S_IRUSR _S_IREAD #else diff --git a/lib/pmfileio.c b/lib/pmfileio.c index abcb05cf..1d7d2643 100644 --- a/lib/pmfileio.c +++ b/lib/pmfileio.c @@ -122,10 +122,10 @@ tempFileOpenFlags(void) { retval = 0 | O_CREAT | O_RDWR -#ifndef WIN32 +#if !MSVCRT | O_EXCL #endif -#ifdef WIN32 +#if MSVCRT | O_BINARY #endif ; diff --git a/lib/util/nsleep.c b/lib/util/nsleep.c index d9fed571..24d48207 100644 --- a/lib/util/nsleep.c +++ b/lib/util/nsleep.c @@ -1,4 +1,6 @@ -#ifdef WIN32 +#include "pm_config.h" + +#if MSVCRT #include #include #else @@ -12,7 +14,7 @@ void pm_sleep(unsigned int const milliseconds) { -#ifdef WIN32 +#if MSVCRT SleepEx(milliseconds, TRUE); #else diff --git a/pm_config.in.h b/pm_config.in.h index b7243786..2cea5a86 100644 --- a/pm_config.in.h +++ b/pm_config.in.h @@ -125,12 +125,37 @@ */ #define A_STRERROR +/* MSVCRT means we're using the Microsoft Visual C++ runtime library. + + _WIN32, set by the compiler, apparently means the same thing; we see it set + in compiles using the Microsoft Visual C++ development environment and also + with Mingw, which is the Windows version of the GNU compiler (which brings + with it a runtime library which wraps around the Microsoft one). We don't + see it set in Cygwin compiles, which use GNU libraries instead of the + Microsoft one. + + There is also _MSC_VER, which is set by MSVC to the version number of the + MSVC runtime library and __MINGW32__. + */ + +#ifdef _WIN32 +#define MSVCRT 1 +#else +#define MSVCRT 0 +#endif + +/* WIN32 is a macro that some older compilers predefine (compilers aren't + supposed to because it doesn't start with an underscore, hence the change. + Many build systems (project files, etc.) set WIN32 explicitly for + backward compatibility. Netpbm doesn't use it. +*/ + /* CONFIGURE: If your system has the setmode() function, set HAVE_SETMODE. ** If you do, and also the O_BINARY file mode, pm_init() will set the mode ** of stdin and stdout to binary for all Netpbm programs. ** You need this with Cygwin (Windows). */ -#if defined(WIN32) || defined(__CYGWIN__) || defined(DJGPP) +#if MSVCRT || defined(__CYGWIN__) || defined(DJGPP) #define HAVE_SETMODE #endif @@ -306,7 +331,7 @@ typedef long int pm_filepos; typedef int qsort_comparison_fn(const void *, const void *); /* A compare function to pass to 's qsort() */ -#if defined(WIN32) && !defined(__CYGWIN__) +#if MSVCRT #define pm_mkdir(dir, perm) _mkdir(dir) #else #define pm_mkdir(dir, perm) mkdir(dir, perm) diff --git a/urt/rle_config.h b/urt/rle_config.h index 7b44bfdd..c1f4629d 100644 --- a/urt/rle_config.h +++ b/urt/rle_config.h @@ -1,5 +1,5 @@ #include "pm_config.h" -#if defined(WIN32) && !defined(__CYGWIN__) +#if MSVCRT #define NO_OPEN_PIPES #endif -- cgit 1.4.1