2017-12-27  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.

	* 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/cmspcs.c (_cmsLCMScolorSpace):  Use int instead as cmsColorSpaceSignature
	as return type.

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






diff -aprNU5 lcms2-2.9.orig/include/lcms2.h lcms2-2.9/include/lcms2.h
--- lcms2-2.9.orig/include/lcms2.h	2017-11-20 20:59:38 +0000
+++ lcms2-2.9/include/lcms2.h	2017-12-27 20:01:04 +0000
@@ -161,10 +161,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
 
@@ -251,11 +256,15 @@ typedef int                  cmsBool;
 #    define CMS_NO_PTHREADS 1
 # endif
 #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.9.orig/src/cmscgats.c lcms2-2.9/src/cmscgats.c
--- lcms2-2.9.orig/src/cmscgats.c	2017-11-20 20:59:38 +0000
+++ lcms2-2.9/src/cmscgats.c	2017-12-27 20:01:04 +0000
@@ -39,11 +39,14 @@
 
 #ifdef CMS_IS_WINDOWS_
 #    include <io.h>
 #    define DIR_CHAR    '\\'
 #else
-#    define DIR_CHAR    '/'
+#    define DIR_CHAR            '/'
+#    ifdef CMS_IS_DJGPP_
+#        define DIR_CHAR_ALT    '\\'
+#    endif
 #endif
 
 
 // Symbols
 typedef enum {
@@ -394,14 +397,18 @@ cmsBool isabsolutepath(const char *path)
         return FALSE;
 
     strncpy(ThreeChars, path, 3);
     ThreeChars[3] = 0;
 
-    if(ThreeChars[0] == DIR_CHAR)
+#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;
 }
@@ -425,11 +432,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.9.orig/src/cmspcs.c lcms2-2.9/src/cmspcs.c
--- lcms2-2.9.orig/src/cmspcs.c	2017-11-20 20:59:38 +0000
+++ lcms2-2.9/src/cmspcs.c	2017-12-27 20:19:24 +0000
@@ -867,11 +867,11 @@ int CMSEXPORT _cmsLCMScolorSpace(cmsColo
     case cmsSig14colorData:return PT_MCH14;
 
     case cmsSigMCHFData:
     case cmsSig15colorData:return PT_MCH15;
 
-    default:  return (cmsColorSpaceSignature) 0;
+    default:  return (int)(cmsColorSpaceSignature) 0;
     }
 }
 
 
 cmsUInt32Number CMSEXPORT cmsChannelsOf(cmsColorSpaceSignature ColorSpace)
diff -aprNU5 lcms2-2.9.orig/utils/transicc/transicc.c lcms2-2.9/utils/transicc/transicc.c
--- lcms2-2.9.orig/utils/transicc/transicc.c	2017-11-20 20:59:38 +0000
+++ lcms2-2.9/utils/transicc/transicc.c	2017-12-27 20:01:04 +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
