2018-11-10 Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* src/strconv.c (jsonp_strtod):  Set errno to ERANGE if
	value is either HUGE_VAL or -HUGE_VAL.


2018-05-01 Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* jansson_private_config.h.in:  Define macro FALLTHROUGH
	to work with GCC7's -Werror=implicit-fallthrough=.

	* src/dump.c (loop_check):  Pacify compiler.

	* src/lookup3.h (hashlittle):   Use new FALLTHROUGH macro
	in place of each comment.

	* src/pack_unpack.c (unpack):  Use new FALLTHROUGH macro
	in place of each comment.

	* test/bin/json_process.c [__DJGPP__]:  Include io.h and
	fcntl.h.
	[O_BINARY]:  If not defined define _O_BINARY to O_BINARY,
	define _fileno to fileno and define _setmode to setmode.
	(use_env):  Use O_BINARY, fileno and setmode.





diff -aprNU5 jansson-2.11.orig/jansson_private_config.h.in jansson-2.11/jansson_private_config.h.in
--- jansson-2.11.orig/jansson_private_config.h.in	2018-02-11 18:26:10 +0000
+++ jansson-2.11/jansson_private_config.h.in	2018-11-11 00:29:24 +0000
@@ -154,5 +154,14 @@
 #undef uint32_t
 
 /* Define to the type of an unsigned integer type of width exactly 8 bits if
    such a type exists and the standard includes do not define it. */
 #undef uint8_t
+
+/* Define macro FALLTHROUGH to work with GCC7's -Werror=implicit-fallthrough=.  */
+#ifndef FALLTHROUGH
+# if __GNUC__ < 7
+#  define FALLTHROUGH ((void) 0)
+# else
+#  define FALLTHROUGH __attribute__ ((__fallthrough__))
+# endif
+#endif
diff -aprNU5 jansson-2.11.orig/src/lookup3.h jansson-2.11/src/lookup3.h
--- jansson-2.11.orig/src/lookup3.h	2018-02-08 09:05:40 +0000
+++ jansson-2.11/src/lookup3.h	2018-11-11 00:29:24 +0000
@@ -307,27 +307,27 @@ static uint32_t hashlittle(const void *k
     {
     case 12: c+=k[4]+(((uint32_t)k[5])<<16);
              b+=k[2]+(((uint32_t)k[3])<<16);
              a+=k[0]+(((uint32_t)k[1])<<16);
              break;
-    case 11: c+=((uint32_t)k8[10])<<16;     /* fall through */
+    case 11: c+=((uint32_t)k8[10])<<16;     FALLTHROUGH;
     case 10: c+=k[4];
              b+=k[2]+(((uint32_t)k[3])<<16);
              a+=k[0]+(((uint32_t)k[1])<<16);
              break;
-    case 9 : c+=k8[8];                      /* fall through */
+    case 9 : c+=k8[8];                      FALLTHROUGH;
     case 8 : b+=k[2]+(((uint32_t)k[3])<<16);
              a+=k[0]+(((uint32_t)k[1])<<16);
              break;
-    case 7 : b+=((uint32_t)k8[6])<<16;      /* fall through */
+    case 7 : b+=((uint32_t)k8[6])<<16;      FALLTHROUGH;
     case 6 : b+=k[2];
              a+=k[0]+(((uint32_t)k[1])<<16);
              break;
-    case 5 : b+=k8[4];                      /* fall through */
+    case 5 : b+=k8[4];                      FALLTHROUGH;
     case 4 : a+=k[0]+(((uint32_t)k[1])<<16);
              break;
-    case 3 : a+=((uint32_t)k8[2])<<16;      /* fall through */
+    case 3 : a+=((uint32_t)k8[2])<<16;      FALLTHROUGH;
     case 2 : a+=k[0];
              break;
     case 1 : a+=k8[0];
              break;
     case 0 : return c;                     /* zero length requires no mixing */
@@ -357,21 +357,21 @@ static uint32_t hashlittle(const void *k
     }
 
     /*-------------------------------- last block: affect all 32 bits of (c) */
     switch(length)                   /* all the case statements fall through */
     {
-    case 12: c+=((uint32_t)k[11])<<24; /* fall through */
-    case 11: c+=((uint32_t)k[10])<<16; /* fall through */
-    case 10: c+=((uint32_t)k[9])<<8; /* fall through */
-    case 9 : c+=k[8]; /* fall through */
-    case 8 : b+=((uint32_t)k[7])<<24; /* fall through */
-    case 7 : b+=((uint32_t)k[6])<<16; /* fall through */
-    case 6 : b+=((uint32_t)k[5])<<8; /* fall through */
-    case 5 : b+=k[4]; /* fall through */
-    case 4 : a+=((uint32_t)k[3])<<24; /* fall through */
-    case 3 : a+=((uint32_t)k[2])<<16; /* fall through */
-    case 2 : a+=((uint32_t)k[1])<<8; /* fall through */
+    case 12: c+=((uint32_t)k[11])<<24; FALLTHROUGH;
+    case 11: c+=((uint32_t)k[10])<<16; FALLTHROUGH;
+    case 10: c+=((uint32_t)k[9])<<8; FALLTHROUGH;
+    case 9 : c+=k[8]; FALLTHROUGH;
+    case 8 : b+=((uint32_t)k[7])<<24; FALLTHROUGH;
+    case 7 : b+=((uint32_t)k[6])<<16; FALLTHROUGH;
+    case 6 : b+=((uint32_t)k[5])<<8; FALLTHROUGH;
+    case 5 : b+=k[4]; FALLTHROUGH;
+    case 4 : a+=((uint32_t)k[3])<<24; FALLTHROUGH;
+    case 3 : a+=((uint32_t)k[2])<<16; FALLTHROUGH;
+    case 2 : a+=((uint32_t)k[1])<<8; FALLTHROUGH;
     case 1 : a+=k[0];
              break;
     case 0 : return c;
     }
   }
diff -aprNU5 jansson-2.11.orig/src/pack_unpack.c jansson-2.11/src/pack_unpack.c
--- jansson-2.11.orig/src/pack_unpack.c	2018-02-09 07:55:14 +0000
+++ jansson-2.11/src/pack_unpack.c	2018-11-11 00:29:24 +0000
@@ -755,11 +755,11 @@ static int unpack(scanner_t *s, json_t *
             return 0;
 
         case 'O':
             if(root && !(s->flags & JSON_VALIDATE_ONLY))
                 json_incref(root);
-            /* Fall through */
+            FALLTHROUGH;
 
         case 'o':
             if(!(s->flags & JSON_VALIDATE_ONLY)) {
                 json_t **target = va_arg(*ap, json_t**);
                 if(root)
diff -aprNU5 jansson-2.11.orig/src/strconv.c jansson-2.11/src/strconv.c
--- jansson-2.11.orig/src/strconv.c	2018-02-08 09:05:40 +0000
+++ jansson-2.11/src/strconv.c	2018-11-11 00:29:24 +0000
@@ -75,10 +75,16 @@ int jsonp_strtod(strbuffer_t *strbuffer,
 
     errno = 0;
     value = strtod(strbuffer->value, &end);
     assert(end == strbuffer->value + strbuffer->length);
 
+#ifdef __DJGPP__
+/*  Current version of DJGPP's strtod does not set errno correctly.  */
+    if((value == HUGE_VAL || value == -HUGE_VAL) && errno != ERANGE)
+        errno = ERANGE;
+#endif
+
     if((value == HUGE_VAL || value == -HUGE_VAL) && errno == ERANGE) {
         /* Overflow */
         return -1;
     }
 
diff -aprNU5 jansson-2.11.orig/test/bin/json_process.c jansson-2.11/test/bin/json_process.c
--- jansson-2.11.orig/test/bin/json_process.c	2018-02-08 09:05:40 +0000
+++ jansson-2.11/test/bin/json_process.c	2018-11-11 00:29:24 +0000
@@ -23,13 +23,26 @@
 #include <io.h>  /* for _setmode() */
 #include <fcntl.h>  /* for _O_BINARY */
 
 static const char dir_sep = '\\';
 #else
+#ifdef __DJGPP__
+#include <io.h>  /* for _setmode() */
+#include <fcntl.h>  /* for O_BINARY */
+#endif
+
 static const char dir_sep = '/';
 #endif
 
+#ifndef O_BINARY
+# ifdef _O_BINARY
+#  define O_BINARY _O_BINARY
+#  define fileno   _fileno
+#  define setmode  _setmode
+# endif
+#endif
+
 
 struct config {
     int indent;
     int compact;
     int preserve_order;
@@ -260,15 +273,15 @@ int use_env()
     int indent, precision;
     size_t flags = 0;
     json_t *json;
     json_error_t error;
 
-    #ifdef _WIN32
+    #if (O_BINARY - 0)
     /* On Windows, set stdout and stderr to binary mode to avoid
        outputting DOS line terminators */
-    _setmode(_fileno(stdout), _O_BINARY);
-    _setmode(_fileno(stderr), _O_BINARY);
+    setmode(fileno(stdout), O_BINARY);
+    setmode(fileno(stderr), O_BINARY);
     #endif
 
     indent = getenv_int("JSON_INDENT");
     if(indent < 0 || indent > 31) {
         fprintf(stderr, "invalid value for JSON_INDENT: %d\n", indent);
