diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-08-11 12:49:31 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-08-11 12:49:31 +0000 |
commit | 666c8fa4c8e4ff13487dca37f26c26663adff579 (patch) | |
tree | de494a522db3066b0bf605e1a89a395f8883b10d /src/regex | |
parent | ef3a1ee88ce00bde339214774813f01464fd0b77 (diff) | |
download | gnunet-666c8fa4c8e4ff13487dca37f26c26663adff579.tar.gz gnunet-666c8fa4c8e4ff13487dca37f26c26663adff579.zip |
-fix more shift errors
Diffstat (limited to 'src/regex')
-rw-r--r-- | src/regex/regex_internal.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/regex/regex_internal.c b/src/regex/regex_internal.c index 5575c89dc..a74471ba1 100644 --- a/src/regex/regex_internal.c +++ b/src/regex/regex_internal.c | |||
@@ -606,6 +606,8 @@ sb_nullstrcmp (const struct StringBuffer *s1, | |||
606 | return -1; | 606 | return -1; |
607 | if (s1->slen != s2->slen) | 607 | if (s1->slen != s2->slen) |
608 | return -1; | 608 | return -1; |
609 | if (0 == s1->slen) | ||
610 | return 0; | ||
609 | return memcmp (s1->sbuf, s2->sbuf, s1->slen); | 611 | return memcmp (s1->sbuf, s2->sbuf, s1->slen); |
610 | } | 612 | } |
611 | 613 | ||
@@ -624,6 +626,8 @@ sb_strcmp (const struct StringBuffer *s1, | |||
624 | { | 626 | { |
625 | if (s1->slen != s2->slen) | 627 | if (s1->slen != s2->slen) |
626 | return -1; | 628 | return -1; |
629 | if (0 == s1->slen) | ||
630 | return 0; | ||
627 | return memcmp (s1->sbuf, s2->sbuf, s1->slen); | 631 | return memcmp (s1->sbuf, s2->sbuf, s1->slen); |
628 | } | 632 | } |
629 | 633 | ||
@@ -2011,7 +2015,7 @@ dfa_merge_nondistinguishable_states (struct REGEX_INTERNAL_Context *ctx, | |||
2011 | (!s1->accepting && s2->accepting) ) | 2015 | (!s1->accepting && s2->accepting) ) |
2012 | { | 2016 | { |
2013 | idx = (unsigned long long) s1->marked * state_cnt + s2->marked; | 2017 | idx = (unsigned long long) s1->marked * state_cnt + s2->marked; |
2014 | table[idx / 32] |= (1 << (idx % 32)); | 2018 | table[idx / 32] |= (1U << (idx % 32)); |
2015 | } | 2019 | } |
2016 | 2020 | ||
2017 | /* Find all equal states */ | 2021 | /* Find all equal states */ |
@@ -2024,7 +2028,7 @@ dfa_merge_nondistinguishable_states (struct REGEX_INTERNAL_Context *ctx, | |||
2024 | for (s2 = a->states_head; NULL != s2 && s1 != s2; s2 = s2->next) | 2028 | for (s2 = a->states_head; NULL != s2 && s1 != s2; s2 = s2->next) |
2025 | { | 2029 | { |
2026 | idx = (unsigned long long) s1->marked * state_cnt + s2->marked; | 2030 | idx = (unsigned long long) s1->marked * state_cnt + s2->marked; |
2027 | if (0 != (table[idx / 32] & (1 << (idx % 32)))) | 2031 | if (0 != (table[idx / 32] & (1U << (idx % 32)))) |
2028 | continue; | 2032 | continue; |
2029 | num_equal_edges = 0; | 2033 | num_equal_edges = 0; |
2030 | for (t1 = s1->transitions_head; NULL != t1; t1 = t1->next) | 2034 | for (t1 = s1->transitions_head; NULL != t1; t1 = t1->next) |
@@ -2040,9 +2044,9 @@ dfa_merge_nondistinguishable_states (struct REGEX_INTERNAL_Context *ctx, | |||
2040 | idx1 = (unsigned long long) t1->to_state->marked * state_cnt + t2->to_state->marked; | 2044 | idx1 = (unsigned long long) t1->to_state->marked * state_cnt + t2->to_state->marked; |
2041 | else | 2045 | else |
2042 | idx1 = (unsigned long long) t2->to_state->marked * state_cnt + t1->to_state->marked; | 2046 | idx1 = (unsigned long long) t2->to_state->marked * state_cnt + t1->to_state->marked; |
2043 | if (0 != (table[idx1 / 32] & (1 << (idx1 % 32)))) | 2047 | if (0 != (table[idx1 / 32] & (1U << (idx1 % 32)))) |
2044 | { | 2048 | { |
2045 | table[idx / 32] |= (1 << (idx % 32)); | 2049 | table[idx / 32] |= (1U << (idx % 32)); |
2046 | change = 1; /* changed a marker, need to run again */ | 2050 | change = 1; /* changed a marker, need to run again */ |
2047 | } | 2051 | } |
2048 | } | 2052 | } |
@@ -2052,7 +2056,7 @@ dfa_merge_nondistinguishable_states (struct REGEX_INTERNAL_Context *ctx, | |||
2052 | (num_equal_edges != s2->transition_count) ) | 2056 | (num_equal_edges != s2->transition_count) ) |
2053 | { | 2057 | { |
2054 | /* Make sure ALL edges of possible equal states are the same */ | 2058 | /* Make sure ALL edges of possible equal states are the same */ |
2055 | table[idx / 32] |= (1 << (idx % 32)); | 2059 | table[idx / 32] |= (1U << (idx % 32)); |
2056 | change = 1; /* changed a marker, need to run again */ | 2060 | change = 1; /* changed a marker, need to run again */ |
2057 | } | 2061 | } |
2058 | } | 2062 | } |
@@ -2067,7 +2071,7 @@ dfa_merge_nondistinguishable_states (struct REGEX_INTERNAL_Context *ctx, | |||
2067 | { | 2071 | { |
2068 | s2_next = s2->next; | 2072 | s2_next = s2->next; |
2069 | idx = (unsigned long long) s1->marked * state_cnt + s2->marked; | 2073 | idx = (unsigned long long) s1->marked * state_cnt + s2->marked; |
2070 | if (0 == (table[idx / 32] & (1 << (idx % 32)))) | 2074 | if (0 == (table[idx / 32] & (1U << (idx % 32)))) |
2071 | automaton_merge_states (ctx, a, s1, s2); | 2075 | automaton_merge_states (ctx, a, s1, s2); |
2072 | } | 2076 | } |
2073 | } | 2077 | } |