[前][次][番号順一覧][スレッド一覧]

ruby-changes:56971

From: Nobuyoshi <ko1@a...>
Date: Mon, 12 Aug 2019 20:51:50 +0900 (JST)
Subject: [ruby-changes:56971] Nobuyoshi Nakada: 3fc10eff1e (master): date_parse.c: trim off

https://git.ruby-lang.org/ruby.git/commit/?id=3fc10eff1e

From 3fc10eff1e6dd63bc0daa753108072954adc89ac Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Fri, 30 Sep 2016 20:49:58 +0900
Subject: date_parse.c: trim off

* ext/date/date_parse.c (date_zone_to_diff): trim off by zone name
  length.

diff --git a/ext/date/date_parse.c b/ext/date/date_parse.c
index 8717850..519f29c 100644
--- a/ext/date/date_parse.c
+++ b/ext/date/date_parse.c
@@ -438,13 +438,13 @@ date_zone_to_diff(VALUE str) https://github.com/ruby/ruby/blob/trunk/ext/date/date_parse.c#L438
 	}
 	{
 	    long sl = shrunk_size(s, l);
-	    if (sl) {
+	    if (sl > 0 && sl <= MAX_WORD_LENGTH) {
 		char *d = ALLOCV_N(char, vbuf, sl);
 		l = shrink_space(d, s, l);
 		s = d;
 	    }
 	}
-	{
+	if (l > 0 && l <= MAX_WORD_LENGTH) {
 	    const struct zone *z = zonetab(s, (unsigned int)l);
 	    if (z) {
 		int d = z->offset;
diff --git a/ext/date/prereq.mk b/ext/date/prereq.mk
index 4aff03a..b9d9a24 100644
--- a/ext/date/prereq.mk
+++ b/ext/date/prereq.mk
@@ -1,7 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ext/date/prereq.mk#L1
 .SUFFIXES: .list
 
 .list.h:
-	gperf --ignore-case -E -C -c -P -p -j1 -i 1 -g -o -t -N $(*F) $< \
+	gperf --ignore-case -C -c -P -p -j1 -i 1 -g -o -t -N $(*F) $< \
 	| sed -f $(top_srcdir)/tool/gperf.sed \
 	> $(@F)
 
diff --git a/ext/date/zonetab.h b/ext/date/zonetab.h
index c76056d..37df5b9 100644
--- a/ext/date/zonetab.h
+++ b/ext/date/zonetab.h
@@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ext/date/zonetab.h#L1
 /* ANSI-C code produced by gperf version 3.1 */
-/* Command-line: gperf --ignore-case -E -C -c -P -p -j1 -i 1 -g -o -t -N zonetab zonetab.list  */
+/* Command-line: gperf --ignore-case -C -c -P -p -j1 -i 1 -g -o -t -N zonetab zonetab.list  */
 /* Computed positions: -k'1-4,$' */
 
 #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
@@ -39,6 +39,12 @@ struct zone { https://github.com/ruby/ruby/blob/trunk/ext/date/zonetab.h#L39
 static const struct zone *zonetab();
 #line 9 "zonetab.list"
 struct zone;
+
+#define TOTAL_KEYWORDS 170
+#define MIN_WORD_LENGTH 1
+#define MAX_WORD_LENGTH 17
+#define MIN_HASH_VALUE 5
+#define MAX_HASH_VALUE 438
 /* maximum key range = 434, duplicates = 0 */
 
 #ifndef GPERF_DOWNCASE
@@ -495,15 +501,6 @@ static const struct stringpool_t stringpool_contents = https://github.com/ruby/ruby/blob/trunk/ext/date/zonetab.h#L501
 const struct zone *
 zonetab (register const char *str, register size_t len)
 {
-  enum
-    {
-      TOTAL_KEYWORDS = 170,
-      MIN_WORD_LENGTH = 1,
-      MAX_WORD_LENGTH = 17,
-      MIN_HASH_VALUE = 5,
-      MAX_HASH_VALUE = 438
-    };
-
   static const struct zone wordlist[] =
     {
       {-1}, {-1}, {-1}, {-1}, {-1},
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]