diff --git a/node.c b/node.c index 79ef00f1b7..9844401331 100644 --- a/node.c +++ b/node.c @@ -53,7 +53,7 @@ init_node_buffer_list(node_buffer_list_t * nb, node_buffer_elem_t *head, void *x #ifdef UNIVERSAL_PARSER static node_buffer_t * -rb_node_buffer_new(rb_parser_config_t *config) +rb_node_buffer_new(const rb_parser_config_t *config) #else static node_buffer_t * rb_node_buffer_new(void) @@ -318,7 +318,7 @@ rb_ast_delete_node(rb_ast_t *ast, NODE *n) #ifdef UNIVERSAL_PARSER rb_ast_t * -rb_ast_new(rb_parser_config_t *config) +rb_ast_new(const rb_parser_config_t *config) { node_buffer_t *nb = rb_node_buffer_new(config); return config->ast_new((VALUE)nb); diff --git a/node.h b/node.h index d8d104975a..009d39b856 100644 --- a/node.h +++ b/node.h @@ -43,14 +43,14 @@ struct node_buffer_struct { // Array, whose entry is array VALUE tokens; #ifdef UNIVERSAL_PARSER - rb_parser_config_t *config; + const rb_parser_config_t *config; #endif }; RUBY_SYMBOL_EXPORT_BEGIN #ifdef UNIVERSAL_PARSER -rb_ast_t *rb_ast_new(rb_parser_config_t *config); +rb_ast_t *rb_ast_new(const rb_parser_config_t *config); #else rb_ast_t *rb_ast_new(void); #endif diff --git a/parse.y b/parse.y index 339efb3297..7cb92b88e3 100644 --- a/parse.y +++ b/parse.y @@ -611,7 +611,7 @@ struct parser_params { struct lex_context ctxt; #ifdef UNIVERSAL_PARSER - rb_parser_config_t *config; + const rb_parser_config_t *config; #endif /* compile_option */ signed int frozen_string_literal:2; /* -1: not specified, 0: false, 1: true */ @@ -15989,7 +15989,7 @@ rb_reserved_word(const char *str, unsigned int len) #ifdef UNIVERSAL_PARSER rb_parser_t * -rb_ruby_parser_allocate(rb_parser_config_t *config) +rb_ruby_parser_allocate(const rb_parser_config_t *config) { /* parser_initialize expects fields to be set to 0 */ rb_parser_t *p = (rb_parser_t *)config->calloc(1, sizeof(rb_parser_t)); @@ -15998,7 +15998,7 @@ rb_ruby_parser_allocate(rb_parser_config_t *config) } rb_parser_t * -rb_ruby_parser_new(rb_parser_config_t *config) +rb_ruby_parser_new(const rb_parser_config_t *config) { /* parser_initialize expects fields to be set to 0 */ rb_parser_t *p = rb_ruby_parser_allocate(config); diff --git a/ruby_parser.c b/ruby_parser.c index a76a8231f5..d932b0f7be 100644 --- a/ruby_parser.c +++ b/ruby_parser.c @@ -484,7 +484,7 @@ extern VALUE rb_eArgError; extern VALUE rb_mRubyVMFrozenCore; VALUE rb_node_case_when_optimizable_literal(const NODE *const node); -rb_parser_config_t rb_global_parser_config = (rb_parser_config_t) { +static const rb_parser_config_t rb_global_parser_config = { .malloc = ruby_xmalloc, .calloc = ruby_xcalloc, .realloc = ruby_xrealloc, diff --git a/rubyparser.h b/rubyparser.h index 974a03992c..2bd93bf0b2 100644 --- a/rubyparser.h +++ b/rubyparser.h @@ -1439,8 +1439,8 @@ void rb_ruby_parser_free(void *ptr); rb_ast_t* rb_ruby_parser_compile_string(rb_parser_t *p, const char *f, VALUE s, int line); #ifdef UNIVERSAL_PARSER -rb_parser_t *rb_ruby_parser_allocate(rb_parser_config_t *config); -rb_parser_t *rb_ruby_parser_new(rb_parser_config_t *config); +rb_parser_t *rb_ruby_parser_allocate(const rb_parser_config_t *config); +rb_parser_t *rb_ruby_parser_new(const rb_parser_config_t *config); #endif long rb_parser_string_length(rb_parser_string_t *str);