Skip to content

Commit

Permalink
bring over latest from yajl upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
brianmario committed Dec 19, 2010
1 parent 7c0a60f commit 12b105a
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 10 deletions.
6 changes: 5 additions & 1 deletion ext/api/yajl_common.h
Expand Up @@ -49,7 +49,11 @@ extern "C" {
# define YAJL_API __declspec(dllimport)
# endif
#else
# define YAJL_API
# if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
# define YAJL_API __attribute__ ((visibility("default")))
# else
# define YAJL_API
# endif
#endif

/** pointer to a malloc function, supporting client overriding memory
Expand Down
2 changes: 1 addition & 1 deletion ext/api/yajl_gen.h
Expand Up @@ -134,7 +134,7 @@ extern "C" {
const unsigned char * str,
unsigned int len);
YAJL_API yajl_gen_status yajl_gen_null(yajl_gen hand);
YAJL_API yajl_gen_status yajl_gen_bool(yajl_gen hand, int boolean);
YAJL_API yajl_gen_status yajl_gen_bool(yajl_gen hand, int boolean);
YAJL_API yajl_gen_status yajl_gen_map_open(yajl_gen hand);
YAJL_API yajl_gen_status yajl_gen_map_close(yajl_gen hand);
YAJL_API yajl_gen_status yajl_gen_array_open(yajl_gen hand);
Expand Down
6 changes: 3 additions & 3 deletions ext/api/yajl_parse.h
Expand Up @@ -131,12 +131,12 @@ extern "C" {
const yajl_parser_config * config,
const yajl_alloc_funcs * allocFuncs,
void * ctx);

/** allow resetting of the lexer without the need to realloc a new parser */
void yajl_reset_parser(yajl_handle hand);

/** free a parser handle */
void YAJL_API yajl_free(yajl_handle handle);
/** free a parser handle */
YAJL_API void yajl_free(yajl_handle handle);

/** Parse some json!
* \param hand - a handle to the json parser allocated with yajl_alloc
Expand Down
23 changes: 23 additions & 0 deletions ext/api/yajl_version.h
@@ -0,0 +1,23 @@
#ifndef YAJL_VERSION_H_
#define YAJL_VERSION_H_

#include "api/yajl_common.h"

#define YAJL_MAJOR 1
#define YAJL_MINOR 0
#define YAJL_MICRO 11

#define YAJL_VERSION ((YAJL_MAJOR * 10000) + (YAJL_MINOR * 100) + YAJL_MICRO)

#ifdef __cplusplus
extern "C" {
#endif

extern int YAJL_API yajl_version(void);

#ifdef __cplusplus
}
#endif

#endif /* YAJL_VERSION_H_ */

4 changes: 2 additions & 2 deletions ext/yajl_gen.c
Expand Up @@ -171,7 +171,7 @@ yajl_gen_free(yajl_gen g)
} \

#define FINAL_NEWLINE

yajl_gen_status
yajl_gen_integer(yajl_gen g, long int number)
{
Expand All @@ -197,7 +197,7 @@ yajl_gen_double(yajl_gen g, double number)
ENSURE_VALID_STATE; ENSURE_NOT_KEY;
if (isnan(number) || isinf(number)) return yajl_gen_invalid_number;
INSERT_SEP; INSERT_WHITESPACE;
sprintf(i, "%g", number);
sprintf(i, "%.20g", number);
g->print(g->ctx, i, strlen(i));
APPENDED_ATOM;
FINAL_NEWLINE;
Expand Down
7 changes: 4 additions & 3 deletions ext/yajl_lex.c
Expand Up @@ -131,11 +131,12 @@ yajl_lex_alloc(yajl_alloc_funcs * alloc,

yajl_lexer
yajl_lex_realloc(yajl_lexer orig) {
orig->lineOff = 0;
orig->charOff = 0;
orig->error = yajl_lex_e_ok;
yajl_buf_clear(orig->buf);
orig->bufInUse = 0;
orig->bufOff = 0;
orig->lineOff = 0;
orig->lineOff = 0;
orig->bufInUse = 0;
return orig;
}

Expand Down
7 changes: 7 additions & 0 deletions ext/yajl_version.c
@@ -0,0 +1,7 @@
#include "api/yajl_version.h"

int yajl_version(void)
{
return YAJL_VERSION;
}

0 comments on commit 12b105a

Please sign in to comment.