|
11 | 11 | * Portions Copyright (c) 1994, Regents of the University of California
|
12 | 12 | *
|
13 | 13 | * IDENTIFICATION
|
14 |
| - * $Header: /cvsroot/pgsql/src/backend/utils/adt/like.c,v 1.42 2000/09/15 18:45:26 tgl Exp $ |
| 14 | + * $Header: /cvsroot/pgsql/src/backend/utils/adt/like.c,v 1.43 2000/12/11 05:00:18 ishii Exp $ |
15 | 15 | *
|
16 | 16 | *-------------------------------------------------------------------------
|
17 | 17 | */
|
@@ -63,35 +63,34 @@ static int wchareq(unsigned char *p1, unsigned char *p2)
|
63 | 63 | * If they match, returns 1 otherwise returns 0.
|
64 | 64 | *--------------------
|
65 | 65 | */
|
66 |
| -#define UCHARMAX 0xff |
| 66 | +#define CHARMAX 0x80 |
67 | 67 |
|
68 | 68 | static int iwchareq(unsigned char *p1, unsigned char *p2)
|
69 | 69 | {
|
70 |
| - int c1, c2; |
| 70 | + int c1[2], c2[2]; |
71 | 71 | int l;
|
72 | 72 |
|
73 |
| - /* short cut. if *p1 and *p2 is lower than UCHARMAX, then |
74 |
| - we assume they are ASCII */ |
75 |
| - if (*p1 < UCHARMAX && *p2 < UCHARMAX) |
| 73 | + /* short cut. if *p1 and *p2 is lower than CHARMAX, then |
| 74 | + we could assume they are ASCII */ |
| 75 | + if (*p1 < CHARMAX && *p2 < CHARMAX) |
76 | 76 | return(tolower(*p1) == tolower(*p2));
|
77 | 77 |
|
78 |
| - if (*p1 < UCHARMAX) |
79 |
| - c1 = tolower(*p1); |
80 |
| - else |
81 |
| - { |
82 |
| - l = pg_mblen(p1); |
83 |
| - (void)pg_mb2wchar_with_len(p1, (pg_wchar *)&c1, l); |
84 |
| - c1 = tolower(c1); |
85 |
| - } |
86 |
| - if (*p2 < UCHARMAX) |
87 |
| - c2 = tolower(*p2); |
88 |
| - else |
89 |
| - { |
90 |
| - l = pg_mblen(p2); |
91 |
| - (void)pg_mb2wchar_with_len(p2, (pg_wchar *)&c2, l); |
92 |
| - c2 = tolower(c2); |
93 |
| - } |
94 |
| - return(c1 == c2); |
| 78 | + /* if one of them is an ASCII while the other is not, then |
| 79 | + they must be different characters |
| 80 | + */ |
| 81 | + else if (*p1 < CHARMAX || *p2 < CHARMAX) |
| 82 | + return(0); |
| 83 | + |
| 84 | + /* ok, p1 and p2 are both > CHARMAX, then they must be multi-byte |
| 85 | + characters |
| 86 | + */ |
| 87 | + l = pg_mblen(p1); |
| 88 | + (void)pg_mb2wchar_with_len(p1, (pg_wchar *)c1, l); |
| 89 | + c1[0] = tolower(c1[0]); |
| 90 | + l = pg_mblen(p2); |
| 91 | + (void)pg_mb2wchar_with_len(p2, (pg_wchar *)c2, l); |
| 92 | + c2[0] = tolower(c2[0]); |
| 93 | + return(c1[0] == c2[0]); |
95 | 94 | }
|
96 | 95 |
|
97 | 96 | #endif
|
|
0 commit comments