#define min(X, Y) ((X) < (Y) ? (X) : (Y))
#define max(X, Y) ((X) > (Y) ? (X) : (Y))
\f
+void
+invalid_character (c)
+ int c;
+{
+ error ("Invalid character: %o, %d, 0x%x", c);
+}
+
+
/* Set STR a pointer to the multi-byte form of the character C. If C
is not a composite character, the multi-byte form is set in WORKBUF
and STR points WORKBUF. The caller should allocate at least 4-byte
}
else
{
- error ("Invalid character: %d", c);
+ invalid_character (c);
}
}
|| ! CHARSET_DEFINED_P (charset)
|| c1 >= 0 && c1 < 32
|| c2 >= 0 && c2 < 32)
- error ("Invalid character: %d", c);
+ invalid_character (c);
*str = workbuf;
*workbuf++ = CHARSET_LEADING_CODE_BASE (charset);
CHECK_NUMBER (ch, 0);
charset = CHAR_CHARSET (XFASTINT (ch));
if (!CHARSET_DEFINED_P (charset))
- error ("Invalid character: %d", XINT (ch));
+ invalid_character (XINT (ch));
return CHARSET_TABLE_INFO (charset, CHARSET_DIRECTION_IDX);
}
unsigned char *ptr;
int nbytes;
{
- unsigned char *endp;
+ unsigned char *endp, c;
int chars;
/* current_buffer is null at early stages of Emacs initialization. */
while (ptr < endp)
{
- if (*ptr == LEADING_CODE_COMPOSITION)
- {
- ptr++;
- while (ptr < endp && ! CHAR_HEAD_P (*ptr)) ptr++;
- }
- else
- ptr += BYTES_BY_CHAR_HEAD (*ptr);
+ c = *ptr++;
+
+ if (BASE_LEADING_CODE_P (c))
+ while (ptr < endp && ! CHAR_HEAD_P (*ptr)) ptr++;
chars++;
}
unsigned char *ptr;
int nbytes;
{
- unsigned char *endp;
+ unsigned char *endp, c;
int chars;
endp = ptr + nbytes;
while (ptr < endp)
{
- if (*ptr == LEADING_CODE_COMPOSITION)
- {
- ptr++;
- while (ptr < endp && ! CHAR_HEAD_P (*ptr)) ptr++;
- }
- else
- ptr += BYTES_BY_CHAR_HEAD (*ptr);
+ c = *ptr++;
+
+ if (BASE_LEADING_CODE_P (c))
+ while (ptr < endp && ! CHAR_HEAD_P (*ptr)) ptr++;
chars++;
}
int i;
struct cmpchar_info *cmpcharp;
- if (len < 5)
- /* Any composite char have at least 3-byte length. */
- return -1;
-
/* The second byte 0xFF means compostion rule is embedded. */
embedded_rule = (str[1] == 0xFF);
int bytes;
while (endp < lastp && ! CHAR_HEAD_P (*endp)) endp++;
+ if (endp - str < 5)
+ /* Any composite char have at least 5-byte length. */
+ return -1;
+
chars = 0;
- p = str + 1 + embedded_rule;
+ p = str + 1;
while (p < endp)
{
+ if (embedded_rule) p++;
/* No need of checking if *P is 0xA0 because
- BYTES_BY_CHAR_HEAD (0x80) surely returns 2. */
- p += (bytes = BYTES_BY_CHAR_HEAD (*p - 0x20) + embedded_rule);
+ BYTES_BY_CHAR_HEAD (0x80) surely returns 2. */
+ p += BYTES_BY_CHAR_HEAD (*p - 0x20);
chars++;
}
- len = (p -= embedded_rule) - str;
- if (p > endp)
- len -= - bytes, chars--;
-
- if (chars < 2 || chars > MAX_COMPONENT_COUNT)
- /* Invalid number of components. */
+ if (p > endp || chars < 2 || chars > MAX_COMPONENT_COUNT)
+ /* Invalid components. */
return -1;
+ len = p - str;
}
hash_idx = hash_string (str, len) % CMPCHAR_HASH_TABLE_SIZE;
hashp = cmpchar_hash_table[hash_idx];