Changeset: efddfa319de3 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/efddfa319de3
Modified Files:
clients/mapiclient/mclient.c
common/utils/mutf8.h
Branch: default
Log Message:
When breaking off strings, do it after all combining characters.
diffs (44 lines):
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -409,7 +409,11 @@ utf8strlenmax(char *s, char *e, size_t m
return len0;
}
if (len == max) {
- *t = s;
+ /* add any following combining (zero
width) characters */
+ do {
+ *t = s;
+ s = nextcharn(s, e == NULL ? 4
: (size_t) (e - s), &codepoint);
+ } while (codepoint > 0 &&
charwidth(codepoint) == 0);
return len;
}
}
diff --git a/common/utils/mutf8.h b/common/utils/mutf8.h
--- a/common/utils/mutf8.h
+++ b/common/utils/mutf8.h
@@ -63,3 +63,24 @@ nextchar(const char *s, uint32_t *c)
*c = 0;
return NULL;
}
+
+/* like the above, but s is at most n bytes long */
+static inline char *
+nextcharn(const char *s, size_t n, uint32_t *c)
+{
+ uint32_t codepoint = 0, state = 0;
+ while (n-- > 0 && *s) {
+ switch (decode(&state, &codepoint, (uint8_t) *s++)) {
+ case UTF8_ACCEPT:
+ *c = codepoint;
+ return (char *) s;
+ case UTF8_REJECT:
+ *c = 0;
+ return NULL;
+ default:
+ break;
+ }
+ }
+ *c = 0;
+ return NULL;
+}
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]