X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Futf8.c;h=98b68ef657c076e53f108df96e43aa8762fea79e;hb=51d122af23533b0b8318911c4fc8b128ad8eafb7;hp=c3d97cc783f06e2805a4a2394a162e87a3b8b0e1;hpb=8f6ce71fe79d897b67157d92869db87ee2042af6;p=elogind.git diff --git a/src/shared/utf8.c b/src/shared/utf8.c index c3d97cc78..98b68ef65 100644 --- a/src/shared/utf8.c +++ b/src/shared/utf8.c @@ -3,6 +3,7 @@ /*** This file is part of systemd. + Copyright 2008-2011 Kay Sievers Copyright 2012 Lennart Poettering systemd is free software; you can redistribute it and/or modify it @@ -19,7 +20,7 @@ along with systemd; If not, see . ***/ -/* This file is based on the GLIB utf8 validation functions. The +/* Parts of this file are based on the GLIB utf8 validation functions. The * original license text follows. */ /* gutf8.c - Operations on UTF-8 strings. @@ -97,7 +98,7 @@ static int utf8_encoded_expected_len(const char *str) { } /* decode one unicode char */ -static int utf8_encoded_to_unichar(const char *str) { +int utf8_encoded_to_unichar(const char *str) { int unichar; int len; int i; @@ -140,14 +141,15 @@ bool utf8_is_printable(const char* str, size_t length) { assert(str); - for (p = (const uint8_t*) str; length; p++) { + for (p = (const uint8_t*) str; length;) { int encoded_len = utf8_encoded_valid_unichar((const char *)p); - int32_t val = utf8_encoded_to_unichar((const char*)p); + int val = utf8_encoded_to_unichar((const char*)p); if (encoded_len < 0 || val < 0 || is_unicode_control(val)) return false; length -= encoded_len; + p += encoded_len; } return true;