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

ruby-changes:44240

From: nobu <ko1@a...>
Date: Sat, 1 Oct 2016 17:52:51 +0900 (JST)
Subject: [ruby-changes:44240] nobu:r56313 (trunk): zonetab.h: use strncmp

nobu	2016-10-01 17:52:43 +0900 (Sat, 01 Oct 2016)

  New Revision: 56313

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56313

  Log:
    zonetab.h: use strncmp
    
    * ext/date/zonetab.h (zonetab): use strncmp.

  Modified files:
    trunk/ext/date/date_parse.c
    trunk/ext/date/prereq.mk
    trunk/ext/date/zonetab.h
Index: ext/date/prereq.mk
===================================================================
--- ext/date/prereq.mk	(revision 56312)
+++ ext/date/prereq.mk	(revision 56313)
@@ -1,7 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ext/date/prereq.mk#L1
 .SUFFIXES: .list
 
 .list.h:
-	gperf -E -C -P -p -j1 -i 1 -g -o -t -N $(*F) $< \
+	gperf -E -C -c -P -p -j1 -i 1 -g -o -t -N $(*F) $< \
 	| sed 's/(int)(long)&((\(struct stringpool_t\) *\*)0)->\(stringpool_[a-z0-9]*\)/offsetof(\1, \2)/g' \
 	> $(@F)
 
Index: ext/date/date_parse.c
===================================================================
--- ext/date/date_parse.c	(revision 56312)
+++ ext/date/date_parse.c	(revision 56313)
@@ -386,16 +386,13 @@ date_zone_to_diff(VALUE str) https://github.com/ruby/ruby/blob/trunk/ext/date/date_parse.c#L386
 
 	if (l >= (int)sizeof(STD) - 1 && strcmp(d - (sizeof(STD) - 1), STD) == 0) {
 	    l -= sizeof(STD) - 1;
-	    s[l] = '\0';
 	}
 	else if (l >= (int)sizeof(DST1) - 1 && strcmp(d - (sizeof(DST1) - 1), DST1) == 0) {
 	    l -= sizeof(DST1) - 1;
-	    s[l] = '\0';
 	    dst = 1;
 	}
 	else if (l >= (int)sizeof(DST2) - 1 && strcmp(d - (sizeof(DST2) - 1), DST2) == 0) {
 	    l -= sizeof(DST2) - 1;
-	    s[l] = '\0';
 	    dst = 1;
 	}
 	{
Index: ext/date/zonetab.h
===================================================================
--- ext/date/zonetab.h	(revision 56312)
+++ ext/date/zonetab.h	(revision 56313)
@@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ext/date/zonetab.h#L1
 /* C code produced by gperf version 3.0.4 */
-/* Command-line: gperf -E -C -P -p -j1 -i 1 -g -o -t -N zonetab zonetab.list  */
+/* Command-line: gperf -E -C -c -P -p -j1 -i 1 -g -o -t -N zonetab zonetab.list  */
 /* Computed positions: -k'1-4,$' */
 
 #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
@@ -891,7 +891,7 @@ zonetab (str, len) https://github.com/ruby/ruby/blob/trunk/ext/date/zonetab.h#L891
             {
               register const char *s = o + stringpool;
 
-              if (*str == *s && !strcmp (str + 1, s + 1))
+              if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
                 return &wordlist[key];
             }
         }

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

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