Add errno_ptr property for Universal Parser
authoryui-knk <[email protected]>
Thu, 28 Dec 2023 02:52:50 +0000 (28 11:52 +0900)
committerYuichiro Kaneko <[email protected]>
Thu, 28 Dec 2023 04:17:36 +0000 (28 13:17 +0900)
ruby_parser.c
rubyparser.h
universal_parser.c

index 68d4576..844dbba 100644 (file)
@@ -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)
 {
@@ -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;
 
index 0add750..e6a0a6b 100644 (file)
@@ -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);
index 8fc358b..61acaf7 100644 (file)
@@ -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