ruby-changes:56116
From: Nobuyoshi <ko1@a...>
Date: Sat, 15 Jun 2019 12:16:47 +0900 (JST)
Subject: [ruby-changes:56116] Nobuyoshi Nakada: 6fa4c90448 (trunk): Prefer `enum yytokentype` to int
https://git.ruby-lang.org/ruby.git/commit/?id=6fa4c90448 From 6fa4c904483588d2aa08d1fd84e2b8efc95227df Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sat, 15 Jun 2019 11:58:02 +0900 Subject: Prefer `enum yytokentype` to int diff --git a/ext/ripper/eventids2.c b/ext/ripper/eventids2.c index 66e7c8f..663f8c1 100644 --- a/ext/ripper/eventids2.c +++ b/ext/ripper/eventids2.c @@ -294,13 +294,13 @@ static const struct token_assoc { https://github.com/ruby/ruby/blob/trunk/ext/ripper/eventids2.c#L294 }; static ID -ripper_token2eventid(int tok) +ripper_token2eventid(enum yytokentype tok) { int i; for (i = 0; i < numberof(token_to_eventid); i++) { const struct token_assoc *const a = &token_to_eventid[i]; - if (a->token == tok) + if ((enum yytokentype)a->token == tok) return *(const ID *)((const char *)&ripper_scanner_ids + a->id_offset); } if (tok < 256) { diff --git a/parse.y b/parse.y index bac64e4..1ce75fd 100644 --- a/parse.y +++ b/parse.y @@ -5330,7 +5330,7 @@ ripper_has_scan_event(struct parser_params *p) https://github.com/ruby/ruby/blob/trunk/parse.y#L5330 } static VALUE -ripper_scan_event_val(struct parser_params *p, int t) +ripper_scan_event_val(struct parser_params *p, enum yytokentype t) { VALUE str = STR_NEW(p->lex.ptok, p->lex.pcur - p->lex.ptok); VALUE rval = ripper_dispatch1(p, ripper_token2eventid(t), str); @@ -5339,7 +5339,7 @@ ripper_scan_event_val(struct parser_params *p, int t) https://github.com/ruby/ruby/blob/trunk/parse.y#L5339 } static void -ripper_dispatch_scan_event(struct parser_params *p, int t) +ripper_dispatch_scan_event(struct parser_params *p, enum yytokentype t) { if (!ripper_has_scan_event(p)) return; add_mark_object(p, yylval_rval = ripper_scan_event_val(p, t)); @@ -5347,7 +5347,7 @@ ripper_dispatch_scan_event(struct parser_params *p, int t) https://github.com/ruby/ruby/blob/trunk/parse.y#L5347 #define dispatch_scan_event(p, t) ripper_dispatch_scan_event(p, t) static void -ripper_dispatch_delayed_token(struct parser_params *p, int t) +ripper_dispatch_delayed_token(struct parser_params *p, enum yytokentype t) { int saved_line = p->ruby_sourceline; const char *saved_tokp = p->lex.ptok; -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/