Skip to content
Merged
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
25 changes: 12 additions & 13 deletions dln.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ void *xrealloc();
# include <unistd.h>
#endif

#ifndef UNREACHABLE_RETURN
# define UNREACHABLE_RETURN(x) return (x)
#endif

#ifndef dln_loaderror
static void
dln_loaderror(const char *format, ...)
Expand Down Expand Up @@ -348,6 +352,7 @@ dln_open(const char *file)
void *handle;

#if defined(_WIN32)
# define DLN_DEFINED
char message[1024];

/* Convert the file path to wide char */
Expand All @@ -374,6 +379,7 @@ dln_open(const char *file)
# endif

#elif defined(USE_DLN_DLOPEN)
# define DLN_DEFINED

# ifndef RTLD_LAZY
# define RTLD_LAZY 1
Expand Down Expand Up @@ -505,7 +511,7 @@ abi_check_enabled_p(void)
static void *
dln_load_and_init(const char *file, const char *init_fct_name)
{
#if defined(_WIN32) || defined(USE_DLN_DLOPEN)
#if defined(DLN_DEFINED)
void *handle = dln_open(file);

#ifdef RUBY_DLN_CHECK_ABI
Expand All @@ -523,6 +529,7 @@ dln_load_and_init(const char *file, const char *init_fct_name)
return handle;

#elif defined(_AIX)
# define DLN_DEFINED
{
void (*init_fct)(void);

Expand All @@ -539,33 +546,25 @@ dln_load_and_init(const char *file, const char *init_fct_name)
}
#else
dln_notimplement();
UNREACHABLE_RETURN(0);
#endif

return 0; /* dummy return */
}

void *
dln_load(const char *file)
{
#if defined(_WIN32) || defined(USE_DLN_DLOPEN)
char *init_fct_name;
init_funcname(&init_fct_name, file);
return dln_load_and_init(file, init_fct_name);
#else
dln_notimplement();
return 0;
#endif
return dln_load_feature(file, file);
}

void *
dln_load_feature(const char *file, const char *fname)
{
#if defined(_WIN32) || defined(USE_DLN_DLOPEN)
#if defined(DLN_DEFINED)
char *init_fct_name;
init_funcname(&init_fct_name, fname);
return dln_load_and_init(file, init_fct_name);
#else
dln_notimplement();
return 0;
UNREACHABLE_RETURN(0);
#endif
}
12 changes: 12 additions & 0 deletions ext/json/lib/json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,18 @@
# When enabled:
# JSON.parse(%{"Hello\nWorld"}, allow_control_characters: true) # => "Hello\nWorld"
#
# ---
#
# Option +allow_invalid_escape+ (boolean) specifies whether to ignore backslahes that are followed
# by an invalid escape character in strings;
# defaults to +false+.
#
# With the default, +false+:
# JSON.parse(%{"Hell\\o"}) # invalid escape character in string (JSON::ParserError)
#
# When enabled:
# JSON.parse(%{"Hell\\o"}, allow_invalid_escape: true) # => "Hello"
#
# ====== Output Options
#
# Option +freeze+ (boolean) specifies whether the returned objects will be frozen;
Expand Down
10 changes: 8 additions & 2 deletions ext/json/parser/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ static VALUE CNaN, CInfinity, CMinusInfinity;

static ID i_new, i_try_convert, i_uminus, i_encode;

static VALUE sym_max_nesting, sym_allow_nan, sym_allow_trailing_comma, sym_allow_control_characters, sym_symbolize_names, sym_freeze,
sym_decimal_class, sym_on_load, sym_allow_duplicate_key;
static VALUE sym_max_nesting, sym_allow_nan, sym_allow_trailing_comma, sym_allow_control_characters,
sym_allow_invalid_escape, sym_symbolize_names, sym_freeze, sym_decimal_class, sym_on_load,
sym_allow_duplicate_key;

static int binary_encindex;
static int utf8_encindex;
Expand Down Expand Up @@ -336,6 +337,7 @@ typedef struct JSON_ParserStruct {
bool allow_nan;
bool allow_trailing_comma;
bool allow_control_characters;
bool allow_invalid_escape;
bool symbolize_names;
bool freeze;
} JSON_ParserConfig;
Expand Down Expand Up @@ -746,6 +748,8 @@ NOINLINE(static) VALUE json_string_unescape(JSON_ParserState *state, JSON_Parser
}
raise_parse_error_at("invalid ASCII control character in string: %s", state, pe - 1);
}
} else if (config->allow_invalid_escape) {
APPEND_CHAR(*pe);
} else {
raise_parse_error_at("invalid escape character in string: %s", state, pe - 1);
}
Expand Down Expand Up @@ -1435,6 +1439,7 @@ static int parser_config_init_i(VALUE key, VALUE val, VALUE data)
else if (key == sym_allow_nan) { config->allow_nan = RTEST(val); }
else if (key == sym_allow_trailing_comma) { config->allow_trailing_comma = RTEST(val); }
else if (key == sym_allow_control_characters) { config->allow_control_characters = RTEST(val); }
else if (key == sym_allow_invalid_escape) { config->allow_invalid_escape = RTEST(val); }
else if (key == sym_symbolize_names) { config->symbolize_names = RTEST(val); }
else if (key == sym_freeze) { config->freeze = RTEST(val); }
else if (key == sym_on_load) { config->on_load_proc = RTEST(val) ? val : Qfalse; }
Expand Down Expand Up @@ -1653,6 +1658,7 @@ void Init_parser(void)
sym_allow_nan = ID2SYM(rb_intern("allow_nan"));
sym_allow_trailing_comma = ID2SYM(rb_intern("allow_trailing_comma"));
sym_allow_control_characters = ID2SYM(rb_intern("allow_control_characters"));
sym_allow_invalid_escape = ID2SYM(rb_intern("allow_invalid_escape"));
sym_symbolize_names = ID2SYM(rb_intern("symbolize_names"));
sym_freeze = ID2SYM(rb_intern("freeze"));
sym_on_load = ID2SYM(rb_intern("on_load"));
Expand Down
7 changes: 7 additions & 0 deletions lib/prism/translation/ripper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2623,6 +2623,13 @@ def visit_nil_node(node)
on_var_ref(on_kw("nil"))
end

# def foo(&nil); end
# ^^^^
def visit_no_block_parameter_node(node)
bounds(node.location)
on_blockarg(:nil)
end

# def foo(**nil); end
# ^^^^^
def visit_no_keywords_parameter_node(node)
Expand Down
Loading