From a2384d008a9e0d159f2c86473e688e2f421e3dd6 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Mon, 26 Dec 2005 19:30:45 +0000 Subject: [PATCH] More uses of IS_HIGHBIT_SET() macro. --- src/backend/utils/mb/conv.c | 14 +++++------- .../euc_cn_and_mic/euc_cn_and_mic.c | 8 +++---- .../euc_jp_and_sjis/euc_jp_and_sjis.c | 16 +++++--------- .../euc_kr_and_mic/euc_kr_and_mic.c | 8 +++---- .../euc_tw_and_big5/euc_tw_and_big5.c | 12 +++++----- src/backend/utils/mb/wchar.c | 22 +++++++++---------- 6 files changed, 34 insertions(+), 46 deletions(-) diff --git a/src/backend/utils/mb/conv.c b/src/backend/utils/mb/conv.c index 831a6061f1..c0c410da9b 100644 --- a/src/backend/utils/mb/conv.c +++ b/src/backend/utils/mb/conv.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/mb/conv.c,v 1.57 2005/12/25 02:14:17 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/conv.c,v 1.58 2005/12/26 19:30:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -95,7 +95,7 @@ mic2gb18030(unsigned char *mic, unsigned char *p, int len) { len -= pg_mic_mblen(mic++); - if (c1 <= 0x7f) /* ASCII */ + if (!IS_HIGHBIT_SET(c1)) /* ASCII */ *p++ = c1; else if (c1 >= 0x81 && c1 <= 0xfe) { @@ -141,10 +141,8 @@ latin2mic(unsigned char *l, unsigned char *p, int len, int lc) while (len-- > 0 && (c1 = *l++)) { - if (c1 > 0x7f) - { /* Latin? */ - *p++ = lc; - } + if (IS_HIGHBIT_SET(c1)) + *p++ = lc; /* Latin? */ *p++ = c1; } *p = '\0'; @@ -164,7 +162,7 @@ mic2latin(unsigned char *mic, unsigned char *p, int len, int lc) if (c1 == lc) *p++ = *mic++; - else if (c1 > 0x7f) + else if (IS_HIGHBIT_SET(c1)) { mic--; pg_print_bogus_char(&mic, &p); @@ -201,7 +199,7 @@ pg_mic2ascii(unsigned char *mic, unsigned char *p, int len) while (len-- > 0 && (c1 = *mic)) { - if (c1 > 0x7f) + if (IS_HIGHBIT_SET(c1)) pg_print_bogus_char(&mic, &p); else { /* should be ASCII */ diff --git a/src/backend/utils/mb/conversion_procs/euc_cn_and_mic/euc_cn_and_mic.c b/src/backend/utils/mb/conversion_procs/euc_cn_and_mic/euc_cn_and_mic.c index 17bad84329..b565fdf2dd 100644 --- a/src/backend/utils/mb/conversion_procs/euc_cn_and_mic/euc_cn_and_mic.c +++ b/src/backend/utils/mb/conversion_procs/euc_cn_and_mic/euc_cn_and_mic.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $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 $ + * $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 $ * *------------------------------------------------------------------------- */ @@ -110,15 +110,13 @@ mic2euc_cn(unsigned char *mic, unsigned char *p, int len) *p++ = *mic++; *p++ = *mic++; } - else if (c1 > 0x7f) + else if (IS_HIGHBIT_SET(c1)) { /* cannot convert to EUC_CN! */ mic--; pg_print_bogus_char(&mic, &p); } else - { /* should be ASCII */ - *p++ = c1; - } + *p++ = c1; /* should be ASCII */ } *p = '\0'; } diff --git a/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c b/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c index 3b215b2c4f..2081cc4a6c 100644 --- a/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c +++ b/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $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 $ + * $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 $ * *------------------------------------------------------------------------- */ @@ -180,7 +180,7 @@ sjis2mic(unsigned char *sjis, unsigned char *p, int len) *p++ = LC_JISX0201K; *p++ = c1; } - else if (c1 > 0x7f) + else if (IS_HIGHBIT_SET(c1)) { /* * JIS X0208, X0212, user defined extended characters @@ -355,16 +355,14 @@ mic2sjis(unsigned char *mic, unsigned char *p, int len) } } } - else if (c1 > 0x7f) + else if (IS_HIGHBIT_SET(c1)) { /* cannot convert to SJIS! */ *p++ = PGSJISALTCODE >> 8; *p++ = PGSJISALTCODE & 0xff; } else - { /* should be ASCII */ - *p++ = c1; - } + *p++ = c1; /* should be ASCII */ } *p = '\0'; } @@ -436,15 +434,13 @@ mic2euc_jp(unsigned char *mic, unsigned char *p, int len) *p++ = *mic++; *p++ = *mic++; } - else if (c1 > 0x7f) + else if (IS_HIGHBIT_SET(c1)) { /* cannot convert to EUC_JP! */ mic--; pg_print_bogus_char(&mic, &p); } else - { /* should be ASCII */ - *p++ = c1; - } + *p++ = c1; /* should be ASCII */ } *p = '\0'; } diff --git a/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c b/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c index bed09bf737..938dfeb3da 100644 --- a/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c +++ b/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $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 $ + * $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 $ * *------------------------------------------------------------------------- */ @@ -110,15 +110,13 @@ mic2euc_kr(unsigned char *mic, unsigned char *p, int len) *p++ = *mic++; *p++ = *mic++; } - else if (c1 > 0x7f) + else if (IS_HIGHBIT_SET(c1)) { /* cannot convert to EUC_KR! */ mic--; pg_print_bogus_char(&mic, &p); } else - { /* should be ASCII */ - *p++ = c1; - } + *p++ = c1; /* should be ASCII */ } *p = '\0'; } diff --git a/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c b/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c index 3f11a0fba3..d60b3a8b49 100644 --- a/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c +++ b/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $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 $ + * $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 $ * *------------------------------------------------------------------------- */ @@ -224,15 +224,13 @@ mic2euc_tw(unsigned char *mic, unsigned char *p, int len) *p++ = *mic++; *p++ = *mic++; } - else if (c1 > 0x7f) + else if (IS_HIGHBIT_SET(c1)) { /* cannot convert to EUC_TW! */ mic--; pg_print_bogus_char(&mic, &p); } else - { /* should be ASCII */ - *p++ = c1; - } + *p++ = c1; /* should be ASCII */ } *p = '\0'; } @@ -252,7 +250,7 @@ big52mic(unsigned char *big5, unsigned char *p, int len) while (len >= 0 && (c1 = *big5++)) { - if (c1 <= 0x7fU) + if (!IS_HIGHBIT_SET(c1)) { /* ASCII */ len--; *p++ = c1; @@ -328,7 +326,7 @@ mic2big5(unsigned char *mic, unsigned char *p, int len) *p++ = big5buf & 0x00ff; } } - else if (c1 <= 0x7f) /* ASCII */ + else if (!IS_HIGHBIT_SET(c1)) /* ASCII */ *p++ = c1; else { /* cannot convert to Big5! */ diff --git a/src/backend/utils/mb/wchar.c b/src/backend/utils/mb/wchar.c index 3a0408614b..346668711f 100644 --- a/src/backend/utils/mb/wchar.c +++ b/src/backend/utils/mb/wchar.c @@ -1,7 +1,7 @@ /* * conversion functions between pg_wchar and multibyte streams. * Tatsuo Ishii - * $PostgreSQL: pgsql/src/backend/utils/mb/wchar.c,v 1.51 2005/12/25 02:14:18 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/wchar.c,v 1.52 2005/12/26 19:30:44 momjian Exp $ * * WIN1250 client encoding updated by Pavel Behal * @@ -542,7 +542,7 @@ pg_sjis_mblen(const unsigned char *s) if (*s >= 0xa1 && *s <= 0xdf) len = 1; /* 1 byte kana? */ - else if (*s > 0x7f) + else if (IS_HIGHBIT_SET(*s)) len = 2; /* kanji? */ else len = 1; /* should be ASCII */ @@ -556,7 +556,7 @@ pg_sjis_dsplen(const unsigned char *s) if (*s >= 0xa1 && *s <= 0xdf) len = 1; /* 1 byte kana? */ - else if (*s > 0x7f) + else if (IS_HIGHBIT_SET(*s)) len = 2; /* kanji? */ else len = 1; /* should be ASCII */ @@ -571,7 +571,7 @@ pg_big5_mblen(const unsigned char *s) { int len; - if (*s > 0x7f) + if (IS_HIGHBIT_SET(*s)) len = 2; /* kanji? */ else len = 1; /* should be ASCII */ @@ -583,7 +583,7 @@ pg_big5_dsplen(const unsigned char *s) { int len; - if (*s > 0x7f) + if (IS_HIGHBIT_SET(*s)) len = 2; /* kanji? */ else len = 1; /* should be ASCII */ @@ -598,7 +598,7 @@ pg_gbk_mblen(const unsigned char *s) { int len; - if (*s > 0x7f) + if (IS_HIGHBIT_SET(*s)) len = 2; /* kanji? */ else len = 1; /* should be ASCII */ @@ -610,7 +610,7 @@ pg_gbk_dsplen(const unsigned char *s) { int len; - if (*s > 0x7f) + if (IS_HIGHBIT_SET(*s)) len = 2; /* kanji? */ else len = 1; /* should be ASCII */ @@ -625,7 +625,7 @@ pg_uhc_mblen(const unsigned char *s) { int len; - if (*s > 0x7f) + if (IS_HIGHBIT_SET(*s)) len = 2; /* 2byte? */ else len = 1; /* should be ASCII */ @@ -637,7 +637,7 @@ pg_uhc_dsplen(const unsigned char *s) { int len; - if (*s > 0x7f) + if (IS_HIGHBIT_SET(*s)) len = 2; /* 2byte? */ else len = 1; /* should be ASCII */ @@ -653,7 +653,7 @@ pg_gb18030_mblen(const unsigned char *s) { int len; - if (*s <= 0x7f) + if (!IS_HIGHBIT_SET(*s)) len = 1; /* ASCII */ else { @@ -672,7 +672,7 @@ pg_gb18030_dsplen(const unsigned char *s) { int len; - if (*s <= 0x7f) + if (!IS_HIGHBIT_SET(*s)) len = 1; /* ASCII */ else len = 2; -- 2.40.0