diff options
author | Nobuyoshi Nakada <[email protected]> | 2024-09-28 00:20:09 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2024-09-28 01:59:33 +0900 |
commit | 7e19904c88fde024051333dfbd534b9fd3b26bf9 () | |
tree | ac4cc1b5628c30d8212c7d7ad809ac3815c97fa3 | |
parent | d1324170b6c25e893b0dec4d7829e6d561b15cf3 (diff) |
Remove on `RSTRING_END` dependency from parser
Notes: Merged: https://.com/ruby/ruby/pull/11713
-rw-r--r-- | parse.y | 19 | ||||
-rw-r--r-- | ruby_parser.c | 1 | ||||
-rw-r--r-- | rubyparser.h | 1 | ||||
-rw-r--r-- | universal_parser.c | 2 |
4 files changed, 10 insertions, 13 deletions
@@ -709,10 +709,11 @@ after_pop_stack(int len, struct parser_params *p) #define VALID_SYMNAME_P(s, l, enc, type) (rb_enc_symname_type(s, l, enc, (1U<<(type))) == (int)(type)) #ifndef RIPPER -static inline bool -end_with_newline_p(struct parser_params *p, VALUE str) { - return RSTRING_LEN(str) > 0 && RSTRING_END(str)[-1] == '\n'; } #endif @@ -2002,10 +2003,10 @@ parser_memhash(const void *ptr, long len) ((ptrvar) = str->ptr, \ (lenvar) = str->len) -static inline bool -parser_string_end_with_newline_p(struct parser_params *p, rb_parser_string_t *str) { - return PARSER_STRING_LEN(str) > 0 && PARSER_STRING_END(str)[-1] == '\n'; } static rb_parser_string_t * @@ -7354,7 +7355,7 @@ ruby_show_error_line(struct parser_params *p, VALUE errbuf, const YYLTYPE *yyllo } if (RTEST(errbuf)) { mesg = rb_attr_get(errbuf, idMesg); - if (RSTRING_LEN(mesg) > 0 && *(RSTRING_END(mesg)-1) != '\n') rb_str_cat_cstr(mesg, "\n"); } else { @@ -7750,7 +7751,7 @@ parser_add_delayed_token(struct parser_params *p, const char *tok, const char *e if (tok < end) { if (has_delayed_token(p)) { - bool next_line = parser_string_end_with_newline_p(p, p->delayed.token); int end_line = (next_line ? 1 : 0) + p->delayed.end_line; int end_col = (next_line ? 0 : p->delayed.end_col); if (end_line != p->ruby_sourceline || end_col != tok - p->lex.pbeg) { @@ -15961,7 +15962,7 @@ rb_parser_printf(struct parser_params *p, const char *fmt, ...) va_start(ap, fmt); rb_str_vcatf(mesg, fmt, ap); va_end(ap); - if (end_with_newline_p(p, mesg)) { rb_io_write(p->debug_output, mesg); p->debug_buffer = Qnil; } @@ -373,7 +373,6 @@ static const rb_parser_config_t rb_global_parser_config = { .str_vcatf = rb_str_vcatf, .rb_sprintf = rb_sprintf, .rstring_ptr = RSTRING_PTR, - .rstring_end = RSTRING_END, .rstring_len = RSTRING_LEN, .obj_as_string = rb_obj_as_string, @@ -1227,7 +1227,6 @@ typedef struct rb_parser_config_struct { RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2) VALUE (*rb_sprintf)(const char *format, ...); char *(*rstring_ptr)(VALUE str); - char *(*rstring_end)(VALUE str); long (*rstring_len)(VALUE str); VALUE (*obj_as_string)(VALUE); @@ -126,8 +126,6 @@ #define rb_sprintf p->config->rb_sprintf #undef RSTRING_PTR #define RSTRING_PTR p->config->rstring_ptr -#undef RSTRING_END -#define RSTRING_END p->config->rstring_end #undef RSTRING_LEN #define RSTRING_LEN p->config->rstring_len #define rb_obj_as_string p->config->obj_as_string |