fix for the SUNpro 8 on yofuh's E420:

cc: Sun C 5.8 Patch 121015-04 2007/01/10
This commit is contained in:
tg 2007-06-05 19:48:47 +00:00
parent 487eff541d
commit 63c31c43e3
6 changed files with 65 additions and 18 deletions

View File

@ -1,5 +1,5 @@
#!/bin/sh
# $MirOS: src/bin/mksh/Build.sh,v 1.196 2007/06/05 19:39:20 tg Exp $
# $MirOS: src/bin/mksh/Build.sh,v 1.197 2007/06/05 19:48:45 tg Exp $
#-
# Environment used: CC CFLAGS CPP CPPFLAGS LDFLAGS LIBS NOWARN NROFF TARGET_OS
# CPPFLAGS recognised: MKSH_SMALL MKSH_ASSUME_UTF8 MKSH_NEED_MKNOD MKSH_NOPWNAM
@ -316,7 +316,10 @@ cat >scn.c <<-'EOF'
#endif
EOF
ct=unknown
eval `$CC -E scn.c | grep ct=`
eval 'v "$CC -E scn.c | grep ct= >x" 2>&'$h | sed 's/^/] /'
test $h = 1 && sed 's/^/[ /' x
eval `cat x`
rm -f x
case $ct in
gcc|sunpro) ;;
*) ct=unknown ;;
@ -398,7 +401,16 @@ if test $ct = gcc; then
ac_flags 1 wall "-Wall"
elif test $ct = sunpro; then
ac_flags 1 v "-v"
ac_flags 1 xc99 "-xc99"
fi
ac_test expstmt '' "if the compiler supports statements as expressions" <<-'EOF'
#define ksh_isspace(c) __extension__({ \
unsigned char ksh_isspace_c = (c); \
(ksh_isspace_c >= 0x09 && ksh_isspace_c <= 0x0D) || \
(ksh_isspace_c == 0x20); \
})
int main(int ac, char *av[]) { return (ksh_isspace(ac + **av)); }
EOF
#
# mksh: flavours (full/small mksh, omit certain stuff)
@ -436,6 +448,7 @@ if test 0 = $HAVE_MKSH_FULL; then
: ${HAVE_SETLOCALE_CTYPE=0}
check_categories=$check_categories,smksh
test 0 = $HAVE_MKSH_DEFUTF8 || check_categories=$check_categories,dutf
fi
#

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/Makefile,v 1.41 2007/06/04 21:55:38 tg Exp $
# $MirOS: src/bin/mksh/Makefile,v 1.42 2007/06/05 19:48:45 tg Exp $
#-
# use CPPFLAGS=-DDEBUG __CRAZY=Yes to check for certain more stuff
@ -10,8 +10,8 @@ SRCS= alloc.c edit.c eval.c exec.c expr.c funcs.c histrap.c \
.if !make(test-build)
CPPFLAGS+= -DMKSH_ASSUME_UTF8 \
-DHAVE_ATTRIBUTE=1 -DHAVE_ATTRIBUTE_BOUNDED=1 \
-DHAVE_ATTRIBUTE_USED=1 -DHAVE_SYS_PARAM_H=1 \
-DHAVE_SYS_MKDEV_H=0 -DHAVE_SYS_MMAN_H=1 \
-DHAVE_ATTRIBUTE_USED=1 -DHAVE_EXPSTMT=1 \
-DHAVE_SYS_PARAM_H=1 -DHAVE_SYS_MKDEV_H=0 -DHAVE_SYS_MMAN_H=1 \
-DHAVE_SYS_SYSMACROS_H=0 -DHAVE_LIBGEN_H=1 -DHAVE_PATHS_H=1 \
-DHAVE_STDBOOL_H=1 -DHAVE_STDINT_H=1 -DHAVE_GRP_H=1 \
-DHAVE_ULIMIT_H=0 -DHAVE_VALUES_H=0 -DHAVE_RLIM_T=1 \

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.109 2007/06/04 21:33:27 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.110 2007/06/05 19:48:46 tg Exp $
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
@ -7,7 +7,7 @@
# http://www.research.att.com/~gsf/public/ifs.sh
expected-stdout:
@(#)MIRBSD KSH R29 2007/06/04
@(#)MIRBSD KSH R29 2007/06/05
description:
Check version of shell.
category: pdksh
@ -3955,8 +3955,7 @@ expected-stdout:
name: utf8bom-3
description:
Reading the UTF-8 BOM should enable the utf8-hack flag
(unless both MKSH_ASSUME_UTF8 and MKSH_SMALL are set)
category: pdksh
category: pdksh,!dutf
stdin:
$0 -c ':; x=$(set +o); if [[ $x = *utf8* ]]; then print on; else print off; fi'
$0 -c ':; x=$(set +o); if [[ $x = *utf8* ]]; then print on; else print off; fi'

16
edit.c
View File

@ -5,7 +5,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.98 2007/05/24 19:15:46 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.99 2007/06/05 19:48:46 tg Exp $");
/* tty driver characters we are interested in */
typedef struct {
@ -765,6 +765,7 @@ static void utf_ptradj(char *, char **);
/* UTF-8 hack: high-level functions */
#if HAVE_EXPSTMT
#define utf_backch(c) \
(!Flag(FUTFHACK) ? (c) - 1 : __extension__({ \
u_char *utf_backch_cp = (u_char *)(c); \
@ -774,6 +775,19 @@ static void utf_ptradj(char *, char **);
--utf_backch_cp; \
(__typeof__ (c))utf_backch_cp; \
}))
#else
#define utf_backch(c) (!Flag(FUTFHACK) ? (c) - 1 : \
(c) + (ptrdiff_t)(utf_backch_((u_char *)c) - ((u_char *)(c))))
static u_char *utf_backch_(u_char *);
static u_char *
utf_backch_(u_char *utf_backch_cp)
{
--utf_backch_cp;
while ((*utf_backch_cp >= 0x80) && (*utf_backch_cp < 0xC0))
--utf_backch_cp;
return (utf_backch_cp);
}
#endif
int
utf_widthadj(const char *src, const char **dst)

11
misc.c
View File

@ -6,7 +6,7 @@
#include <grp.h>
#endif
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.54 2007/05/13 18:33:29 tg Exp $\t"
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.55 2007/06/05 19:48:47 tg Exp $\t"
MKSH_SH_H_ID);
#undef USE_CHVT
@ -1425,3 +1425,12 @@ stristr(const char *b, const char *l)
return (b - 1);
}
#endif
#if !HAVE_EXPSTMT
bool
ksh_isspace_(unsigned char ksh_isspace_c)
{
return ((ksh_isspace_c >= 0x09 && ksh_isspace_c <= 0x0D) ||
(ksh_isspace_c == 0x20));
}
#endif

26
sh.h
View File

@ -8,8 +8,8 @@
/* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */
/* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.140 2007/06/05 19:35:13 tg Exp $"
#define MKSH_VERSION "R29 2007/06/04"
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.141 2007/06/05 19:48:47 tg Exp $"
#define MKSH_VERSION "R29 2007/06/05"
#if HAVE_SYS_PARAM_H
#include <sys/param.h>
@ -146,12 +146,16 @@ typedef int bool;
#define ksh_toupper(c) (((c) >= 'a') && ((c) <= 'z') ? (c) - 'a' + 'A' : (c))
#define ksh_isdash(s) (((s) != NULL) && ((s)[0] == '-') && ((s)[1] == '\0'))
#if HAVE_EXPSTMT
/* this macro must not evaluate its arguments several times */
#define ksh_isspace(c) __extension__({ \
unsigned char ksh_isspace_c = (c); \
(ksh_isspace_c >= 0x09 && ksh_isspace_c <= 0x0D) || \
(ksh_isspace_c == 0x20); \
})
#define ksh_isspace(c) __extension__({ \
unsigned char ksh_isspace_c = (c); \
(ksh_isspace_c >= 0x09 && ksh_isspace_c <= 0x0D) || \
(ksh_isspace_c == 0x20); \
})
#else
#define ksh_isspace(c) ksh_isspace_((unsigned char)(c))
#endif
#ifndef S_ISTXT
#define S_ISTXT 0001000
@ -295,6 +299,7 @@ char *ucstrstr(char *, const char *);
})
#endif
#else
#if HAVE_EXPSTMT
#define cstrchr(s,c) __extension__({ \
union mksh_cchack out; \
\
@ -307,6 +312,10 @@ char *ucstrstr(char *, const char *);
out.rw = strstr((b), (l)); \
(out.ro); \
})
#else
#define cstrchr(s,c) ((const char *)strchr((s), (c)))
#define cstrstr(s,c) ((const char *)strstr((s), (c)))
#endif
#define vstrchr strchr
#define vstrstr strstr
#if HAVE_STRCASESTR
@ -1404,6 +1413,9 @@ int make_path(const char *, const char *, char **, XString *, int *);
void simplify_path(char *);
char *get_phys_path(const char *);
void set_current_wd(char *);
#if !HAVE_EXPSTMT
bool ksh_isspace_(unsigned char);
#endif
/* shf.c */
struct shf *shf_open(const char *, int, int, int);
struct shf *shf_fdopen(int, int, struct shf *);