1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* regparse.c (PFETCH_READY): suppress Wunused-but-set-variable.

* regparse.c (is_onechar_cclass): restructured to clarify that c is
  used iff found == 1.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2012-06-13 20:46:11 +00:00
parent 114ae69b45
commit bad859ca3e
2 changed files with 24 additions and 23 deletions

View file

@ -1,3 +1,10 @@
Thu Jun 14 05:23:05 2012 NARUSE, Yui <naruse@ruby-lang.org>
* regparse.c (PFETCH_READY): suppress Wunused-but-set-variable.
* regparse.c (is_onechar_cclass): restructured to clarify that c is
used iff found == 1.
Thu Jun 14 02:54:17 2012 NARUSE, Yui <naruse@ruby-lang.org> Thu Jun 14 02:54:17 2012 NARUSE, Yui <naruse@ruby-lang.org>
* configure.in: use -fbuiltin with -ansi -std=iso9899:199409. * configure.in: use -fbuiltin with -ansi -std=iso9899:199409.

View file

@ -264,8 +264,8 @@ strdup_with_null(OnigEncoding enc, UChar* s, UChar* end)
#define PEND_VALUE 0 #define PEND_VALUE 0
#ifdef __GNUC__ #ifdef __GNUC__
/* get rid of Wunused-but-set-variable */ /* get rid of Wunused-but-set-variable and Wuninitialized */
#define PFETCH_READY UChar* pfetch_prev = NULL #define PFETCH_READY UChar* pfetch_prev = NULL; (void)pfetch_prev
#else #else
#define PFETCH_READY UChar* pfetch_prev #define PFETCH_READY UChar* pfetch_prev
#endif #endif
@ -5684,10 +5684,9 @@ countbits(unsigned int bits)
static int static int
is_onechar_cclass(CClassNode* cc, OnigCodePoint* code) is_onechar_cclass(CClassNode* cc, OnigCodePoint* code)
{ {
OnigCodePoint c; OnigCodePoint c; /* c is used iff found == 1 */
int found = 0; int found = 0;
int i, j = -1; int i;
Bits b1, b2;
BBuf *bbuf = cc->mbuf; BBuf *bbuf = cc->mbuf;
if (IS_NCCLASS_NOT(cc)) return 0; if (IS_NCCLASS_NOT(cc)) return 0;
@ -5699,44 +5698,39 @@ is_onechar_cclass(CClassNode* cc, OnigCodePoint* code)
data = (OnigCodePoint* )(bbuf->p) + 1; data = (OnigCodePoint* )(bbuf->p) + 1;
if ((n == 1) && (data[0] == data[1])) { if ((n == 1) && (data[0] == data[1])) {
/* only one char found in the bbuf, save the code point. */ /* only one char found in the bbuf, save the code point. */
found = 1;
c = data[0]; 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;
}
} }
else { else {
return 0; /* the bbuf contains multiple chars */ return 0; /* the bbuf contains multiple chars */
} }
} }
if (found && (c < SINGLE_BYTE_SIZE) && BITSET_AT(cc->bs, c)) {
/* c is included in the bitset, ignore the result of bbuf. */
found = 0;
}
/* check bitset */ /* check bitset */
for (i = 0; i < (int )BITSET_SIZE; i++) { for (i = 0; i < (int )BITSET_SIZE; i++) {
b1 = cc->bs[i]; Bits b1 = cc->bs[i];
if (b1 != 0) { if (b1 != 0) {
if (((b1 & (b1 - 1)) == 0) && (found == 0)) { if (((b1 & (b1 - 1)) == 0) && (found == 0)) {
found = 1; found = 1;
j = i; c = BITS_IN_ROOM * i + countbits(b1 - 1);
b2 = b1;
} else { } else {
return 0; /* the character class contains multiple chars */ return 0; /* the character class contains multiple chars */
} }
} }
} }
if (found == 0) {
/* the character class contains no char. */ if (found) {
return 0;
}
if (j >= 0) {
/* only one char found in the bitset, calculate the code point. */
c = BITS_IN_ROOM * j + countbits(b2 - 1);
}
*code = c; *code = c;
return 1; return 1;
} }
/* the character class contains no char. */
return 0;
}
static int static int
parse_exp(Node** np, OnigToken* tok, int term, parse_exp(Node** np, OnigToken* tok, int term,