]> granicus.if.org Git - json-c/commitdiff
* Fix bug in escaping of control characters
authorMichael Clark <michael@metaparadigm.com>
Tue, 13 Mar 2007 08:26:25 +0000 (08:26 +0000)
committerMichael Clark <michael@metaparadigm.com>
Tue, 13 Mar 2007 08:26:25 +0000 (08:26 +0000)
    Johan Bj�rklund, johbjo09 at kth dot se
  * Remove include "config.h" from headers (should only
    be included from .c files)
    Michael Clark <michael@metaparadigm.com>

git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@12 327403b1-1117-474d-bef2-5cb71233fd97

ChangeLog
README.html
bits.h
debug.h
json_object.c
json_object.h
json_tokener.c
json_tokener.h
json_util.c
json_util.h
linkhash.h

index 3b0d1bba30a28f51e2e96928e68ebedcda21894e..a0f848e26107c4bacb1cb1379c2e2ae955772024 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+0.6
+  * Fix bug in escaping of control characters
+    Johan Björklund, johbjo09 at kth dot se
+  * Remove include "config.h" from headers (should only
+    be included from .c files)
+    Michael Clark <michael@metaparadigm.com>
+
 0.5
   * Make headers C++ compatible by change *this to *obj
   * Add ifdef C++ extern "C" to headers
index c55600a96595128655876b88f2342bca5c904f0f..7b3a65ebe9a07d59081c4ab2df075d415b1ed053 100644 (file)
@@ -8,7 +8,7 @@
        </head>\r
        <body>\r
                <h2>JSON-C - A JSON implementation in C</h2>\r
-               <p>Latest release: <a href="json-c-0.5.tar.gz">json-c-0.5.tar.gz</a></p>\r
+               <p>Latest release: <a href="json-c-0.6.tar.gz">json-c-0.6.tar.gz</a></p>\r
                <p>JSON-C implements a reference counting object model that allows you to easily \r
                        construct JSON objects in C, output them as JSON formatted strings and parse \r
                        JSON formatted strings back into the C representation of JSON objects.</p>\r
diff --git a/bits.h b/bits.h
index 379793ae3cf5866f834ee2a5705381c78987780a..2c107cce11a42fd1dd7821613e55dcb4666d1484 100644 (file)
--- a/bits.h
+++ b/bits.h
@@ -1,5 +1,5 @@
 /*
- * $Id: bits.h,v 1.9 2006/01/26 02:16:28 mclark Exp $
+ * $Id: bits.h,v 1.10 2006/01/30 23:07:57 mclark Exp $
  *
  * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
  * Michael Clark <michael@metaparadigm.com>
 #ifndef _bits_h_
 #define _bits_h_
 
-#include "config.h"
-
-#if STDC_HEADERS
-# include <stddef.h>
-#endif /* STDC_HEADERS */
-
-/* CAW: wrapped in ifndef's to make win32 compliant
-**      this fails to take over GCC specifics, but this
-**      seems to be unimportant.
- */
-
 #ifndef min
 #define min(a,b) ((a) < (b) ? (a) : (b))
 #endif
diff --git a/debug.h b/debug.h
index f825a44cf57570d89280cdfb5ae544a12d03ef65..1db69ef016d6a405fe6272ed5abcbed2083fff82 100644 (file)
--- a/debug.h
+++ b/debug.h
@@ -1,5 +1,5 @@
 /*
- * $Id: debug.h,v 1.4 2006/01/26 02:16:28 mclark Exp $
+ * $Id: debug.h,v 1.5 2006/01/30 23:07:57 mclark Exp $
  *
  * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
  * Michael Clark <michael@metaparadigm.com>
 #ifndef _DEBUG_H_
 #define _DEBUG_H_
 
-#include "config.h"
-
-#if HAVE_STRERROR
-#define errstr strerror(errno)
-#else /* !HAVE_STRERROR */
-#define errstr
-#endif /* HAVE_STRERROR */
-
 extern void mc_set_debug(int debug);
 extern int mc_get_debug();
 
index fecd72bf1fabca9bfdc49235609263f2ca0c58dd..525e2171e9aac12ea47e4e5c1867a4293e292b56 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: json_object.c,v 1.14 2006/01/26 02:16:28 mclark Exp $
+ * $Id: json_object.c,v 1.15 2006/01/30 23:07:57 mclark Exp $
  *
  * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
  * Michael Clark <michael@metaparadigm.com>
 #include "json_object_private.h"
 #include "json_tokener.h"
 
+#if !HAVE_STRNDUP
+  char* strndup(const char* str, size_t n);
+#endif /* !HAVE_STRNDUP */
+
 /* #define REFCOUNT_DEBUG 1 */
 
 char *json_number_chars = "0123456789.+-e";
@@ -78,10 +82,12 @@ static void json_object_fini() {
 static int json_escape_str(struct printbuf *pb, char *str)
 {
   int pos = 0, start_offset = 0;
-  char c;
+  unsigned char c;
   do {
     c = str[pos];
     switch(c) {
+    case '\0':
+      break;
     case '\b':
     case '\n':
     case '\r':
@@ -97,14 +103,14 @@ static int json_escape_str(struct printbuf *pb, char *str)
       start_offset = ++pos;
       break;
     default:
-      if(c && c < ' ') {
+      if(c < ' ') {
        if(pos - start_offset > 0)
          printbuf_memappend(pb, str + start_offset, pos - start_offset);
        sprintbuf(pb, "\\u00%c%c",
                  json_hex_chars[c >> 4],
                  json_hex_chars[c & 0xf]);
        start_offset = ++pos;
-      } else if(c) pos++;
+      } else pos++;
     }
   } while(c);
   if(pos - start_offset > 0)
index 423244702b22af603eec9cb38992aa581403c894..5c25968dbaf0e09c3c637e513090ca7216a981b7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: json_object.h,v 1.11 2006/01/26 02:16:28 mclark Exp $
+ * $Id: json_object.h,v 1.12 2006/01/30 23:07:57 mclark Exp $
  *
  * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
  * Michael Clark <michael@metaparadigm.com>
@@ -12,8 +12,6 @@
 #ifndef _json_object_h_
 #define _json_object_h_
 
-#include "config.h"
-
 #define JSON_OBJECT_DEF_HASH_ENTIRES 16
 
 #undef FALSE
index 6a1ea893a615bf8ee018cbc447007c6179085aae..a3ebf10878b2619151e8325c21fbca9ac7dcb981 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: json_tokener.c,v 1.18 2006/01/26 02:16:28 mclark Exp $
+ * $Id: json_tokener.c,v 1.19 2006/01/30 23:07:57 mclark Exp $
  *
  * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
  * Michael Clark <michael@metaparadigm.com>
 #include "json_object.h"
 #include "json_tokener.h"
 
+#if !HAVE_STRNCASECMP && defined(_MSC_VER)
+  /* MSC has the version as _strnicmp */
+# define strncasecmp _strnicmp
+#elif !HAVE_STRNCASECMP
+# error You do not have strncasecmp on your system.
+#endif /* HAVE_STRNCASECMP */
+
+
 static struct json_object* json_tokener_do_parse(struct json_tokener *this);
 
 struct json_object* json_tokener_parse(char * s)
index f36c05851453bf499dfb256c24517a1e90cda0ce..12227a996bb8a93786e9855b837424a192f1cc74 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: json_tokener.h,v 1.8 2006/01/26 02:16:28 mclark Exp $
+ * $Id: json_tokener.h,v 1.9 2006/01/30 23:07:57 mclark Exp $
  *
  * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
  * Michael Clark <michael@metaparadigm.com>
@@ -12,7 +12,6 @@
 #ifndef _json_tokener_h_
 #define _json_tokener_h_
 
-#include "config.h"
 #include "json_object.h"
 
 enum json_tokener_error {
@@ -59,17 +58,6 @@ struct json_tokener
   struct printbuf *pb;
 };
 
-#if !HAVE_STRNCASECMP && defined(_MSC_VER)
-  /* MSC has the version as _strnicmp */
-# define strncasecmp _strnicmp
-#elif !HAVE_STRNCASECMP
-# error You do not have strncasecmp on your system.  
-#endif /* HAVE_STRNCASECMP */
-
-#if !HAVE_STRNDUP
-  char* strndup(const char* str, size_t n);
-#endif /* !HAVE_STRNDUP */
-
 extern struct json_object* json_tokener_parse(char *s);
 
 #endif
index 0aaf0f796f55f671b6bd89ddc8a3f089df94df0c..e20be240387e13d3500de53169071b05aca03a41 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: json_util.c,v 1.3 2006/01/26 02:16:28 mclark Exp $
+ * $Id: json_util.c,v 1.4 2006/01/30 23:07:57 mclark Exp $
  *
  * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
  * Michael Clark <michael@metaparadigm.com>
 # include <io.h>
 #endif /* defined(WIN32) */
 
+#if !HAVE_OPEN && defined(WIN32)
+# define open _open
+#endif
+
+
 #include "bits.h"
 #include "debug.h"
 #include "printbuf.h"
index cbaab5d45185ca9c32ed9b8f2ddb3b86056363ca..30fe2ab2c4dfefceb88cfc9b82fa694833f58d91 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: json_util.h,v 1.3 2006/01/26 02:16:28 mclark Exp $
+ * $Id: json_util.h,v 1.4 2006/01/30 23:07:57 mclark Exp $
  *
  * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
  * Michael Clark <michael@metaparadigm.com>
 #ifndef _json_util_h_
 #define _json_util_h_
 
-#include "config.h"
-
-#ifdef WIN32
-# define WIN32_LEAN_AND_MEAN
-# include <windows.h>
-# include <io.h>
-#endif
-
 #include "json_object.h"
 
-#if !HAVE_OPEN && defined(WIN32)
-# define open _open
-#endif
-
 #define JSON_FILE_BUF_SIZE 4096
 
 /* utlitiy functions */
index 86110b89b1bf8c9653d2c9cb23361df4c8f85dab..5c9fa852d8efba088164e22f4203cd935d0cc5bb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: linkhash.h,v 1.5 2006/01/26 02:16:28 mclark Exp $
+ * $Id: linkhash.h,v 1.6 2006/01/30 23:07:57 mclark Exp $
  *
  * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
  * Michael Clark <michael@metaparadigm.com>
@@ -12,8 +12,6 @@
 #ifndef _linkhash_h_
 #define _linkhash_h_
 
-#include "config.h"
-
 /**
  * golden prime used in hash functions
  */