/*
- * Copyright (c) 2009 Petri Lehtinen <petri@digip.org>
+ * Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
#include <string.h>
#include <stdarg.h>
#include <assert.h>
+#include <stdint.h>
#include <jansson.h>
#include "jansson_private.h"
for(i = 1; i < count; i++)
stream->buffer[i] = stream->get(stream->data);
- if(!utf8_check_full(stream->buffer, count))
+ if(!utf8_check_full(stream->buffer, count, NULL))
goto out;
stream->stream_pos += count;
}
/* assumes that str points to 'u' plus at least 4 valid hex digits */
-static int decode_unicode_escape(const char *str)
+static int32_t decode_unicode_escape(const char *str)
{
int i;
- int value = 0;
+ int32_t value = 0;
assert(str[0] == 'u');
if(*p == 'u') {
char buffer[4];
int length;
- int value;
+ int32_t value;
value = decode_unicode_escape(p);
p += 5;
if(0xD800 <= value && value <= 0xDBFF) {
/* surrogate pair */
if(*p == '\\' && *(p + 1) == 'u') {
- int value2 = decode_unicode_escape(++p);
+ int32_t value2 = decode_unicode_escape(++p);
p += 5;
if(0xDC00 <= value2 && value2 <= 0xDFFF) {
goto out;
}
}
- else /* c != '0' */ {
+ else if(isdigit(c)) {
c = lex_get_save(lex, error);
while(isdigit(c))
c = lex_get_save(lex, error);
}
+ else {
+ lex_unget_unsave(lex, c);
+ goto out;
+ }
if(c != '.' && c != 'E' && c != 'e') {
long value;
return json;
}
-json_t *parse_json(lex_t *lex, json_error_t *error)
+static json_t *parse_json(lex_t *lex, json_error_t *error)
{
error_init(error);