From: Wayne Davison <wayned@users.sourceforge.net>
To: zsh-workers@sunsite.dk
Subject: Re: bug in completion/expansion of files with LANG=C
Date: Sun, 8 Jan 2006 17:42:57 -0800 [thread overview]
Message-ID: <20060109014257.GB17056@dot.blorf.net> (raw)
In-Reply-To: <20060106215829.GG10111@dot.blorf.net>
[-- Attachment #1: Type: text/plain, Size: 1446 bytes --]
I looked around at the other calls to mbrtowc() in the code, and cleaned
up a few things:
1. I made all the code assign the return value to a size_t, not an int.
This should prevent a failure on a system where the size of an int is
larger than the size of a size_t (since the (size_t)-1 and (size_t)-2
values won't get converted into negative numbers if that is the case).
2. I added STOUC() around a couple char args that were getting passed to
nicechar() when mbrtowc() failed.
3. One of the calls needed to reset the mbstate_t object when continuing
to parse the string after mbrtowc() failed.
4. The code in sub_match() (in Src/Zle/compmatch.c) had a bug when it
assembled a wide-char value from multiple bytes (decoded from a metafied
string): the code was not advancing past all the raw values used if
there was a meta char or a multibyte character sequence (and I think a
'\0' byte might have even looped infinitely).
After doing all that, it was time to begin looking at the next stage of
the non-inputable-filename problem: I decided to do the easiest possible
change first, so attached is a patch that causes zsh to insert a literal
question-mark in place of each errant character. This allows me to at
least match a name that cannot be input into the command-line, but it
could be a little dangerous if it happens to match other filenames too,
so this is probably not something we'd want to use in an actual release.
..wayne..
[-- Attachment #2: questionable.patch --]
[-- Type: text/plain, Size: 771 bytes --]
--- Src/Zle/zle_utils.c 9 Jan 2006 00:29:57 -0000 1.34
+++ Src/Zle/zle_utils.c 9 Jan 2006 01:20:35 -0000
@@ -277,13 +277,13 @@ stringaszleline(char *instr, int incs, i
while (ll > 0) {
size_t ret = mbrtowc(outptr, inptr, ll, &ps);
- /*
- * At this point we don't handle either incomplete (-2) or
- * invalid (-1) multibyte sequences. Use the current length
- * and return.
- */
- if (ret == (size_t)-1 || ret == (size_t)-2)
- break;
+ if (ret == (size_t)-1 || ret == (size_t)-2) {
+ /* Transform invalid character sequences into literal
+ * question marks, at least for now... */
+ *outptr = L'?';
+ ret = 1;
+ memset(&ps, '\0', sizeof ps);
+ }
/*
* Careful: converting a wide NUL returns zero, but we
prev parent reply other threads:[~2006-01-09 1:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-06 21:58 Wayne Davison
2006-01-06 22:40 ` Peter Stephenson
2006-01-07 0:59 ` Wayne Davison
2006-01-07 0:17 ` Wayne Davison
2006-01-07 22:44 ` Wayne Davison
2006-01-08 5:56 ` Bart Schaefer
2006-01-08 8:06 ` Wayne Davison
2006-01-08 18:03 ` Peter Stephenson
2006-01-08 23:16 ` Wayne Davison
2006-01-12 1:26 ` Wayne Davison
2006-01-09 1:42 ` Wayne Davison [this message]
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=20060109014257.GB17056@dot.blorf.net \
--to=wayned@users.sourceforge.net \
--cc=zsh-workers@sunsite.dk \
/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).