about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>2015-09-12 20:35:56 +0900
committerJun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>2015-09-12 20:35:56 +0900
commit8b1676e3b7bca183fea725d38d62350d2688078b (patch)
tree3730287550cf94e1bb614fd23fee786991701c43
parentc76f4f96a65c7bfbba2183c422a1fb567069981f (diff)
downloadzsh-8b1676e3b7bca183fea725d38d62350d2688078b.tar.gz
zsh-8b1676e3b7bca183fea725d38d62350d2688078b.tar.xz
zsh-8b1676e3b7bca183fea725d38d62350d2688078b.zip
36491: Multibyte support for parameter expansion flags B,E,N
-rw-r--r--ChangeLog5
-rw-r--r--Src/glob.c6
-rw-r--r--Test/D07multibyte.ztst15
3 files changed, 23 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index aedeaed4c..c70396dd4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-12  Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
+
+	* 36491: Src/glob.c, Test/D07multibyte.ztst: Multibyte
+	support for the parameter expansion flags B, E and N.
+
 2015-09-11  Daniel Shahaf  <d.s@daniel.shahaf.name>
 
 	* 36443: Doc/Zsh/zle.yo Src/Zle/zle_refresh.c: Set
diff --git a/Src/glob.c b/Src/glob.c
index dea1bf50e..43d135b99 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -2491,17 +2491,17 @@ get_match_ret(char *s, int b, int e, int fl, char *replstr,
 	ll += 1 + (l - (e - b));
     if (fl & SUB_BIND) {
 	/* position of start of matched portion */
-	sprintf(buf, "%d ", b + 1);
+	sprintf(buf, "%d ", MB_METASTRLEN2END(s, 0, s+b) + 1);
 	ll += (bl = strlen(buf));
     }
     if (fl & SUB_EIND) {
 	/* position of end of matched portion */
-	sprintf(buf + bl, "%d ", e + 1);
+	sprintf(buf + bl, "%d ", MB_METASTRLEN2END(s, 0, s+e) + 1);
 	ll += (bl = strlen(buf));
     }
     if (fl & SUB_LEN) {
 	/* length of matched portion */
-	sprintf(buf + bl, "%d ", e - b);
+	sprintf(buf + bl, "%d ", MB_METASTRLEN2END(s+b, 0, s+e));
 	ll += (bl = strlen(buf));
     }
     if (bl)
diff --git a/Test/D07multibyte.ztst b/Test/D07multibyte.ztst
index ace191f06..5ae9b2c12 100644
--- a/Test/D07multibyte.ztst
+++ b/Test/D07multibyte.ztst
@@ -293,6 +293,21 @@
 >Ἐν ἀρχῇ ἦν ὁ λόγος, καὶ ὁ λόγος ἦν πρὸς τὸν θεόν, καὶ  ἦν ὁ λόγος
 >Ἐν ἀρχῇ ἦν ὁ λόγος, καὶ ὁ λόγος ἦν πρὸς τὸν θεόν, καὶ 
 
+  a="1ë34ë6"
+  print ${(BEN)a#*4}
+  print ${(BEN)a##*ë}
+  print ${(BEN)a%4*}
+  print ${(BEN)a%%ë*}
+  print ${(SBEN)a#ë3}
+  print ${(SBEN)a%4ë}
+0:Flags B, E, N and S in ${...#...} and ${...%...}
+>1 5 4
+>1 6 5
+>4 7 3
+>2 7 5
+>2 4 2
+>4 6 2
+
   foo=(κατέβην χθὲς εἰς Πειραιᾶ)
   print ${(l.3..¥.r.3..£.)foo}
   print ${(l.4..¥.r.2..£.)foo}