dovecot-2.0: Added a global utf8_replacement_char variable.
dovecot at dovecot.org
dovecot at dovecot.org
Fri Aug 20 22:38:50 EEST 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/6105706de7b6
changeset: 12024:6105706de7b6
user: Timo Sirainen <tss at iki.fi>
date: Fri Aug 20 20:37:31 2010 +0100
description:
Added a global utf8_replacement_char variable.
diffstat:
src/lib/unichar.c | 15 +++++++--------
src/lib/unichar.h | 3 +++
2 files changed, 10 insertions(+), 8 deletions(-)
diffs (52 lines):
diff -r d7a3abc9e0e0 -r 6105706de7b6 src/lib/unichar.c
--- a/src/lib/unichar.c Fri Aug 20 20:12:51 2010 +0100
+++ b/src/lib/unichar.c Fri Aug 20 20:37:31 2010 +0100
@@ -10,6 +10,9 @@
#define HANGUL_FIRST 0xac00
#define HANGUL_LAST 0xd7a3
+const unsigned char utf8_replacement_char[UTF8_REPLACEMENT_CHAR_LEN] =
+ { 0xef, 0xbf, 0xbd }; /* 0xfffd */
+
static const uint8_t utf8_non1_bytes[256 - 192 - 2] = {
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,1,1
@@ -269,18 +272,14 @@
static void output_add_replacement_char(buffer_t *output)
{
- /* 0xfffd */
- static const unsigned char replacement_utf8[] = { 0xef, 0xbf, 0xbd };
-#define REPLACEMENT_UTF8_LEN 3
-
- if (output->used >= REPLACEMENT_UTF8_LEN &&
+ if (output->used >= UTF8_REPLACEMENT_CHAR_LEN &&
memcmp(CONST_PTR_OFFSET(output->data,
- output->used - REPLACEMENT_UTF8_LEN),
- replacement_utf8, REPLACEMENT_UTF8_LEN) == 0) {
+ output->used - UTF8_REPLACEMENT_CHAR_LEN),
+ utf8_replacement_char, UTF8_REPLACEMENT_CHAR_LEN) == 0) {
/* don't add the replacement char multiple times */
return;
}
- buffer_append(output, replacement_utf8, REPLACEMENT_UTF8_LEN);
+ buffer_append(output, utf8_replacement_char, UTF8_REPLACEMENT_CHAR_LEN);
}
int uni_utf8_to_decomposed_titlecase(const void *_input, size_t max_len,
diff -r d7a3abc9e0e0 -r 6105706de7b6 src/lib/unichar.h
--- a/src/lib/unichar.h Fri Aug 20 20:12:51 2010 +0100
+++ b/src/lib/unichar.h Fri Aug 20 20:37:31 2010 +0100
@@ -22,9 +22,12 @@
(UTF16_SURROGATE_LOW_FIRST + \
(((chr) - UTF16_SURROGATE_BASE) & UTF16_SURROGATE_MASK))
+#define UTF8_REPLACEMENT_CHAR_LEN 3
+
typedef uint32_t unichar_t;
ARRAY_DEFINE_TYPE(unichars, unichar_t);
+extern const unsigned char utf8_replacement_char[UTF8_REPLACEMENT_CHAR_LEN];
extern const uint8_t *const uni_utf8_non1_bytes;
/* Returns number of characters in a NUL-terminated unicode string */
More information about the dovecot-cvs
mailing list