summaryrefslogtreecommitdiff
path: root/src/shared/utf8.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-04-23 22:40:26 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-06-09 13:49:38 -0400
commit31f7bf1994523f5b8fd014c69b97e09d7043d9ff (patch)
treee511987f3b7b94df5743d7cf32d06f60de86c3fa /src/shared/utf8.c
parent4e09014daf8f98584b3f15e64e93bed232e70a6b (diff)
logs-show: print multiline messages
[ 0.019862] fedora kernel: CPU0: Thermal monitoring enabled (TM1) [ 0.019900] fedora kernel: Last level iTLB entries: 4KB 512, 2MB 0, 4MB 0 Last level dTLB entries: 4KB 512, 2MB 32, 4MB 32 tlb_flushall_shift: 5 [ 0.020118] fedora kernel: Freeing SMP alternatives: 24k freed
Diffstat (limited to 'src/shared/utf8.c')
-rw-r--r--src/shared/utf8.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/shared/utf8.c b/src/shared/utf8.c
index 3964e8b1ce..655cc771d4 100644
--- a/src/shared/utf8.c
+++ b/src/shared/utf8.c
@@ -86,11 +86,11 @@ static bool is_unicode_control(uint32_t ch) {
'\t' is in C0 range, but more or less harmless and commonly used.
*/
- return (ch < ' ' && ch != '\t') ||
+ return (ch < ' ' && ch != '\t' && ch != '\n') ||
(0x7F <= ch && ch <= 0x9F);
}
-char* utf8_is_printable_n(const char* str, size_t length) {
+bool utf8_is_printable(const char* str, size_t length) {
uint32_t val = 0;
uint32_t min = 0;
const uint8_t *p;
@@ -113,40 +113,37 @@ char* utf8_is_printable_n(const char* str, size_t length) {
min = (1 << 16);
val = (uint32_t) (*p & 0x07);
} else
- goto error;
+ return false;
p++;
length--;
if (!length || !is_continuation_char(*p))
- goto error;
+ return false;
merge_continuation_char(&val, *p);
TWO_REMAINING:
p++;
length--;
if (!is_continuation_char(*p))
- goto error;
+ return false;
merge_continuation_char(&val, *p);
ONE_REMAINING:
p++;
length--;
if (!is_continuation_char(*p))
- goto error;
+ return false;
merge_continuation_char(&val, *p);
if (val < min)
- goto error;
+ return false;
}
if (is_unicode_control(val))
- goto error;
+ return false;
}
- return (char*) str;
-
-error:
- return NULL;
+ return true;
}
static char* utf8_validate(const char *str, char *output) {