From 4c5d7094efd275d7766ab99c153b10dd62af329c Mon Sep 17 00:00:00 2001 From: tg Date: Mon, 17 Dec 2012 22:14:27 +0000 Subject: [PATCH] RT also said what was missing on SunOS 4.1.1 (it also needs -DMKSH_UNEMPLOYED?) --- Build.sh | 23 +++++++++++++++++++++-- sh.h | 11 ++++++++++- shf.c | 21 ++++++++++++++++++++- 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/Build.sh b/Build.sh index 03ff00d..cedfa02 100644 --- a/Build.sh +++ b/Build.sh @@ -1,5 +1,5 @@ #!/bin/sh -srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.599 2012/12/17 21:55:04 tg Exp $' +srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.600 2012/12/17 22:14:24 tg Exp $' #- # Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011, 2012 @@ -1304,6 +1304,10 @@ ac_test attribute_bounded '' 'for __attribute__((__bounded__))' <<-'EOF' __attribute__((__bounded__ (__buffer__, 2, 3))); int main(int ac, char *av[]) { return (xcopy(av[0], av[--ac], 1)); } int xcopy(const void *s, void *d, size_t n) { + /* + * if memmove does not exist, we are not on a system + * with GCC with __bounded__ attribute either so poo + */ memmove(d, s, n); return ((int)n); } #endif @@ -1528,7 +1532,7 @@ else #define EXTERN #define MKSH_INCLUDES_ONLY #include "sh.h" - __RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.599 2012/12/17 21:55:04 tg Exp $"); + __RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.600 2012/12/17 22:14:24 tg Exp $"); int main(void) { printf("Hello, World!\n"); return (0); } EOF case $cm in @@ -1633,6 +1637,16 @@ ac_test killpg <<-'EOF' int main(int ac, char *av[]) { return (av[0][killpg(123, ac)]); } EOF +ac_test memmove <<-'EOF' + #include + #if HAVE_STRINGS_H + #include + #endif + int main(int ac, char *av[]) { + return ((int)memmove(av[0], av[1], ac)); + } +EOF + ac_test mknod '' 'if to use mknod(), makedev() and friends' <<-'EOF' #define MKSH_INCLUDES_ONLY #include "sh.h" @@ -1765,6 +1779,11 @@ EOF fi fi +ac_test strerror <<-'EOF' + extern char *strerror(int); + int main(int ac, char *av[]) { return (*strerror(*av[ac])); } +EOF + ac_test strlcpy <<-'EOF' #include int main(int ac, char *av[]) { return (strlcpy(*av, av[1], diff --git a/sh.h b/sh.h index 0d1395e..0bd65c3 100644 --- a/sh.h +++ b/sh.h @@ -160,7 +160,7 @@ #endif #ifdef EXTERN -__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.616 2012/12/17 21:55:06 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.617 2012/12/17 22:14:26 tg Exp $"); #endif #define MKSH_VERSION "R41 2012/12/07" @@ -354,10 +354,19 @@ extern int flock(int, int); extern int getrusage(int, struct rusage *); #endif +#if !HAVE_MEMMOVE +/* we assume either memmove or bcopy exist, at the moment */ +#define memmove(dst, src, len) bcopy((src), (dst), (len)) +#endif + #if !HAVE_REVOKE_DECL extern int revoke(const char *); #endif +#if !HAVE_STRERROR +extern char *strerror(int); +#endif + #if !HAVE_STRLCPY size_t strlcpy(char *, const char *, size_t); #endif diff --git a/shf.c b/shf.c index fefe4a6..eee2e15 100644 --- a/shf.c +++ b/shf.c @@ -24,7 +24,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/shf.c,v 1.50 2012/12/08 18:30:31 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/shf.c,v 1.51 2012/12/17 22:14:27 tg Exp $"); /* flags to shf_emptybuf() */ #define EB_READSW 0x01 /* about to switch to reading */ @@ -1077,3 +1077,22 @@ shf_putc(int c, struct shf *shf) return (shf_putc_i(c, shf)); } #endif + +#if !HAVE_STRERROR +/* + * This is absolutely minimalistic. We could catch a number of well- + * known errors (like ENOENT) and provide real error strings for them, + * but to do that, I'd like a survey of which errors usually occur on + * what systems, to be worth it. Modern systems do have strerror; this + * is a porting aid only right now. + */ +char * +strerror(int errnum) +{ + /* "Errno. " + sign + rounded(octal) bits + NUL */ + static char errbuf[7 + 1 + (8 * sizeof(int) + 2) / 3 + 1]; + + shf_snprintf(errbuf, sizeof(errbuf), "Errno. %d", errnum); + return (errbuf); +} +#endif