aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2010-01-04 21:00:29 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2010-01-04 21:00:29 +0000
commit93d115c54e276cc56c0fdf0686c4a548d4ab62e7 (patch)
tree99f47101d350def67436582be6b9669144ac6847 /main
parenta81984b2a13790c6257e3f63fad426af8523f573 (diff)
Merged revisions 237494 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ................ r237494 | tilghman | 2010-01-04 14:59:01 -0600 (Mon, 04 Jan 2010) | 15 lines Merged revisions 237493 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r237493 | tilghman | 2010-01-04 14:57:35 -0600 (Mon, 04 Jan 2010) | 8 lines Regression in issue #15421 - Pattern matching (closes issue #16482) Reported by: wdoekes Patches: astsvn-16482-betterfix.diff uploaded by wdoekes (license 717) 20091223__issue16482.diff.txt uploaded by tilghman (license 14) Tested by: wdoekes, tilghman ........ ................ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@237495 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r--main/pbx.c42
1 files changed, 20 insertions, 22 deletions
diff --git a/main/pbx.c b/main/pbx.c
index 557800ca9..000831328 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -1685,31 +1685,28 @@ static int ext_cmp1(const char **p, unsigned char *bitwise)
int c, cmin = 0xff, count = 0;
const char *end;
- /* load, sign extend and advance pointer until we find
- * a valid character.
- */
+ /* load value and advance pointer */
c = *(*p)++;
- memset(bitwise, 0xff, 32);
/* always return unless we have a set of chars */
switch (toupper(c)) {
default: /* ordinary character */
- return 0x0000 | (c & 0xff);
+ bitwise[c / 8] = 1 << (c % 8);
+ return 0x0100 | (c & 0xff);
case 'N': /* 2..9 */
- bitwise[6] = 0x01;
- bitwise[7] = 0xfe;
+ bitwise[6] = 0xfc;
+ bitwise[7] = 0x03;
return 0x0800 | '2';
case 'X': /* 0..9 */
- bitwise[5] = 0x7f;
- bitwise[6] = 0x00;
- bitwise[7] = 0xfe;
+ bitwise[6] = 0xff;
+ bitwise[7] = 0x03;
return 0x0A00 | '0';
case 'Z': /* 1..9 */
- bitwise[6] = 0x00;
- bitwise[7] = 0xfe;
+ bitwise[6] = 0xfe;
+ bitwise[7] = 0x03;
return 0x0900 | '1';
case '.': /* wildcard */
@@ -1747,14 +1744,13 @@ static int ext_cmp1(const char **p, unsigned char *bitwise)
}
for (; c1 <= c2; c1++) {
unsigned char mask = 1 << (c1 % 8);
- /* Count the number of characters in the class, discarding duplicates. */
- if ( (bitwise[ c1 / 8 ] & mask) == 1) {
+ /*!\note If two patterns score the same, the one with the lowest
+ * ascii values will compare as coming first. */
+ /* Flag the character as included (used) and count it. */
+ if (!(bitwise[ c1 / 8 ] & mask)) {
+ bitwise[ c1 / 8 ] |= mask;
count += 0x100;
}
- /*!\note If two patterns score the same, but one includes '0' (as
- * the lowest ASCII value in the given class) and the other does
- * not, then the one including '0' will compare as coming first. */
- bitwise[ c1 / 8 ] &= ~mask;
}
}
(*p)++;
@@ -1770,7 +1766,6 @@ static int ext_cmp(const char *a, const char *b)
* If a is not a pattern, it either comes first or
* we do a more complex pattern comparison.
*/
- unsigned char bitwise[2][32];
int ret = 0;
if (a[0] != '_')
@@ -1780,14 +1775,17 @@ static int ext_cmp(const char *a, const char *b)
if (b[0] != '_')
return 1;
- /* ok we need full pattern sorting routine */
- while (!ret && a && b) {
+ /* ok we need full pattern sorting routine.
+ * skip past the underscores */
+ ++a; ++b;
+ do {
+ unsigned char bitwise[2][32] = { { 0, } };
ret = ext_cmp1(&a, bitwise[0]) - ext_cmp1(&b, bitwise[1]);
if (ret == 0) {
/* Are the classes different, even though they score the same? */
ret = memcmp(bitwise[0], bitwise[1], 32);
}
- }
+ } while (!ret && a && b);
if (ret == 0) {
return 0;
} else {