1
1
/*
2
2
* conversion functions between pg_wchar and multibyte streams.
3
3
* Tatsuo Ishii
4
- * $PostgreSQL: pgsql/src/backend/utils/mb/wchar.c,v 1.50 2005/12/24 17:19:40 momjian Exp $
4
+ * $PostgreSQL: pgsql/src/backend/utils/mb/wchar.c,v 1.51 2005/12/25 02:14:18 momjian Exp $
5
5
*
6
6
* WIN1250 client encoding updated by Pavel Behal
7
7
*
@@ -79,7 +79,7 @@ static int pg_euc2wchar_with_len
79
79
* to |= * from ++ ;
80
80
len -= 3 ;
81
81
}
82
- else if ((* from & 0x80 ) && len >= 2 ) /* JIS X 0208 KANJI */
82
+ else if (IS_HIGHBIT_SET (* from ) && len >= 2 ) /* JIS X 0208 KANJI */
83
83
{
84
84
* to = * from ++ << 8 ;
85
85
* to |= * from ++ ;
@@ -106,7 +106,7 @@ pg_euc_mblen(const unsigned char *s)
106
106
len = 2 ;
107
107
else if (* s == SS3 )
108
108
len = 3 ;
109
- else if (* s & 0x80 )
109
+ else if (IS_HIGHBIT_SET ( * s ) )
110
110
len = 2 ;
111
111
else
112
112
len = 1 ;
@@ -122,7 +122,7 @@ pg_euc_dsplen(const unsigned char *s)
122
122
len = 2 ;
123
123
else if (* s == SS3 )
124
124
len = 2 ;
125
- else if (* s & 0x80 )
125
+ else if (IS_HIGHBIT_SET ( * s ) )
126
126
len = 2 ;
127
127
else
128
128
len = 1 ;
@@ -153,7 +153,7 @@ pg_eucjp_dsplen(const unsigned char *s)
153
153
len = 1 ;
154
154
else if (* s == SS3 )
155
155
len = 2 ;
156
- else if (* s & 0x80 )
156
+ else if (IS_HIGHBIT_SET ( * s ) )
157
157
len = 2 ;
158
158
else
159
159
len = 1 ;
@@ -206,7 +206,7 @@ static int pg_euccn2wchar_with_len
206
206
* to |= * from ++ ;
207
207
len -= 3 ;
208
208
}
209
- else if ((* from & 0x80 ) && len >= 2 ) /* code set 1 */
209
+ else if (IS_HIGHBIT_SET (* from ) && len >= 2 ) /* code set 1 */
210
210
{
211
211
* to = * from ++ << 8 ;
212
212
* to |= * from ++ ;
@@ -229,7 +229,7 @@ pg_euccn_mblen(const unsigned char *s)
229
229
{
230
230
int len ;
231
231
232
- if (* s & 0x80 )
232
+ if (IS_HIGHBIT_SET ( * s ) )
233
233
len = 2 ;
234
234
else
235
235
len = 1 ;
@@ -241,7 +241,7 @@ pg_euccn_dsplen(const unsigned char *s)
241
241
{
242
242
int len ;
243
243
244
- if (* s & 0x80 )
244
+ if (IS_HIGHBIT_SET ( * s ) )
245
245
len = 2 ;
246
246
else
247
247
len = 1 ;
@@ -274,7 +274,7 @@ static int pg_euctw2wchar_with_len
274
274
* to |= * from ++ ;
275
275
len -= 3 ;
276
276
}
277
- else if ((* from & 0x80 ) && len >= 2 ) /* code set 2 */
277
+ else if (IS_HIGHBIT_SET (* from ) && len >= 2 ) /* code set 2 */
278
278
{
279
279
* to = * from ++ << 8 ;
280
280
* to |= * from ++ ;
@@ -301,7 +301,7 @@ pg_euctw_mblen(const unsigned char *s)
301
301
len = 4 ;
302
302
else if (* s == SS3 )
303
303
len = 3 ;
304
- else if (* s & 0x80 )
304
+ else if (IS_HIGHBIT_SET ( * s ) )
305
305
len = 2 ;
306
306
else
307
307
len = 1 ;
@@ -317,7 +317,7 @@ pg_euctw_dsplen(const unsigned char *s)
317
317
len = 2 ;
318
318
else if (* s == SS3 )
319
319
len = 2 ;
320
- else if (* s & 0x80 )
320
+ else if (IS_HIGHBIT_SET ( * s ) )
321
321
len = 2 ;
322
322
else
323
323
len = 1 ;
@@ -361,7 +361,7 @@ pg_utf2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
361
361
362
362
while (len > 0 && * from )
363
363
{
364
- if ((* from & 0x80 ) == 0 )
364
+ if (! IS_HIGHBIT_SET (* from ) )
365
365
{
366
366
* to = * from ++ ;
367
367
len -- ;
@@ -866,7 +866,7 @@ pg_verifymbstr(const char *mbstr, int len, bool noError)
866
866
* we expect that every multibyte char consists of bytes
867
867
* having the 8th bit set
868
868
*/
869
- if (i >= len || (mbstr [i ] & 0x80 ) == 0 )
869
+ if (i >= len || ! IS_HIGHBIT_SET (mbstr [i ]) )
870
870
{
871
871
char buf [8 * 2 + 1 ];
872
872
char * p = buf ;
0 commit comments