#include "libjson/linkhash.h"
#include "libjson/arraylist.h"
#include "libjson/json_object.h"
+#include "libjson/ossupport.h"
#include "libjson/json_object_private.h"
case '\n':
case '\r':
case '\t':
- case '"':
+ case '"':
if(pos - start_offset > 0)
printbuf_memappend(pb, str + start_offset, pos - start_offset);
if(c == '\b') printbuf_memappend(pb, "\\b", 2);
#include <ctype.h>
#include <string.h>
+#include "libjson/json_tokener.h"
#include "libjson/bits.h"
#include "libjson/debug.h"
#include "libjson/printbuf.h"
+#include "libjson/linkhash.h"
#include "libjson/arraylist.h"
#include "libjson/json_object.h"
-#include "libjson/json_tokener.h"
+#include "libjson/ossupport.h"
+#include "libjson/json_object_private.h"
+
static struct json_object* json_tokener_do_parse(struct json_tokener *this);
enum json_tokener_error err = json_tokener_success;
struct json_object *current = NULL, *obj;
char *obj_field_name = NULL;
- char quote_char = 0;
- int deemed_double = 0;
- int start_offset = 0;
+ char quote_char;
+ int deemed_double, start_offset;
state = json_tokener_state_eatws;
saved_state = json_tokener_state_start;
switch(c) {
case '"':
case '\\':
+ case '/':
printbuf_memappend(this->pb, this->source + start_offset,
this->pos - start_offset - 1);
start_offset = this->pos++;
#include <sys/stat.h>
#include <fcntl.h>
-#include "bits.h"
-#include "debug.h"
-#include "printbuf.h"
-#include "json_object.h"
-#include "json_tokener.h"
-#include "json_util.h"
+#include "libjson/json_util.h"
+#include "libjson/json_tokener.h"
+#include "libjson/bits.h"
+#include "libjson/debug.h"
+#include "libjson/printbuf.h"
+#include "libjson/linkhash.h"
+#include "libjson/arraylist.h"
+#include "libjson/json_object.h"
+#include "libjson/ossupport.h"
+#include "libjson/json_object_private.h"
+
struct json_object* json_object_from_file(char *filename)
{
struct printbuf *p;
- //if(!(p = calloc(1, sizeof(struct printbuf)))) return NULL;
-
- size_t len = sizeof(struct printbuf);
- p = (struct printbuf*) malloc(len);
- if(!p) return NULL;
- memset( p, 0, len );
-
+ if(!(p = calloc(1, sizeof(struct printbuf)))) return NULL;
p->size = 32;
p->bpos = 0;
-
- if(!(p->buf = (char*) malloc(p->size))) {
+ if(!(p->buf = malloc(p->size))) {
free(p);
return NULL;
}
-
- memset(p->buf, 0, p->size);
-
return p;
}
p->size = new_size;
p->buf = t;
}
-
- char* tmp = strdup(p->buf);
- memset( p->buf, 0, p->size);
- memcpy( p->buf, tmp, strlen(tmp));
- memcpy(p->buf + p->bpos, buf, size);
- free(tmp);
-
-
-// memcpy(p->buf + p->bpos, buf, size);
+ memcpy(p->buf + p->bpos, buf, size);
p->bpos += size;
p->buf[p->bpos]= '\0';
return size;