Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: avoid hashing command names twice on Cygwin



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);
 }



Messages sorted by: Reverse Date, Date, Thread, Author