From a26a387545ae530cb3222fd4daa5ed088e068de2 Mon Sep 17 00:00:00 2001 From: Xavier G Date: Fri, 13 May 2016 17:31:11 +0200 Subject: [PATCH] Adjust some conditions. --- src/core/utf8.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/utf8.c b/src/core/utf8.c index d1f58599..29b277e1 100644 --- a/src/core/utf8.c +++ b/src/core/utf8.c @@ -48,7 +48,7 @@ int string_advance(char const **str, int policy) int string_policy(const char *str) { if (is_utf8()) { - if (!str || g_utf8_validate(str, -1, NULL)) { + if (str == NULL || g_utf8_validate(str, -1, NULL)) { /* No string provided or valid UTF-8 string: treat as UTF-8: */ return TREAT_STRING_AS_UTF8; } @@ -98,8 +98,8 @@ int string_chars_for_width(const char *str, int policy, unsigned int n, unsigned g_return_val_if_fail(str != NULL, -1); /* Handle the dummy case where n is 0: */ - if (!n) { - if (bytes) { + if (n == 0) { + if (bytes != NULL) { *bytes = 0; } return 0; @@ -128,7 +128,7 @@ int string_chars_for_width(const char *str, int policy, unsigned int n, unsigned * columns, which is less than or equal to n. */ /* Optionally provide the equivalent amount of bytes: */ - if (bytes) { + if (bytes != NULL) { *bytes = c - str; } return char_count;