ruby-changes:71274
From: Nobuyoshi <ko1@a...>
Date: Fri, 25 Feb 2022 19:52:46 +0900 (JST)
Subject: [ruby-changes:71274] d54a3df2e5 (master): [ruby/date] Separate era from preceding word
https://git.ruby-lang.org/ruby.git/commit/?id=d54a3df2e5 From d54a3df2e53a964c8bb36b87bc10ba2512830a60 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Fri, 9 Jul 2021 06:41:29 +0900 Subject: [ruby/date] Separate era from preceding word https://github.com/ruby/date/commit/017149e53e --- ext/date/date_parse.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ext/date/date_parse.c b/ext/date/date_parse.c index 0e7067f4d8..021df3793b 100644 --- a/ext/date/date_parse.c +++ b/ext/date/date_parse.c @@ -694,6 +694,9 @@ parse_time(VALUE str, VALUE hash) https://github.com/ruby/ruby/blob/trunk/ext/date/date_parse.c#L694 #endif } +#define BEGIN_ERA "\\b" +#define END_ERA "(?!(?<!\\.)[a-z])" + #ifdef TIGHT_PARSER static int parse_era1_cb(VALUE m, VALUE hash) @@ -705,7 +708,7 @@ static int https://github.com/ruby/ruby/blob/trunk/ext/date/date_parse.c#L708 parse_era1(VALUE str, VALUE hash) { static const char pat_source[] = - "(a(?:d|\\.d\\.))"; + BEGIN_ERA "(a(?:d\\b|\\.d\\.))" END_ERA; static VALUE pat = Qnil; REGCOMP_I(pat); @@ -727,8 +730,9 @@ parse_era2_cb(VALUE m, VALUE hash) https://github.com/ruby/ruby/blob/trunk/ext/date/date_parse.c#L730 static int parse_era2(VALUE str, VALUE hash) { - static const char pat_source[] = - "(c(?:e|\\.e\\.)|b(?:ce|\\.c\\.e\\.)|b(?:c|\\.c\\.))"; + static const char pat_source[] = BEGIN_ERA + "(c(?:e\\b|\\.e\\.)|b(?:ce\\b|\\.c\\.e\\.)|b(?:c\\b|\\.c\\.))" + END_ERA; static VALUE pat = Qnil; REGCOMP_I(pat); @@ -845,7 +849,11 @@ parse_eu(VALUE str, VALUE hash) https://github.com/ruby/ruby/blob/trunk/ext/date/date_parse.c#L849 "(?:" "\\s*" #ifndef TIGHT_PARSER - "(c(?:e|\\.e\\.)|b(?:ce|\\.c\\.e\\.)|a(?:d|\\.d\\.)|b(?:c|\\.c\\.))?" + "(?:" + BEGIN_ERA + "(c(?:e|\\.e\\.)|b(?:ce|\\.c\\.e\\.)|a(?:d|\\.d\\.)|b(?:c|\\.c\\.))" + END_ERA + ")?" "\\s*" "('?-?\\d+(?:(?:st|nd|rd|th)\\b)?)" #else -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/