From: "Jun T." <takimoto-j@kba.biglobe.ne.jp>
To: zsh-workers@zsh.org
Subject: Re: Unicode, Korean, normalization form, Mac OS X and tab completion
Date: Mon, 2 Jun 2014 02:00:55 +0900 [thread overview]
Message-ID: <CD609837-A990-4621-A7D9-E8F4FD89A9EB@kba.biglobe.ne.jp> (raw)
In-Reply-To: <140601005624.ZM3283@torch.brasslantern.com>
There is a patch by a Japanese user which simply converts
file names obtained by readder() into the composed form ("NFC"):
https://gist.github.com/waltarix/1403346
The patch in this gist is against zsh-5.0.0 (I guess).
I attached the same patch against the current git master below
(I added defined(__APPLE__) to the #if condition).
We may use this to see what kind of problem may appear by this simple
approach.
Kwon Yeolhyun, can you test this patch ?
In the current zsh (without this patch),
$ ls 가<TAB>
doesn't work if 가 is input from keyboard (NFC), but works if it is
pasted from the ls output (NFD). With the patch, the opposite happens.
Of course this patch affect not only Korean but any languages which
have decomposable character. For example, if you have a file named über
in the current directory, with the current zsh (without the patch):
$ ls u<TAB> # completes to über (useful for some user??)
$ ls ü<TAB> # fails to complete
and u* matches with über while ü* doesn't.
With the patch, the we get the opposite behavior.
Jun
diff --git a/Src/utils.c b/Src/utils.c
index 9439227..86b61f1 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -4270,6 +4270,13 @@ mod_export char *
zreaddir(DIR *dir, int ignoredots)
{
struct dirent *de;
+#if defined(HAVE_ICONV) && defined(__APPLE__)
+ static iconv_t conv_ds = (iconv_t)NULL;
+ static char *conv_name = (char *)NULL;
+ char *temp_name;
+ char *temp_name_ptr, *orig_name_ptr;
+ size_t temp_name_len, orig_name_len;
+#endif
do {
de = readdir(dir);
@@ -4278,6 +4285,23 @@ zreaddir(DIR *dir, int ignoredots)
} while(ignoredots && de->d_name[0] == '.' &&
(!de->d_name[1] || (de->d_name[1] == '.' && !de->d_name[2])));
+#if defined(HAVE_ICONV) && defined(__APPLE__)
+ if (!conv_ds)
+ conv_ds = iconv_open("UTF-8", "UTF-8-MAC");
+ if (conv_ds) {
+ orig_name_ptr = de->d_name;
+ orig_name_len = strlen(de->d_name);
+ conv_name = zrealloc(conv_name, orig_name_len+1);
+ temp_name_ptr = conv_name;
+ temp_name_len = orig_name_len;
+ if (iconv(conv_ds,&orig_name_ptr,&orig_name_len,&temp_name_ptr,&temp_name_len) >= 0) {
+ *temp_name_ptr = '\0';
+ temp_name = conv_name;
+ return metafy(temp_name, -1, META_STATIC);
+ }
+ }
+#endif
+
return metafy(de->d_name, -1, META_STATIC);
}
next prev parent reply other threads:[~2014-06-01 17:40 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-31 3:56 Kwon Yeolhyun
2014-05-31 15:21 ` Chet Ramey
2014-05-31 18:47 ` Bart Schaefer
2014-05-31 19:16 ` Peter Stephenson
2014-05-31 21:29 ` Bart Schaefer
2014-06-01 2:25 ` Daniel Shahaf
2014-06-01 5:30 ` Kwon Yeolhyun
2014-06-01 16:53 ` Daniel Shahaf
2014-06-01 7:56 ` Bart Schaefer
2014-06-01 16:46 ` Daniel Shahaf
2014-06-01 17:00 ` Jun T. [this message]
2014-06-01 19:13 ` Bart Schaefer
2014-06-02 17:01 ` Jun T.
2014-06-02 17:14 ` Bart Schaefer
2014-06-01 19:53 ` Bart Schaefer
2014-06-02 11:58 ` Kwon Yeolhyun
2014-06-02 14:23 ` Kwon Yeolhyun
2014-06-02 15:14 ` Bart Schaefer
2014-06-02 15:27 ` Peter Stephenson
2014-06-02 15:48 ` Kwon Yeolhyun
2014-06-02 15:27 ` Kwon Yeolhyun
2014-06-02 15:49 ` Bart Schaefer
2014-06-02 15:58 ` Kwon Yeolhyun
2014-06-02 14:31 ` Bart Schaefer
2014-06-02 17:15 ` Jun T.
2014-06-02 17:27 ` Bart Schaefer
2014-06-05 14:34 ` Jun T.
2014-06-05 15:00 ` Bart Schaefer
2014-06-02 5:17 ` Kwon Yeolhyun
2014-06-02 7:39 ` Jun T.
2014-06-02 8:42 ` Kwon Yeolhyun
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CD609837-A990-4621-A7D9-E8F4FD89A9EB@kba.biglobe.ne.jp \
--to=takimoto-j@kba.biglobe.ne.jp \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).