floating-point fix for x86_64
[ghc-hetmet.git] / glafp-utils / lndir / lndir.c
index 27ae80e..c65715e 100644 (file)
@@ -44,6 +44,7 @@ in this Software without prior written authorization from the X Consortium.
 */
 
 #include "lndir-Xos.h"
+#include <stdlib.h>
 #include <stdio.h>
 #include <sys/stat.h>
 #include <sys/param.h>
@@ -69,6 +70,10 @@ in this Software without prior written authorization from the X Consortium.
 #define MAXPATHLEN 2048
 #endif
 
+#ifdef __CYGWIN32__
+#include <sys/cygwin.h>
+#endif
+
 #if NeedVarargsPrototypes
 #include <stdarg.h>
 #endif
@@ -226,7 +231,9 @@ int rel;                    /* if true, prepend "../" to fn before using */
 #endif
            {
                /* directory */
+#ifndef __CYGWIN32__   /* don't trust cygwin's n_dirs count */
                n_dirs--;
+#endif
                if (dp->d_name[0] == '.' &&
                    (dp->d_name[1] == '\0' || (dp->d_name[1] == '.' &&
                                               dp->d_name[2] == '\0')))
@@ -237,6 +244,10 @@ int rel;                   /* if true, prepend "../" to fn before using */
                    continue;
                if (!strcmp (dp->d_name, "CVS"))
                    continue;
+               if (!strcmp (dp->d_name, ".svn"))
+                   continue;
+               if (!strcmp (dp->d_name, "_darcs"))
+                   continue;
                if (!strcmp (dp->d_name, "CVS.adm"))
                    continue;
                ocurdir = rcurdir;
@@ -312,29 +323,45 @@ int ac;
 char **av;
 {
     char *prog_name = av[0];
-    char *fn, *tn;
+    char* tn;
     struct stat fs, ts;
+#ifdef __CYGWIN32__
+    /*   
+    The lndir code assumes unix-style paths to work. cygwin
+    lets you get away with using dos'ish paths (e.g., "f:/oo")
+    in most contexts. Using them with 'lndir' will seriously
+    confuse the user though, so under-the-hood, we convert the
+    path into something POSIX-like.
+    */
+    static char fn[MAXPATHLEN+1];
+#else
+    char *fn;
+#endif
 
     while (++av, --ac) {
-       if (strcmp(*av, "-silent") == 0)
-           silent = 1;
-       if (strcmp(*av, "-f") == 0)
-           force = 1;
-       else if (strcmp(*av, "-ignorelinks") == 0)
-           ignore_links = 1;
-       else if (strcmp(*av, "--") == 0) {
-           ++av, --ac;
-           break;
-       }
-       else
-           break;
+      if (strcmp(*av, "-silent") == 0)
+         silent = 1;
+      else if (strcmp(*av, "-f") == 0)
+         force = 1;
+      else if (strcmp(*av, "-ignorelinks") == 0)
+         ignore_links = 1;
+      else if (strcmp(*av, "--") == 0) {
+         ++av, --ac;
+         break;
+      } else
+         break;
     }
 
     if (ac < 1 || ac > 2)
        quit (1, "usage: %s [-f] [-silent] [-ignorelinks] fromdir [todir]",
              prog_name);
 
+#ifdef __CYGWIN32__
+    cygwin_conv_to_full_posix_path(av[0], fn);
+#else
     fn = av[0];
+#endif
+
     if (ac == 2)
        tn = av[1];
     else