Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ext/yajl/extconf.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'mkmf'
require 'rbconfig'

$CFLAGS << ' -Wall -funroll-loops'
$CFLAGS << ' -Wextra -O0 -ggdb3' if ENV['DEBUG']
$CFLAGS << ' -Wall -funroll-loops' unless $mswin
$CFLAGS << ' -Wextra -O0 -ggdb3' if ENV['DEBUG'] && !$mswin

create_makefile('yajl/yajl')
16 changes: 11 additions & 5 deletions ext/yajl/yajl_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ static int yajl_found_boolean(void * ctx, int boolean) {
}

static int yajl_found_number(void * ctx, const char * numberVal, unsigned int numberLen) {
char buf[numberLen+1];
char *buf = ruby_xmalloc(numberLen+1);
buf[numberLen] = 0;
memcpy(buf, numberVal, numberLen);

Expand All @@ -256,6 +256,7 @@ static int yajl_found_number(void * ctx, const char * numberVal, unsigned int nu
} else {
yajl_set_static_value(ctx, rb_cstr2inum(buf, 10));
}
ruby_xfree(buf);
return 1;
}

Expand Down Expand Up @@ -285,15 +286,17 @@ static int yajl_found_hash_key(void * ctx, const unsigned char * stringVal, unsi
#endif

if (wrapper->symbolizeKeys) {
char buf[stringLen+1];
VALUE stringEncoded;
char *buf = ruby_xmalloc(stringLen+1);
memcpy(buf, stringVal, stringLen);
buf[stringLen] = 0;
VALUE stringEncoded = rb_str_new2(buf);
stringEncoded = rb_str_new2(buf);
#ifdef HAVE_RUBY_ENCODING_H
rb_enc_associate(stringEncoded, rb_utf8_encoding());
#endif

yajl_set_static_value(ctx, ID2SYM(rb_to_id(stringEncoded)));
ruby_xfree(buf);
} else {
keyStr = rb_str_new((const char *)stringVal, stringLen);
#ifdef HAVE_RUBY_ENCODING_H
Expand Down Expand Up @@ -388,7 +391,8 @@ static VALUE rb_yajl_parser_new(int argc, VALUE * argv, VALUE klass) {
symbolizeKeys = 1;
}
}
cfg = (yajl_parser_config){allowComments, checkUTF8};
cfg.allowComments = allowComments;
cfg.checkUTF8 = checkUTF8;

obj = Data_Make_Struct(klass, yajl_parser_wrapper, yajl_parser_wrapper_mark, yajl_parser_wrapper_free, wrapper);
wrapper->parser = yajl_alloc(&callbacks, &cfg, NULL, (void *)obj);
Expand Down Expand Up @@ -587,7 +591,9 @@ static VALUE rb_yajl_encoder_new(int argc, VALUE * argv, VALUE klass) {
if (!indentString) {
indentString = defaultIndentString;
}
cfg = (yajl_gen_config){beautify, (const char *)indentString, htmlSafe};
cfg.beautify = beautify;
cfg.indentString = (const char *)indentString;
cfg.htmlSafe = htmlSafe;

obj = Data_Make_Struct(klass, yajl_encoder_wrapper, yajl_encoder_wrapper_mark, yajl_encoder_wrapper_free, wrapper);
wrapper->indentString = actualIndent;
Expand Down
2 changes: 2 additions & 0 deletions ext/yajl/yajl_gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#include "ruby.h"

#include "api/yajl_gen.h"
#include "yajl_buf.h"
#include "yajl_encode.h"
Expand Down