2012-05-03  Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* include/lcms2.h [DJGPP]: For DJGPP define CMS_IS_DJGPP_.
	[CMS_IS_DJGPP_] : For DJGPP use 260 instead of 256 as default for
	cmsMAX_PATH.

	* include/lcms2_internal.h [DJGPP, DJGPP_MINOR]: For DJGPP 2.03 provide
	snprintf and vsnprintf prototypes.

	* src/cmscgats.c [CMS_IS_DJGPP_]: For DJGPP define DIR_CHAR_ALT as
	backslash for alternate directory separator character.
	(isabsolutepath) [CMS_IS_DJGPP_]: For DJGPP check for absolute path
	allowing both slash and backslash characters.
	(BuildAbsolutePath) [CMS_IS_DJGPP_]: For DJGPP check for absolute path
	allowing both slash and backslash charcters.

	* src/cmsplugin.c: Define internal types __cmsFloat32Number_a and
	__cmsUInt32Number_a to be used for avoiding strict aliasing warnings.
	(cmsReadFloat32Number): Use __cmsFloat32Number_a.
	(cmsWriteFloat32Number): Use __cmsUInt32Number_a.

	* utils/jpgicc/jpgicc.c (Help): Remove superflous SW.

	* utils/transicc/transicc.c [DJGPP]: For DJGPP include unistd.h for
	isatty prototype.






diff -aprNU5 lcms2-2.3.orig/include/lcms2.h lcms2-2.3/include/lcms2.h
--- lcms2-2.3.orig/include/lcms2.h	2011-12-15 15:45:46 +0000
+++ lcms2-2.3/include/lcms2.h	2012-05-03 18:55:48 +0000
@@ -152,10 +152,15 @@ typedef cmsInt32Number       cmsS15Fixed
 typedef cmsUInt32Number      cmsU16Fixed16Number;
 
 // Boolean type, which will be using the native integer
 typedef int                  cmsBool;
 
+// Try to detect DJGPP
+#if defined (DJGPP) || defined(__DJGPP__)
+#  define CMS_IS_DJGPP_ 1
+#endif
+
 // Try to detect windows
 #if defined (_WIN32) || defined(_WIN64) || defined(WIN32) || defined(_WIN32_)
 #  define CMS_IS_WINDOWS_ 1
 #endif
 
@@ -214,11 +219,15 @@ typedef int                  cmsBool;
 # define CMSEXPORT
 # define CMSAPI
 #endif
 
 // Some common definitions
-#define cmsMAX_PATH     256
+#ifdef CMS_IS_DJGPP_
+# define cmsMAX_PATH     260  /*  Max value from pathconf.  */
+#else
+# define cmsMAX_PATH     256
+#endif
 
 #ifndef FALSE
 #       define FALSE 0
 #endif
 #ifndef TRUE
diff -aprNU5 lcms2-2.3.orig/src/cmscgats.c lcms2-2.3/src/cmscgats.c
--- lcms2-2.3.orig/src/cmscgats.c	2011-12-15 15:45:46 +0000
+++ lcms2-2.3/src/cmscgats.c	2012-05-03 19:00:24 +0000
@@ -37,13 +37,16 @@
 
 #define DEFAULT_DBL_FORMAT  "%.10g" // Double formatting
 
 #ifdef CMS_IS_WINDOWS_
 #    include <io.h>
-#    define DIR_CHAR    '\\'
+#    define DIR_CHAR            '\\'
 #else
-#    define DIR_CHAR    '/'
+#    define DIR_CHAR            '/'
+#    ifdef CMS_IS_DJGPP_
+#        define DIR_CHAR_ALT    '\\'
+#    endif
 #endif
 
 // Symbols
 typedef enum { 
 
@@ -393,14 +396,18 @@ cmsBool isabsolutepath(const char *path)
         return FALSE;
 
     strncpy(ThreeChars, path, 3);
     ThreeChars[3] = 0;
 
+#ifdef CMS_IS_DJGPP_
+    if(ThreeChars[0] == DIR_CHAR || ThreeChars[0] == DIR_CHAR_ALT)
+#else
     if(ThreeChars[0] == DIR_CHAR)
+#endif
         return TRUE;
 
-#ifdef  CMS_IS_WINDOWS_
+#if defined( CMS_IS_DJGPP_) || defined( CMS_IS_WINDOWS_)
     if (isalpha((int) ThreeChars[0]) && ThreeChars[1] == ':')
         return TRUE;
 #endif
     return FALSE;
 }
@@ -423,11 +430,18 @@ cmsBool BuildAbsolutePath(const char *re
 
     // No, search for last 
     strncpy(buffer, basePath, MaxLen);  
     buffer[MaxLen-1] = 0;
 
+#ifdef CMS_IS_DJGPP_
+    for (len = MaxLen; len;)
+      if (len--, buffer[len] == DIR_CHAR || buffer[len] == DIR_CHAR_ALT)
+        break;
+    tail = len ? buffer + len : NULL;
+#else
     tail = strrchr(buffer, DIR_CHAR);
+#endif
     if (tail == NULL) return FALSE;    // Is not absolute and has no separators??
 
     len = (cmsUInt32Number) (tail - buffer);
     if (len >= MaxLen) return FALSE;
 
diff -aprNU5 lcms2-2.3.orig/src/cmsplugin.c lcms2-2.3/src/cmsplugin.c
--- lcms2-2.3.orig/src/cmsplugin.c	2011-12-15 15:45:46 +0000
+++ lcms2-2.3/src/cmsplugin.c	2012-05-03 19:06:26 +0000
@@ -24,10 +24,31 @@
 //---------------------------------------------------------------------------------
 //
 
 #include "lcms2_internal.h"
 
+/* Define internal type to be used to avoid strict aliasing warnings */
+#if (__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ > 3))
+typedef float __attribute__((__may_alias__)) __cmsFloat32Number_a;
+# if (UINT_MAX == 4294967295U)
+typedef unsigned int __attribute__((__may_alias__)) __cmsUInt32Number_a;
+# elif (ULONG_MAX == 4294967295U)
+typedef unsigned long __attribute__((__may_alias__)) __cmsUInt32Number_a;
+# else
+#  error "Unable to find 32 bit unsigned type, unsupported compiler"
+# endif
+#else
+typedef float __cmsFloat32Number_a;
+# if (UINT_MAX == 4294967295U)
+typedef unsigned int __cmsUInt32Number_a;
+# elif (ULONG_MAX == 4294967295U)
+typedef unsigned long __cmsUInt32Number_a;
+# else
+#  error "Unable to find 32 bit unsigned type, unsupported compiler"
+# endif
+#endif
+
 
 // ----------------------------------------------------------------------------------
 // Encoding & Decoding support functions
 // ----------------------------------------------------------------------------------
 
@@ -172,11 +193,11 @@ cmsBool CMSEXPORT  _cmsReadFloat32Number
             return FALSE;   
 
     if (n != NULL) {
 
         tmp = _cmsAdjustEndianess32(tmp);
-        *n = *(cmsFloat32Number*) &tmp;
+        *n = *(__cmsFloat32Number_a*) &tmp;
     }
     return TRUE;
 }
 
 
@@ -301,11 +322,11 @@ cmsBool CMSEXPORT  _cmsWriteFloat32Numbe
 {
     cmsUInt32Number tmp;
 
     _cmsAssert(io != NULL);
 
-    tmp = *(cmsUInt32Number*) &n;
+    tmp = *(__cmsUInt32Number_a *) &n;
     tmp = _cmsAdjustEndianess32(tmp);
     if (io -> Write(io, sizeof(cmsUInt32Number), &tmp) != 1) 
             return FALSE;   
     
     return TRUE;
diff -aprNU5 lcms2-2.3.orig/src/lcms2_internal.h lcms2-2.3/src/lcms2_internal.h
--- lcms2-2.3.orig/src/lcms2_internal.h	2011-12-15 15:45:46 +0000
+++ lcms2-2.3/src/lcms2_internal.h	2012-05-03 19:10:12 +0000
@@ -44,10 +44,21 @@
 
 #ifndef M_LOG10E
 #       define M_LOG10E    0.434294481903251827651
 #endif
 
+#if defined(__DJGPP__) && __DJGPP__ == 2 && __DJGPP_MINOR__ < 4
+/*
+ *  snprintf declaration for djgpp.
+ *  This will be removed as soon as
+ *  djdev203 is definitivly replaced
+ *  by djdev204.
+ */
+int snprintf(char *str, size_t n, const char *fmt, ...);
+int vsnprintf(char *str, size_t n, const char *fmt, va_list ap);
+#endif
+
 // BorlandC 5.5, VC2003 are broken on that
 #if defined(__BORLANDC__) || (_MSC_VER <= 1400) // 1400 == VC++ 8.0 
 #define sinf(x) (float)sin((float)x)
 #define sqrtf(x) (float)sqrt((float)x)
 #endif
diff -aprNU5 lcms2-2.3.orig/utils/jpgicc/jpgicc.c lcms2-2.3/utils/jpgicc/jpgicc.c
--- lcms2-2.3.orig/utils/jpgicc/jpgicc.c	2011-12-15 15:45:46 +0000
+++ lcms2-2.3/utils/jpgicc/jpgicc.c	2012-05-03 19:12:40 +0000
@@ -1089,11 +1089,11 @@ void Help(int level)
                      "\tjpegicc %coprinter.icm inrgb.jpg outcmyk.jpg\n"
                      "To recover sRGB from a CMYK separation:\n"
                      "\tjpegicc %ciprinter.icm incmyk.jpg outrgb.jpg\n"
                      "To convert from CIELab ITU/Fax JPEG to sRGB\n"
                      "\tjpegicc in.jpg out.jpg\n\n", 
-                     SW, SW, SW, SW, SW, SW);
+                     SW, SW, SW, SW, SW);
      break;
 
      case 2:
 		 PrintBuiltins();
 		 break;
diff -aprNU5 lcms2-2.3.orig/utils/transicc/transicc.c lcms2-2.3/utils/transicc/transicc.c
--- lcms2-2.3.orig/utils/transicc/transicc.c	2011-12-15 15:45:46 +0000
+++ lcms2-2.3/utils/transicc/transicc.c	2012-05-03 19:13:28 +0000
@@ -28,10 +28,14 @@
 
 #ifndef _MSC_VER 
 #    include <unistd.h> 
 #endif 
 
+#ifdef CMS_IS_DJGPP_
+#    include <unistd.h>
+#endif
+
 #ifdef CMS_IS_WINDOWS_
 #    include <io.h>
 #endif
 
 #define MAX_INPUT_BUFFER 4096
