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

ruby-changes:24389

From: nobu <ko1@a...>
Date: Wed, 18 Jul 2012 17:41:10 +0900 (JST)
Subject: [ruby-changes:24389] nobu:r36440 (trunk): warning: no indirect flag

nobu	2012-07-18 17:41:01 +0900 (Wed, 18 Jul 2012)

  New Revision: 36440

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36440

  Log:
    warning: no indirect flag
    
    * regparse.c (is_onechar_cclass): remove "found" indirect flag to
      suppress warnings by gcc 4.7.

  Modified files:
    trunk/regparse.c

Index: regparse.c
===================================================================
--- regparse.c	(revision 36439)
+++ regparse.c	(revision 36440)
@@ -5684,8 +5684,8 @@
 static int
 is_onechar_cclass(CClassNode* cc, OnigCodePoint* code)
 {
-  OnigCodePoint c; /* c is used iff found == 1 */
-  int found = 0;
+  const OnigCodePoint not_found = (OnigCodePoint)-1;
+  OnigCodePoint c = not_found;
   int i;
   BBuf *bbuf = cc->mbuf;
 
@@ -5699,9 +5699,9 @@
     if ((n == 1) && (data[0] == data[1])) {
       /* only one char found in the bbuf, save the code point. */
       c = data[0];
-      if ((c >= SINGLE_BYTE_SIZE) || !BITSET_AT(cc->bs, c)) {
-        /* set found=1 if c is not included in the bitset */
-        found = 1;
+      if (((c < SINGLE_BYTE_SIZE) && BITSET_AT(cc->bs, c))) {
+        /* skip if c is included in the bitset */
+	c = not_found;
       }
     }
     else {
@@ -5713,8 +5713,7 @@
   for (i = 0; i < (int )BITSET_SIZE; i++) {
     Bits b1 = cc->bs[i];
     if (b1 != 0) {
-      if (((b1 & (b1 - 1)) == 0) && (found == 0)) {
-        found = 1;
+      if (((b1 & (b1 - 1)) == 0) && (c == not_found)) {
         c = BITS_IN_ROOM * i + countbits(b1 - 1);
       } else {
         return 0;  /* the character class contains multiple chars */
@@ -5722,7 +5721,7 @@
     }
   }
 
-  if (found) {
+  if (c != not_found) {
     *code = c;
     return 1;
   }

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

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