aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2005-12-25 02:14:19 +0000
committerBruce Momjian <bruce@momjian.us>2005-12-25 02:14:19 +0000
commit261114a23f51c3d35a50ac27f2f453c6767bfeff (patch)
treebe7be693d6fe6782a4f1535fa3b05cb2e76cb363 /src/backend/utils/adt
parenta4d69a410d9690340456c11dec5be1200ce760b7 (diff)
downloadpostgresql-261114a23f51c3d35a50ac27f2f453c6767bfeff.tar.gz
postgresql-261114a23f51c3d35a50ac27f2f453c6767bfeff.zip
I have added these macros to c.h:
#define HIGHBIT (0x80) #define IS_HIGHBIT_SET(ch) ((unsigned char)(ch) & HIGHBIT) and removed CSIGNBIT and mapped it uses to HIGHBIT. I have also added uses for IS_HIGHBIT_SET where appropriate. This change is purely for code clarity.
Diffstat (limited to 'src/backend/utils/adt')
-rw-r--r--src/backend/utils/adt/network.c12
-rw-r--r--src/backend/utils/adt/varbit.c14
2 files changed, 13 insertions, 13 deletions
diff --git a/src/backend/utils/adt/network.c b/src/backend/utils/adt/network.c
index 3b526d0655b..e3917960775 100644
--- a/src/backend/utils/adt/network.c
+++ b/src/backend/utils/adt/network.c
@@ -1,7 +1,7 @@
/*
* PostgreSQL type definitions for the INET and CIDR types.
*
- * $PostgreSQL: pgsql/src/backend/utils/adt/network.c,v 1.56 2005/10/17 16:24:19 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/network.c,v 1.57 2005/12/25 02:14:17 momjian Exp $
*
* Jon Postel RIP 16 Oct 1998
*/
@@ -904,16 +904,16 @@ bitncmp(void *l, void *r, int n)
rb = ((const u_char *) r)[b];
for (b = n % 8; b > 0; b--)
{
- if ((lb & 0x80) != (rb & 0x80))
+ if (IS_HIGHBIT_SET(lb) != IS_HIGHBIT_SET(rb))
{
- if (lb & 0x80)
- return (1);
- return (-1);
+ if (IS_HIGHBIT_SET(lb))
+ return 1;
+ return -1;
}
lb <<= 1;
rb <<= 1;
}
- return (0);
+ return 0;
}
static bool
diff --git a/src/backend/utils/adt/varbit.c b/src/backend/utils/adt/varbit.c
index 7dbbed16f69..8fb0e4186a0 100644
--- a/src/backend/utils/adt/varbit.c
+++ b/src/backend/utils/adt/varbit.c
@@ -9,7 +9,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/varbit.c,v 1.47 2005/10/15 02:49:30 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/varbit.c,v 1.48 2005/12/25 02:14:17 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -120,7 +120,7 @@ bit_in(PG_FUNCTION_ARGS)
{
/* Parse the bit representation of the string */
/* We know it fits, as bitlen was compared to atttypmod */
- x = BITHIGH;
+ x = HIGHBIT;
for (; *sp; sp++)
{
if (*sp == '1')
@@ -134,7 +134,7 @@ bit_in(PG_FUNCTION_ARGS)
x >>= 1;
if (x == 0)
{
- x = BITHIGH;
+ x = HIGHBIT;
r++;
}
}
@@ -401,7 +401,7 @@ varbit_in(PG_FUNCTION_ARGS)
{
/* Parse the bit representation of the string */
/* We know it fits, as bitlen was compared to atttypmod */
- x = BITHIGH;
+ x = HIGHBIT;
for (; *sp; sp++)
{
if (*sp == '1')
@@ -415,7 +415,7 @@ varbit_in(PG_FUNCTION_ARGS)
x >>= 1;
if (x == 0)
{
- x = BITHIGH;
+ x = HIGHBIT;
r++;
}
}
@@ -477,14 +477,14 @@ varbit_out(PG_FUNCTION_ARGS)
x = *sp;
for (k = 0; k < BITS_PER_BYTE; k++)
{
- *r++ = (x & BITHIGH) ? '1' : '0';
+ *r++ = IS_HIGHBIT_SET(x) ? '1' : '0';
x <<= 1;
}
}
x = *sp;
for (k = i; k < len; k++)
{
- *r++ = (x & BITHIGH) ? '1' : '0';
+ *r++ = IS_HIGHBIT_SET(x) ? '1' : '0';
x <<= 1;
}
*r = '\0';