From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 733 invoked from network); 9 Jan 2006 01:43:09 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.0 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 9 Jan 2006 01:43:09 -0000 Received: (qmail 56255 invoked from network); 9 Jan 2006 01:43:03 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 9 Jan 2006 01:43:03 -0000 Received: (qmail 27386 invoked by alias); 9 Jan 2006 01:43:01 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22149 Received: (qmail 27374 invoked from network); 9 Jan 2006 01:43:00 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 9 Jan 2006 01:43:00 -0000 Received: (qmail 55975 invoked from network); 9 Jan 2006 01:42:59 -0000 Received: from dsl3-63-249-88-2.cruzio.com (HELO dot.blorf.net) (63.249.88.2) by a.mx.sunsite.dk with SMTP; 9 Jan 2006 01:42:58 -0000 Received: by dot.blorf.net (Postfix, from userid 1000) id E27898E8D; Sun, 8 Jan 2006 17:42:57 -0800 (PST) Date: Sun, 8 Jan 2006 17:42:57 -0800 From: Wayne Davison To: zsh-workers@sunsite.dk Subject: Re: bug in completion/expansion of files with LANG=C Message-ID: <20060109014257.GB17056@dot.blorf.net> References: <20060106215829.GG10111@dot.blorf.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="TB36FDmn/VVEgNH/" Content-Disposition: inline In-Reply-To: <20060106215829.GG10111@dot.blorf.net> User-Agent: Mutt/1.5.11 --TB36FDmn/VVEgNH/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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.. --TB36FDmn/VVEgNH/ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="questionable.patch" --- 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 --TB36FDmn/VVEgNH/--