From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4274 invoked from network); 26 Jan 2001 13:25:45 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 26 Jan 2001 13:25:45 -0000 Received: (qmail 28985 invoked by alias); 26 Jan 2001 13:25:39 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 13390 Received: (qmail 28974 invoked from network); 26 Jan 2001 13:25:38 -0000 X-Envelope-Sender-Is: Andrej.Borsenkow@mow.siemens.ru (at relayer goliath.siemens.de) From: "Andrej Borsenkow" To: "ZSH workers mailing list" Subject: PATCH: avoid hashing command names twice on Cygwin Date: Fri, 26 Jan 2001 16:25:34 +0300 Message-ID: <000201c0879b$76bca8d0$21c9ca95@mow.siemens.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Under Cygwin every foo.exe was hashed twice - as foo and foo.exe. Actually, the code was funny. It contained one block that was executed unconditionally and exactly the same later under condition. -andrej Have a nice DOS! B >> Index: Src/hashtable.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/hashtable.c,v retrieving revision 1.8 diff -u -r1.8 hashtable.c --- Src/hashtable.c 2001/01/16 13:44:20 1.8 +++ Src/hashtable.c 2001/01/26 13:21:33 @@ -638,29 +638,25 @@ return; while ((fn = zreaddir(dir, 1))) { +#if defined(_WIN32) || defined(__CYGWIN__) + /* + * Hash foo.exe as foo, since when no real foo exists, foo.exe + * will get executed by DOS and Cygwin automatically. This quiets + * spurious corrections when CORRECT or CORRECT_ALL is set. + */ + if ((exe = strrchr(fn, '.')) && + (exe[1] == 'E' || exe[1] == 'e') && + (exe[2] == 'X' || exe[2] == 'x') && + (exe[3] == 'E' || exe[3] == 'e') && exe[4] == 0) + *exe = 0; +#endif /* _WIN32 || __CYGWIN__ */ if (!cmdnamtab->getnode(cmdnamtab, fn)) { cn = (Cmdnam) zcalloc(sizeof *cn); cn->flags = 0; cn->u.name = dirp; cmdnamtab->addnode(cmdnamtab, ztrdup(fn), cn); - } -#ifdef _WIN32 - /* Hash foo.exe as foo, since when no real foo exists, foo.exe - will get executed by DOS automatically. This quiets - spurious corrections when CORRECT or CORRECT_ALL is set. */ - if ((exe = strrchr(fn, '.')) && - (exe[1] == 'E' || exe[1] == 'e') && - (exe[2] == 'X' || exe[2] == 'x') && - (exe[3] == 'E' || exe[3] == 'e') && exe[4] == 0) { - *exe = 0; - if (!cmdnamtab->getnode(cmdnamtab, fn)) { - cn = (Cmdnam) zcalloc(sizeof *cn); - cn->flags = 0; - cn->u.name = dirp; - cmdnamtab->addnode(cmdnamtab, ztrdup(fn), cn); - } } -#endif /* _WIN32 */ + } closedir(dir); }