From 744c3140595c34171553515e127d080634704db3 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 1 Apr 2019 05:21:36 +0000 Subject: date_parse.c: extract Japanese era initials git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67397 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/date/date_parse.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'ext/date') diff --git a/ext/date/date_parse.c b/ext/date/date_parse.c index 69ac37f0a3..c9f93074b9 100644 --- a/ext/date/date_parse.c +++ b/ext/date/date_parse.c @@ -1212,6 +1212,8 @@ parse_iso2(VALUE str, VALUE hash) return 1; } +#define JAPANESE_ERA_INITIALS "mtshr" + static int gengo(int c) { @@ -1252,11 +1254,11 @@ parse_jis(VALUE str, VALUE hash) { static const char pat_source[] = #ifndef TIGHT_PARSER - "\\b([mtsh])(\\d+)\\.(\\d+)\\.(\\d+)" + "\\b([" JAPANESE_ERA_INITIALS "])(\\d+)\\.(\\d+)\\.(\\d+)" #else BOS FPW_COM FPT_COM - "([mtsh])(\\d+)\\.(\\d+)\\.(\\d+)" + "([" JAPANESE_ERA_INITIALS "])(\\d+)\\.(\\d+)\\.(\\d+)" TEE_FPT COM_FPW EOS #endif @@ -2979,7 +2981,7 @@ static int jisx0301(VALUE str, VALUE hash) { static const char pat_source[] = - "\\A\\s*([mtsh])?(\\d{2})\\.(\\d{2})\\.(\\d{2})" + "\\A\\s*([" JAPANESE_ERA_INITIALS "])?(\\d{2})\\.(\\d{2})\\.(\\d{2})" "(?:t" "(?:(\\d{2}):(\\d{2})(?::(\\d{2})(?:[,.](\\d*))?)?" "(z|[-+]\\d{2}(?::?\\d{2})?)?)?)?\\s*\\z"; -- cgit v1.2.3