From fd781247738c8502c7ba77ba9aa990e0c3443421 Mon Sep 17 00:00:00 2001
From: Cheng Shao <terrorjack@type.dance>
Date: Mon, 26 Feb 2024 10:24:42 +0000
Subject: [PATCH] utils: remove unused lndir from tree

Ever since the removal of the make build system, the in tree lndir
hasn't been actually built, so this patch removes it.

(cherry picked from commit d3a050d2a1eac0244f989badb3a2c75c84e0a160)
(cherry picked from commit 04860c24cd7aa5e004b7ff7fe84d3a20402e4909)
---
 .gitignore                       |   1 -
 configure.ac                     |   1 -
 hadrian/src/Rules/Clean.hs       |   3 +-
 testsuite/tests/linters/Makefile |   2 -
 utils/lndir/lndir-Xos.h          | 149 ----------
 utils/lndir/lndir-Xosdefs.h      |  96 ------
 utils/lndir/lndir.c              | 486 -------------------------------
 7 files changed, 1 insertion(+), 737 deletions(-)
 delete mode 100644 utils/lndir/lndir-Xos.h
 delete mode 100644 utils/lndir/lndir-Xosdefs.h
 delete mode 100644 utils/lndir/lndir.c

diff --git a/.gitignore b/.gitignore
index f9367b97357..bbd838a79ff 100644
--- a/.gitignore
+++ b/.gitignore
@@ -201,7 +201,6 @@ _darcs/
 /utils/runghc/runghc.cabal
 /utils/gen-dll/gen-dll.cabal
 /utils/ghc-pkg/ghc-pkg.cabal
-utils/lndir/fs.*
 utils/unlit/fs.*
 libraries/base/include/fs.h
 libraries/base/cbits/fs.c
diff --git a/configure.ac b/configure.ac
index 82195267f36..808421a78b8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -603,7 +603,6 @@ AC_MSG_NOTICE([done.])
 dnl ** Copy the files from the "fs" utility into the right folders.
 dnl --------------------------------------------------------------
 AC_MSG_NOTICE([Creating links for in-tree file handling routines])
-ln -f utils/fs/fs.* utils/lndir/
 ln -f utils/fs/fs.* utils/unlit/
 ln -f utils/fs/fs.* rts/
 ln -f utils/fs/fs.h libraries/base/include/
diff --git a/hadrian/src/Rules/Clean.hs b/hadrian/src/Rules/Clean.hs
index 19e7f3be5b2..3ac95989b4c 100644
--- a/hadrian/src/Rules/Clean.hs
+++ b/hadrian/src/Rules/Clean.hs
@@ -32,8 +32,7 @@ cleanMingwTarballs = do
 -- Clean all temporary fs files copied by configure into the source folder
 cleanFsUtils :: Action ()
 cleanFsUtils = do
-    let dirs = [ "utils/lndir/"
-               , "utils/unlit/"
+    let dirs = [ "utils/unlit/"
                , "rts/"
                , "libraries/base/include/"
                , "libraries/base/cbits/"
diff --git a/testsuite/tests/linters/Makefile b/testsuite/tests/linters/Makefile
index 2b4c2ad2c37..3651c614fd8 100644
--- a/testsuite/tests/linters/Makefile
+++ b/testsuite/tests/linters/Makefile
@@ -94,6 +94,4 @@ whitespace:
 				rts/win32/veh_excn.h\
 				utils/genprimopcode/Parser.y\
 				utils/genprimopcode/Syntax.hs\
-				utils/lndir/lndir-Xos.h\
-				utils/lndir/lndir-Xosdefs.h\
   )
diff --git a/utils/lndir/lndir-Xos.h b/utils/lndir/lndir-Xos.h
deleted file mode 100644
index 6421d4a0bf2..00000000000
--- a/utils/lndir/lndir-Xos.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * $XConsortium: Xos.h,v 1.47 91/08/17 17:14:38 rws Exp $
- * 
- * Copyright 1987 by the Massachusetts Institute of Technology
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided 
- * that the above copyright notice appear in all copies and that both that 
- * copyright notice and this permission notice appear in supporting 
- * documentation, and that the name of M.I.T. not be used in advertising
- * or publicity pertaining to distribution of the software without specific, 
- * written prior permission. M.I.T. makes no representations about the 
- * suitability of this software for any purpose.  It is provided "as is"
- * without express or implied warranty.
- *
- * The X Window System is a Trademark of MIT.
- *
- */
-
-/* This is a collection of things to try and minimize system dependencies
- * in a "significant" number of source files.
- */
-
-#pragma once
-
-#include "lndir-Xosdefs.h"
-
-/*
- * Get major data types (esp. caddr_t)
- */
-
-#if defined(USG)
-#if !defined(__TYPES__)
-#if defined(CRAY)
-#define word word_t
-#endif /* CRAY */
-#include <sys/types.h>			/* forgot to protect it... */
-#define __TYPES__
-#endif /* __TYPES__ */
-#else /* USG */
-#if defined(_POSIX_SOURCE) && defined(MOTOROLA)
-#undef _POSIX_SOURCE
-#include <sys/types.h>
-#define _POSIX_SOURCE
-#else
-#include <sys/types.h>
-#endif
-#endif /* USG */
-
-
-/*
- * Just about everyone needs the strings routines.  We provide both forms here,
- * index/rindex and strchr/strrchr, so any systems that don't provide them all
- * need to have #defines here.
- */
-
-#if !defined(X_NOT_STDC_ENV)
-#include <string.h>
-#define index strchr
-#define rindex strrchr
-#else
-#if defined(SYSV)
-#include <string.h>
-#define index strchr
-#define rindex strrchr
-#else
-#include <strings.h>
-#define strchr index
-#define strrchr rindex
-#endif
-#endif
-
-
-/*
- * Get open(2) constants
- */
-#if defined(X_NOT_POSIX)
-#include <fcntl.h>
-#if defined(USL)
-#include <unistd.h>
-#endif /* USL */
-#if defined(CRAY)
-#include <unistd.h>
-#endif /* CRAY */
-#if defined(MOTOROLA)
-#include <unistd.h>
-#endif /* MOTOROLA */
-#if defined(SYSV386)
-#include <unistd.h>
-#endif /* SYSV386 */
-#include <sys/file.h>
-#else /* X_NOT_POSIX */
-#if !defined(_POSIX_SOURCE) && defined(macII)
-#define _POSIX_SOURCE
-#include <fcntl.h>
-#undef _POSIX_SOURCE
-#else
-#include <fcntl.h>
-#endif
-#include <unistd.h>
-#endif /* X_NOT_POSIX else */
-
-/*
- * Get struct timeval
- */
-
-#if defined(SYSV)
-
-#if !defined(USL)
-#include <sys/time.h>
-#endif
-#include <time.h>
-#if defined(CRAY)
-#undef word
-#endif /* CRAY */
-#if defined(USG) && !defined(CRAY) && !defined(MOTOROLA)
-struct timeval {
-    long tv_sec;
-    long tv_usec;
-};
-#if !defined(USL_SHARELIB)
-struct timezone {
-    int tz_minuteswest;
-    int tz_dsttime;
-};
-#endif /* USL_SHARELIB */
-#endif /* USG */
-
-#else /* not SYSV */
-
-#if defined(_POSIX_SOURCE) && defined(SVR4)
-/* need to omit _POSIX_SOURCE in order to get what we want in SVR4 */
-#undef _POSIX_SOURCE
-#include <sys/time.h>
-#define _POSIX_SOURCE
-#else
-#include <sys/time.h>
-#endif
-
-#endif /* SYSV */
-
-/* use POSIX name for signal */
-#if defined(X_NOT_POSIX) && defined(SYSV) && !defined(SIGCHLD)
-#define SIGCHLD SIGCLD
-#endif
-
-#if defined(ISC)
-#include <sys/bsdtypes.h>
-#endif
diff --git a/utils/lndir/lndir-Xosdefs.h b/utils/lndir/lndir-Xosdefs.h
deleted file mode 100644
index 09658937ad4..00000000000
--- a/utils/lndir/lndir-Xosdefs.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * O/S-dependent (mis)feature macro definitions
- *
- * $XConsortium: Xosdefs.h,v 1.7 91/07/19 23:22:19 rws Exp $
- *
- * Copyright 1991 Massachusetts Institute of Technology
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of M.I.T. not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission.  M.I.T. makes no representations about the
- * suitability of this software for any purpose.  It is provided "as is"
- * without express or implied warranty.
- *
- * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
- * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#pragma once
-
-/*
- * X_NOT_STDC_ENV means does not have ANSI C header files.  Lack of this
- * symbol does NOT mean that the system has stdarg.h.
- *
- * X_NOT_POSIX means does not have POSIX header files.  Lack of this
- * symbol does NOT mean that the POSIX environment is the default.
- * You may still have to define _POSIX_SOURCE to get it.
- */
-
-#if defined(NOSTDHDRS)
-#define X_NOT_POSIX
-#define X_NOT_STDC_ENV
-#endif
-
-#if defined(NeXT)
-#define X_NOT_POSIX
-#endif
-
-#if defined(sony)
-#if !defined(SYSTYPE_SYSV)
-#define X_NOT_POSIX
-#endif
-#endif
-
-#if defined(UTEK)
-#define X_NOT_POSIX
-#define X_NOT_STDC_ENV
-#endif
-
-#if defined(CRAY)
-#define X_NOT_POSIX
-#endif
-
-#if defined(vax)
-#if !defined(ultrix)			/* assume vanilla BSD */
-#define X_NOT_POSIX
-#define X_NOT_STDC_ENV
-#endif
-#endif
-
-#if defined(luna)
-#define X_NOT_POSIX
-#define X_NOT_STDC_ENV
-#endif
-
-#if defined(Mips)
-#define X_NOT_POSIX
-#define X_NOT_STDC_ENV
-#endif
-  
-#if defined(USL)
-#if defined(SYSV) /* (release 3.2) */
-#define X_NOT_POSIX
-#define X_NOT_STDC_ENV
-#endif
-#endif
-
-#if defined(SYSV386)
-#if defined(SYSV)
-#define X_NOT_POSIX
-#define X_NOT_STDC_ENV
-#endif
-#endif
-
-#if defined(MOTOROLA)
-#if defined(SYSV)
-#define X_NOT_STDC_ENV
-#endif
-#endif
diff --git a/utils/lndir/lndir.c b/utils/lndir/lndir.c
deleted file mode 100644
index 8ea5ab2ab48..00000000000
--- a/utils/lndir/lndir.c
+++ /dev/null
@@ -1,486 +0,0 @@
-/* $XConsortium: lndir.c /main/16 1996/09/28 16:16:40 rws $ */
-/* Create shadow link tree (after X11R4 script of the same name)
-   Mark Reinhold (mbr@lcs.mit.edu)/3 January 1990 */
-
-/*
-Copyright (c) 1990,  X Consortium
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of the X Consortium shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from the X Consortium.
-
-*/
-
-/* From the original /bin/sh script:
-
-  Used to create a copy of the a directory tree that has links for all
-  non-directories (except those named RCS, SCCS or CVS.adm).  If you are
-  building the distribution on more than one machine, you should use
-  this technique.
-
-  If your master sources are located in /usr/local/src/X and you would like
-  your link tree to be in /usr/local/src/new-X, do the following:
-
-        %  mkdir /usr/local/src/new-X
-        %  cd /usr/local/src/new-X
-        %  lndir ../X
-*/
-
-#define NeedVarargsPrototypes 1
-
-#include "lndir-Xos.h"
-#include "fs.h"
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/stat.h>
-#include <sys/param.h>
-#include <errno.h>
-
-#if !defined(X_NOT_POSIX)
-#include <dirent.h>
-#else
-#if defined(SYSV)
-#include <dirent.h>
-#else
-#if defined(USG)
-#include <dirent.h>
-#else
-#include <sys/dir.h>
-#if !defined(dirent)
-#define dirent direct
-#endif
-#endif
-#endif
-#endif
-#if !defined(MAXPATHLEN)
-#define MAXPATHLEN 2048
-#endif
-
-#if defined(__CYGWIN32__)
-#include <sys/cygwin.h>
-#endif
-
-#if NeedVarargsPrototypes
-#include <stdarg.h>
-#endif
-
-#if defined(X_NOT_STDC_ENV)
-extern int errno;
-#endif
-int silent = 0;                 /* -silent */
-int copy = 0;                   /* -copy */
-int ignore_links = 0;           /* -ignorelinks */
-
-char *rcurdir;
-char *curdir;
-
-int force=0;
-
-#if defined(WIN32)
-#define mymkdir(X, Y) mkdir(X)
-#else
-#define mymkdir(X, Y) mkdir(X, Y)
-#endif
-
-#if !defined(WIN32)
-#define SYMLINKS
-#define BELIEVE_ST_NLINK
-#endif
-
-void
-quit (
-#if NeedVarargsPrototypes
-    int code, char * fmt, ...)
-#else
-    code, fmt, a1, a2, a3)
-    char *fmt;
-#endif
-{
-#if NeedVarargsPrototypes
-    va_list args;
-    va_start(args, fmt);
-    vfprintf (stderr, fmt, args);
-    va_end(args);
-#else
-    fprintf (stderr, fmt, a1, a2, a3);
-#endif
-    putc ('\n', stderr);
-    exit (code);
-}
-
-void
-quiterr (code, s)
-    char *s;
-{
-    perror (s);
-    exit (code);
-}
-
-void
-msg (
-#if NeedVarargsPrototypes
-    char * fmt, ...)
-#else
-    fmt, a1, a2, a3)
-    char *fmt;
-#endif
-{
-#if NeedVarargsPrototypes
-    va_list args;
-#endif
-    if (curdir) {
-        fprintf (stderr, "%s:\n", curdir);
-        curdir = 0;
-    }
-#if NeedVarargsPrototypes
-    va_start(args, fmt);
-    vfprintf (stderr, fmt, args);
-    va_end(args);
-#else
-    fprintf (stderr, fmt, a1, a2, a3);
-#endif
-    putc ('\n', stderr);
-}
-
-void
-mperror (s)
-    char *s;
-{
-    if (curdir) {
-        fprintf (stderr, "%s:\n", curdir);
-        curdir = 0;
-    }
-    perror (s);
-}
-
-#define BUFSIZE 1024
-int copyfile(const char *oldpath, const char *newpath) {
-    FILE *f_old;
-    FILE *f_new;
-    int e;
-    ssize_t s;
-    char buf[BUFSIZE];
-
-#if defined(SYMLINKS)
-    if (copy == 0) {
-        return symlink(oldpath, newpath);
-    } else {
-#endif
-        f_old = __hs_fopen(oldpath, "rb");
-        if (f_old == NULL) {
-            return -1;
-        }
-        f_new = __hs_fopen(newpath, "wbx");
-        if (f_new == NULL) {
-            e = errno;
-            fclose(f_old);
-            errno = e;
-            return -1;
-        }
-        while ((s = fread(buf, 1, BUFSIZE, f_old)) > 0) {
-            if (fwrite(buf, 1, s, f_new) < s) {
-                e = errno;
-                fclose(f_old);
-                fclose(f_new);
-                errno = e;
-                return -1;
-            }
-        }
-        if (!feof(f_old)) {
-            e = errno;
-            fclose(f_old);
-            fclose(f_new);
-            errno = e;
-            return -1;
-        }
-        if (fclose(f_new) == EOF) {
-            e = errno;
-            fclose(f_old);
-            errno = e;
-            return -1;
-        }
-        fclose(f_old);
-        return 0;
-#if defined(SYMLINKS)
-    }
-#endif
-}
-
-int equivalent(lname, rname)
-    char *lname;
-    char *rname;
-{
-    char *s;
-
-    if (!strcmp(lname, rname))
-        return 1;
-    for (s = lname; *s && (s = strchr(s, '/')); s++) {
-        while (s[1] == '/')
-            strcpy(s+1, s+2);
-    }
-    return !strcmp(lname, rname);
-}
-
-
-/* Recursively create symbolic links from the current directory to the "from"
-   directory.  Assumes that files described by fs and ts are directories. */
-
-dodir (fn, fs, ts, rel)
-char *fn;                       /* name of "from" directory, either absolute or
-                                   relative to cwd */
-struct stat *fs, *ts;           /* stats for the "from" directory and cwd */
-int rel;                        /* if true, prepend "../" to fn before using */
-{
-    DIR *df;
-    struct dirent *dp;
-    char buf[MAXPATHLEN + 1], *p;
-    char symbuf[MAXPATHLEN + 1];
-    char basesym[MAXPATHLEN + 1];
-    struct stat sb, sc;
-    int n_dirs;
-    int symlen = -1;
-    int basesymlen = -1;
-    char *ocurdir;
-
-    if ((fs->st_dev == ts->st_dev) &&
-        (fs->st_ino == ts->st_ino) &&
-        /* inode is always 0 on Windows; we don't want to fail in that case */
-        (fs->st_ino != 0)
-       ) {
-        msg ("%s: From and to directories are identical!", fn);
-        return 1;
-    }
-
-    if (rel)
-        strcpy (buf, "../");
-    else
-        buf[0] = '\0';
-    strcat (buf, fn);
-
-    if (!(df = opendir (buf))) {
-        msg ("%s: Cannot opendir", buf);
-        return 1;
-    }
-
-    p = buf + strlen (buf);
-    *p++ = '/';
-    n_dirs = fs->st_nlink;
-    while (dp = readdir (df)) {
-        if (dp->d_name[strlen(dp->d_name) - 1] == '~')
-            continue;
-        if (dp->d_name[0] == '.' && dp->d_name[1] == '#') /* 'non-conflict files' left behind by CVS */
-            continue;
-        strcpy (p, dp->d_name);
-
-        if (
-#if defined(BELIEVE_ST_NLINK)
-            n_dirs > 0
-#else
-            /* st_nlink is 1 on Windows, so we have to keep looking for
-             * directories forever */
-            1
-#endif
-           ) {
-            if (stat (buf, &sb) < 0) {
-                mperror (buf);
-                continue;
-            }
-
-#if defined(S_ISDIR)
-            if(S_ISDIR(sb.st_mode))
-#else
-            if (sb.st_mode & S_IFDIR)
-#endif
-            {
-                /* directory */
-#if !defined(__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')))
-                    continue;
-                if (!strcmp (dp->d_name, "RCS"))
-                    continue;
-                if (!strcmp (dp->d_name, "SCCS"))
-                    continue;
-                if (!strcmp (dp->d_name, "CVS"))
-                    continue;
-                if (!strcmp (dp->d_name, ".svn"))
-                    continue;
-                if (!strcmp (dp->d_name, ".git"))
-                    continue;
-                if (!strcmp (dp->d_name, "_darcs"))
-                    continue;
-                if (!strcmp (dp->d_name, "CVS.adm"))
-                    continue;
-                ocurdir = rcurdir;
-                rcurdir = buf;
-                curdir = silent ? buf : (char *)0;
-                if (!silent)
-                    printf ("%s:\n", buf);
-                if ((stat (dp->d_name, &sc) < 0) && (errno == ENOENT)) {
-                    if (mymkdir (dp->d_name, 0777) < 0 ||
-                        stat (dp->d_name, &sc) < 0) {
-                        mperror (dp->d_name);
-                        curdir = rcurdir = ocurdir;
-                        continue;
-                    }
-                }
-#if defined(SYMLINKS)
-                if (readlink (dp->d_name, symbuf, sizeof(symbuf) - 1) >= 0) {
-                    msg ("%s: is a link instead of a directory", dp->d_name);
-                    curdir = rcurdir = ocurdir;
-                    continue;
-                }
-#endif
-                if (chdir (dp->d_name) < 0) {
-                    mperror (dp->d_name);
-                    curdir = rcurdir = ocurdir;
-                    continue;
-                }
-                rel = (fn[0] != '/') && ((fn[0] == '\0') || (fn[1] != ':'));
-                dodir (buf, &sb, &sc, rel);
-                if (chdir ("..") < 0)
-                    quiterr (1, "..");
-                curdir = rcurdir = ocurdir;
-                continue;
-            }
-        }
-
-        /* non-directory */
-#if defined(SYMLINKS)
-        symlen = readlink (dp->d_name, symbuf, sizeof(symbuf) - 1);
-        if (symlen >= 0)
-            symbuf[symlen] = '\0';
-
-        /* The option to ignore links exists mostly because
-           checking for them slows us down by 10-20%.
-           But it is off by default because this really is a useful check. */
-        if (!ignore_links) {
-            /* see if the file in the base tree was a symlink */
-            basesymlen = readlink(buf, basesym, sizeof(basesym) - 1);
-            if (basesymlen >= 0)
-                basesym[basesymlen] = '\0';
-        }
-#endif
-
-        if (symlen >= 0) {
-          if (!equivalent (basesymlen>=0 ? basesym : buf, symbuf)) {
-            if (force) {
-              unlink(dp->d_name);
-              if (copyfile (basesymlen>=0 ? basesym : buf, dp->d_name) < 0)
-                mperror (dp->d_name);
-            } else {
-              /* Link exists in new tree.  Print message if it doesn't match. */
-              msg ("%s: %s", dp->d_name, symbuf);
-            }
-          }
-        } else {
-          if (copyfile (basesymlen>=0 ? basesym : buf, dp->d_name) < 0)
-            mperror (dp->d_name);
-        }
-    }
-
-    closedir (df);
-    return 0;
-}
-
-main (ac, av)
-int ac;
-char **av;
-{
-    char *prog_name = av[0];
-    char* tn;
-    struct stat fs, ts;
-#if defined(__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;
-      else if (strcmp(*av, "-f") == 0)
-          force = 1;
-      else if (strcmp(*av, "-ignorelinks") == 0)
-          ignore_links = 1;
-      else if (strcmp(*av, "-copy") == 0)
-          copy = 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);
-
-#if defined(__CYGWIN32__)
-    cygwin_conv_to_full_posix_path(av[0], fn);
-#else
-    fn = av[0];
-#endif
-
-    if (ac == 2)
-        tn = av[1];
-    else
-        tn = ".";
-
-    /* to directory */
-    if (stat (tn, &ts) < 0) {
-      if (force && (tn[0] != '.' || tn[1] != '\0') ) {
-         mymkdir(tn, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH );
-      }
-      else {
-        quiterr (1, tn);
-#if defined(S_ISDIR)
-        if (!(S_ISDIR(ts.st_mode)))
-#else
-        if (!(ts.st_mode & S_IFDIR))
-#endif
-           quit (2, "%s: Not a directory", tn);
-      }
-    }
-    if (chdir (tn) < 0)
-        quiterr (1, tn);
-
-    /* from directory */
-    if (stat (fn, &fs) < 0)
-        quiterr (1, fn);
-#if defined(S_ISDIR)
-    if (!(S_ISDIR(fs.st_mode)))
-#else
-    if (!(fs.st_mode & S_IFDIR))
-#endif
-        quit (2, "%s: Not a directory", fn);
-
-    exit (dodir (fn, &fs, &ts, 0));
-}
-- 
GitLab