/* Process first byte of a triplet. */
- put_byte (base64_value_to_char[MASK (6) & character >> 2], subtask);
- value = (MASK (2) & character) << 4;
+ put_byte (base64_value_to_char[BIT_MASK (6) & character >> 2], subtask);
+ value = (BIT_MASK (2) & character) << 4;
/* Process second byte of a triplet. */
put_byte ('=', subtask);
break;
}
- put_byte (base64_value_to_char[value | (MASK (4) & character >> 4)],
+ put_byte (base64_value_to_char[value | (BIT_MASK (4) & character >> 4)],
subtask);
- value = (MASK (4) & character) << 2;
+ value = (BIT_MASK (4) & character) << 2;
/* Process third byte of a triplet. */
put_byte ('=', subtask);
break;
}
- put_byte (base64_value_to_char[value | (MASK (2) & character >> 6)],
+ put_byte (base64_value_to_char[value | (BIT_MASK (2) & character >> 6)],
subtask);
- put_byte (base64_value_to_char[MASK (6) & character], subtask);
+ put_byte (base64_value_to_char[BIT_MASK (6) & character], subtask);
}
/* Complete last partial line. */
else
RETURN_IF_NOGO (RECODE_INVALID_INPUT, subtask);
- put_byte (MASK (8) & value >> 8, subtask);
+ put_byte (BIT_MASK (8) & value >> 8, subtask);
/* Process fourth byte of a quadruplet. */
else
RETURN_IF_NOGO (RECODE_INVALID_INPUT, subtask);
- put_byte (MASK (8) & value, subtask);
+ put_byte (BIT_MASK (8) & value, subtask);
}
}
#define N_(Text) Text
/* Generate a mask of LENGTH one-bits, right justified in a word. */
-#define MASK(Length) ((unsigned) ~(~0 << (Length)))
+#define BIT_MASK(Length) ((unsigned) ~(~0 << (Length)))
/* Indicate if CHARACTER holds into 7 bits. */
#define IS_ASCII(Character) \
- (!((Character) & ~MASK (7)))
+ (!((Character) & ~BIT_MASK (7)))
/* Debugging the memory allocator. */
#if WITH_DMALLOC
while (character != EOF)
{
- unsigned value = MASK (8) & character;
+ unsigned value = BIT_MASK (8) & character;
unsigned byte_count;
char buffer[14];
const char *cursor;
character = get_byte (subtask);
if (character == EOF)
break;
- value = (value << 8) | (MASK (8) & character);
+ value = (value << 8) | (BIT_MASK (8) & character);
}
/* Write delimiters. */
/* Produce the output bytes. */
for (unsigned shift = size; shift != 0; shift--)
- put_byte (MASK (8) & value >> ((shift * 8) - 8), subtask);
+ put_byte (BIT_MASK (8) & value >> ((shift * 8) - 8), subtask);
}
/* Skip separators. */
RETURN_IF_NOGO (RECODE_AMBIGUOUS_OUTPUT, subtask);
put_byte ('M', subtask);
put_byte ('-', subtask);
- input_char &= MASK (7);
+ input_char &= BIT_MASK (7);
}
- if (input_char < ' ' || input_char == MASK (7))
+ if (input_char < ' ' || input_char == BIT_MASK (7))
{
RETURN_IF_NOGO (RECODE_AMBIGUOUS_OUTPUT, subtask);
put_byte ('^', subtask);
while (character = get_byte (subtask), character != EOF)
if (IS_ASCII (character))
put_byte (character, subtask);
- else if ((character & MASK (8)) == prefix)
+ else if ((character & BIT_MASK (8)) == prefix)
{
character = get_byte (subtask);
- while ((character & MASK (8)) == prefix)
+ while ((character & BIT_MASK (8)) == prefix)
{
/* This happens in practice, sometimes, that Emacs goes a bit
berzerk and generates strings of prefix characters. Remove
unsigned offset = data->offset[code / STRIP_SIZE];
unsigned value = pool[offset + code % STRIP_SIZE];
- return value == MASK (16) ? -1 : (int) value;
+ return value == BIT_MASK (16) ? -1 : (int) value;
}
/*---------------------------------------------------------.
if (value1 != value2)
{
- if (value1 == MASK (16))
+ if (value1 == BIT_MASK (16))
distance++;
else
{
unsigned nibble; \
\
put_byte ('=', subtask); \
- nibble = MASK (4) & (Character) >> 4; \
+ nibble = BIT_MASK (4) & (Character) >> 4; \
put_byte ((nibble < 10 ? '0' : 'A' - 10) + nibble, subtask); \
- nibble = MASK (4) & (Character); \
+ nibble = BIT_MASK (4) & (Character); \
put_byte ((nibble < 10 ? '0' : 'A' - 10) + nibble, subtask); \
} while (false)
{
unsigned code = pool[offset + position_counter];
- if (code != MASK (16))
+ if (code != BIT_MASK (16))
{
/* Establish a new binding item. */
item_cursor->byte = byte;
/*---------------------------------------------------------------------.
| Return an UCS-2 value, given an RFC 1345 short form in a CHARSET, or |
-| MASK (16) if the short form is unknown. |
+| BIT_MASK (16) if the short form is unknown. |
`---------------------------------------------------------------------*/
static _GL_ATTRIBUTE_PURE recode_ucs2
|| (WIFSIGNALED (wait_status)
&& WTERMSIG (wait_status) == SIGPIPE)))
#endif
- if ((wait_status & MASK (8)) != 0
- && (wait_status & MASK (8)) != SIGPIPE)
+ if ((wait_status & BIT_MASK (8)) != 0
+ && (wait_status & BIT_MASK (8)) != SIGPIPE)
{
recode_error (outer, _("Child process wait status is 0x%0.2x"),
wait_status);
switch (subtask->task->swap_input)
{
case RECODE_SWAP_UNDECIDED:
- chunk = ((MASK (8) & character1) << 8) | (MASK (8) & character2);
+ chunk = ((BIT_MASK (8) & character1) << 8) | (BIT_MASK (8) & character2);
switch (chunk)
{
case BYTE_ORDER_MARK:
break;
case RECODE_SWAP_NO:
- chunk = ((MASK (8) & character1) << 8) | (MASK (8) & character2);
+ chunk = ((BIT_MASK (8) & character1) << 8) | (BIT_MASK (8) & character2);
switch (chunk)
{
case BYTE_ORDER_MARK:
break;
case RECODE_SWAP_YES:
- chunk = ((MASK (8) & character2) << 8) | (MASK (8) & character1);
+ chunk = ((BIT_MASK (8) & character2) << 8) | (BIT_MASK (8) & character1);
switch (chunk)
{
case BYTE_ORDER_MARK:
bool
put_ucs2 (unsigned value, RECODE_SUBTASK subtask)
{
- put_byte (MASK (8) & value >> 8, subtask);
- put_byte (MASK (8) & value, subtask);
+ put_byte (BIT_MASK (8) & value >> 8, subtask);
+ put_byte (BIT_MASK (8) & value, subtask);
return true;
}
\f
character = get_byte (subtask);
if (character == EOF)
return false;
- chunk = (MASK (8) & character) << 24;
+ chunk = (BIT_MASK (8) & character) << 24;
character = get_byte (subtask);
if (character == EOF)
SET_SUBTASK_ERROR (RECODE_INVALID_INPUT, subtask);
return false;
}
- chunk |= (MASK (8) & character) << 16;
+ chunk |= (BIT_MASK (8) & character) << 16;
character = get_byte (subtask);
if (character == EOF)
SET_SUBTASK_ERROR (RECODE_INVALID_INPUT, subtask);
return false;
}
- chunk |= (MASK (8) & character) << 8;
+ chunk |= (BIT_MASK (8) & character) << 8;
character = get_byte (subtask);
if (character == EOF)
SET_SUBTASK_ERROR (RECODE_INVALID_INPUT, subtask);
return false;
}
- chunk |= MASK (8) & character;
+ chunk |= BIT_MASK (8) & character;
*value = chunk;
return true;
bool
put_ucs4 (unsigned value, RECODE_SUBTASK subtask)
{
- put_byte (MASK (8) & value >> 24, subtask);
- put_byte (MASK (8) & value >> 16, subtask);
- put_byte (MASK (8) & value >> 8, subtask);
- put_byte (MASK (8) & value, subtask);
+ put_byte (BIT_MASK (8) & value >> 24, subtask);
+ put_byte (BIT_MASK (8) & value >> 16, subtask);
+ put_byte (BIT_MASK (8) & value >> 8, subtask);
+ put_byte (BIT_MASK (8) & value, subtask);
return true;
}
\f
int character;
while (character = get_byte (subtask), character != EOF)
- put_ucs4 (MASK (8) & character, subtask);
+ put_ucs4 (BIT_MASK (8) & character, subtask);
SUBTASK_RETURN (subtask);
}
while (true)
{
- if (value & ~MASK (16))
+ if (value & ~BIT_MASK (16))
if (value < (1 << 16 | 1 << 20))
{
/* Double UCS-2 character. */
value -= 1 << 16;
- put_ucs2 (0xD800 | (MASK (10) & value >> 10), subtask);
- put_ucs2 (0xDC00 | (MASK (10) & value), subtask);
+ put_ucs2 (0xD800 | (BIT_MASK (10) & value >> 10), subtask);
+ put_ucs2 (0xDC00 | (BIT_MASK (10) & value), subtask);
}
else
{
/* Process first UCS-2 value of a triplet. */
- put_byte (base64_value_to_char[MASK (6) & value >> 10], subtask);
- put_byte (base64_value_to_char[MASK (6) & value >> 4], subtask);
- split = (value & MASK (4)) << 2;
+ put_byte (base64_value_to_char[BIT_MASK (6) & value >> 10], subtask);
+ put_byte (base64_value_to_char[BIT_MASK (6) & value >> 4], subtask);
+ split = (value & BIT_MASK (4)) << 2;
if (!get_ucs2 (&value, subtask))
{
put_byte (base64_value_to_char[split], subtask);
put_byte (base64_value_to_char[split], subtask);
break;
}
- put_byte (base64_value_to_char[split | (MASK (2) & value >> 14)],
+ put_byte (base64_value_to_char[split | (BIT_MASK (2) & value >> 14)],
subtask);
- put_byte (base64_value_to_char[MASK (6) & value >> 8], subtask);
- put_byte (base64_value_to_char[MASK (6) & value >> 2], subtask);
- split = (value & MASK (2)) << 4;
+ put_byte (base64_value_to_char[BIT_MASK (6) & value >> 8], subtask);
+ put_byte (base64_value_to_char[BIT_MASK (6) & value >> 2], subtask);
+ split = (value & BIT_MASK (2)) << 4;
if (!get_ucs2 (&value, subtask))
{
put_byte (base64_value_to_char[split], subtask);
put_byte (base64_value_to_char[split], subtask);
break;
}
- put_byte (base64_value_to_char[split | (MASK (4) & value >> 12)],
+ put_byte (base64_value_to_char[split | (BIT_MASK (4) & value >> 12)],
subtask);
- put_byte (base64_value_to_char[MASK (6) & value >> 6], subtask);
- put_byte (base64_value_to_char[MASK (6) & value], subtask);
+ put_byte (base64_value_to_char[BIT_MASK (6) & value >> 6], subtask);
+ put_byte (base64_value_to_char[BIT_MASK (6) & value], subtask);
if (!get_ucs2 (&value, subtask))
SUBTASK_RETURN (subtask);
}
if (!IS_BASE64 (character))
{
- if (MASK (2) & split)
+ if (BIT_MASK (2) & split)
RETURN_IF_NOGO (RECODE_INVALID_INPUT, subtask);
break;
}
- value = ((MASK (2) & split) << 14
+ value = ((BIT_MASK (2) & split) << 14
| base64_char_to_value[character] << 8);
character = get_byte (subtask);
if (!IS_BASE64 (character))
{
- if (MASK (4) & split)
+ if (BIT_MASK (4) & split)
RETURN_IF_NOGO (RECODE_INVALID_INPUT, subtask);
break;
}
- value = ((MASK (4) & split) << 12
+ value = ((BIT_MASK (4) & split) << 12
| base64_char_to_value[character] << 6);
character = get_byte (subtask);
RETURN_IF_NOGO (RECODE_INVALID_INPUT, subtask); \
break; \
} \
- else if ((MASK (2) << 6 & character) != 1 << 7) \
+ else if ((BIT_MASK (2) << 6 & character) != 1 << 7) \
{ \
RETURN_IF_NOGO (RECODE_INVALID_INPUT, subtask); \
continue; \
Merge it into `value' at POSITION. This macro is meant to be used only
within the `while' loop in `transform_utf8_ucs[24]'. */
#define GET_DATA_BYTE_AT(Position) \
- GET_DATA_BYTE /* ... else */ value |= (MASK (6) & character) << Position
+ GET_DATA_BYTE /* ... else */ value |= (BIT_MASK (6) & character) << Position
\f
static bool
transform_ucs2_utf8 (RECODE_SUBTASK subtask)
while (get_ucs2 (&value, subtask))
{
- if (value & ~MASK (7))
- if (value & ~MASK (11))
+ if (value & ~BIT_MASK (7))
+ if (value & ~BIT_MASK (11))
{
/* 3 bytes - more than 11 bits, but not more than 16. */
- put_byte ((MASK (3) << 5) | (MASK (6) & value >> 12), subtask);
- put_byte ((1 << 7) | (MASK (6) & value >> 6), subtask);
- put_byte ((1 << 7) | (MASK (6) & value), subtask);
+ put_byte ((BIT_MASK (3) << 5) | (BIT_MASK (6) & value >> 12), subtask);
+ put_byte ((1 << 7) | (BIT_MASK (6) & value >> 6), subtask);
+ put_byte ((1 << 7) | (BIT_MASK (6) & value), subtask);
}
else
{
/* 2 bytes - more than 7 bits, but not more than 11. */
- put_byte ((MASK (2) << 6) | (MASK (6) & value >> 6), subtask);
- put_byte ((1 << 7) | (MASK (6) & value), subtask);
+ put_byte ((BIT_MASK (2) << 6) | (BIT_MASK (6) & value >> 6), subtask);
+ put_byte ((1 << 7) | (BIT_MASK (6) & value), subtask);
}
else
/* 1 byte - not more than 7 bits (that is, ASCII). */
unsigned value;
while (get_ucs4 (&value, subtask))
- if (value & ~MASK (16))
- if (value & ~MASK (26))
- if (value & ~MASK (31))
+ if (value & ~BIT_MASK (16))
+ if (value & ~BIT_MASK (26))
+ if (value & ~BIT_MASK (31))
{
#if HANDLE_32_BITS
/* 7 bytes - more than 31 bits (that is, exactly 32 :-). */
- put_byte (MASK (7) << 1);
- put_byte ((1 << 7) | (MASK (6) & value >> 30), subtask);
- put_byte ((1 << 7) | (MASK (6) & value >> 24), subtask);
- put_byte ((1 << 7) | (MASK (6) & value >> 18), subtask);
- put_byte ((1 << 7) | (MASK (6) & value >> 12), subtask);
- put_byte ((1 << 7) | (MASK (6) & value >> 6), subtask);
- put_byte ((1 << 7) | (MASK (6) & value), subtask);
+ put_byte (BIT_MASK (7) << 1);
+ put_byte ((1 << 7) | (BIT_MASK (6) & value >> 30), subtask);
+ put_byte ((1 << 7) | (BIT_MASK (6) & value >> 24), subtask);
+ put_byte ((1 << 7) | (BIT_MASK (6) & value >> 18), subtask);
+ put_byte ((1 << 7) | (BIT_MASK (6) & value >> 12), subtask);
+ put_byte ((1 << 7) | (BIT_MASK (6) & value >> 6), subtask);
+ put_byte ((1 << 7) | (BIT_MASK (6) & value), subtask);
#else
RETURN_IF_NOGO (RECODE_INVALID_INPUT, subtask);
#endif
else
{
/* 6 bytes - more than 26 bits, but not more than 31. */
- put_byte ((MASK (6) << 2) | (MASK (6) & value >> 30), subtask);
- put_byte ((1 << 7) | (MASK (6) & value >> 24), subtask);
- put_byte ((1 << 7) | (MASK (6) & value >> 18), subtask);
- put_byte ((1 << 7) | (MASK (6) & value >> 12), subtask);
- put_byte ((1 << 7) | (MASK (6) & value >> 6), subtask);
- put_byte ((1 << 7) | (MASK (6) & value), subtask);
+ put_byte ((BIT_MASK (6) << 2) | (BIT_MASK (6) & value >> 30), subtask);
+ put_byte ((1 << 7) | (BIT_MASK (6) & value >> 24), subtask);
+ put_byte ((1 << 7) | (BIT_MASK (6) & value >> 18), subtask);
+ put_byte ((1 << 7) | (BIT_MASK (6) & value >> 12), subtask);
+ put_byte ((1 << 7) | (BIT_MASK (6) & value >> 6), subtask);
+ put_byte ((1 << 7) | (BIT_MASK (6) & value), subtask);
}
- else if (value & ~MASK (21))
+ else if (value & ~BIT_MASK (21))
{
/* 5 bytes - more than 21 bits, but not more than 26. */
- put_byte ((MASK (5) << 3) | (MASK (6) & value >> 24), subtask);
- put_byte ((1 << 7) | (MASK (6) & value >> 18), subtask);
- put_byte ((1 << 7) | (MASK (6) & value >> 12), subtask);
- put_byte ((1 << 7) | (MASK (6) & value >> 6), subtask);
- put_byte ((1 << 7) | (MASK (6) & value), subtask);
+ put_byte ((BIT_MASK (5) << 3) | (BIT_MASK (6) & value >> 24), subtask);
+ put_byte ((1 << 7) | (BIT_MASK (6) & value >> 18), subtask);
+ put_byte ((1 << 7) | (BIT_MASK (6) & value >> 12), subtask);
+ put_byte ((1 << 7) | (BIT_MASK (6) & value >> 6), subtask);
+ put_byte ((1 << 7) | (BIT_MASK (6) & value), subtask);
}
else
{
/* 4 bytes - more than 16 bits, but not more than 21. */
- put_byte ((MASK (4) << 4) | (MASK (6) & value >> 18), subtask);
- put_byte ((1 << 7) | (MASK (6) & value >> 12), subtask);
- put_byte ((1 << 7) | (MASK (6) & value >> 6), subtask);
- put_byte ((1 << 7) | (MASK (6) & value), subtask);
+ put_byte ((BIT_MASK (4) << 4) | (BIT_MASK (6) & value >> 18), subtask);
+ put_byte ((1 << 7) | (BIT_MASK (6) & value >> 12), subtask);
+ put_byte ((1 << 7) | (BIT_MASK (6) & value >> 6), subtask);
+ put_byte ((1 << 7) | (BIT_MASK (6) & value), subtask);
}
- else if (value & ~MASK (7))
- if (value & ~MASK (11))
+ else if (value & ~BIT_MASK (7))
+ if (value & ~BIT_MASK (11))
{
/* 3 bytes - more than 11 bits, but not more than 16. */
- put_byte ((MASK (3) << 5) | (MASK (6) & value >> 12), subtask);
- put_byte ((1 << 7) | (MASK (6) & value >> 6), subtask);
- put_byte ((1 << 7) | (MASK (6) & value), subtask);
+ put_byte ((BIT_MASK (3) << 5) | (BIT_MASK (6) & value >> 12), subtask);
+ put_byte ((1 << 7) | (BIT_MASK (6) & value >> 6), subtask);
+ put_byte ((1 << 7) | (BIT_MASK (6) & value), subtask);
}
else
{
/* 2 bytes - more than 7 bits, but not more than 11. */
- put_byte ((MASK (2) << 6) | (MASK (6) & value >> 6), subtask);
- put_byte ((1 << 7) | (MASK (6) & value), subtask);
+ put_byte ((BIT_MASK (2) << 6) | (BIT_MASK (6) & value >> 6), subtask);
+ put_byte ((1 << 7) | (BIT_MASK (6) & value), subtask);
}
else
/* 1 byte - not more than 7 bits (that is, ASCII). */
/* Process one UTF-8 value. EOF is acceptable on first byte only. */
- if ((character & MASK (4) << 4) == MASK (4) << 4)
- if ((character & MASK (6) << 2) == MASK (6) << 2)
- if ((character & MASK (7) << 1) == MASK (7) << 1)
+ if ((character & BIT_MASK (4) << 4) == BIT_MASK (4) << 4)
+ if ((character & BIT_MASK (6) << 2) == BIT_MASK (6) << 2)
+ if ((character & BIT_MASK (7) << 1) == BIT_MASK (7) << 1)
{
/* 7 bytes - more than 31 bits (that is, exactly 32 :-). */
#if HANDLE_32_BITS
else
{
/* 6 bytes - more than 26 bits, but not more than 31. */
- value = (MASK (1) & character) << 30;
+ value = (BIT_MASK (1) & character) << 30;
GET_DATA_BYTE_AT (24);
GET_DATA_BYTE_AT (18);
GET_DATA_BYTE_AT (12);
put_ucs4 (value, subtask);
character = get_byte (subtask);
}
- else if ((character & MASK (5) << 3) == MASK (5) << 3)
+ else if ((character & BIT_MASK (5) << 3) == BIT_MASK (5) << 3)
{
/* 5 bytes - more than 21 bits, but not more than 26. */
- value = (MASK (2) & character) << 24;
+ value = (BIT_MASK (2) & character) << 24;
GET_DATA_BYTE_AT (18);
GET_DATA_BYTE_AT (12);
GET_DATA_BYTE_AT (6);
else
{
/* 4 bytes - more than 16 bits, but not more than 21. */
- value = (MASK (3) & character) << 18;
+ value = (BIT_MASK (3) & character) << 18;
GET_DATA_BYTE_AT (12);
GET_DATA_BYTE_AT (6);
GET_DATA_BYTE_AT (0);
put_ucs4 (value, subtask);
character = get_byte (subtask);
}
- else if ((character & MASK (2) << 6) == MASK (2) << 6)
- if ((character & MASK (3) << 5) == MASK (3) << 5)
+ else if ((character & BIT_MASK (2) << 6) == BIT_MASK (2) << 6)
+ if ((character & BIT_MASK (3) << 5) == BIT_MASK (3) << 5)
{
/* 3 bytes - more than 11 bits, but not more than 16. */
- value = (MASK (4) & character) << 12;
+ value = (BIT_MASK (4) & character) << 12;
GET_DATA_BYTE_AT (6);
GET_DATA_BYTE_AT (0);
put_ucs4 (value, subtask);
else
{
/* 2 bytes - more than 7 bits, but not more than 11. */
- value = (MASK (5) & character) << 6;
+ value = (BIT_MASK (5) & character) << 6;
GET_DATA_BYTE_AT (0);
put_ucs4 (value, subtask);
character = get_byte (subtask);
else
{
/* 1 byte - not more than 7 bits (that is, ASCII). */
- put_ucs4 (MASK (8) & character, subtask);
+ put_ucs4 (BIT_MASK (8) & character, subtask);
character = get_byte (subtask);
}