about summary refs log tree commit diff stats
path: root/src/LYStrings.c
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2013-05-29 01:08:07 -0400
committerThomas E. Dickey <dickey@invisible-island.net>2013-05-29 01:08:07 -0400
commit43b53f58808f6681e864f35999d749922eec7868 (patch)
tree5e91c494b4a50d11a786d74d315aa2fbfcae7462 /src/LYStrings.c
parentf7f5657f1e38597bf3b301d56aa5368c12979524 (diff)
downloadlynx-snapshots-43b53f58808f6681e864f35999d749922eec7868.tar.gz
snapshot of project "lynx", label v2-8-8dev_15g
Diffstat (limited to 'src/LYStrings.c')
-rw-r--r--src/LYStrings.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/LYStrings.c b/src/LYStrings.c
index 0dfa664f..ae8326eb 100644
--- a/src/LYStrings.c
+++ b/src/LYStrings.c
@@ -1,4 +1,4 @@
-/* $LynxId: LYStrings.c,v 1.213 2013/05/04 12:21:36 tom Exp $ */
+/* $LynxId: LYStrings.c,v 1.214 2013/05/28 23:38:17 tom Exp $ */
 #include <HTUtils.h>
 #include <HTCJK.h>
 #include <UCAux.h>
@@ -3038,15 +3038,19 @@ static int cell2char(char *s, int cells)
 
     CTRACE_EDIT((tfp, "cell2char(%d) %d:%s\n", cells, len, s));
     /* FIXME - make this a binary search */
-    for (pos = 0; pos <= len; ++pos) {
-	have = LYstrExtent2(s, pos);
-	CTRACE_EDIT((tfp, "  %2d:%2d:%.*s\n", pos, have, pos, s));
-	if (have >= cells) {
-	    break;
+    if (len != 0) {
+	for (pos = 0; pos <= len; ++pos) {
+	    have = LYstrExtent2(s, pos);
+	    CTRACE_EDIT((tfp, "  %2d:%2d:%.*s\n", pos, have, pos, s));
+	    if (have >= cells) {
+		break;
+	    }
 	}
+	if (pos > len)
+	    pos = len;
+    } else {
+	pos = 0;
     }
-    if (pos > len)
-	pos = len;
     result = mbcs_glyphs(s, pos);
     CTRACE_EDIT((tfp, "->%d\n", result));
     return result;
@@ -3830,7 +3834,7 @@ void LYRefreshEdit(EDREC * edit)
 	 * away a single cell for the right scroll-indicator, that would force
 	 * us to display fewer characters.  Check for that, and recompute.
 	 */
-	if (rgt_shift) {
+	if (rgt_shift && *str) {
 	    int old_cells = dpy_cells;
 
 	    dpy_cells = LYstrExtent2(str, dpy_bytes);