From 8b1de8bffb8e3069d9fc23a6a1a189b9b9d30198 Mon Sep 17 00:00:00 2001
From: Jim Dishaw <jim@dishaw.org>
Date: Wed, 3 Jun 2015 14:21:40 -0400
Subject: [PATCH 1/2] Fixes to correct builds on WIN32

---
 src/plbuf.c      | 8 ++++++++
 src/plfreetype.c | 6 +++---
 src/plmetafile.c | 9 ++++++++-
 src/plstdio.c    | 2 +-
 4 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/src/plbuf.c b/src/plbuf.c
index 6e6c305..e200a07 100644
--- a/src/plbuf.c
+++ b/src/plbuf.c
@@ -29,6 +29,14 @@
 
 #include <string.h>
 
+#if defined ( _MSC_VER ) && _MSC_VER <= 1500
+// Older versions of Visual Studio (2005 perhaps 2008) do not define uint8_t
+// The newer versions of Visual Studio will not install on Vista or older
+// versions of Windows.
+typedef unsigned char uint8_t;
+typedef unsigned short int uint16_t;
+#endif
+
 //
 // Function prototypes
 //
diff --git a/src/plfreetype.c b/src/plfreetype.c
index 90ad2ee..a7108c3 100644
--- a/src/plfreetype.c
+++ b/src/plfreetype.c
@@ -63,9 +63,7 @@
 //
 //
 
-#if !defined ( WIN32 ) || defined ( __GNUC__ )
-  #include <unistd.h>
-#else
+#if defined ( WIN32 ) || defined ( _WIN32 ) || !defined ( __GNUC__ )
   #define F_OK    1
   #include <stdio.h>
 int access( char *filename, int flag )
@@ -82,6 +80,8 @@ int access( char *filename, int flag )
         return 1;
     }
 }
+#else
+  #include <unistd.h>
 #endif
 
 #define makeunixslash( b )    do { char *I; for ( I = b; *I != 0; *I++ ) if ( *I == '\\' ) *I = '/';} while ( 0 )
diff --git a/src/plmetafile.c b/src/plmetafile.c
index 1f43545..f456e21 100644
--- a/src/plmetafile.c
+++ b/src/plmetafile.c
@@ -32,6 +32,13 @@
 
 #define MAX_BUFFER    256 // Character buffer size for reading records
 
+#if defined ( _MSC_VER ) && _MSC_VER <= 1500
+// Older versions of Visual Studio (2005 perhaps 2008) do not define uint8_t
+// The newer versions of Visual Studio will not install on Vista or older
+// versions of Windows.
+typedef unsigned char uint8_t;
+#endif
+
 // Not all platforms support the lround() function and the coordinate system
 // representation is going to be redone, thus this is just a placeholder until
 // everything is sorted out.
@@ -74,7 +81,7 @@ enum _plp_types
 };
 
 // Data format entry structure
-struct _plm_format
+struct _plm_format 
 {
     char            *name;     // Name of the field
     enum _pdf_types pdf_type;  // Field data type in metafile
diff --git a/src/plstdio.c b/src/plstdio.c
index 1e77d85..4390809 100644
--- a/src/plstdio.c
+++ b/src/plstdio.c
@@ -23,7 +23,7 @@
 
 #include "plplotP.h"
 
-#if defined ( MSDOS ) || defined ( WIN32 )
+#if defined ( MSDOS ) || defined ( WIN32 ) || defined ( _WIN32 )
 #include <sys/types.h>
 #include <fcntl.h>
 #endif
-- 
1.9.5.github.0

