Merge branch '1.0'
authorPetri Lehtinen <petri@digip.org>
Sun, 11 Oct 2009 18:51:54 +0000 (21:51 +0300)
committerPetri Lehtinen <petri@digip.org>
Sun, 11 Oct 2009 18:51:54 +0000 (21:51 +0300)
Conflicts:
configure.ac
doc/conf.py

1  2 
configure.ac
doc/conf.py
src/Makefile.am
src/dump.c
src/load.c

diff --combined configure.ac
@@@ -1,5 -1,5 +1,5 @@@
- AC_PREREQ([2.63])
- AC_INIT([jansson], [1.0.3+], [petri@digip.org])
+ AC_PREREQ([2.59])
 -AC_INIT([jansson], [1.0.4], [petri@digip.org])
++AC_INIT([jansson], [1.0.4+], [petri@digip.org])
  
  AM_INIT_AUTOMAKE([1.10 foreign])
  
diff --combined doc/conf.py
@@@ -52,7 -52,7 +52,7 @@@ copyright = u'2009, Petri Lehtinen
  # The short X.Y version.
  version = '1.0'
  # The full version, including alpha/beta/rc tags.
- release = '1.0.3+'
 -release = '1.0.4'
++release = '1.0.4+'
  
  # The language for content autogenerated by Sphinx. Refer to documentation
  # for a list of supported languages.
diff --combined src/Makefile.am
@@@ -13,6 -13,6 +13,6 @@@ libjansson_la_SOURCES = 
        utf.h \
        util.h \
        value.c
- libjansson_la_LDFLAGS = -version-info 0:3:0
+ libjansson_la_LDFLAGS = -version-info 0:4:0
  
 -AM_CFLAGS = -Wall -Wextra -Werror -std=c99
 +AM_CFLAGS = -Wall -Wextra -Werror
diff --combined src/dump.c
@@@ -9,6 -9,7 +9,6 @@@
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
 -#include <unistd.h>
  
  #include <jansson.h>
  #include "strbuffer.h"
@@@ -35,23 -36,22 +35,23 @@@ static int dump_to_file(const char *buf
      return 0;
  }
  
 -static int dump_indent(uint32_t flags, int depth, dump_func dump, void *data)
 +/* 256 spaces (the maximum indentation size) */
 +static char whitespace[] = "                                                                                                                                                                                                                                                                ";
 +
 +static int dump_indent(unsigned long flags, int depth, dump_func dump, void *data)
  {
      if(JSON_INDENT(flags) > 0)
      {
 -        char *ws_buffer;
 -        int ws_count = JSON_INDENT(flags) * depth;
 +        int i, ws_count = JSON_INDENT(flags);
  
          if(dump("\n", 1, data))
              return -1;
  
 -        if(ws_count == 0)
 -            return 0;
 -
 -        ws_buffer = alloca(ws_count);
 -        memset(ws_buffer, ' ', ws_count);
 -        return dump(ws_buffer, ws_count, data);
 +        for(i = 0; i < depth; i++)
 +        {
 +            if(dump(whitespace, ws_count, data))
 +                return -1;
 +        }
      }
      return 0;
  }
@@@ -70,7 -70,7 +70,7 @@@ static int dump_string(const char *str
          char seq[7];
          int length;
  
-         while(*end && *end != '\\' && *end != '"' && (*end < 0 || *end > 0x1F))
+         while(*end && *end != '\\' && *end != '"' && (unsigned char)*end > 0x1F)
              end++;
  
          if(end != str) {
      return dump("\"", 1, data);
  }
  
 -static int do_dump(const json_t *json, uint32_t flags, int depth,
 +static int do_dump(const json_t *json, unsigned long flags, int depth,
                     dump_func dump, void *data)
  {
      switch(json_typeof(json)) {
  }
  
  
 -char *json_dumps(const json_t *json, uint32_t flags)
 +char *json_dumps(const json_t *json, unsigned long flags)
  {
      strbuffer_t strbuff;
      char *result;
      return result;
  }
  
 -int json_dumpf(const json_t *json, FILE *output, uint32_t flags)
 +int json_dumpf(const json_t *json, FILE *output, unsigned long flags)
  {
      if(!json_is_array(json) && !json_is_object(json))
          return -1;
      return dump_to_file("\n", 1, (void *)output);
  }
  
 -int json_dump_file(const json_t *json, const char *path, uint32_t flags)
 +int json_dump_file(const json_t *json, const char *path, unsigned long flags)
  {
      int result;
  
diff --combined src/load.c
@@@ -13,6 -13,7 +13,6 @@@
  #include <stdlib.h>
  #include <string.h>
  #include <stdarg.h>
 -#include <unistd.h>
  #include <assert.h>
  
  #include <jansson.h>
@@@ -134,7 -135,7 +134,7 @@@ static char stream_get(stream_t *stream
  
          c = stream->buffer[0];
  
-         if(c < 0 && c != EOF)
+         if((unsigned char)c >= 0x80 && c != (char)EOF)
          {
              /* multi-byte UTF-8 sequence */
              int i, count;
@@@ -257,14 -258,14 +257,14 @@@ static void lex_scan_string(lex_t *lex
      c = lex_get_save(lex, error);
  
      while(c != '"') {
-         if(c == EOF) {
+         if(c == (char)EOF) {
              lex_unget_unsave(lex, c);
              if(lex_eof(lex))
                  error_set(error, lex, "premature end of input");
              goto out;
          }
  
-         else if(0 <= c && c <= 0x1F) {
+         else if((unsigned char)c <= 0x1F) {
              /* control character */
              lex_unget_unsave(lex, c);
              if(c == '\n')
@@@ -518,7 -519,7 +518,7 @@@ static int lex_scan(lex_t *lex, json_er
          c = lex_get(lex, error);
      }
  
-     if(c == EOF) {
+     if(c == (char)EOF) {
          if(lex_eof(lex))
              lex->token = TOKEN_EOF;
          else
@@@ -571,17 -572,6 +571,17 @@@ out
      return lex->token;
  }
  
 +static char *lex_steal_string(lex_t *lex)
 +{
 +    char *result = NULL;
 +    if(lex->token == TOKEN_STRING)
 +    {
 +        result = lex->value.string;
 +        lex->value.string = NULL;
 +    }
 +    return result;
 +}
 +
  static int lex_init(lex_t *lex, get_func get, eof_func eof, void *data)
  {
      stream_init(&lex->stream, get, eof, data);
@@@ -625,7 -615,7 +625,7 @@@ static json_t *parse_object(lex_t *lex
              goto error;
          }
  
 -        key = strdup(lex->value.string);
 +        key = lex_steal_string(lex);
          if(!key)
              return NULL;