From 5cbfc77d2cf09b4d6473baed8dafea03ba7ab3e5 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Wed, 14 Jan 2015 11:19:54 +0300 Subject: [PATCH] g_utf8_next_char() never returns NULL. Remove redundant checks. Signed-off-by: Andrew Borodin --- src/diffviewer/ydiff.c | 3 ++- src/editor/editbuffer.c | 8 +------- src/editor/format.c | 3 +-- src/viewer/datasource.c | 5 +---- 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/diffviewer/ydiff.c b/src/diffviewer/ydiff.c index 7d87cc273..73bc3bc2b 100644 --- a/src/diffviewer/ydiff.c +++ b/src/diffviewer/ydiff.c @@ -586,7 +586,6 @@ dview_get_utf (char *str, int *char_length, gboolean * result) { int res = -1; gunichar ch; - gchar *next_ch = NULL; int ch_len = 0; *result = TRUE; @@ -603,6 +602,8 @@ dview_get_utf (char *str, int *char_length, gboolean * result) ch = *str; else { + gchar *next_ch; + ch = res; /* Calculate UTF-8 char length */ next_ch = g_utf8_next_char (str); diff --git a/src/editor/editbuffer.c b/src/editor/editbuffer.c index 3f034ec8a..8932d5619 100644 --- a/src/editor/editbuffer.c +++ b/src/editor/editbuffer.c @@ -255,13 +255,7 @@ edit_buffer_get_utf (const edit_buffer_t * buf, off_t byte_index, int *char_leng ch = res; /* Calculate UTF-8 char length */ next_ch = g_utf8_next_char (str); - if (next_ch != NULL) - *char_length = next_ch - str; - else - { - ch = 0; - *char_length = 0; - } + *char_length = next_ch - str; } return (int) ch; diff --git a/src/editor/format.c b/src/editor/format.c index b198533b7..28d36db59 100644 --- a/src/editor/format.c +++ b/src/editor/format.c @@ -252,8 +252,7 @@ line_pixel_length (unsigned char *t, off_t b, off_t l, gboolean utf8) /* Calculate UTF-8 char length */ next_ch = g_utf8_next_char (tb); - if (next_ch != NULL) - char_length = next_ch - tb; + char_length = next_ch - tb; if (g_unichar_iswide (ch)) x++; diff --git a/src/viewer/datasource.c b/src/viewer/datasource.c index 9b9324abf..fe2aceb8d 100644 --- a/src/viewer/datasource.c +++ b/src/viewer/datasource.c @@ -213,10 +213,7 @@ mcview_get_utf (mcview_t * view, off_t byte_index, int *char_length, gboolean * ch = res; /* Calculate UTF-8 char length */ next_ch = g_utf8_next_char (str); - if (next_ch != NULL) - *char_length = next_ch - str; - else - return 0; + *char_length = next_ch - str; } *result = TRUE; return ch;