From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4602 invoked from network); 14 Jun 2002 13:14:54 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 14 Jun 2002 13:14:54 -0000 Received: (qmail 23487 invoked by alias); 14 Jun 2002 13:14:38 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 17318 Received: (qmail 23471 invoked from network); 14 Jun 2002 13:14:36 -0000 To: zsh-workers@sunsite.dk (Zsh hackers list) Subject: PATCH: ${(z)...} with error Date: Fri, 14 Jun 2002 14:14:07 +0100 Message-ID: <15432.1024060447@csr.com> From: Peter Stephenson If a ${(z)...} aborts early, the space we added at the end for the lexer to be able to spot the end of the last word isn't stripped, so we end up returning a final string with a bogus space at the end. It's hard to know if there are pathological cases, however. I think this is better than it was before, but it may well not be perfect. It would actually be quite nice to indicate to the user a lexical error in the last word, but it's hard to pass back. Index: Src/hist.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/hist.c,v retrieving revision 1.44 diff -u -r1.44 hist.c --- Src/hist.c 24 Mar 2002 23:52:47 -0000 1.44 +++ Src/hist.c 14 Jun 2002 13:13:04 -0000 @@ -2291,7 +2291,16 @@ } } while (tok != ENDINPUT && tok != LEXERR); if (buf && tok == LEXERR && tokstr && *tokstr) { + int plen; untokenize((p = dupstring(tokstr))); + plen = strlen(p); + /* + * Strip the space we added for lexing but which won't have + * been swallowed by the lexer because we aborted early. + * The test is paranoia. + */ + if (plen && p[plen-1] == ' ' && (plen == 1 || p[plen-2] != Meta)) + p[plen - 1] = '\0'; addlinknode(list, p); num++; } -- Peter Stephenson Software Engineer CSR Ltd., Science Park, Milton Road, Cambridge, CB4 0WH, UK Tel: +44 (0)1223 392070 ********************************************************************** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. **********************************************************************