2021-02-13  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.12.orig/include/lcms2.h lcms2-2.12/include/lcms2.h
--- lcms2-2.12.orig/include/lcms2.h	2021-02-06 17:44:30 +0000
+++ lcms2-2.12/include/lcms2.h	2021-02-14 03:45:06 +0000
@@ -171,10 +171,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
 
@@ -261,11 +266,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.12.orig/src/cmscgats.c lcms2-2.12/src/cmscgats.c
--- lcms2-2.12.orig/src/cmscgats.c	2021-02-06 17:44:30 +0000
+++ lcms2-2.12/src/cmscgats.c	2021-02-15 17:31:36 +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.12.orig/src/cmspcs.c lcms2-2.12/src/cmspcs.c
--- lcms2-2.12.orig/src/cmspcs.c	2021-02-06 17:44:30 +0000
+++ lcms2-2.12/src/cmspcs.c	2021-02-15 17:21:40 +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.12.orig/utils/transicc/transicc.c lcms2-2.12/utils/transicc/transicc.c
--- lcms2-2.12.orig/utils/transicc/transicc.c	2021-02-06 17:44:30 +0000
+++ lcms2-2.12/utils/transicc/transicc.c	2021-02-15 17:12:38 +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





2021-02-20  Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	Patches taken from http://deb.debian.org/debian/pool/main/l/lcms2/lcms2_2.12~rc1-2.debian.tar.xz






diff -aprNU5 lcms2-2.12.orig/include/lcms2.h lcms2-2.12/include/lcms2.h
--- lcms2-2.12.orig/include/lcms2.h	2021-02-20 17:02:54 +0000
+++ lcms2-2.12/include/lcms2.h	2021-02-20 17:20:40 +0000
@@ -28,12 +28,14 @@
 
 #ifndef _lcms2_H
 
 // ********** Configuration toggles ****************************************
 
-// Uncomment this one if you are using big endian machines
-// #define CMS_USE_BIG_ENDIAN   1
+#include <machine/endian.h>
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define USE_BIG_ENDIAN   1
+#endif
 
 // Uncomment this one if your compiler/machine does NOT support the
 // "long long" type.
 // #define CMS_DONT_USE_INT64        1
 
diff -aprNU5 lcms2-2.12.orig/src/cmstypes.c lcms2-2.12/src/cmstypes.c
--- lcms2-2.12.orig/src/cmstypes.c	2021-02-06 16:44:30 +0000
+++ lcms2-2.12/src/cmstypes.c	2021-02-20 17:06:04 +0000
@@ -3166,10 +3166,14 @@ cmsBool Type_NamedColor_Write(struct _cm
 
     if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
     if (!_cmsWriteUInt32Number(io, nColors)) return FALSE;
     if (!_cmsWriteUInt32Number(io, NamedColorList ->ColorantCount)) return FALSE;
 
+    // Ensure we don't write unitialized memory.
+    memset(prefix, 0, sizeof(prefix));
+    memset(suffix, 0, sizeof(suffix));
+
     strncpy(prefix, (const char*) NamedColorList->Prefix, 32);
     strncpy(suffix, (const char*) NamedColorList->Suffix, 32);
 
     suffix[32] = prefix[32] = 0;
 
@@ -3180,10 +3184,13 @@ cmsBool Type_NamedColor_Write(struct _cm
 
        cmsUInt16Number PCS[3];
        cmsUInt16Number Colorant[cmsMAXCHANNELS];
        char Root[cmsMAX_PATH];
 
+        // Ensure we don't write unitialized memory.
+        memset(Root, 0, sizeof(Root));
+
         if (!cmsNamedColorInfo(NamedColorList, i, Root, NULL, NULL, PCS, Colorant)) return 0;
         Root[32] = 0;
         if (!io ->Write(io, 32 , Root)) return FALSE;
         if (!_cmsWriteUInt16Array(io, 3, PCS)) return FALSE;
         if (!_cmsWriteUInt16Array(io, NamedColorList ->ColorantCount, Colorant)) return FALSE;
