|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From f1f5b2a3bdc3178d57c4088a7cd7758afaeba9cb Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From: David Herrmann <dh.herrmann@gmail.com>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Date: Thu, 2 Oct 2014 16:36:09 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Subject: [PATCH] terminal: make utf8 decoder return length
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Lets return the parsed length in term_utf8_decode() instead of a buffer
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
pointer. Store the pointer in the passed argument.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
This makes it adhere to the systemd coding-style, were we always avoid
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
returning pointers, but store them in output arguments. In this case, the
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
storage is not allocated, so it doesn't fit 100% to this idiom, but still
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
looks much nicer.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/libsystemd-terminal/subterm.c | 4 +--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/libsystemd-terminal/term-parser.c | 24 ++++++++-------
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/libsystemd-terminal/term-screen.c | 4 +--
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/libsystemd-terminal/term.h | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/libsystemd-terminal/test-term-parser.c | 49 +++++++++++++++---------------
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
5 files changed, 43 insertions(+), 40 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/libsystemd-terminal/subterm.c b/src/libsystemd-terminal/subterm.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 3990fb392b..adc4caa42e 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/libsystemd-terminal/subterm.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/libsystemd-terminal/subterm.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -716,10 +716,10 @@ static int terminal_io_fn(sd_event_source *source, int fd, uint32_t revents, voi
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
for (i = 0; i < len; ++i) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
const term_seq *seq;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- const uint32_t *str;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ uint32_t *str;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
size_t n_str, j;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- str = term_utf8_decode(&t->utf8, &n_str, buf[i]);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ n_str = term_utf8_decode(&t->utf8, &str, buf[i]);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
for (j = 0; j < n_str; ++j) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
type = term_parser_feed(t->parser, &seq, str[j]);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (type < 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/libsystemd-terminal/term-parser.c b/src/libsystemd-terminal/term-parser.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index c8c1d13d2e..f9326d563a 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/libsystemd-terminal/term-parser.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/libsystemd-terminal/term-parser.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -81,15 +81,16 @@ size_t term_utf8_encode(char *out_utf8, uint32_t g) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
/**
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
* term_utf8_decode() - Try decoding the next UCS-4 character
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
* @p: decoder object to operate on or NULL
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- * @out_len: output buffer for length of decoded UCS-4 string or NULL
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ * @out_len: output storage for pointer to decoded UCS-4 string or NULL
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
* @c: next char to push into decoder
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
*
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
* This decodes a UTF-8 stream. It must be called for each input-byte of the
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- * UTF-8 stream and returns a UCS-4 stream. The length of the returned UCS-4
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- * string (number of parsed characters) is stored in @out_len if non-NULL. A
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- * pointer to the string is returned (or NULL if none was parsed). The string
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- * is not zero-terminated! Furthermore, the string is only valid until the next
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- * invokation of this function. It is also bound to the parser-state @p.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ * UTF-8 stream and returns a UCS-4 stream. A pointer to the parsed UCS-4
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ * string is stored in @out_buf if non-NULL. The length of this string (number
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ * of parsed UCS4 characters) is returned as result. The string is not
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ * zero-terminated! Furthermore, the string is only valid until the next
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ * invocation of this function. It is also bound to the parser state @p and
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ * must not be freed nor written to by the caller.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
*
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
* This function is highly optimized to work with terminal-emulators. Instead
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
* of being strict about UTF-8 validity, this tries to perform a fallback to
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -100,9 +101,10 @@ size_t term_utf8_encode(char *out_utf8, uint32_t g) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
* no helpers to do that for you. To initialize it, simply reset it to all
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
* zero. You can reset or free the object at any point in time.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
*
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- * Returns: Pointer to the UCS-4 string or NULL.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ * Returns: Number of parsed UCS4 characters
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
*/
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-const uint32_t *term_utf8_decode(term_utf8 *p, size_t *out_len, char c) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+size_t term_utf8_decode(term_utf8 *p, uint32_t **out_buf, char c) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ static uint32_t ucs4_null = 0;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
uint32_t t, *res = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
uint8_t byte;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
size_t len = 0;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -246,9 +248,9 @@ const uint32_t *term_utf8_decode(term_utf8 *p, size_t *out_len, char c) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
p->n_bytes = 0;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
out:
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- if (out_len)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- *out_len = len;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- return len > 0 ? res : NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (out_buf)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ *out_buf = res ? : &ucs4_null;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ return len;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
/*
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/libsystemd-terminal/term-screen.c b/src/libsystemd-terminal/term-screen.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 14c32aceb9..2f3f6f91cb 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/libsystemd-terminal/term-screen.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/libsystemd-terminal/term-screen.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -3756,7 +3756,7 @@ unsigned int term_screen_get_height(term_screen *screen) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int term_screen_feed_text(term_screen *screen, const uint8_t *in, size_t size) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- const uint32_t *ucs4_str;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ uint32_t *ucs4_str;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
size_t i, j, ucs4_len;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
const term_seq *seq;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -3768,7 +3768,7 @@ int term_screen_feed_text(term_screen *screen, const uint8_t *in, size_t size) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
* 8bit mode if the stream is not valid UTF-8. This should be more than
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
* enough to support old 7bit/8bit modes. */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
for (i = 0; i < size; ++i) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- ucs4_str = term_utf8_decode(&screen->utf8, &ucs4_len, in[i]);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ ucs4_len = term_utf8_decode(&screen->utf8, &ucs4_str, in[i]);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
for (j = 0; j < ucs4_len; ++j) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
r = term_parser_feed(screen->parser, &seq, ucs4_str[j]);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/libsystemd-terminal/term.h b/src/libsystemd-terminal/term.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 021cf1c42b..d5b934fc59 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/libsystemd-terminal/term.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/libsystemd-terminal/term.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -111,7 +111,7 @@ struct term_utf8 {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
};
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
size_t term_utf8_encode(char *out_utf8, uint32_t g);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-const uint32_t *term_utf8_decode(term_utf8 *p, size_t *out_len, char c);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+size_t term_utf8_decode(term_utf8 *p, uint32_t **out_buf, char c);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
/*
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
* Parsers
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/libsystemd-terminal/test-term-parser.c b/src/libsystemd-terminal/test-term-parser.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index ed16f5f276..e8d5dcfbf2 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/libsystemd-terminal/test-term-parser.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/libsystemd-terminal/test-term-parser.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -33,39 +33,40 @@
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
static void test_term_utf8_invalid(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
term_utf8 p = { };
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- const uint32_t *res;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ uint32_t *res;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
size_t len;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- res = term_utf8_decode(NULL, NULL, 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- assert_se(res == NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ len = term_utf8_decode(NULL, NULL, 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ assert_se(!len);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- res = term_utf8_decode(&p, NULL, 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- assert_se(res != NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- len = 5;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- res = term_utf8_decode(NULL, &len, 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- assert_se(res == NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- assert_se(len == 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ len = term_utf8_decode(&p, NULL, 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ assert_se(len == 1);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- len = 5;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- res = term_utf8_decode(&p, &len, 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ res = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ len = term_utf8_decode(NULL, &res, 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ assert_se(!len);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(res != NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ assert_se(!*res);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ len = term_utf8_decode(&p, &res, 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(len == 1);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ assert_se(res != NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ assert_se(!*res);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- len = 5;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- res = term_utf8_decode(&p, &len, 0xCf);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- assert_se(res == NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ len = term_utf8_decode(&p, &res, 0xCf);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(len == 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
-
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- len = 5;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- res = term_utf8_decode(&p, &len, 0x0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(res != NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ assert_se(!*res);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ len = term_utf8_decode(&p, &res, 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(len == 2);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ assert_se(res != NULL);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ assert_se(res[0] == 0xCf && res[1] == 0);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
static void test_term_utf8_range(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
term_utf8 p = { };
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- const uint32_t *res;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ uint32_t *res;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
char u8[4];
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
uint32_t i, j;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
size_t ulen, len;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -78,8 +79,8 @@ static void test_term_utf8_range(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
continue;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
for (j = 0; j < ulen; ++j) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- res = term_utf8_decode(&p, &len, u8[j]);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- if (!res) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ len = term_utf8_decode(&p, &res, u8[j]);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (len < 1) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(j + 1 != ulen);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
continue;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -117,13 +118,13 @@ static void test_term_utf8_mix(void) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
0x00F0, 0x0080, 0x0080, 0x0001,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
};
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
term_utf8 p = { };
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- const uint32_t *res;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ uint32_t *res;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
unsigned int i, j;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
size_t len;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
for (i = 0, j = 0; i < sizeof(source); ++i) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- res = term_utf8_decode(&p, &len, source[i]);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- if (!res)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ len = term_utf8_decode(&p, &res, source[i]);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (len < 1)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
continue;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert_se(j + len <= ELEMENTSOF(result));
|