From 5daaae50763dba0e91d9f80d4b341ee413d22796 Mon Sep 17 00:00:00 2001 From: Cameron Katri Date: Sun, 23 May 2021 11:48:06 -0400 Subject: file_cmds: Fix compilation for lower targets --- file_cmds/common/rpmatch.c | 57 +++++++++++++++++++++++++++++++++++++++++++ file_cmds/compress/Makefile | 2 ++ file_cmds/compress/compress.c | 4 +++ file_cmds/cp/Makefile | 2 ++ file_cmds/cp/cp.c | 4 +++ file_cmds/cp/utils.c | 4 +++ file_cmds/ipcs/ipcs.c | 12 ++++----- file_cmds/ls/ls.c | 4 +++ file_cmds/mv/Makefile | 2 ++ file_cmds/mv/mv.c | 4 +++ file_cmds/rm/Makefile | 2 ++ file_cmds/rm/rm.c | 4 +++ 12 files changed, 95 insertions(+), 6 deletions(-) create mode 100644 file_cmds/common/rpmatch.c diff --git a/file_cmds/common/rpmatch.c b/file_cmds/common/rpmatch.c new file mode 100644 index 0000000..e4c366a --- /dev/null +++ b/file_cmds/common/rpmatch.c @@ -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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +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); +} diff --git a/file_cmds/compress/Makefile b/file_cmds/compress/Makefile index 1dba0de..9f151da 100644 --- a/file_cmds/compress/Makefile +++ b/file_cmds/compress/Makefile @@ -7,4 +7,6 @@ BINDIR=/usr/bin LINKS+= ${BINDIR}/compress ${BINDIR}/uncompress +CFLAGS+=-I${.CURDIR}/../common + .include diff --git a/file_cmds/compress/compress.c b/file_cmds/compress/compress.c index 97c70f2..ba05189 100644 --- a/file_cmds/compress/compress.c +++ b/file_cmds/compress/compress.c @@ -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); diff --git a/file_cmds/cp/Makefile b/file_cmds/cp/Makefile index 492fb0d..29e1063 100644 --- a/file_cmds/cp/Makefile +++ b/file_cmds/cp/Makefile @@ -3,4 +3,6 @@ SRCS= cp.c utils.c BINDIR=/bin +CFLAGS+=-I${.CURDIR}/../common + .include diff --git a/file_cmds/cp/cp.c b/file_cmds/cp/cp.c index c856fd9..4db6c81 100644 --- a/file_cmds/cp/cp.c +++ b/file_cmds/cp/cp.c @@ -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; \ diff --git a/file_cmds/cp/utils.c b/file_cmds/cp/utils.c index feecc0c..6332956 100644 --- a/file_cmds/cp/utils.c +++ b/file_cmds/cp/utils.c @@ -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)) diff --git a/file_cmds/ipcs/ipcs.c b/file_cmds/ipcs/ipcs.c index 986b229..8ee4e0e 100644 --- a/file_cmds/ipcs/ipcs.c +++ b/file_cmds/ipcs/ipcs.c @@ -42,19 +42,19 @@ #include #include -#include "sys/types.h" +#include #include #include #include #include #include #include -#include "sys/ipcs.h" +#include #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 +#include +#include +#include /* The following is a kludge, until the problem of multiple inclusions diff --git a/file_cmds/ls/ls.c b/file_cmds/ls/ls.c index 50fb91c..0a6b1a0 100644 --- a/file_cmds/ls/ls.c +++ b/file_cmds/ls/ls.c @@ -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; diff --git a/file_cmds/mv/Makefile b/file_cmds/mv/Makefile index 81f7de0..dbf5b3d 100644 --- a/file_cmds/mv/Makefile +++ b/file_cmds/mv/Makefile @@ -4,4 +4,6 @@ LDADD+=-liosexec BINDIR=/bin +CFLAGS+=-I${.CURDIR}/../common + .include diff --git a/file_cmds/mv/mv.c b/file_cmds/mv/mv.c index e237123..17ef1e0 100644 --- a/file_cmds/mv/mv.c +++ b/file_cmds/mv/mv.c @@ -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 *); diff --git a/file_cmds/rm/Makefile b/file_cmds/rm/Makefile index c20e93e..7a721c1 100644 --- a/file_cmds/rm/Makefile +++ b/file_cmds/rm/Makefile @@ -5,4 +5,6 @@ BINDIR=/bin LINKS+= ${BINDIR}/rm ${BINDIR}/unlink +CFLAGS+=-I${.CURDIR}/../common + .include diff --git a/file_cmds/rm/rm.c b/file_cmds/rm/rm.c index ef457c5..389df6e 100644 --- a/file_cmds/rm/rm.c +++ b/file_cmds/rm/rm.c @@ -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; -- cgit v1.2.3-56-ge451