From 3f301dd437628ce9ea593b4d96de9b0bd4a5f0c9 Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
Date: Tue, 21 Jun 2005 19:47:39 +0000
Subject: [PATCH] in do_yesno(), add a missing assert, and use display_string()
 to display the prompt, so that we don't end it in the middle of a multibyte
 character if it's more than (COLS - 1) bytes long

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2751 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog   | 3 +++
 src/winio.c | 8 +++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index e2a72403..7657cd05 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -324,6 +324,9 @@ CVS code -
 	  (DLR)
   do_yesno()
 	- Allow refreshing the screen via Ctrl-L, as Pico does. (DLR)
+	- Add a missing assert, and use display_string() to display the
+	  prompt, so that we don't end it in the middle of a multibyte
+	  character if it's more than (COLS - 1) bytes long. (DLR)
   total_redraw()
 	- Simplify to call clearok(TRUE) and wrefresh() on edit, which
 	  updates the entire screen in fewer function calls. (DLR)
diff --git a/src/winio.c b/src/winio.c
index 8683b06c..15041d91 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -3606,6 +3606,9 @@ int do_yesno(bool all, const char *msg)
     const char *yesstr;		/* String of yes characters accepted. */
     const char *nostr;		/* Same for no. */
     const char *allstr;		/* And all, surprise! */
+    char *expmsg;		/* Expanded version of msg. */
+
+    assert(msg != NULL);
 
     /* yesstr, nostr, and allstr are strings of any length.  Each string
      * consists of all single-byte characters accepted as valid
@@ -3647,7 +3650,10 @@ int do_yesno(bool all, const char *msg)
     wattron(bottomwin, A_REVERSE);
 
     blank_statusbar();
-    mvwaddnstr(bottomwin, 0, 0, msg, COLS - 1);
+
+    expmsg = display_string(msg, 0, COLS - 1, FALSE);
+    mvwaddstr(bottomwin, 0, 0, msg);
+    free(expmsg);
 
     wattroff(bottomwin, A_REVERSE);
 
-- 
GitLab