diff options
author | Nobuyoshi Nakada <[email protected]> | 2024-05-12 23:12:02 +0900 |
---|---|---|
committer | Yuichiro Kaneko <[email protected]> | 2024-05-13 08:26:54 +0900 |
commit | 3c16d93cd3a7c4d1362e07070c9ed9826a7272a8 () | |
tree | 4c8b04c9e9e938fcbbcccb19da728e0028b89bca | |
parent | b911d2222f907d3fad397938e8f513ecfb4635b8 (diff) |
Constify encoding type in universal parser
Fixed warning about discarding modifiers. ``` ../src/ruby_parser.c:677:48: warning: passing 'rb_encoding *' (aka 'const struct OnigEncodingTypeST *') to parameter of type 'void *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] 677 | ast = rb_parser_compile(p, gets, ptr, len, enc, input, line); | ^~~ ../src/internal/parse.h:58:128: note: passing argument to parameter 'fname_enc' here 58 | rb_ast_t *rb_parser_compile(rb_parser_t *p, rb_parser_lex_gets_func *gets, const char *fname_ptr, long fname_len, rb_encoding *fname_enc, rb_parser_input_data input, int line); | ^ ```
-rw-r--r-- | internal/parse.h | 2 | ||||
-rw-r--r-- | ruby_parser.c | 98 | ||||
-rw-r--r-- | rubyparser.h | 2 | ||||
-rw-r--r-- | universal_parser.c | 2 |
4 files changed, 53 insertions, 51 deletions
@@ -13,7 +13,7 @@ #include "internal/static_assert.h" #ifdef UNIVERSAL_PARSER -#define rb_encoding void #endif struct rb_iseq_struct; /* in vm_core.h */ @@ -32,6 +32,8 @@ #include "vm_core.h" #include "symbol.h" static int is_ascii_string2(VALUE str) { @@ -41,9 +43,9 @@ is_ascii_string2(VALUE str) RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 6, 0) static VALUE syntax_error_append(VALUE exc, VALUE file, int line, int column, - void *enc, const char *fmt, va_list args) { - return rb_syntax_error_append(exc, file, line, column, (rb_encoding *)enc, fmt, args); } static int @@ -59,9 +61,9 @@ dvar_defined(ID id, const void *p) } static int -is_usascii_enc(void *enc) { - return rb_is_usascii_enc((rb_encoding *)enc); } static int @@ -83,21 +85,21 @@ is_notop_id2(ID id) } static VALUE -enc_str_new(const char *ptr, long len, void *enc) { - return rb_enc_str_new(ptr, len, (rb_encoding *)enc); } static int -enc_isalnum(OnigCodePoint c, void *enc) { - return rb_enc_isalnum(c, (rb_encoding *)enc); } static int -enc_precise_mbclen(const char *p, const char *e, void *enc) { - return rb_enc_precise_mbclen(p, e, (rb_encoding *)enc); } static int @@ -113,93 +115,93 @@ mbclen_charfound_len(int len) } static const char * -enc_name(void *enc) { - return rb_enc_name((rb_encoding *)enc); } static char * -enc_prev_char(const char *s, const char *p, const char *e, void *enc) { - return rb_enc_prev_char(s, p, e, (rb_encoding *)enc); } -static void * enc_get(VALUE obj) { - return (void *)rb_enc_get(obj); } static int -enc_asciicompat(void *enc) { - return rb_enc_asciicompat((rb_encoding *)enc); } -static void * utf8_encoding(void) { - return (void *)rb_utf8_encoding(); } static VALUE -enc_associate(VALUE obj, void *enc) { - return rb_enc_associate(obj, (rb_encoding *)enc); } -static void * ascii8bit_encoding(void) { - return (void *)rb_ascii8bit_encoding(); } static int -enc_codelen(int c, void *enc) { - return rb_enc_codelen(c, (rb_encoding *)enc); } static int -enc_mbcput(unsigned int c, void *buf, void *enc) { - return rb_enc_mbcput(c, buf, (rb_encoding *)enc); } static int -enc_mbclen(const char *p, const char *e, void *enc) { - return rb_enc_mbclen(p, e, (rb_encoding *)enc); } -static void * enc_from_index(int idx) { - return (void *)rb_enc_from_index(idx); } static int -enc_isspace(OnigCodePoint c, void *enc) { - return rb_enc_isspace(c, (rb_encoding *)enc); } static ID -intern3(const char *name, long len, void *enc) { - return rb_intern3(name, len, (rb_encoding *)enc); } -static void * usascii_encoding(void) { - return (void *)rb_usascii_encoding(); } static int -enc_symname_type(const char *name, long len, void *enc, unsigned int allowed_attrset) { - return rb_enc_symname_type(name, len, (rb_encoding *)enc, allowed_attrset); } typedef struct { @@ -220,7 +222,7 @@ reg_named_capture_assign_iter(const OnigUChar *name, const OnigUChar *name_end, long len = name_end - name; const char *s = (const char *)name; - return rb_reg_named_capture_assign_iter_impl(p, s, len, (void *)enc, &arg->succ_block, loc); } static NODE * @@ -305,25 +307,25 @@ static_id2sym(ID id) } static long -str_coderange_scan_restartable(const char *s, const char *e, void *enc, int *cr) { - return rb_str_coderange_scan_restartable(s, e, (rb_encoding *)enc, cr); } static int -enc_mbminlen(void *enc) { - return rb_enc_mbminlen((rb_encoding *)enc); } static bool -enc_isascii(OnigCodePoint c, void *enc) { - return rb_enc_isascii(c, (rb_encoding *)enc); } static OnigCodePoint -enc_mbc_to_codepoint(const char *p, const char *e, void *enc) { const OnigUChar *up = RBIMPL_CAST((const OnigUChar *)p); const OnigUChar *ue = RBIMPL_CAST((const OnigUChar *)e); @@ -9,7 +9,7 @@ #ifdef UNIVERSAL_PARSER -#define rb_encoding void #define OnigCodePoint unsigned int #include "parser_st.h" #ifndef RUBY_RUBY_H @@ -59,7 +59,7 @@ #undef st_lookup #define st_lookup rb_parser_st_lookup -#define rb_encoding void #undef xmalloc #define xmalloc p->config->malloc |