From 4921d19a72cf0d37c054352d87afd8f13f699ed0 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Mon, 13 Mar 2017 16:16:33 -0400 Subject: [PATCH] removed some defines from config.h and ifdefs throughout the code. This fork intends to only support POSIX if at all possible. Specifically linux and osx --- Makefile | 4 +- addon.c | 25 -------- addon.h | 31 ---------- builtins.c | 52 +++++----------- config.h | 174 ---------------------------------------------------- exec.c | 2 +- execve.c | 62 ------------------- fn.c | 7 --- getgroups.h | 10 --- glob.c | 20 +----- glom.c | 53 ---------------- jbwrap.h | 8 --- print.c | 18 +----- proto.h | 70 --------------------- rc.h | 7 --- rlimit.h | 26 -------- signal.c | 21 ------- stat.h | 6 -- wait.h | 2 - which.c | 18 +----- 20 files changed, 27 insertions(+), 589 deletions(-) delete mode 100644 addon.c delete mode 100644 addon.h delete mode 100644 execve.c delete mode 100644 getgroups.h delete mode 100644 stat.h diff --git a/Makefile b/Makefile index 68909c5..97be0b1 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -CPPFLAGS = -DHAVE_CONFIG_H -I. +CPPFLAGS = -I. CCCMD = $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS) RCOBJS = builtins.o except.o builtins.o except.o exec.o fn.o footobar.o getopt.o glob.o glom.o hash.o heredoc.o input.o lex.o list.o main.o match.o nalloc.o open.o parse.o print.o redir.o signal.o status.o tree.o utils.o var.o wait.o walk.o which.o sigmsgs.o edit-null.o system.o @@ -20,4 +20,4 @@ rc: $(RCOBJS) $(CCCMD) clean: - $(RM) rc *.o + $(RM) rc *.o mksignal mkstatval sigmsgs.* statval.h diff --git a/addon.c b/addon.c deleted file mode 100644 index 6e6c232..0000000 --- a/addon.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - This file is NOT BUILT by default. Together with addon.h, it - provides an example of how to add new builtins to rc. -*/ - -#include "rc.h" -#include "addon.h" - -void b_sum(char **av) { - long sum = 0; - - while (*++av) - sum += atol(*av); - fprint(1, "%ld\n", sum); - set(TRUE); -} - -void b_prod(char **av) { - long sum = 1; - - while (*++av) - sum *= atol(*av); - fprint(1, "%ld\n", sum); - set(TRUE); -} diff --git a/addon.h b/addon.h deleted file mode 100644 index 4a69375..0000000 --- a/addon.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - This file is NOT BUILT by default. Together with addon.c, it - provides an example of how to add new builtins to rc. - - To define a new builtin, it must appear in the macro ADDONS, which - is a comma-separated list of pairs of function pointers (the - implementation of the new builtin) and string literals (the name of - the new builtin). - - Any new builtin functions must also have proper prototypes in this - file. This is always of the same form. - - void b_NAME(char **av); - - The first argument, av[0], is the name of the builtin. The last - argument is followed by a NULL pointer. - - Builtins report their exit status using set(TRUE) or set(FALSE). - -*/ - -#if RC_ADDON - -#define ADDONS \ - { b_sum, "+" }, \ - { b_prod, "x" }, - -extern void b_sum(char **av); -extern void b_prod(char **av); - -#endif diff --git a/builtins.c b/builtins.c index 75ac9cf..cd137c1 100644 --- a/builtins.c +++ b/builtins.c @@ -14,7 +14,6 @@ #include #include -#include "addon.h" #include "input.h" #include "jbwrap.h" #include "rlimit.h" @@ -22,42 +21,27 @@ static void b_break(char **), b_cd(char **), b_eval(char **), b_exit(char **), b_newpgrp(char **), b_return(char **), b_shift(char **), b_umask(char **), - b_wait(char **), b_whatis(char **); - -#if HAVE_SETRLIMIT -static void b_limit(char **); -#endif - -#if RC_ECHO -static void b_echo(char **); -#endif + b_wait(char **), b_whatis(char **), b_limit(char **), b_echo(char **); static struct { builtin_t *p; char *name; } builtins[] = { - { b_break, "break" }, - { b_builtin, "builtin" }, - { b_cd, "cd" }, -#if RC_ECHO - { b_echo, "echo" }, -#endif - { b_eval, "eval" }, - { b_exec, "exec" }, - { b_exit, "exit" }, -#if HAVE_SETRLIMIT - { b_limit, "limit" }, -#endif - { b_newpgrp, "newpgrp" }, - { b_return, "return" }, - { b_shift, "shift" }, - { b_umask, "umask" }, - { b_wait, "wait" }, - { b_whatis, "whatis" }, - { b_dot, "." }, -#ifdef ADDONS - ADDONS -#endif + { b_break, "break" }, + { b_builtin, "builtin" }, + { b_cd, "cd" }, + { b_echo, "echo" }, + { b_eval, "eval" }, + { b_exec, "exec" }, + { b_exit, "exit" }, + { b_limit, "limit" }, + { b_newpgrp, "newpgrp" }, + { b_return, "return" }, + { b_shift, "shift" }, + { b_umask, "umask" }, + { b_wait, "wait" }, + { b_whatis, "whatis" }, + { b_dot, "." }, }; extern builtin_t *isbuiltin(char *s) { @@ -102,7 +86,6 @@ static void badnum(char *num) { extern void b_exec(char **ignore) { } -#if RC_ECHO /* echo -n omits a newline. echo -- -n echos '-n' */ static void b_echo(char **av) { @@ -116,7 +99,6 @@ static void b_echo(char **av) { fprint(1, format, av); set(TRUE); } -#endif /* cd. traverse $cdpath if the directory given is not an absolute pathname */ @@ -418,7 +400,6 @@ static void b_newpgrp(char **av) { /* Berkeley limit support was cleaned up by Paul Haahr. */ -#if HAVE_SETRLIMIT static const struct Suffix kbsuf = { NULL, 1024, "k" }, mbsuf = { &kbsuf, 1024*1024, "m" }, @@ -555,4 +536,3 @@ static void b_limit(char **av) { set(TRUE); } } -#endif diff --git a/config.h b/config.h index 98230a1..746e374 100644 --- a/config.h +++ b/config.h @@ -1,195 +1,21 @@ -/* config.h. Generated from config.h.in by configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ - /* The default interpreter */ #define DEFAULTINTERP "/bin/sh" /* The default path */ #define DEFAULTPATH "/usr/local/bin","/usr/bin","/bin","." -/* Define to the type of elements in the array set by `getgroups'. Usually - this is either `int' or `gid_t'. */ -#define GETGROUPS_T gid_t - -/* Define to 1 if your kernel understands `#!' magic numbers */ -#define HASH_BANG 1 - -/* Define to 1 if you have /dev/fd. */ -#define HAVE_DEV_FD 1 - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -#define HAVE_DIRENT_H 1 - -/* Define to 1 if you have the `mkfifo' function. */ -/* #undef HAVE_FIFO */ - -/* Define to 1 if you have the `getgroups' function. */ -#define HAVE_GETGROUPS 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the `lstat' function. */ -#define HAVE_LSTAT 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the `mkfifo' function. */ -/* #undef HAVE_MKFIFO */ - -/* Define to 1 if you have the header file, and it defines `DIR'. */ -/* #undef HAVE_NDIR_H */ - -/* Define to 1 if you have the `getgroups' function with POSIX semantics. */ -#define HAVE_POSIX_GETGROUPS 1 - -/* Define to 1 if you have /proc/self/fd. */ -/* #undef HAVE_PROC_SELF_FD */ - -/* Define to 1 if you have the `quad_t' type. */ -/* #undef HAVE_QUAD_T */ - -/* Define to 1 if system calls automatically restart after interruption by a - signal. */ -/* #undef HAVE_RESTARTABLE_SYSCALLS */ - -/* Define to 1 if you have the `rlim_t' type. */ -#define HAVE_RLIM_T 1 - -/* Define to 1 if you have the `setpgrp' function. */ -#define HAVE_SETPGRP 1 - -/* Define to 1 if you have the `setrlimit' function. */ -#define HAVE_SETRLIMIT 1 - -/* Define to 1 if you have the `sigaction' function. */ -#define HAVE_SIGACTION 1 - -/* Define to 1 if you have the `sigsetjmp' function or macro. */ -#define HAVE_SIGSETJMP 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the `strerror' function or macro. */ -#define HAVE_STRERROR 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Has SysV SIGCLD */ -#define HAVE_SYSV_SIGCLD 1 - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -/* #undef HAVE_SYS_DIR_H */ - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -/* #undef HAVE_SYS_NDIR_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_RESOURCE_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TIME_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have that is POSIX.1 compatible. */ -#define HAVE_SYS_WAIT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - /* Name of package */ #define PACKAGE "rc" -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "rc" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "rc 1.7.4" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "rc" - -/* Define to the home page for this package. */ -#define PACKAGE_URL "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "1.7.4" - /* Define to 1 to encode exported environment names. */ #define PROTECT_ENV 1 -/* Define to 1 to use addon functions. */ -/* #undef RC_ADDON */ - -/* Define to 1 to include `echo' as a builtin. */ -#define RC_ECHO 1 - /* Define to 1 to use job-control-style backgrounding. */ #define RC_JOB 1 /* Release date */ #define RELDATE "2017-03-13" -/* Define to 1 if `_KERNEL' must be defined for `RLIMIT_*' macros. */ -/* #undef RLIMIT_NEEDS_KERNEL */ - -/* Define to 1 if `rlim_t' is `quad_t'. */ -/* #undef RLIM_T_IS_QUAD_T */ - -/* Define to 1 if the `setpgrp' function takes no argument. */ -#define SETPGRP_VOID 1 - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - /* Version number of package */ #define VERSION "1.7.4" -/* Enable large inode numbers on Mac OS X 10.5. */ -#ifndef _DARWIN_USE_64_BIT_INODE -# define _DARWIN_USE_64_BIT_INODE 1 -#endif - -/* Number of bits in a file offset, on hosts where this is settable. */ -/* #undef _FILE_OFFSET_BITS */ - -/* Define for large files, on AIX-style hosts. */ -/* #undef _LARGE_FILES */ - -/* Define to `int' if doesn't define. */ -/* #undef gid_t */ - -/* Define to `int' if does not define. */ -/* #undef pid_t */ - -/* Define to 1 if you have the `sig_atomic_t' type. */ -/* #undef sig_atomic_t */ - -/* Define to `unsigned int' if does not define. */ -/* #undef size_t */ - -/* Define to `long' if does not define. */ -/* #undef ssize_t */ - -/* Define to `int' if doesn't define. */ -/* #undef uid_t */ diff --git a/exec.c b/exec.c index c9244c2..08116e0 100644 --- a/exec.c +++ b/exec.c @@ -94,7 +94,7 @@ extern void exec(List *s, bool parent) { return; rc_exit(getstatus()); } - rc_execve(path, (char * const *) av, (char * const *) ev); + execve(path, (char * const *) av, (char * const *) ev); #ifdef DEFAULTINTERP if (errno == ENOEXEC) { diff --git a/execve.c b/execve.c deleted file mode 100644 index 5edde11..0000000 --- a/execve.c +++ /dev/null @@ -1,62 +0,0 @@ -/* execve.c: an execve() for geriatric unices without #! */ - -/* - NOTE: this file depends on a hack in footobar.c which places two free - spots before av[][] so that execve does not have to call malloc. -*/ - -#include "rc.h" - -#include - -#define giveupif(x) { if (x) goto fail; } - -extern int rc_execve(char *path, char **av, char **ev) { - int fd, len, fst, snd, end; - bool noarg; - char pb[256]; /* arbitrary but generous limit */ - execve(path, av, ev); - if (errno != ENOEXEC) - return -1; - fd = rc_open(path, rFrom); - giveupif(fd < 0); - len = read(fd, pb, sizeof pb); - close(fd); - /* reject scripts which don't begin with #! */ - giveupif(len <= 0 || pb[0] != '#' || pb[1] != '!'); - for (fst = 2; fst < len && (pb[fst] == ' ' || pb[fst] == '\t'); fst++) - ; /* skip leading whitespace */ - giveupif(fst == len); - for (snd = fst; snd < len && pb[snd] != ' ' && pb[snd] != '\t' && pb[snd] != '\n'; snd++) - ; /* skip first arg */ - giveupif(snd == len); - noarg = (pb[snd] == '\n'); - pb[snd++] = '\0'; /* null terminate the first arg */ - if (!noarg) { - while (snd < len && (pb[snd] == ' ' || pb[snd] == '\t')) - snd++; /* skip whitespace to second arg */ - giveupif(snd == len); - noarg = (pb[snd] == '\n'); /* could have trailing whitespace after only one arg */ - if (!noarg) { - for (end = snd; end < len && pb[end] != ' ' && pb[end] != '\t' && pb[end] != '\n'; end++) - ; /* skip to the end of the second arg */ - giveupif(end == len); - if (pb[end] == '\n') { - pb[end] = '\0'; /* null terminate the first arg */ - } else { /* else check for a spurious third arg */ - pb[end++] = '\0'; - while (end < len && (pb[end] == ' ' || pb[end] == '\t')) - end++; - giveupif(end == len || pb[end] != '\n'); - } - } - } - *av = path; - if (!noarg) - *--av = pb + snd; - *--av = pb + fst; - execve(*av, av, ev); - return -1; -fail: errno = ENOEXEC; - return -1; -} diff --git a/fn.c b/fn.c index 7d9e4f7..2aa6f9d 100644 --- a/fn.c +++ b/fn.c @@ -29,9 +29,6 @@ extern void inithandler() { null.type = nBody; null.u[0].p = null.u[1].p = NULL; for (i = 1; i < NUMOFSIGNALS; i++) -#if HAVE_SYSV_SIGCLD - if (i != SIGCLD) -#endif if (sighandlers[i] == SIG_IGN) fnassign(signals[i].name, NULL); /* ignore incoming ignored signals */ if (interactive || sighandlers[SIGINT] != SIG_IGN) { @@ -151,10 +148,6 @@ extern void fnassign(char *name, Node *def) { new->def = newdef; new->extdef = NULL; if (strncmp(name, "sig", conststrlen("sig")) == 0) { /* slight optimization */ -#if HAVE_SYSV_SIGCLD /* System V machines treat SIGCLD very specially */ - if (streq(name, "sigcld")) - rc_error("can't trap SIGCLD"); -#endif if (streq(name, "sigexit")) runexit = TRUE; for (i = 1; i < NUMOFSIGNALS; i++) /* zero is a bogus signal */ diff --git a/getgroups.h b/getgroups.h deleted file mode 100644 index 982dfa0..0000000 --- a/getgroups.h +++ /dev/null @@ -1,10 +0,0 @@ -#if HAVE_GETGROUPS -#if HAVE_POSIX_GETGROUPS -/* We love POSIX. */ -#else -/* OK, so you've got getgroups, but you don't have the POSIX semantics -of a zero first argument. The conclusion is that you're on a reasonably -pure BSD system, and we can include for NGROUPS. */ -#include -#endif -#endif diff --git a/glob.c b/glob.c index 5507678..18f62f4 100644 --- a/glob.c +++ b/glob.c @@ -1,25 +1,11 @@ /* glob.c: rc's (ugly) globber. This code is not elegant, but it works */ #include "rc.h" -#include "stat.h" +#include /* Lifted from autoconf documentation.*/ -#if HAVE_DIRENT_H -# include -# define NAMLEN(dirent) strlen((dirent)->d_name) -#else -# define dirent direct -# define NAMLEN(dirent) (dirent)->d_namlen -# if HAVE_SYS_NDIR_H -# include -# endif -# if HAVE_SYS_DIR_H -# include -# endif -# if HAVE_NDIR_H -# include -# endif -#endif +#include +#define NAMLEN(dirent) strlen((dirent)->d_name) static List *dmatch(char *, char *, char *); static List *doglob(char *, char *); diff --git a/glom.c b/glom.c index c44f0d5..2414f9f 100644 --- a/glom.c +++ b/glom.c @@ -286,50 +286,6 @@ extern void qredir(Node *n) { next->n = NULL; } -#if HAVE_DEV_FD || HAVE_PROC_SELF_FD -static List *mkcmdarg(Node *n) { - char *name; - List *ret = nnew(List); - Estack *e = nnew(Estack); - Edata efd; - int p[2]; - if (pipe(p) < 0) { - uerror("pipe"); - return NULL; - } - if (rc_fork() == 0) { - setsigdefaults(FALSE); - if (mvfd(p[n->u[0].i == rFrom], n->u[0].i == rFrom) < 0) /* stupid hack */ - exit(1); - close(p[n->u[0].i != rFrom]); - redirq = NULL; - walk(n->u[2].p, FALSE); - exit(getstatus()); - } - -#if HAVE_DEV_FD - name = nprint("/dev/fd/%d", p[n->u[0].i != rFrom]); -#else - name = nprint("/proc/self/fd/%d", p[n->u[0].i != rFrom]); -#endif - - efd.fd = p[n->u[0].i != rFrom]; - except(eFd, efd, e); - close(p[n->u[0].i == rFrom]); - ret->w = name; - ret->m = NULL; - ret->n = NULL; - return ret; -} - -#elif HAVE_FIFO - -#if HAVE_MKFIFO -/* Have POSIX mkfifo(). */ -#else -#define mkfifo(n,m) mknod(n, S_IFIFO | m, 0) -#endif - static List *mkcmdarg(Node *n) { int fd; char *name; @@ -364,15 +320,6 @@ static List *mkcmdarg(Node *n) { return ret; } -#else - -static List *mkcmdarg(Node *n) { - rc_error("command arguments are not supported"); - return NULL; -} - -#endif - extern List *glom(Node *n) { List *v, *head, *tail; Node *words; diff --git a/jbwrap.h b/jbwrap.h index 4b3ea86..f8d34e0 100644 --- a/jbwrap.h +++ b/jbwrap.h @@ -5,14 +5,6 @@ use a jmp_buf. This probably fails on a traditional SysV machine, where jmp_bufs don't preserve signal masks. I'm not worrying about this till someone reports it as a bug :-). */ -#if HAVE_SIGSETJMP -#else -#define sigjmp_buf jmp_buf -#define sigsetjmp(x,y) setjmp(x) -#define siglongjmp longjmp -#endif /* HAVE_SIGSETJMP */ - - /* Certain braindamaged environments don't define jmp_buf as an array, so wrap it in a structure. Potentially, we could use configure to do this only where it needs to be done, but the effort is probably not diff --git a/print.c b/print.c index 2a30b5c..6309e87 100644 --- a/print.c +++ b/print.c @@ -19,13 +19,9 @@ static bool name(Format *format, int ignore) { \ return TRUE; \ } -Flag(uconv, FMT_unsigned) +Flag(uconv, FMT_unsigned) Flag(rc_lconv, FMT_long) - -#if HAVE_QUAD_T -Flag(qconv, FMT_quad) -#endif - +Flag(qconv, FMT_quad) Flag(altconv, FMT_altform) Flag(leftconv, FMT_leftside) Flag(dotconv, FMT_f2set) @@ -94,12 +90,6 @@ static void intconv(Format *format, unsigned int radix, int upper, const char *a flags = format->flags; -#if HAVE_QUAD_T - if (flags & FMT_quad) - n = va_arg(format->args, quad_t); - else -#endif - if (flags & FMT_long) n = va_arg(format->args, long); else @@ -204,10 +194,6 @@ static void inittab(void) { fmttab['-'] = leftconv; fmttab['.'] = dotconv; -#if HAVE_QUAD_T - fmttab['q'] = qconv; -#endif - fmttab['0'] = zeroconv; for (i = '1'; i <= '9'; i++) fmttab[i] = digitconv; diff --git a/proto.h b/proto.h index 4a2d74a..34a8a68 100644 --- a/proto.h +++ b/proto.h @@ -4,17 +4,11 @@ file, or---for older systems---declaring the functions directly. */ -#if HAVE_SYS_TYPES_H #include -#endif #include -#if HAVE_QUAD_T -typedef quad_t align_t; -#else typedef long align_t; -#endif /* We need . If you really need to build rc on a system which @@ -30,71 +24,7 @@ assignment works. */ #define va_copy(x,y) (x)=(y) #endif -#if STDC_HEADERS - #include #include - -#else /* STDC_HEADERS */ - -/* fake string.h */ -extern int strncmp(const char *, const char *, size_t); -extern int strcmp(const char *, const char *); -extern size_t strlen(const char *); -extern char *strchr(const char *, int); -extern char *strrchr(const char *, int); -extern char *strcpy(char *, const char *); -extern char *strncpy(char *, const char *, size_t); -extern char *strcat(char *, const char *); -extern char *strncat(char *, const char *, size_t); -extern void *memcpy(void *, const void *, size_t); -extern void *memset(void *, int, size_t); - -/* fake stdlib.h */ -extern void exit(int); -extern void free(void *); -extern void *malloc(size_t); -extern void *realloc(void *, size_t); -extern void qsort(void *, size_t, size_t, int (*)(const void *, const void *)); - -#endif /* STDC_HEADERS */ - -#if HAVE_STRERROR -/* Smells like POSIX. */ -#else -/* Assume BSD-style sys_errlist[]. */ -extern int sys_nerr; -extern char *sys_errlist[]; -#define strerror(x) ((0 <= (x)) && (errno < (x)) ? sys_errlist[x] : (char *)0) -#endif - -#if HAVE_UNISTD_H #include -#endif - -#if HAVE_SETPGRP - -#if SETPGRP_VOID -/* Smells like POSIX: should all be ok. */ -#else -/* Old BSD: fake it. */ -#define setpgid(pid, pgrp) setpgrp(pid, pgrp) -#include -#define tcgetpgrp(fd) ioctl((fd), TIOCGPGRP) -#define tcsetpgrp(fd, pgrp) ioctl((fd), TIOCSPGRP, &(pgrp)) -#endif - -#else /* HAVE_SETPGRP */ -/* Nothing doing. */ -#define setpgid() -#define tcgetpgrp() -#define tcsetpgrp() - -#endif /*HAVE_SETPGRP */ - - -/* fake errno.h for mips (which doesn't declare errno in errno.h!?!?) */ -#ifdef host_mips -extern int errno; -#endif diff --git a/rc.h b/rc.h index 2912e60..9769e01 100644 --- a/rc.h +++ b/rc.h @@ -192,13 +192,6 @@ extern void sigint(int); /* exec.c */ extern void exec(List *, bool); -#if HASH_BANG -#define rc_execve execve -#else -/* execve.c */ -extern int my_execve(char *, char **, char **); -#endif - /* footobar.c */ extern char **list2array(List *, bool); extern char *get_name(char *); diff --git a/rlimit.h b/rlimit.h index a3dbe8d..1486bd7 100644 --- a/rlimit.h +++ b/rlimit.h @@ -1,39 +1,14 @@ /* What a mess. This file attempts to straighten everything out. */ -#if HAVE_SETRLIMIT - -#if HAVE_SYS_RESOURCE_H #include -#if RLIMIT_NEEDS_KERNEL -#define _KERNEL -#endif #include -#if RLIMIT_NEEDS_KERNEL -#undef _KERNEL -#endif -#else -#include -#endif #if HAVE_LIMITS_H #include #endif -#ifndef HAVE_RLIM_T -#if RLIM_T_IS_QUAD_T -typedef quad_t rlim_t; -#else -typedef long rlim_t; -#endif -#endif - -#if HAVE_QUAD_T -#define RLIM_CONV quad_t -#define RLIM_FMT "%s \t%qd%s\n" -#else #define RLIM_CONV long #define RLIM_FMT "%s \t%ld%s\n" -#endif #if defined(RLIMIT_OFILE) && !defined (RLIMIT_NOFILE) #define RLIMIT_NOFILE RLIMIT_OFILE @@ -50,4 +25,3 @@ struct Limit { int flag; const struct Suffix *suffix; }; -#endif /* HAVE_SETRLIMIT */ diff --git a/signal.c b/signal.c index 037be1d..f3569e7 100644 --- a/signal.c +++ b/signal.c @@ -8,7 +8,6 @@ #include "sigmsgs.h" #include "jbwrap.h" -#if HAVE_SIGACTION void (*sys_signal(int signum, void (*handler)(int)))(int) { struct sigaction new, old; @@ -18,11 +17,6 @@ void (*sys_signal(int signum, void (*handler)(int)))(int) { sigaction(signum, &new, &old); return old.sa_handler; } -#else -void (*sys_signal(int signum, void (*handler)(int)))(int) { - return signal(signum, handler); -} -#endif void (*sighandlers[NUMOFSIGNALS])(int); @@ -34,12 +28,6 @@ extern void catcher(int s) { caught[s] = 1; } sys_signal(s, catcher); - -#if HAVE_RESTARTABLE_SYSCALLS - if (slow) { - siglongjmp(slowbuf.j, s); - } -#endif } extern void sigchk() { @@ -82,15 +70,6 @@ extern void initsignal() { void (*h)(int); int i; -#if HAVE_SYSV_SIGCLD - /* Ensure that SIGCLD is not SIG_IGN. Solaris's rshd does this. :-( */ - h = sys_signal(SIGCLD, SIG_IGN); - if (h != SIG_IGN && h != SIG_ERR) - sys_signal(SIGCLD, h); - else - sys_signal(SIGCLD, SIG_DFL); -#endif - for (i = 1; i < NUMOFSIGNALS; i++) { #ifdef SIGKILL if (i == SIGKILL) continue; diff --git a/stat.h b/stat.h deleted file mode 100644 index 5f87a69..0000000 --- a/stat.h +++ /dev/null @@ -1,6 +0,0 @@ -#include - -#if HAVE_LSTAT -#else -#define lstat(name, buf) (stat((name), (buf))) -#endif diff --git a/wait.h b/wait.h index e54ae45..a23ca79 100644 --- a/wait.h +++ b/wait.h @@ -1,6 +1,4 @@ -#if HAVE_SYS_WAIT_H #include -#endif /* Fake the POSIX wait() macros if we don't have them. */ #ifndef WIFEXITED diff --git a/which.c b/which.c index 798d7b0..3fc3f1a 100644 --- a/which.c +++ b/which.c @@ -14,8 +14,6 @@ #include #include -#include "getgroups.h" - #define X_USR 0100 #define X_GRP 0010 #define X_OTH 0001 @@ -25,9 +23,8 @@ static bool initialized = FALSE; static uid_t uid; static gid_t gid; -#if HAVE_GETGROUPS static int ngroups; -static GETGROUPS_T *gidset; +static gid_t* gidset; /* determine whether gid lies in gidset */ @@ -38,9 +35,6 @@ static int ingidset(gid_t g) { return 1; return 0; } -#else -#define ingidset(g) (FALSE) -#endif /* A home-grown access/stat. Does the right thing for group-executable files. @@ -97,21 +91,15 @@ extern char *which(char *name, bool verbose) { initialized = TRUE; uid = geteuid(); gid = getegid(); -#if HAVE_GETGROUPS -#if HAVE_POSIX_GETGROUPS - ngroups = getgroups(0, (GETGROUPS_T *)0); + ngroups = getgroups(0, (gid_t *)0); if (ngroups < 0) { uerror("getgroups"); rc_exit(1); } -#else - ngroups = NGROUPS; -#endif if (ngroups) { - gidset = ealloc(ngroups * sizeof(GETGROUPS_T)); + gidset = ealloc(ngroups * sizeof(gid_t)); getgroups(ngroups, gidset); } -#endif } if (isabsolute(name)) /* absolute pathname? */ return rc_access(name, verbose) ? name : NULL; -- 2.49.0