parser.rl: rb_scan_args
* ext/json/parser/parser.rl (cParser_initialize): use ':' in rb_scan_args. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51936 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c416efa440
commit
f12fccbec5
@ -570,7 +570,7 @@ static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *resu
|
|||||||
|
|
||||||
static VALUE convert_encoding(VALUE source)
|
static VALUE convert_encoding(VALUE source)
|
||||||
{
|
{
|
||||||
char *ptr = RSTRING_PTR(source);
|
const char *ptr = RSTRING_PTR(source);
|
||||||
long len = RSTRING_LEN(source);
|
long len = RSTRING_LEN(source);
|
||||||
if (len < 2) {
|
if (len < 2) {
|
||||||
rb_raise(eParserError, "A JSON text must at least contain two octets!");
|
rb_raise(eParserError, "A JSON text must at least contain two octets!");
|
||||||
@ -643,12 +643,18 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
|
|||||||
if (json->Vsource) {
|
if (json->Vsource) {
|
||||||
rb_raise(rb_eTypeError, "already initialized instance");
|
rb_raise(rb_eTypeError, "already initialized instance");
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH
|
||||||
|
rb_scan_args(argc, argv, "1:", &source, &opts);
|
||||||
|
#else
|
||||||
rb_scan_args(argc, argv, "11", &source, &opts);
|
rb_scan_args(argc, argv, "11", &source, &opts);
|
||||||
|
#endif
|
||||||
if (!NIL_P(opts)) {
|
if (!NIL_P(opts)) {
|
||||||
|
#ifndef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH
|
||||||
opts = rb_convert_type(opts, T_HASH, "Hash", "to_hash");
|
opts = rb_convert_type(opts, T_HASH, "Hash", "to_hash");
|
||||||
if (NIL_P(opts)) {
|
if (NIL_P(opts)) {
|
||||||
rb_raise(rb_eArgError, "opts needs to be like a hash");
|
rb_raise(rb_eArgError, "opts needs to be like a hash");
|
||||||
} else {
|
} else {
|
||||||
|
#endif
|
||||||
VALUE tmp = ID2SYM(i_max_nesting);
|
VALUE tmp = ID2SYM(i_max_nesting);
|
||||||
if (option_given_p(opts, tmp)) {
|
if (option_given_p(opts, tmp)) {
|
||||||
VALUE max_nesting = rb_hash_aref(opts, tmp);
|
VALUE max_nesting = rb_hash_aref(opts, tmp);
|
||||||
@ -711,7 +717,9 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
|
|||||||
} else {
|
} else {
|
||||||
json->match_string = Qnil;
|
json->match_string = Qnil;
|
||||||
}
|
}
|
||||||
|
#ifndef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
json->max_nesting = 100;
|
json->max_nesting = 100;
|
||||||
json->allow_nan = 0;
|
json->allow_nan = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user