aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/list_window.c2
-rw-r--r--src/support.c10
-rw-r--r--src/support.h6
-rw-r--r--src/wreadln.c7
4 files changed, 20 insertions, 5 deletions
diff --git a/src/list_window.c b/src/list_window.c
index 7bbc6e193..896662292 100644
--- a/src/list_window.c
+++ b/src/list_window.c
@@ -193,7 +193,7 @@ list_window_paint(list_window_t *lw,
if( label )
{
int selected = lw->start+i == lw->selected;
- size_t len = strlen(label);
+ size_t len = my_strlen(label);
if( highlight )
colors_use(lw->w, COLOR_LIST_BOLD);
diff --git a/src/support.c b/src/support.c
index 254c15eb1..ade5ee4eb 100644
--- a/src/support.c
+++ b/src/support.c
@@ -35,6 +35,15 @@ extern void screen_status_printf(char *format, ...);
static gboolean noconvert = TRUE;
+size_t
+my_strlen(char *str)
+{
+ if( g_utf8_validate(str,-1,NULL) )
+ return g_utf8_strlen(str,-1);
+ else
+ return strlen(str);
+}
+
char *
remove_trailing_slash(char *path)
{
@@ -136,7 +145,6 @@ strscroll(char *str, char *separator, int width, scroll_state_t *st)
}
-
void
charset_init(gboolean disable)
{
diff --git a/src/support.h b/src/support.h
index 0a72e39b0..8b4a28c18 100644
--- a/src/support.h
+++ b/src/support.h
@@ -28,4 +28,10 @@ void charset_init(gboolean disable);
char *utf8_to_locale(char *str);
char *locale_to_utf8(char *str);
+/* number of characters in str */
+size_t my_strlen(char *str);
+/* number of bytes in str */
+size_t my_strsize(char *str);
+
+
#endif
diff --git a/src/wreadln.c b/src/wreadln.c
index 930cb5429..d817ee628 100644
--- a/src/wreadln.c
+++ b/src/wreadln.c
@@ -44,6 +44,7 @@ wrln_gcmp_pre_cb_t wrln_pre_completion_callback = NULL;
wrln_gcmp_post_cb_t wrln_post_completion_callback = NULL;
extern void screen_bell(void);
+extern size_t my_strlen(char *str);
gchar *
wreadln(WINDOW *w,
@@ -61,7 +62,7 @@ wreadln(WINDOW *w,
/* move the cursor one step to the right */
void cursor_move_right(void) {
- if( cursor < strlen(line) && cursor<wrln_max_line_size-1 )
+ if( cursor < my_strlen(line) && cursor<wrln_max_line_size-1 )
{
cursor++;
if( cursor+x0 >= x1 && start<cursor-width+1)
@@ -79,7 +80,7 @@ wreadln(WINDOW *w,
}
/* move the cursor to the end of the line */
void cursor_move_to_eol(void) {
- cursor = strlen(line);
+ cursor = my_strlen(line);
if( cursor+x0 >= x1 )
start = cursor-width+1;
}
@@ -247,7 +248,7 @@ wreadln(WINDOW *w,
break;
case KEY_DC: /* handle delete key. As above */
case KEY_CTRL_D:
- if( cursor <= strlen(line) - 1 )
+ if( cursor <= my_strlen(line) - 1 )
{
for (i = cursor; line[i] != 0; i++)
line[i] = line[i + 1];