diff --git a/aclocal.m4 b/aclocal.m4 index 9f07f3d..bec5c09 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,4 +1,4 @@ -dnl $MirBSD: src/bin/ksh/aclocal.m4,v 2.5 2004/12/31 18:41:46 tg Exp $ +dnl $MirBSD: src/bin/ksh/aclocal.m4,v 2.6 2004/12/31 19:37:03 tg Exp $ dnl- dnl Copyright (c) 2004 dnl Thorsten "mirabile" Glaser @@ -224,63 +224,6 @@ AC_DEFUN(KSH_DEV_FD, ])dnl dnl dnl -dnl Check for sys_siglist[] declaration and existence. -AC_DEFUN(KSH_SYS_SIGLIST, - [AC_DECL_SYS_SIGLIST - if test ac_cv_decl_sys_siglist = yes; then - AC_DEFINE(HAVE_SYS_SIGLIST) - else - AC_CACHE_CHECK(for sys_siglist in library, ksh_cv_var_sys_siglist, - [AC_TRY_LINK(, [ - extern char *sys_siglist[]; - char *p = sys_siglist[2]; - if (p) - return 12; - ], ksh_cv_var_sys_siglist=yes, ksh_cv_var_sys_siglist=no)]) - if test $ksh_cv_var_sys_siglist = yes; then - AC_DEFINE(HAVE_SYS_SIGLIST) - fi - fi - ])dnl -dnl -dnl -dnl Check for sys_errlist[] declaration and existence. -AC_DEFUN(KSH_SYS_ERRLIST, - [AC_CACHE_CHECK(for sys_errlist declaration in errno.h, ksh_cv_decl_sys_errlist, - [AC_TRY_COMPILE([#include ], - [char *msg = *(sys_errlist + 1); if (msg && *msg) return 12; ], - ksh_cv_decl_sys_errlist=yes, ksh_cv_decl_sys_errlist=no)]) - if test $ksh_cv_decl_sys_errlist = yes; then - AC_DEFINE(SYS_ERRLIST_DECLARED) - AC_DEFINE(HAVE_SYS_ERRLIST) - else - AC_CACHE_CHECK(for sys_errlist in library, ksh_cv_var_sys_errlist, - [AC_TRY_LINK(, [ - extern char *sys_errlist[]; - extern int sys_nerr; - char *p; - p = sys_errlist[sys_nerr - 1]; - if (p) return 12; - ], ksh_cv_var_sys_errlist=yes, ksh_cv_var_sys_errlist=no)]) - if test $ksh_cv_var_sys_errlist = yes; then - AC_DEFINE(HAVE_SYS_ERRLIST) - fi - fi - ])dnl -dnl -dnl -dnl Check if time() declared in time.h -AC_DEFUN(KSH_TIME_DECLARED, - [AC_CACHE_CHECK(time() declaration in time.h, ksh_cv_time_delcared, - [AC_TRY_COMPILE([#include -#include ], [time_t (*f)() = time; if (f) return 12;], - ksh_cv_time_delcared=yes, ksh_cv_time_delcared=no)]) - if test $ksh_cv_time_delcared = yes; then - AC_DEFINE(TIME_DECLARED) - fi - ])dnl -dnl -dnl AC_DEFUN(KSH_C_VOID, [AC_CACHE_CHECK(if compiler understands void, ksh_cv_c_void, [AC_TRY_COMPILE( diff --git a/config.h b/config.h index 8a34936..b7fefce 100644 --- a/config.h +++ b/config.h @@ -1,4 +1,4 @@ -/** $MirBSD: src/bin/ksh/config.h,v 2.5 2004/12/31 18:41:46 tg Exp $ */ +/** $MirBSD: src/bin/ksh/config.h,v 2.6 2004/12/31 19:37:03 tg Exp $ */ /* $OpenBSD: config.h,v 1.9 2003/10/22 07:40:38 jmc Exp $ */ /* @@ -61,12 +61,6 @@ /* Define if the 'S_IS*' macros in do not work properly. */ /* #undef STAT_MACROS_BROKEN */ -/* Define if 'sys_siglist' is declared by . */ -#define SYS_SIGLIST_DECLARED 1 - -/* Define if you can safely include both and . */ -#define TIME_WITH_SYS_TIME 1 - /* Define to 'int' if doesn't define. */ /* #undef uid_t */ @@ -109,21 +103,9 @@ /* Define to the type of struct rlimit fields if the rlim_t type is missing */ /* #undef rlim_t */ -/* Define if time() is declared in */ -#define TIME_DECLARED 1 - /* Define to 'unsigned' if doesn't define */ /* #undef sigset_t */ -/* Define if sys_errlist[] and sys_nerr are in the C library */ -#define HAVE_SYS_ERRLIST 1 - -/* Define if sys_errlist[] and sys_nerr are defined in */ -#define SYS_ERRLIST_DECLARED 1 - -/* Define if sys_siglist[] is in the C library */ -#define HAVE_SYS_SIGLIST 1 - /* Define if you have a sane header file */ #define HAVE_TERMIOS_H 1 diff --git a/configure.in b/configure.in index 0a17b8b..9589cb2 100644 --- a/configure.in +++ b/configure.in @@ -1,4 +1,4 @@ -dnl $MirBSD: src/bin/ksh/configure.in,v 2.3 2004/12/31 18:41:47 tg Exp $ +dnl $MirBSD: src/bin/ksh/configure.in,v 2.4 2004/12/31 19:37:03 tg Exp $ dnl dnl Process this file with autoconf to produce a configure script dnl @@ -76,9 +76,6 @@ AC_CHECK_FUNCS(arc4random arc4random_addrandom arc4random_push confstr \ AC_CHECK_FUNCS(sigsetjmp _setjmp, break) AC_FUNC_MMAP KSH_FUNC_LSTAT -KSH_SYS_ERRLIST -KSH_SYS_SIGLIST -KSH_TIME_DECLARED dnl dnl Structures dnl diff --git a/emacs.c b/emacs.c index 4f2ca21..3b1a1f5 100644 --- a/emacs.c +++ b/emacs.c @@ -1,4 +1,4 @@ -/** $MirBSD: src/bin/ksh/emacs.c,v 2.7 2004/12/28 22:37:23 tg Exp $ */ +/** $MirBSD: src/bin/ksh/emacs.c,v 2.8 2004/12/31 19:37:03 tg Exp $ */ /* $OpenBSD: emacs.c,v 1.34 2004/12/23 11:29:02 jsg Exp $ */ /* @@ -13,12 +13,12 @@ #include "sh.h" #include "ksh_stat.h" -#include "ksh_dir.h" +#include #include #include #include "edit.h" -__RCSID("$MirBSD: src/bin/ksh/emacs.c,v 2.7 2004/12/28 22:37:23 tg Exp $"); +__RCSID("$MirBSD: src/bin/ksh/emacs.c,v 2.8 2004/12/31 19:37:03 tg Exp $"); static Area aedit; #define AEDIT &aedit /* area for kill ring and macro defns */ diff --git a/eval.c b/eval.c index 38fcb08..70dffe0 100644 --- a/eval.c +++ b/eval.c @@ -1,4 +1,4 @@ -/** $MirBSD: src/bin/ksh/eval.c,v 2.8 2004/12/28 22:40:39 tg Exp $ */ +/** $MirBSD: src/bin/ksh/eval.c,v 2.9 2004/12/31 19:37:03 tg Exp $ */ /* $OpenBSD: eval.c,v 1.24 2004/12/22 18:52:37 millert Exp $ */ /* @@ -7,10 +7,16 @@ #include "sh.h" #include -#include "ksh_dir.h" +#include #include "ksh_stat.h" -__RCSID("$MirBSD: src/bin/ksh/eval.c,v 2.8 2004/12/28 22:40:39 tg Exp $"); +__RCSID("$MirBSD: src/bin/ksh/eval.c,v 2.9 2004/12/31 19:37:03 tg Exp $"); + +#ifdef OPENDIR_DOES_NONDIR +extern DIR *ksh_opendir(const char *d); +#else /* OPENDIR_DOES_NONDIR */ +# define ksh_opendir(d) opendir(d) +#endif /* OPENDIR_DOES_NONDIR */ /* * string expansion @@ -1097,7 +1103,7 @@ globit(XString *xs, char **xpp, char *sp, XPtrV *wp, int check) || !gmatch(name, sp, true)) continue; - len = NLENGTH(d) + 1; + len = strlen(d->d_name) + 1; XcheckN(*xs, xp, len); memcpy(xp, name, len); *xpp = xp + len - 1; diff --git a/ksh_dir.h b/ksh_dir.h deleted file mode 100644 index 7083e77..0000000 --- a/ksh_dir.h +++ /dev/null @@ -1,32 +0,0 @@ -/** $MirBSD: src/bin/ksh/ksh_dir.h,v 2.1 2004/12/10 18:09:41 tg Exp $ */ -/* $OpenBSD: ksh_dir.h,v 1.1.1.1 1996/08/14 06:19:11 downsj Exp $ */ - -#ifndef KSH_DIR_H -#define KSH_DIR_H - -/* Wrapper around the ugly dir includes/ifdefs */ - -#if defined(HAVE_DIRENT_H) -# include -# define NLENGTH(dirent) (strlen(dirent->d_name)) -#else -# define dirent direct -# define NLENGTH(dirent) (dirent->d_namlen) -# ifdef HAVE_SYS_NDIR_H -# include -# endif /* HAVE_SYS_NDIR_H */ -# ifdef HAVE_SYS_DIR_H -# include -# endif /* HAVE_SYSDIR_H */ -# ifdef HAVE_NDIR_H -# include -# endif /* HAVE_NDIR_H */ -#endif /* HAVE_DIRENT_H */ - -#ifdef OPENDIR_DOES_NONDIR -extern DIR *ksh_opendir(const char *d); -#else /* OPENDIR_DOES_NONDIR */ -# define ksh_opendir(d) opendir(d) -#endif /* OPENDIR_DOES_NONDIR */ - -#endif /* ndef KSH_DIR_H */ diff --git a/ksh_limval.h b/ksh_limval.h deleted file mode 100644 index 356537d..0000000 --- a/ksh_limval.h +++ /dev/null @@ -1,30 +0,0 @@ -/** $MirBSD: src/bin/ksh/ksh_limval.h,v 2.1 2004/12/10 18:09:41 tg Exp $ */ -/* $OpenBSD: ksh_limval.h,v 1.1.1.1 1996/08/14 06:19:11 downsj Exp $ */ - -#ifndef KSH_LIMVAL_H -#define KSH_LIMVAL_H - -/* Wrapper around the values.h/limits.h includes/ifdefs */ - -#ifdef HAVE_VALUES_H -# include -#endif /* HAVE_VALUES_H */ -/* limits.h is included in sh.h */ - -#ifndef DMAXEXP -# define DMAXEXP 128 /* should be big enough */ -#endif - -#ifndef BITSPERBYTE -# ifdef CHAR_BIT -# define BITSPERBYTE CHAR_BIT -# else -# define BITSPERBYTE 8 /* probably true.. */ -# endif -#endif - -#ifndef BITS -# define BITS(t) (BITSPERBYTE * sizeof(t)) -#endif - -#endif /* ndef KSH_LIMVAL_H */ diff --git a/misc.c b/misc.c index c2ad16a..88b6756 100644 --- a/misc.c +++ b/misc.c @@ -1,4 +1,4 @@ -/** $MirBSD: src/bin/ksh/misc.c,v 2.9 2004/12/28 22:33:21 tg Exp $ */ +/** $MirBSD: src/bin/ksh/misc.c,v 2.10 2004/12/31 19:37:03 tg Exp $ */ /* $OpenBSD: misc.c,v 1.20 2003/10/22 07:40:38 jmc Exp $ */ /* @@ -7,13 +7,11 @@ #include "sh.h" #include /* for FILECHCONV */ -#ifdef HAVE_LIMITS_H -# include -#endif #include +#include #include "ksh_stat.h" -__RCSID("$MirBSD: src/bin/ksh/misc.c,v 2.9 2004/12/28 22:33:21 tg Exp $"); +__RCSID("$MirBSD: src/bin/ksh/misc.c,v 2.10 2004/12/31 19:37:03 tg Exp $"); #ifndef UCHAR_MAX # define UCHAR_MAX 0xFF @@ -1191,25 +1189,6 @@ reset_nonblock(int fd) # define MAXPATHLEN PATH #endif /* MAXPATHLEN */ -#ifdef HPUX_GETWD_BUG -# include "ksh_dir.h" - -/* - * Work around bug in hpux 10.x C library - getwd/getcwd dump core - * if current directory is not readable. Done in macro 'cause code - * is needed in GETWD and GETCWD cases. - */ -# define HPUX_GETWD_BUG_CODE \ - { \ - DIR *d = ksh_opendir("."); \ - if (!d) \ - return NULL; \ - closedir(d); \ - } -#else /* HPUX_GETWD_BUG */ -# define HPUX_GETWD_BUG_CODE -#endif /* HPUX_GETWD_BUG */ - /* Like getcwd(), except bsize is ignored if buf is 0 (MAXPATHLEN is used) */ char * ksh_get_wd(char *buf, int bsize) @@ -1218,9 +1197,6 @@ ksh_get_wd(char *buf, int bsize) char *b; char *ret; - /* Before memory allocated */ - HPUX_GETWD_BUG_CODE - /* Assume getcwd() available */ if (!buf) { bsize = MAXPATHLEN; diff --git a/missing.c b/missing.c index 83df359..c9355c3 100644 --- a/missing.c +++ b/missing.c @@ -1,4 +1,4 @@ -/** $MirBSD: src/bin/ksh/missing.c,v 2.5 2004/12/31 18:41:47 tg Exp $ */ +/** $MirBSD: src/bin/ksh/missing.c,v 2.6 2004/12/31 19:37:03 tg Exp $ */ /* $OpenBSD: missing.c,v 1.5 2003/05/16 18:49:46 jsyn Exp $ */ /* @@ -7,140 +7,8 @@ #include "sh.h" #include "ksh_stat.h" -#include "ksh_dir.h" -__RCSID("$MirBSD: src/bin/ksh/missing.c,v 2.5 2004/12/31 18:41:47 tg Exp $"); - -#ifndef HAVE_MEMSET -void * -memset(d, c, n) - void *d; - int c; - size_t n; -{ - unsigned char *p = (unsigned char *) d; - - /* Not amazingly fast.. */ - for (; n > 0; --n) - *p++ = c; - return d; -} -#endif /* !HAVE_MEMSET */ - -#if !defined(HAVE_MEMMOVE) && !defined(HAVE_BCOPY) -void * -memmove(d, s, n) - void *d; - const void *s; - size_t n; -{ - char *dp = (char *) d, *sp = (char *) s; - - if (n <= 0) - ; - else if (dp < sp) - do - *dp++ = *sp++; - while (--n > 0); - else if (dp > sp) { - dp += n; - sp += n; - do - *--dp = *--sp; - while (--n > 0); - } - return d; -} -#endif /* !HAVE_MEMMOVE && !HAVE_BCOPY */ - -#ifndef HAVE_STRCASECMP -/* - * Case insensitive string compare routines, same semantics as str[n]cmp() - * (assumes ASCII..). - */ -static const char ichars[256] = { - 0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, - 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x40, 'a', 'b', 'c', 'd', 'e', 'f', 'g', - 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', - 'x', 'y', 'z', 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, - 0x60, 'a', 'b', 'c', 'd', 'e', 'f', 'g', - 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', - 'x', 'y', 'z', 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, - 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, - 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, - 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, - 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, - 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, - 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, - 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, - 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, - 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, - 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff - }; - -int -strcasecmp(s1, s2) - const char *s1; - const char *s2; -{ - const unsigned char *us1 = (const unsigned char *) s1; - const unsigned char *us2 = (const unsigned char *) s2; - - while (ichars[*us1] == ichars[*us2++]) - if (!*us1++) - return 0; - - return ichars[*us1] - ichars[*--us2]; -} - -int -strncasecmp(s1, s2, n) - const char *s1; - const char *s2; - int n; -{ - const unsigned char *us1 = (const unsigned char *) s1; - const unsigned char *us2 = (const unsigned char *) s2; - - while (--n >= 0 && ichars[*us1] == ichars[*us2++]) - if (!*us1++) - return 0; - - return n < 0 ? 0 : ichars[*us1] - ichars[*--us2]; -} -#endif /* HAVE_STRCASECMP */ - -#ifndef HAVE_STRSTR -char * -strstr(s, p) - const char *s; - const char *p; -{ - int len; - - if (s && p) - for (len = strlen(p); *s; s++) - if (*s == *p && strncmp(s, p, len) == 0) - return (char *) s; - - return 0; -} -#endif /* !HAVE_STRSTR */ +__RCSID("$MirBSD: src/bin/ksh/missing.c,v 2.6 2004/12/31 19:37:03 tg Exp $"); #ifndef HAVE_STRERROR char * @@ -148,20 +16,6 @@ strerror(err) int err; { static char buf[64]; -# ifdef HAVE_SYS_ERRLIST -# ifndef SYS_ERRLIST_DECLARED - extern int sys_nerr; - extern char *sys_errlist[]; -# endif - char *p; - - if (err < 0 || err >= sys_nerr) - shf_snprintf(p = buf, sizeof(buf), "Unknown system error %d", - err); - else - p = sys_errlist[err]; - return p; -# else /* HAVE_SYS_ERRLIST */ switch (err) { case EINVAL: return "Invalid argument"; @@ -185,7 +39,6 @@ strerror(err) shf_snprintf(buf, sizeof(buf), "Unknown system error %d", err); return buf; } -# endif /* HAVE_SYS_ERRLIST */ } #endif /* !HAVE_STRERROR */ diff --git a/sh.h b/sh.h index b95dc59..7d62432 100644 --- a/sh.h +++ b/sh.h @@ -1,4 +1,4 @@ -/** $MirBSD: src/bin/ksh/sh.h,v 2.10 2004/12/31 17:29:28 tg Exp $ */ +/** $MirBSD: src/bin/ksh/sh.h,v 2.11 2004/12/31 19:37:03 tg Exp $ */ /* $OpenBSD: sh.h,v 1.23 2004/12/18 22:11:43 millert Exp $ */ #ifndef SH_H @@ -138,9 +138,6 @@ void *memmove(void *d, const void *s, size_t n); # endif /* L_SET */ #endif /* !SEEK_SET */ -/* Some machines (eg, FreeBSD 1.1.5) define CLK_TCK in limits.h - * (ksh_limval.h assumes limits has been included, if available) - */ #ifdef HAVE_LIMITS_H # include #endif /* HAVE_LIMITS_H */ diff --git a/shf.c b/shf.c index f90f12c..7fa2954 100644 --- a/shf.c +++ b/shf.c @@ -1,4 +1,4 @@ -/** $MirBSD: src/bin/ksh/shf.c,v 2.4 2004/12/31 17:42:45 tg Exp $ */ +/** $MirBSD: src/bin/ksh/shf.c,v 2.5 2004/12/31 19:37:03 tg Exp $ */ /* $OpenBSD: shf.c,v 1.10 2004/12/18 22:35:41 millert Exp $ */ /* @@ -7,9 +7,8 @@ #include "sh.h" #include "ksh_stat.h" -#include "ksh_limval.h" -__RCSID("$MirBSD: src/bin/ksh/shf.c,v 2.4 2004/12/31 17:42:45 tg Exp $"); +__RCSID("$MirBSD: src/bin/ksh/shf.c,v 2.5 2004/12/31 19:37:03 tg Exp $"); /* flags to shf_emptybuf() */ #define EB_READSW 0x01 /* about to switch to reading */ @@ -759,6 +758,9 @@ shf_smprintf(const char *fmt, ...) #undef FP /* if you want floating point stuff */ #define BUF_SIZE 128 +#ifndef DMAXEXP +# define DMAXEXP 128 /* should be big enough */ +#endif #define FPBUF_SIZE (DMAXEXP+16)/* this must be > * MAX(DMAXEXP, log10(pow(2, DSIGNIF))) * + ceil(log10(DMAXEXP)) + 8 (I think). @@ -823,7 +825,7 @@ shf_vfprintf(struct shf *shf, const char *fmt, va_list args) int flags; unsigned long lnum; /* %#o produces the longest output */ - char numbuf[(BITS(long) + 2) / 3 + 1]; + char numbuf[(8*sizeof(long) + 2) / 3 + 1]; /* this stuff for dealing with the buffer */ int nwritten = 0; #ifdef FP diff --git a/var.c b/var.c index 124db30..b3cb9aa 100644 --- a/var.c +++ b/var.c @@ -1,13 +1,12 @@ -/** $MirBSD: src/bin/ksh/var.c,v 2.7 2004/12/31 19:15:39 tg Exp $ */ +/** $MirBSD: src/bin/ksh/var.c,v 2.8 2004/12/31 19:37:03 tg Exp $ */ /* $OpenBSD: var.c,v 1.17 2004/05/08 19:42:35 deraadt Exp $ */ #include "sh.h" #include -#include "ksh_limval.h" #include "ksh_stat.h" #include -__RCSID("$MirBSD: src/bin/ksh/var.c,v 2.7 2004/12/31 19:15:39 tg Exp $"); +__RCSID("$MirBSD: src/bin/ksh/var.c,v 2.8 2004/12/31 19:37:03 tg Exp $"); /* * Variables @@ -291,7 +290,7 @@ str_val(struct tbl *vp) else { /* integer source */ /* worst case number length is when base=2, so use BITS(long) */ /* minus base # number null */ - static char strbuf[1 + 2 + 1 + BITS(long) + 1]; + static char strbuf[1 + 2 + 1 + 8*sizeof(long) + 1]; const char *digits = (vp->flag & UCASEV_AL) ? "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" : "0123456789abcdefghijklmnopqrstuvwxyz";