]> git.cameronkatri.com Git - apple_cmds.git/commitdiff
file_cmds: Fix compilation for lower targets
authorCameron Katri <me@cameronkatri.com>
Sun, 23 May 2021 15:48:06 +0000 (11:48 -0400)
committerCameron Katri <me@cameronkatri.com>
Sun, 23 May 2021 15:48:06 +0000 (11:48 -0400)
12 files changed:
file_cmds/common/rpmatch.c [new file with mode: 0644]
file_cmds/compress/Makefile
file_cmds/compress/compress.c
file_cmds/cp/Makefile
file_cmds/cp/cp.c
file_cmds/cp/utils.c
file_cmds/ipcs/ipcs.c
file_cmds/ls/ls.c
file_cmds/mv/Makefile
file_cmds/mv/mv.c
file_cmds/rm/Makefile
file_cmds/rm/rm.c

diff --git a/file_cmds/common/rpmatch.c b/file_cmds/common/rpmatch.c
new file mode 100644 (file)
index 0000000..e4c366a
--- /dev/null
@@ -0,0 +1,57 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2004-2005 Tim J. Robbins.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <langinfo.h>
+#include <regex.h>
+#include <stdlib.h>
+
+int
+rpmatch(const char *response)
+{
+       regex_t yes, no;
+       int ret;
+
+       if (regcomp(&yes, nl_langinfo(YESEXPR), REG_EXTENDED|REG_NOSUB) != 0)
+               return (-1);
+       if (regcomp(&no, nl_langinfo(NOEXPR), REG_EXTENDED|REG_NOSUB) != 0) {
+               regfree(&yes);
+               return (-1);
+       }
+       if (regexec(&yes, response, 0, NULL, 0) == 0)
+               ret = 1;
+       else if (regexec(&no, response, 0, NULL, 0) == 0)
+               ret = 0;
+       else
+               ret = -1;
+       regfree(&yes);
+       regfree(&no);
+       return (ret);
+}
index 1dba0de308fed8435157302dae6d38b820c76021..9f151da79b37ac3f448ece121653bb87247ba4eb 100644 (file)
@@ -7,4 +7,6 @@ BINDIR=/usr/bin
 
 LINKS+=        ${BINDIR}/compress ${BINDIR}/uncompress
 
+CFLAGS+=-I${.CURDIR}/../common
+
 .include <bsd.prog.mk>
index 97c70f291e278016d2e8e84133f16c35ee81569f..ba05189d990c0a4d9af4331cfd964b4d5d8cccf3 100644 (file)
@@ -59,6 +59,10 @@ __FBSDID("$FreeBSD: src/usr.bin/compress/compress.c,v 1.23 2010/12/11 08:32:16 j
 
 #include "zopen.h"
 
+#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 140000
+#include "rpmatch.c"
+#endif
+
 void   compress(const char *, const char *, int);
 void   cwarn(const char *, ...) __printflike(1, 2);
 void   cwarnx(const char *, ...) __printflike(1, 2);
index 492fb0d143e67be5ee40938130493aa5e23c4464..29e1063732f61ee29e74c4533f758103b07cc46b 100644 (file)
@@ -3,4 +3,6 @@ SRCS=   cp.c utils.c
 
 BINDIR=/bin
 
+CFLAGS+=-I${.CURDIR}/../common
+
 .include <bsd.prog.mk>
index c856fd995d74d95802cee2ce10b0c054d19baaa1..4db6c81084f47214c4844298ce8a214f020a4f99 100644 (file)
@@ -81,6 +81,10 @@ __FBSDID("$FreeBSD: src/bin/cp/cp.c,v 1.52 2005/09/05 04:36:08 csjp Exp $");
 
 #include "extern.h"
 
+#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 140000
+#include "rpmatch.c"
+#endif
+
 #define        STRIP_TRAILING_SLASH(p) {                                       \
         while ((p).p_end > (p).p_path + 1 && (p).p_end[-1] == '/')     \
                 *--(p).p_end = 0;                                      \
index feecc0c85528a475ec18da490a513ddd2258e741..6332956c7aa08976244c42ce8495379a9707037d 100644 (file)
@@ -66,6 +66,10 @@ __FBSDID("$FreeBSD: src/bin/cp/utils.c,v 1.46 2005/09/05 04:36:08 csjp Exp $");
 #define COMPAT_MODE(a,b) (1)
 #endif /* __APPLE__ */
 
+#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 140000
+int rpmatch(const char *);
+#endif
+
 #include "extern.h"
 #define        cp_pct(x,y)     (int)(100.0 * (double)(x) / (double)(y))
 
index 986b229efc035159435f6f882b79565bc4dbcff0..8ee4e0e84d94cf5b9022ffade27770e0d5521a74 100644 (file)
 #include <unistd.h>
 #include <sysexits.h>
 
-#include "sys/types.h"
+#include <sys/types.h>
 #include <sys/ucred.h>
 #include <sys/time.h>
 #include <sys/proc.h>
 #include <sys/param.h>
 #include <sys/sysctl.h>
 #include <errno.h>
-#include "sys/ipcs.h"
+#include <sys/ipcs.h>
 #define KERNEL 1               /* To get new ipc_perm and __(sem|shm|msg)ds_new */
-#include "sys/ipc.h"
-#include "sys/sem_internal.h"
-#include "sys/shm_internal.h"
-#include "sys/msg.h"
+#include <sys/ipc.h>
+#include <sys/sem_internal.h>
+#include <sys/shm_internal.h>
+#include <sys/msg.h>
 
 
 /* The following is a kludge, until the problem of multiple inclusions
index 50fb91caa12bd46513147f6188b5720e0eadbe23..0a6b1a0e48a92b4022c1f5a46d692825f264a50c 100644 (file)
@@ -561,10 +561,12 @@ traverse(int argc, char *argv[], int options)
                                break;
                        }
 
+#ifdef SF_DATALESS
                        if (IS_DATALESS(p->fts_statp)) {
                                fts_set(ftsp, p, FTS_SKIP);
                                break;
                        }
+#endif
 
                        /*
                         * If already output something, put out a newline as
@@ -857,9 +859,11 @@ display(FTSENT *p, FTSENT *list)
                                } else {
                                        np->mode_suffix = ' ';
                                }
+#ifdef SF_DATALESS
                                if (IS_DATALESS(sp)) {
                                        np->mode_suffix = '%';
                                }
+#endif
                                if (!f_acl) {
                                        acl_free(np->acl);
                                        np->acl = NULL;
index 81f7de035ae7385989cb580312d3ae4268cb3dae..dbf5b3db4e7900089bb9b13e9f5d86414f5f02ca 100644 (file)
@@ -4,4 +4,6 @@ LDADD+=-liosexec
 
 BINDIR=/bin
 
+CFLAGS+=-I${.CURDIR}/../common
+
 .include <bsd.prog.mk>
index e2371236416d9146404e92a59f022905ee3cf2af..17ef1e04135284895ae0a14bdc0a1f06b9ab79ec 100644 (file)
@@ -84,6 +84,10 @@ __RCSID("$FreeBSD: src/bin/mv/mv.c,v 1.39 2002/07/09 17:45:13 johan Exp $");
 
 #include "pathnames.h"
 
+#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 140000
+#include "rpmatch.c"
+#endif
+
 int fflg, iflg, nflg, vflg;
 
 int    copy(char *, char *);
index c20e93ebf45689f54b13a870fec8fca159e85e85..7a721c16dbad8fc4c89dc64a9add19d912864dd9 100644 (file)
@@ -5,4 +5,6 @@ BINDIR=/bin
 
 LINKS+=        ${BINDIR}/rm ${BINDIR}/unlink
 
+CFLAGS+=-I${.CURDIR}/../common
+
 .include <bsd.prog.mk>
index ef457c5a19c0d978acc2a25ab1d5f3960150dbe3..389df6edc08707eba216b6fd5e5f035086d1d2fe 100644 (file)
@@ -75,6 +75,10 @@ __used static const char rcsid[] =
 #define COMPAT_MODE(func, mode) 1
 #endif
 
+#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 140000
+#include "rpmatch.c"
+#endif
+
 int dflag, eval, fflag, iflag, Pflag, vflag, Wflag, stdin_ok;
 uid_t uid;