Skip to content

Commit

Permalink
Add errno_ptr property for Universal Parser
Browse files Browse the repository at this point in the history
  • Loading branch information
yui-knk committed Dec 28, 2023
1 parent 02973b7 commit 4374236
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ruby_parser.c
Expand Up @@ -450,6 +450,12 @@ ruby_verbose2(void)
return ruby_verbose;
}

static int *
rb_errno_ptr2(void)
{
return rb_errno_ptr();
}

static int
type_p(VALUE obj, int t)
{
Expand Down Expand Up @@ -724,6 +730,7 @@ rb_parser_config_initialize(rb_parser_config_t *config)
config->bug = rb_bug;
config->fatal = rb_fatal;
config->verbose = ruby_verbose2;
config->errno_ptr = rb_errno_ptr2;

config->make_backtrace = rb_make_backtrace;

Expand Down
1 change: 1 addition & 0 deletions rubyparser.h
Expand Up @@ -1352,6 +1352,7 @@ typedef struct rb_parser_config_struct {
void (*bug)(const char *fmt, ...);
void (*fatal)(const char *fmt, ...);
VALUE (*verbose)(void);
int *(*errno_ptr)(void);

/* VM */
VALUE (*make_backtrace)(void);
Expand Down
2 changes: 2 additions & 0 deletions universal_parser.c
Expand Up @@ -331,6 +331,8 @@ struct rb_imemo_tmpbuf_struct {
#define rb_fatal p->config->fatal
#undef ruby_verbose
#define ruby_verbose p->config->verbose()
#undef errno
#define errno (*p->config->errno_ptr())

#define rb_make_backtrace p->config->make_backtrace

Expand Down

0 comments on commit 4374236

Please sign in to comment.