summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2008-04-03 21:10:54 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2008-04-03 21:10:54 +0000
commitcc026d233989e91186bc50dc201535696aed9b75 (patch)
tree9902bf502d2ae4ec2c6b2d931778efe59860b131
parente5d8a42249026d83c5135869e602fc413346ff0d (diff)
downloadzsh-cc026d233989e91186bc50dc201535696aed9b75.tar.gz
zsh-cc026d233989e91186bc50dc201535696aed9b75.zip
24788: ${(m)#...} returns string print width
-rw-r--r--ChangeLog5
-rw-r--r--Doc/Zsh/expn.yo10
-rw-r--r--Src/subst.c5
3 files changed, 14 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index abb43b1fa..e8b5df536 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-04-03 Peter Stephenson <p.w.stephenson@ntlworld.com>
+
+ * 24788: Doc/Zsh/expn.yo, Src/subst.c: ${(m)#...} returns
+ string print width.
+
2008-04-03 Peter Stephenson <pws@csr.com>
* 24787: Src/Zle/zle_main.c, Src/Zle/zle_refresh.c: reset
diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo
index 4adc09d44..3d4c92d4a 100644
--- a/Doc/Zsh/expn.yo
+++ b/Doc/Zsh/expn.yo
@@ -943,11 +943,13 @@ Control characters are always assumed to be one unit wide; this allows the
mechanism to be used for generating repetitions of control characters.
)
item(tt(m))(
-Only useful together with tt(l) and tt(r) when the tt(MULTIBYTE) option
+Only useful together with one of the flags tt(l) or tt(r) or with the
+tt(#) length operator when the tt(MULTIBYTE) option
is in effect. Use the character width reported by the system in
-calculating the how much of the string it occupies. Most printable
-characters have a width of one unit, however certain Asian character sets
-and certain special effects use wider characters.
+calculating the how much of the string it occupies or the overall
+length of the string. Most printable characters have a width of one
+unit, however certain Asian character sets and certain special effects
+use wider characters; combining characters have zero width.
)
item(tt(r:)var(expr)tt(::)var(string1)tt(::)var(string2)tt(:))(
As tt(l), but pad the words on the right and insert var(string2)
diff --git a/Src/subst.c b/Src/subst.c
index 9df448fc9..1645764ec 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -2589,7 +2589,8 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
else if (getlen == 2) {
if (*aval)
for (len = -sl, ctr = aval;
- len += sl + MB_METASTRLEN(*ctr), *++ctr;);
+ len += sl + MB_METASTRLEN2(*ctr, multi_width),
+ *++ctr;);
}
else
for (ctr = aval;
@@ -2597,7 +2598,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
len += wordcount(*ctr, spsep, getlen > 3), ctr++);
} else {
if (getlen < 3)
- len = MB_METASTRLEN(val);
+ len = MB_METASTRLEN2(val, multi_width);
else
len = wordcount(val, spsep, getlen > 3);
}