From 945ce48b31a50e5973bdf97b47336a9bcd2410bf Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 21 Feb 2012 00:45:22 +0000 Subject: Tidy. git-svn-id: http://svn.drobilla.net/serd/trunk@314 490d8e77-9747-427b-9fa3-0b8f29cee8a0 --- src/writer.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/writer.c') diff --git a/src/writer.c b/src/writer.c index 270bd16f..587a3e3f 100644 --- a/src/writer.c +++ b/src/writer.c @@ -185,10 +185,9 @@ write_text(SerdWriter* writer, TextContext ctx, uint32_t c = 0; size_t size = 0; if ((in & 0x80) == 0) { // Starts with `0' - size = 1; c = in & 0x7F; if (in_range(c, 0x20, 0x7E) - || (is_space(c) && ctx == WRITE_LONG_STRING)) { + || (is_space(c) && ctx == WRITE_LONG_STRING)) { sink(&in, 1, writer); // Print ASCII character } else { snprintf(escape, sizeof(escape), "\\u%04X", c); @@ -197,13 +196,13 @@ write_text(SerdWriter* writer, TextContext ctx, continue; } else if ((in & 0xE0) == 0xC0) { // Starts with `110' size = 2; - c = in & 0x1F; + c = in & 0x1F; } else if ((in & 0xF0) == 0xE0) { // Starts with `1110' size = 3; - c = in & 0x0F; + c = in & 0x0F; } else if ((in & 0xF8) == 0xF0) { // Starts with `11110' size = 4; - c = in & 0x07; + c = in & 0x07; } else { fprintf(stderr, "Invalid UTF-8: %X\n", in); const uint8_t replacement_char[] = { 0xEF, 0xBF, 0xBD }; @@ -221,8 +220,7 @@ write_text(SerdWriter* writer, TextContext ctx, #define READ_BYTE() \ in = utf8[i++] & 0x3f; \ - c <<= 6; \ - c |= in; + c = (c << 6) | in; switch (size) { case 4: READ_BYTE(); -- cgit v1.2.1