summaryrefslogtreecommitdiff
path: root/Src/prompt.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2006-09-15 13:17:27 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2006-09-15 13:17:27 +0000
commitbb3628e898331edcd82da5d6291ef7c8812be267 (patch)
tree0064194df81c61ab42da6558a228085c4640c9f9 /Src/prompt.c
parenta82ac460c29f18ee5e9d57322d977d0b93c0265f (diff)
downloadzsh-bb3628e898331edcd82da5d6291ef7c8812be267.tar.gz
zsh-bb3628e898331edcd82da5d6291ef7c8812be267.zip
assume width 1 for control characters;
don't crash if width of repeated padding string is 0
Diffstat (limited to 'Src/prompt.c')
-rw-r--r--Src/prompt.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/Src/prompt.c b/Src/prompt.c
index 974f70e40..fc0c7ea47 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -944,10 +944,15 @@ countprompt(char *str, int *wp, int *hp, int overf)
multi = 0;
break;
default:
- /* If the character isn't printable, wcwidth() returns -1. */
+ /*
+ * If the character isn't printable, wcwidth() returns
+ * -1. We assume width 1.
+ */
wcw = wcwidth(wc);
- if (wcw > 0)
+ if (wcw >= 0)
w += wcw;
+ else
+ w++;
multi = 0;
break;
}
@@ -1152,8 +1157,10 @@ prompttrunc(int arg, int truncchar, int doprint, int endchar)
break;
default:
wcw = wcwidth(cc);
- if (wcw > 0)
+ if (wcw >= 0)
remw -= wcw;
+ else
+ remw--;
break;
}
#else
@@ -1215,8 +1222,10 @@ prompttrunc(int arg, int truncchar, int doprint, int endchar)
break;
default:
wcw = wcwidth(cc);
- if (wcw > 0)
+ if (wcw >= 0)
maxwidth -= wcw;
+ else
+ maxwidth--;
break;
}
#else