/*
- * 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"
/*** lexical analyzer ***/
-void stream_init(stream_t *stream, get_func get, eof_func eof, void *data)
+static void
+stream_init(stream_t *stream, get_func get, eof_func eof, void *data)
{
stream->get = get;
stream->eof = eof;
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;
value = strtod(saved_text, &end);
assert(end == saved_text + lex->saved_text.length);
- if(value == 0 && errno == ERANGE) {
- error_set(error, lex, "real number underflow");
- goto out;
- }
-
- /* Cannot test for +/-HUGE_VAL because the HUGE_VAL constant is
- only defined in C99 mode. So let's trust in sole errno. */
- else if(errno == ERANGE) {
+ if(errno == ERANGE && value != 0) {
error_set(error, lex, "real number overflow");
goto out;
}
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);