Commit a2384d00 authored by Bruce Momjian's avatar Bruce Momjian

More uses of IS_HIGHBIT_SET() macro.

parent 6840cccd
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * 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) ...@@ -95,7 +95,7 @@ mic2gb18030(unsigned char *mic, unsigned char *p, int len)
{ {
len -= pg_mic_mblen(mic++); len -= pg_mic_mblen(mic++);
if (c1 <= 0x7f) /* ASCII */ if (!IS_HIGHBIT_SET(c1)) /* ASCII */
*p++ = c1; *p++ = c1;
else if (c1 >= 0x81 && c1 <= 0xfe) else if (c1 >= 0x81 && c1 <= 0xfe)
{ {
...@@ -141,10 +141,8 @@ latin2mic(unsigned char *l, unsigned char *p, int len, int lc) ...@@ -141,10 +141,8 @@ latin2mic(unsigned char *l, unsigned char *p, int len, int lc)
while (len-- > 0 && (c1 = *l++)) while (len-- > 0 && (c1 = *l++))
{ {
if (c1 > 0x7f) if (IS_HIGHBIT_SET(c1))
{ /* Latin? */ *p++ = lc; /* Latin? */
*p++ = lc;
}
*p++ = c1; *p++ = c1;
} }
*p = '\0'; *p = '\0';
...@@ -164,7 +162,7 @@ mic2latin(unsigned char *mic, unsigned char *p, int len, int lc) ...@@ -164,7 +162,7 @@ mic2latin(unsigned char *mic, unsigned char *p, int len, int lc)
if (c1 == lc) if (c1 == lc)
*p++ = *mic++; *p++ = *mic++;
else if (c1 > 0x7f) else if (IS_HIGHBIT_SET(c1))
{ {
mic--; mic--;
pg_print_bogus_char(&mic, &p); pg_print_bogus_char(&mic, &p);
...@@ -201,7 +199,7 @@ pg_mic2ascii(unsigned char *mic, unsigned char *p, int len) ...@@ -201,7 +199,7 @@ pg_mic2ascii(unsigned char *mic, unsigned char *p, int len)
while (len-- > 0 && (c1 = *mic)) while (len-- > 0 && (c1 = *mic))
{ {
if (c1 > 0x7f) if (IS_HIGHBIT_SET(c1))
pg_print_bogus_char(&mic, &p); pg_print_bogus_char(&mic, &p);
else else
{ /* should be ASCII */ { /* should be ASCII */
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * 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) ...@@ -110,15 +110,13 @@ mic2euc_cn(unsigned char *mic, unsigned char *p, int len)
*p++ = *mic++; *p++ = *mic++;
*p++ = *mic++; *p++ = *mic++;
} }
else if (c1 > 0x7f) else if (IS_HIGHBIT_SET(c1))
{ /* cannot convert to EUC_CN! */ { /* cannot convert to EUC_CN! */
mic--; mic--;
pg_print_bogus_char(&mic, &p); pg_print_bogus_char(&mic, &p);
} }
else else
{ /* should be ASCII */ *p++ = c1; /* should be ASCII */
*p++ = c1;
}
} }
*p = '\0'; *p = '\0';
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * 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) ...@@ -180,7 +180,7 @@ sjis2mic(unsigned char *sjis, unsigned char *p, int len)
*p++ = LC_JISX0201K; *p++ = LC_JISX0201K;
*p++ = c1; *p++ = c1;
} }
else if (c1 > 0x7f) else if (IS_HIGHBIT_SET(c1))
{ {
/* /*
* JIS X0208, X0212, user defined extended characters * JIS X0208, X0212, user defined extended characters
...@@ -355,16 +355,14 @@ mic2sjis(unsigned char *mic, unsigned char *p, int len) ...@@ -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! */ /* cannot convert to SJIS! */
*p++ = PGSJISALTCODE >> 8; *p++ = PGSJISALTCODE >> 8;
*p++ = PGSJISALTCODE & 0xff; *p++ = PGSJISALTCODE & 0xff;
} }
else else
{ /* should be ASCII */ *p++ = c1; /* should be ASCII */
*p++ = c1;
}
} }
*p = '\0'; *p = '\0';
} }
...@@ -436,15 +434,13 @@ mic2euc_jp(unsigned char *mic, unsigned char *p, int len) ...@@ -436,15 +434,13 @@ mic2euc_jp(unsigned char *mic, unsigned char *p, int len)
*p++ = *mic++; *p++ = *mic++;
*p++ = *mic++; *p++ = *mic++;
} }
else if (c1 > 0x7f) else if (IS_HIGHBIT_SET(c1))
{ /* cannot convert to EUC_JP! */ { /* cannot convert to EUC_JP! */
mic--; mic--;
pg_print_bogus_char(&mic, &p); pg_print_bogus_char(&mic, &p);
} }
else else
{ /* should be ASCII */ *p++ = c1; /* should be ASCII */
*p++ = c1;
}
} }
*p = '\0'; *p = '\0';
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * 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) ...@@ -110,15 +110,13 @@ mic2euc_kr(unsigned char *mic, unsigned char *p, int len)
*p++ = *mic++; *p++ = *mic++;
*p++ = *mic++; *p++ = *mic++;
} }
else if (c1 > 0x7f) else if (IS_HIGHBIT_SET(c1))
{ /* cannot convert to EUC_KR! */ { /* cannot convert to EUC_KR! */
mic--; mic--;
pg_print_bogus_char(&mic, &p); pg_print_bogus_char(&mic, &p);
} }
else else
{ /* should be ASCII */ *p++ = c1; /* should be ASCII */
*p++ = c1;
}
} }
*p = '\0'; *p = '\0';
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * 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) ...@@ -224,15 +224,13 @@ mic2euc_tw(unsigned char *mic, unsigned char *p, int len)
*p++ = *mic++; *p++ = *mic++;
*p++ = *mic++; *p++ = *mic++;
} }
else if (c1 > 0x7f) else if (IS_HIGHBIT_SET(c1))
{ /* cannot convert to EUC_TW! */ { /* cannot convert to EUC_TW! */
mic--; mic--;
pg_print_bogus_char(&mic, &p); pg_print_bogus_char(&mic, &p);
} }
else else
{ /* should be ASCII */ *p++ = c1; /* should be ASCII */
*p++ = c1;
}
} }
*p = '\0'; *p = '\0';
} }
...@@ -252,7 +250,7 @@ big52mic(unsigned char *big5, unsigned char *p, int len) ...@@ -252,7 +250,7 @@ big52mic(unsigned char *big5, unsigned char *p, int len)
while (len >= 0 && (c1 = *big5++)) while (len >= 0 && (c1 = *big5++))
{ {
if (c1 <= 0x7fU) if (!IS_HIGHBIT_SET(c1))
{ /* ASCII */ { /* ASCII */
len--; len--;
*p++ = c1; *p++ = c1;
...@@ -328,7 +326,7 @@ mic2big5(unsigned char *mic, unsigned char *p, int len) ...@@ -328,7 +326,7 @@ mic2big5(unsigned char *mic, unsigned char *p, int len)
*p++ = big5buf & 0x00ff; *p++ = big5buf & 0x00ff;
} }
} }
else if (c1 <= 0x7f) /* ASCII */ else if (!IS_HIGHBIT_SET(c1)) /* ASCII */
*p++ = c1; *p++ = c1;
else else
{ /* cannot convert to Big5! */ { /* cannot convert to Big5! */
......
/* /*
* conversion functions between pg_wchar and multibyte streams. * conversion functions between pg_wchar and multibyte streams.
* Tatsuo Ishii * 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 * WIN1250 client encoding updated by Pavel Behal
* *
...@@ -542,7 +542,7 @@ pg_sjis_mblen(const unsigned char *s) ...@@ -542,7 +542,7 @@ pg_sjis_mblen(const unsigned char *s)
if (*s >= 0xa1 && *s <= 0xdf) if (*s >= 0xa1 && *s <= 0xdf)
len = 1; /* 1 byte kana? */ len = 1; /* 1 byte kana? */
else if (*s > 0x7f) else if (IS_HIGHBIT_SET(*s))
len = 2; /* kanji? */ len = 2; /* kanji? */
else else
len = 1; /* should be ASCII */ len = 1; /* should be ASCII */
...@@ -556,7 +556,7 @@ pg_sjis_dsplen(const unsigned char *s) ...@@ -556,7 +556,7 @@ pg_sjis_dsplen(const unsigned char *s)
if (*s >= 0xa1 && *s <= 0xdf) if (*s >= 0xa1 && *s <= 0xdf)
len = 1; /* 1 byte kana? */ len = 1; /* 1 byte kana? */
else if (*s > 0x7f) else if (IS_HIGHBIT_SET(*s))
len = 2; /* kanji? */ len = 2; /* kanji? */
else else
len = 1; /* should be ASCII */ len = 1; /* should be ASCII */
...@@ -571,7 +571,7 @@ pg_big5_mblen(const unsigned char *s) ...@@ -571,7 +571,7 @@ pg_big5_mblen(const unsigned char *s)
{ {
int len; int len;
if (*s > 0x7f) if (IS_HIGHBIT_SET(*s))
len = 2; /* kanji? */ len = 2; /* kanji? */
else else
len = 1; /* should be ASCII */ len = 1; /* should be ASCII */
...@@ -583,7 +583,7 @@ pg_big5_dsplen(const unsigned char *s) ...@@ -583,7 +583,7 @@ pg_big5_dsplen(const unsigned char *s)
{ {
int len; int len;
if (*s > 0x7f) if (IS_HIGHBIT_SET(*s))
len = 2; /* kanji? */ len = 2; /* kanji? */
else else
len = 1; /* should be ASCII */ len = 1; /* should be ASCII */
...@@ -598,7 +598,7 @@ pg_gbk_mblen(const unsigned char *s) ...@@ -598,7 +598,7 @@ pg_gbk_mblen(const unsigned char *s)
{ {
int len; int len;
if (*s > 0x7f) if (IS_HIGHBIT_SET(*s))
len = 2; /* kanji? */ len = 2; /* kanji? */
else else
len = 1; /* should be ASCII */ len = 1; /* should be ASCII */
...@@ -610,7 +610,7 @@ pg_gbk_dsplen(const unsigned char *s) ...@@ -610,7 +610,7 @@ pg_gbk_dsplen(const unsigned char *s)
{ {
int len; int len;
if (*s > 0x7f) if (IS_HIGHBIT_SET(*s))
len = 2; /* kanji? */ len = 2; /* kanji? */
else else
len = 1; /* should be ASCII */ len = 1; /* should be ASCII */
...@@ -625,7 +625,7 @@ pg_uhc_mblen(const unsigned char *s) ...@@ -625,7 +625,7 @@ pg_uhc_mblen(const unsigned char *s)
{ {
int len; int len;
if (*s > 0x7f) if (IS_HIGHBIT_SET(*s))
len = 2; /* 2byte? */ len = 2; /* 2byte? */
else else
len = 1; /* should be ASCII */ len = 1; /* should be ASCII */
...@@ -637,7 +637,7 @@ pg_uhc_dsplen(const unsigned char *s) ...@@ -637,7 +637,7 @@ pg_uhc_dsplen(const unsigned char *s)
{ {
int len; int len;
if (*s > 0x7f) if (IS_HIGHBIT_SET(*s))
len = 2; /* 2byte? */ len = 2; /* 2byte? */
else else
len = 1; /* should be ASCII */ len = 1; /* should be ASCII */
...@@ -653,7 +653,7 @@ pg_gb18030_mblen(const unsigned char *s) ...@@ -653,7 +653,7 @@ pg_gb18030_mblen(const unsigned char *s)
{ {
int len; int len;
if (*s <= 0x7f) if (!IS_HIGHBIT_SET(*s))
len = 1; /* ASCII */ len = 1; /* ASCII */
else else
{ {
...@@ -672,7 +672,7 @@ pg_gb18030_dsplen(const unsigned char *s) ...@@ -672,7 +672,7 @@ pg_gb18030_dsplen(const unsigned char *s)
{ {
int len; int len;
if (*s <= 0x7f) if (!IS_HIGHBIT_SET(*s))
len = 1; /* ASCII */ len = 1; /* ASCII */
else else
len = 2; len = 2;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment