Skip to content

Commit a2384d0

Browse files
committed
More uses of IS_HIGHBIT_SET() macro.
1 parent 6840ccc commit a2384d0

File tree

6 files changed

+34
-46
lines changed

6 files changed

+34
-46
lines changed

src/backend/utils/mb/conv.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
88
* IDENTIFICATION
9-
* $PostgreSQL: pgsql/src/backend/utils/mb/conv.c,v 1.57 2005/12/25 02:14:17 momjian Exp $
9+
* $PostgreSQL: pgsql/src/backend/utils/mb/conv.c,v 1.58 2005/12/26 19:30:44 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -95,7 +95,7 @@ mic2gb18030(unsigned char *mic, unsigned char *p, int len)
9595
{
9696
len -= pg_mic_mblen(mic++);
9797

98-
if (c1 <= 0x7f) /* ASCII */
98+
if (!IS_HIGHBIT_SET(c1)) /* ASCII */
9999
*p++ = c1;
100100
else if (c1 >= 0x81 && c1 <= 0xfe)
101101
{
@@ -141,10 +141,8 @@ latin2mic(unsigned char *l, unsigned char *p, int len, int lc)
141141

142142
while (len-- > 0 && (c1 = *l++))
143143
{
144-
if (c1 > 0x7f)
145-
{ /* Latin? */
146-
*p++ = lc;
147-
}
144+
if (IS_HIGHBIT_SET(c1))
145+
*p++ = lc; /* Latin? */
148146
*p++ = c1;
149147
}
150148
*p = '\0';
@@ -164,7 +162,7 @@ mic2latin(unsigned char *mic, unsigned char *p, int len, int lc)
164162

165163
if (c1 == lc)
166164
*p++ = *mic++;
167-
else if (c1 > 0x7f)
165+
else if (IS_HIGHBIT_SET(c1))
168166
{
169167
mic--;
170168
pg_print_bogus_char(&mic, &p);
@@ -201,7 +199,7 @@ pg_mic2ascii(unsigned char *mic, unsigned char *p, int len)
201199

202200
while (len-- > 0 && (c1 = *mic))
203201
{
204-
if (c1 > 0x7f)
202+
if (IS_HIGHBIT_SET(c1))
205203
pg_print_bogus_char(&mic, &p);
206204
else
207205
{ /* should be ASCII */

src/backend/utils/mb/conversion_procs/euc_cn_and_mic/euc_cn_and_mic.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
88
* IDENTIFICATION
9-
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/euc_cn_and_mic/euc_cn_and_mic.c,v 1.11 2005/12/25 02:14:18 momjian Exp $
9+
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/euc_cn_and_mic/euc_cn_and_mic.c,v 1.12 2005/12/26 19:30:44 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -110,15 +110,13 @@ mic2euc_cn(unsigned char *mic, unsigned char *p, int len)
110110
*p++ = *mic++;
111111
*p++ = *mic++;
112112
}
113-
else if (c1 > 0x7f)
113+
else if (IS_HIGHBIT_SET(c1))
114114
{ /* cannot convert to EUC_CN! */
115115
mic--;
116116
pg_print_bogus_char(&mic, &p);
117117
}
118118
else
119-
{ /* should be ASCII */
120-
*p++ = c1;
121-
}
119+
*p++ = c1; /* should be ASCII */
122120
}
123121
*p = '\0';
124122
}

src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
88
* IDENTIFICATION
9-
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c,v 1.13 2005/10/15 02:49:34 momjian Exp $
9+
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c,v 1.14 2005/12/26 19:30:44 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -180,7 +180,7 @@ sjis2mic(unsigned char *sjis, unsigned char *p, int len)
180180
*p++ = LC_JISX0201K;
181181
*p++ = c1;
182182
}
183-
else if (c1 > 0x7f)
183+
else if (IS_HIGHBIT_SET(c1))
184184
{
185185
/*
186186
* JIS X0208, X0212, user defined extended characters
@@ -355,16 +355,14 @@ mic2sjis(unsigned char *mic, unsigned char *p, int len)
355355
}
356356
}
357357
}
358-
else if (c1 > 0x7f)
358+
else if (IS_HIGHBIT_SET(c1))
359359
{
360360
/* cannot convert to SJIS! */
361361
*p++ = PGSJISALTCODE >> 8;
362362
*p++ = PGSJISALTCODE & 0xff;
363363
}
364364
else
365-
{ /* should be ASCII */
366-
*p++ = c1;
367-
}
365+
*p++ = c1; /* should be ASCII */
368366
}
369367
*p = '\0';
370368
}
@@ -436,15 +434,13 @@ mic2euc_jp(unsigned char *mic, unsigned char *p, int len)
436434
*p++ = *mic++;
437435
*p++ = *mic++;
438436
}
439-
else if (c1 > 0x7f)
437+
else if (IS_HIGHBIT_SET(c1))
440438
{ /* cannot convert to EUC_JP! */
441439
mic--;
442440
pg_print_bogus_char(&mic, &p);
443441
}
444442
else
445-
{ /* should be ASCII */
446-
*p++ = c1;
447-
}
443+
*p++ = c1; /* should be ASCII */
448444
}
449445
*p = '\0';
450446
}

src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
88
* IDENTIFICATION
9-
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c,v 1.11 2005/12/25 02:14:18 momjian Exp $
9+
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c,v 1.12 2005/12/26 19:30:45 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -110,15 +110,13 @@ mic2euc_kr(unsigned char *mic, unsigned char *p, int len)
110110
*p++ = *mic++;
111111
*p++ = *mic++;
112112
}
113-
else if (c1 > 0x7f)
113+
else if (IS_HIGHBIT_SET(c1))
114114
{ /* cannot convert to EUC_KR! */
115115
mic--;
116116
pg_print_bogus_char(&mic, &p);
117117
}
118118
else
119-
{ /* should be ASCII */
120-
*p++ = c1;
121-
}
119+
*p++ = c1; /* should be ASCII */
122120
}
123121
*p = '\0';
124122
}

src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
88
* IDENTIFICATION
9-
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c,v 1.11 2005/12/25 02:14:18 momjian Exp $
9+
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c,v 1.12 2005/12/26 19:30:45 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -224,15 +224,13 @@ mic2euc_tw(unsigned char *mic, unsigned char *p, int len)
224224
*p++ = *mic++;
225225
*p++ = *mic++;
226226
}
227-
else if (c1 > 0x7f)
227+
else if (IS_HIGHBIT_SET(c1))
228228
{ /* cannot convert to EUC_TW! */
229229
mic--;
230230
pg_print_bogus_char(&mic, &p);
231231
}
232232
else
233-
{ /* should be ASCII */
234-
*p++ = c1;
235-
}
233+
*p++ = c1; /* should be ASCII */
236234
}
237235
*p = '\0';
238236
}
@@ -252,7 +250,7 @@ big52mic(unsigned char *big5, unsigned char *p, int len)
252250

253251
while (len >= 0 && (c1 = *big5++))
254252
{
255-
if (c1 <= 0x7fU)
253+
if (!IS_HIGHBIT_SET(c1))
256254
{ /* ASCII */
257255
len--;
258256
*p++ = c1;
@@ -328,7 +326,7 @@ mic2big5(unsigned char *mic, unsigned char *p, int len)
328326
*p++ = big5buf & 0x00ff;
329327
}
330328
}
331-
else if (c1 <= 0x7f) /* ASCII */
329+
else if (!IS_HIGHBIT_SET(c1)) /* ASCII */
332330
*p++ = c1;
333331
else
334332
{ /* cannot convert to Big5! */

src/backend/utils/mb/wchar.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* conversion functions between pg_wchar and multibyte streams.
33
* Tatsuo Ishii
4-
* $PostgreSQL: pgsql/src/backend/utils/mb/wchar.c,v 1.51 2005/12/25 02:14:18 momjian Exp $
4+
* $PostgreSQL: pgsql/src/backend/utils/mb/wchar.c,v 1.52 2005/12/26 19:30:44 momjian Exp $
55
*
66
* WIN1250 client encoding updated by Pavel Behal
77
*
@@ -542,7 +542,7 @@ pg_sjis_mblen(const unsigned char *s)
542542

543543
if (*s >= 0xa1 && *s <= 0xdf)
544544
len = 1; /* 1 byte kana? */
545-
else if (*s > 0x7f)
545+
else if (IS_HIGHBIT_SET(*s))
546546
len = 2; /* kanji? */
547547
else
548548
len = 1; /* should be ASCII */
@@ -556,7 +556,7 @@ pg_sjis_dsplen(const unsigned char *s)
556556

557557
if (*s >= 0xa1 && *s <= 0xdf)
558558
len = 1; /* 1 byte kana? */
559-
else if (*s > 0x7f)
559+
else if (IS_HIGHBIT_SET(*s))
560560
len = 2; /* kanji? */
561561
else
562562
len = 1; /* should be ASCII */
@@ -571,7 +571,7 @@ pg_big5_mblen(const unsigned char *s)
571571
{
572572
int len;
573573

574-
if (*s > 0x7f)
574+
if (IS_HIGHBIT_SET(*s))
575575
len = 2; /* kanji? */
576576
else
577577
len = 1; /* should be ASCII */
@@ -583,7 +583,7 @@ pg_big5_dsplen(const unsigned char *s)
583583
{
584584
int len;
585585

586-
if (*s > 0x7f)
586+
if (IS_HIGHBIT_SET(*s))
587587
len = 2; /* kanji? */
588588
else
589589
len = 1; /* should be ASCII */
@@ -598,7 +598,7 @@ pg_gbk_mblen(const unsigned char *s)
598598
{
599599
int len;
600600

601-
if (*s > 0x7f)
601+
if (IS_HIGHBIT_SET(*s))
602602
len = 2; /* kanji? */
603603
else
604604
len = 1; /* should be ASCII */
@@ -610,7 +610,7 @@ pg_gbk_dsplen(const unsigned char *s)
610610
{
611611
int len;
612612

613-
if (*s > 0x7f)
613+
if (IS_HIGHBIT_SET(*s))
614614
len = 2; /* kanji? */
615615
else
616616
len = 1; /* should be ASCII */
@@ -625,7 +625,7 @@ pg_uhc_mblen(const unsigned char *s)
625625
{
626626
int len;
627627

628-
if (*s > 0x7f)
628+
if (IS_HIGHBIT_SET(*s))
629629
len = 2; /* 2byte? */
630630
else
631631
len = 1; /* should be ASCII */
@@ -637,7 +637,7 @@ pg_uhc_dsplen(const unsigned char *s)
637637
{
638638
int len;
639639

640-
if (*s > 0x7f)
640+
if (IS_HIGHBIT_SET(*s))
641641
len = 2; /* 2byte? */
642642
else
643643
len = 1; /* should be ASCII */
@@ -653,7 +653,7 @@ pg_gb18030_mblen(const unsigned char *s)
653653
{
654654
int len;
655655

656-
if (*s <= 0x7f)
656+
if (!IS_HIGHBIT_SET(*s))
657657
len = 1; /* ASCII */
658658
else
659659
{
@@ -672,7 +672,7 @@ pg_gb18030_dsplen(const unsigned char *s)
672672
{
673673
int len;
674674

675-
if (*s <= 0x7f)
675+
if (!IS_HIGHBIT_SET(*s))
676676
len = 1; /* ASCII */
677677
else
678678
len = 2;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy