summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog105
-rw-r--r--Makefile2
-rw-r--r--config.make.in1
-rwxr-xr-xconfigure116
-rw-r--r--configure.in1
-rw-r--r--csu/Makefile2
-rw-r--r--elf/Makefile2
-rw-r--r--elf/dl-minimal.c12
-rw-r--r--elf/rtld.c4
-rw-r--r--iconv/gconv.c14
-rw-r--r--iconv/gconv_open.c8
-rw-r--r--iconv/gconv_simple.c110
-rw-r--r--iconv/loop.c6
-rw-r--r--iconv/skeleton.c9
-rw-r--r--iconvdata/Makefile2
-rw-r--r--iconvdata/TESTS26
-rw-r--r--iconvdata/big5.c8
-rw-r--r--iconvdata/iso8859-1.c4
-rwxr-xr-xiconvdata/run-iconv-test.sh39
-rw-r--r--iconvdata/testdata/suntzus1693
-rw-r--r--mach/Makefile8
-rw-r--r--manual/Makefile12
-rw-r--r--manual/users.texi2
-rw-r--r--manual/xtract-typefun.awk43
-rw-r--r--sysdeps/generic/dl-sysdep.c23
-rw-r--r--sysdeps/gnu/Makefile2
-rw-r--r--sysdeps/gnu/errlist.awk15
-rw-r--r--sysdeps/mach/hurd/Dist1
-rw-r--r--sysdeps/mach/hurd/Makefile2
-rw-r--r--sysdeps/mach/hurd/errlist.c26
-rw-r--r--sysdeps/unix/Makefile6
-rw-r--r--time/strftime.c5
-rw-r--r--timezone/Makefile2
-rw-r--r--wcsmbs/btowc.c2
-rw-r--r--wcsmbs/wcsnrtombs.c2
-rw-r--r--wcsmbs/wcsrtombs.c2
36 files changed, 2100 insertions, 217 deletions
diff --git a/ChangeLog b/ChangeLog
index 105bed4c21..8672e03dcd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,92 @@
+1998-04-21 18:00 Ulrich Drepper <drepper@cygnus.com>
+
+ * iconv/gconv.c (__gconv): Remove bogus input buffer size computation.
+
+ * iconv/gconv_open.c (__gconv_open): Initialize outbufend element.
+
+ * iconv/gconv_simple.c (__gconv_transform_internal_ascii): Don't use
+ character in comparison with uint32_t.
+ (__gconv_transform_internal_utf8): Specify MAX_NEEDED_TO.
+ (__gconv_transform_utf8_internal): Specify MAX_NEEDED_FROM.
+ Optimize BODY a bit.
+
+ * iconv/loop.c: Require MIN_NEEDED_INPUT and MIN_NEEDED_OUTPUT to
+ be defined.
+
+ * iconv/skeleton.c: Also reset converted counter in case of an error.
+ Call reset function using correct value for output buffer start.
+
+ * iconvdata/Makefile: Re-enable tests.
+
+ * iconvdata/iso8859-1.c: Swap MIN_NEEDED_INPUT and MIN_NEEDED_OUTPUT
+ value for to-conversion.
+
+ * iconvdata/TESTS: Add new third column.
+ * iconvdata/run-iconv-test.sh: Add support for charsets which are
+ not ASCII based.
+ * iconvdata/testdata/suntzus: New file.
+
+ * elf/dl-minimal.c (__strtol_internal): Increment pointer to string
+ while reading. Correctly used base. Little optimization.
+ (__strtoul_internal): Likewise.
+
+ * elf/rtld.c (dl_main): Test to avoid duplicate call of _dl_init_paths
+ was wrong. Use explicit variable.
+
+1998-04-20 23:49 Zack Weinberg <zack@rabi.phys.columbia.edu>
+
+ * configure.in: Check for awk.
+ * config.make.in: Add AWK to be substituted.
+
+ * manual/xtract-typefun.awk: Rewrite to eliminate gawk extensions.
+ * manual/users.texi: Fix typo exposed by above rewrite.
+
+ * Makefile: Invoke awk using AWK variable.
+ * csu/Makefile: Likewise.
+ * elf/Makefile: Likewise.
+ * mach/Makefile: Likewise.
+ * manual/Makefile: Likewise.
+ * sysdeps/gnu/Makefile: Likewise.
+ * sysdeps/mach/hurd/Makefile: Likewise.
+ * sysdeps/unix/Makefile: Likewise.
+ * timezone/Makefile: Likewise.
+
+1998-04-10 Gordon Matzigkeit <gord@profitpress.com>
+
+ * sysdeps/gnu/errlist.awk (ERR_REMAP): Implement error code to
+ array index translation.
+ (SYS_ERRLIST_ALIAS, SYS_NERR_ALIAS): Make weak aliases only if
+ these are defined.
+
+ * sysdeps/mach/hurd/Dist: Add errlist.c to distribution.
+
+ * sysdeps/mach/hurd/errlist.c: New file.
+ (ERR_TRANSLATE): Map Hurd error codes into errlist indices.
+ (_hurd_errlist): The Hurd error list doesn't have Unix sys_errlist
+ semantics, so rename it.
+
+1998-04-16 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * iconvdata/run-iconv-test.sh: Make portable. Always test all
+ conversions.
+
+1998-04-21 12:30 H.J. Lu <hjl@gnu.org>
+
+ * wcsmbs/wcsrtombs.c (__wcsrtombs): Initialize result to 0.
+ * wcsmbs/wcsnrtombs.c: Likewise.
+
+1998-04-21 Ulrich Drepper <drepper@cygnus.com>
+
+ * sysdeps/generic/dl-sysdep.c: Handle _dl_hwcap correctly.
+
+ * wcsmbs/btowc.c (__btowc): Declare inptr as const char *.
+
+ * time/strftime.c (my_strftime): Initialize pad variable in
+ declaration.
+
+ * iconvdata/big5.c: Don't use character constants in comparisons
+ with unsigned value.
+
1998-04-20 18:00 Ulrich Drepper <drepper@cygnus.com>
* libc.map: Add __dgettext to GLIBC_2.0 and __libc_longjmp, and
@@ -194,14 +283,14 @@
(_PATH_UTMPX): Define to _PATH_UTMP. (_PATH_WTMPX): Define to
_PATH_WTMPX. (RUN_LVL): Define only if __USE_GNU. (ACCOUNTING):
Define if __USE_GNU.
- * sysdeps/gnu/setutxent.c: New file.
- * sysdeps/gnu/getutxent.c: New file.
- * sysdeps/gnu/endutxent.c: New file.
- * sysdeps/gnu/getutxid.c: New file.
- * sysdeps/gnu/getutxline.c: New file.
- * sysdeps/gnu/pututxline.c: New file.
- * sysdeps/gnu/utmpxname.c: New file.
- * sysdeps/gnu/updwtmpx.c: New file.
+ * sysdeps/generic/setutxent.c: New file.
+ * sysdeps/generic/getutxent.c: New file.
+ * sysdeps/generic/endutxent.c: New file.
+ * sysdeps/generic/getutxid.c: New file.
+ * sysdeps/generic/getutxline.c: New file.
+ * sysdeps/generic/pututxline.c: New file.
+ * sysdeps/generic/utmpxname.c: New file.
+ * sysdeps/generic/updwtmpx.c: New file.
* sysdeps/unix/sysv/linux/paths.h (_PATH_UTMP_DB): Remove.
* sysdeps/generic/bits/utmpx.h: Remove.
diff --git a/Makefile b/Makefile
index 923a81ec81..1de8be7008 100644
--- a/Makefile
+++ b/Makefile
@@ -116,7 +116,7 @@ libc-init = set-init
else
libc-init = munch-init
$(objpfx)munch-init.c: munch.awk munch-tmpl.c $(+subdir_inits)
- awk -f $< subdirs='$(+init_subdirs)' $(word 2,$^) > $@-t
+ $(AWK) -f $< subdirs='$(+init_subdirs)' $(word 2,$^) > $@-t
mv -f $@-t $@
generated := $(generated) munch-init.c
endif
diff --git a/config.make.in b/config.make.in
index 0a2c873e7a..ecad392a7f 100644
--- a/config.make.in
+++ b/config.make.in
@@ -78,6 +78,7 @@ MSGFMT = @MSGFMT@
# Script execution tools.
BASH = @BASH@
KSH = @KSH@
+AWK = @AWK@
PERL = @PERL@
# More variables may be inserted below by configure.
diff --git a/configure b/configure
index 083cca461d..474b21ef67 100755
--- a/configure
+++ b/configure
@@ -1968,12 +1968,45 @@ else
fi
-for ac_prog in perl
+for ac_prog in mawk gawk nawk awk
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:1977: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_AWK'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$AWK"; then
+ ac_cv_prog_AWK="$AWK" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_AWK="$ac_prog"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+AWK="$ac_cv_prog_AWK"
+if test -n "$AWK"; then
+ echo "$ac_t""$AWK" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+test -n "$AWK" && break
+done
+
+for ac_prog in perl
+do
+# Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:2010: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_PERL'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2008,7 +2041,7 @@ test -n "$PERL" || PERL="no"
echo $ac_n "checking for signed size_t type""... $ac_c" 1>&6
-echo "configure:2012: checking for signed size_t type" >&5
+echo "configure:2045: checking for signed size_t type" >&5
if eval "test \"`echo '$''{'libc_cv_signed_size_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2032,12 +2065,12 @@ EOF
fi
echo $ac_n "checking for libc-friendly stddef.h""... $ac_c" 1>&6
-echo "configure:2036: checking for libc-friendly stddef.h" >&5
+echo "configure:2069: checking for libc-friendly stddef.h" >&5
if eval "test \"`echo '$''{'libc_cv_friendly_stddef'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2041 "configure"
+#line 2074 "configure"
#include "confdefs.h"
#define __need_size_t
#define __need_wchar_t
@@ -2052,7 +2085,7 @@ size_t size; wchar_t wchar;
if (&size == NULL || &wchar == NULL) abort ();
; return 0; }
EOF
-if { (eval echo configure:2056: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2089: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
libc_cv_friendly_stddef=yes
else
@@ -2071,7 +2104,7 @@ override stddef.h = # The installed <stddef.h> seems to be libc-friendly."
fi
echo $ac_n "checking whether we need to use -P to assemble .S files""... $ac_c" 1>&6
-echo "configure:2075: checking whether we need to use -P to assemble .S files" >&5
+echo "configure:2108: checking whether we need to use -P to assemble .S files" >&5
if eval "test \"`echo '$''{'libc_cv_need_minus_P'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2094,7 +2127,7 @@ asm-CPPFLAGS = -P # The assembler can't grok cpp's # line directives."
fi
echo $ac_n "checking for assembler global-symbol directive""... $ac_c" 1>&6
-echo "configure:2098: checking for assembler global-symbol directive" >&5
+echo "configure:2131: checking for assembler global-symbol directive" >&5
if eval "test \"`echo '$''{'libc_cv_asm_global_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2124,7 +2157,7 @@ EOF
fi
echo $ac_n "checking for .set assembler directive""... $ac_c" 1>&6
-echo "configure:2128: checking for .set assembler directive" >&5
+echo "configure:2161: checking for .set assembler directive" >&5
if eval "test \"`echo '$''{'libc_cv_asm_set_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2158,7 +2191,7 @@ EOF
fi
echo $ac_n "checking for .symver assembler directive""... $ac_c" 1>&6
-echo "configure:2162: checking for .symver assembler directive" >&5
+echo "configure:2195: checking for .symver assembler directive" >&5
if eval "test \"`echo '$''{'libc_cv_asm_symver_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2177,7 +2210,7 @@ fi
echo "$ac_t""$libc_cv_asm_symver_directive" 1>&6
echo $ac_n "checking for ld --version-script""... $ac_c" 1>&6
-echo "configure:2181: checking for ld --version-script" >&5
+echo "configure:2214: checking for ld --version-script" >&5
if eval "test \"`echo '$''{'libc_cv_ld_version_script_option'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2200,7 +2233,7 @@ EOF
if { ac_try='${CC-cc} $CFLAGS -shared -o conftest.so conftest.o
-nostartfiles -nostdlib
-Wl,--version-script,conftest.map
- 1>&5'; { (eval echo configure:2204: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; };
+ 1>&5'; { (eval echo configure:2237: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; };
then
libc_cv_ld_version_script_option=yes
else
@@ -2238,7 +2271,7 @@ if test $VERSIONING = no; then
fi
if test $elf = yes; then
echo $ac_n "checking for .previous assembler directive""... $ac_c" 1>&6
-echo "configure:2242: checking for .previous assembler directive" >&5
+echo "configure:2275: checking for .previous assembler directive" >&5
if eval "test \"`echo '$''{'libc_cv_asm_previous_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2246,7 +2279,7 @@ else
.section foo_section
.previous
EOF
- if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:2250: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
+ if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:2283: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_asm_previous_directive=yes
else
libc_cv_asm_previous_directive=no
@@ -2262,7 +2295,7 @@ EOF
else
echo $ac_n "checking for .popsection assembler directive""... $ac_c" 1>&6
-echo "configure:2266: checking for .popsection assembler directive" >&5
+echo "configure:2299: checking for .popsection assembler directive" >&5
if eval "test \"`echo '$''{'libc_cv_asm_popsection_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2270,7 +2303,7 @@ else
.pushsection foo_section
.popsection
EOF
- if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:2274: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
+ if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:2307: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_asm_popsection_directive=yes
else
libc_cv_asm_popsection_directive=no
@@ -2290,12 +2323,12 @@ fi
if test $elf != yes; then
echo $ac_n "checking for .init and .fini sections""... $ac_c" 1>&6
-echo "configure:2294: checking for .init and .fini sections" >&5
+echo "configure:2327: checking for .init and .fini sections" >&5
if eval "test \"`echo '$''{'libc_cv_have_initfini'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2299 "configure"
+#line 2332 "configure"
#include "confdefs.h"
int main() {
@@ -2304,7 +2337,7 @@ asm (".section .init");
asm (".text");
; return 0; }
EOF
-if { (eval echo configure:2308: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2341: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
libc_cv_have_initfini=yes
else
@@ -2332,19 +2365,19 @@ if test $elf = yes; then
else
if test $ac_cv_prog_cc_works = yes; then
echo $ac_n "checking for _ prefix on C symbol names""... $ac_c" 1>&6
-echo "configure:2336: checking for _ prefix on C symbol names" >&5
+echo "configure:2369: checking for _ prefix on C symbol names" >&5
if eval "test \"`echo '$''{'libc_cv_asm_underscores'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2341 "configure"
+#line 2374 "configure"
#include "confdefs.h"
asm ("_glibc_foobar:");
int main() {
glibc_foobar ();
; return 0; }
EOF
-if { (eval echo configure:2348: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2381: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
libc_cv_asm_underscores=yes
else
@@ -2359,17 +2392,17 @@ fi
echo "$ac_t""$libc_cv_asm_underscores" 1>&6
else
echo $ac_n "checking for _ prefix on C symbol names""... $ac_c" 1>&6
-echo "configure:2363: checking for _ prefix on C symbol names" >&5
+echo "configure:2396: checking for _ prefix on C symbol names" >&5
if eval "test \"`echo '$''{'libc_cv_asm_underscores'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2368 "configure"
+#line 2401 "configure"
#include "confdefs.h"
void underscore_test(void) {
return; }
EOF
-if { (eval echo configure:2373: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2406: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if grep _underscore_test conftest* >/dev/null; then
rm -f conftest*
libc_cv_asm_underscores=yes
@@ -2401,7 +2434,7 @@ if test $elf = yes; then
fi
echo $ac_n "checking for assembler .weak directive""... $ac_c" 1>&6
-echo "configure:2405: checking for assembler .weak directive" >&5
+echo "configure:2438: checking for assembler .weak directive" >&5
if eval "test \"`echo '$''{'libc_cv_asm_weak_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2424,7 +2457,7 @@ echo "$ac_t""$libc_cv_asm_weak_directive" 1>&6
if test $libc_cv_asm_weak_directive = no; then
echo $ac_n "checking for assembler .weakext directive""... $ac_c" 1>&6
-echo "configure:2428: checking for assembler .weakext directive" >&5
+echo "configure:2461: checking for assembler .weakext directive" >&5
if eval "test \"`echo '$''{'libc_cv_asm_weakext_directive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2462,7 +2495,7 @@ EOF
fi
echo $ac_n "checking for ld --no-whole-archive""... $ac_c" 1>&6
-echo "configure:2466: checking for ld --no-whole-archive" >&5
+echo "configure:2499: checking for ld --no-whole-archive" >&5
if eval "test \"`echo '$''{'libc_cv_ld_no_whole_archive'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2473,7 +2506,7 @@ __throw () {}
EOF
if { ac_try='${CC-cc} $CFLAGS
-nostdlib -nostartfiles -Wl,--no-whole-archive
- -o conftest conftest.c 1>&5'; { (eval echo configure:2477: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
+ -o conftest conftest.c 1>&5'; { (eval echo configure:2510: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_ld_no_whole_archive=yes
else
libc_cv_ld_no_whole_archive=no
@@ -2484,7 +2517,7 @@ fi
echo "$ac_t""$libc_cv_ld_no_whole_archive" 1>&6
echo $ac_n "checking for gcc -fno-exceptions""... $ac_c" 1>&6
-echo "configure:2488: checking for gcc -fno-exceptions" >&5
+echo "configure:2521: checking for gcc -fno-exceptions" >&5
if eval "test \"`echo '$''{'libc_cv_gcc_no_exceptions'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2495,7 +2528,7 @@ __throw () {}
EOF
if { ac_try='${CC-cc} $CFLAGS
-nostdlib -nostartfiles -fno-exceptions
- -o conftest conftest.c 1>&5'; { (eval echo configure:2499: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
+ -o conftest conftest.c 1>&5'; { (eval echo configure:2532: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_gcc_no_exceptions=yes
else
libc_cv_gcc_no_exceptions=no
@@ -2507,14 +2540,14 @@ echo "$ac_t""$libc_cv_gcc_no_exceptions" 1>&6
if test "$base_machine" = alpha ; then
echo $ac_n "checking for function ..ng prefix""... $ac_c" 1>&6
-echo "configure:2511: checking for function ..ng prefix" >&5
+echo "configure:2544: checking for function ..ng prefix" >&5
if eval "test \"`echo '$''{'libc_cv_gcc_alpha_ng_prefix'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.c <<\EOF
foo () { }
EOF
-if { ac_try='${CC-cc} -S conftest.c -o - | fgrep "\$foo..ng" > /dev/null'; { (eval echo configure:2518: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; };
+if { ac_try='${CC-cc} -S conftest.c -o - | fgrep "\$foo..ng" > /dev/null'; { (eval echo configure:2551: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; };
then
libc_cv_gcc_alpha_ng_prefix=yes
else
@@ -2538,12 +2571,12 @@ fi
fi
echo $ac_n "checking for DWARF2 unwind info support""... $ac_c" 1>&6
-echo "configure:2542: checking for DWARF2 unwind info support" >&5
+echo "configure:2575: checking for DWARF2 unwind info support" >&5
if eval "test \"`echo '$''{'libc_cv_gcc_dwarf2_unwind_info'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.c <<EOF
-#line 2547 "configure"
+#line 2580 "configure"
static char __EH_FRAME_BEGIN__;
_start ()
{
@@ -2570,7 +2603,7 @@ __bzero () {}
EOF
if { ac_try='${CC-cc} $CFLAGS -DCHECK__register_frame_info
-nostdlib -nostartfiles
- -o conftest conftest.c -lgcc >&5'; { (eval echo configure:2574: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
+ -o conftest conftest.c -lgcc >&5'; { (eval echo configure:2607: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_gcc_dwarf2_unwind_info=static
else
libc_cv_gcc_dwarf2_unwind_info=no
@@ -2578,7 +2611,7 @@ fi
if test $libc_cv_gcc_dwarf2_unwind_info = no; then
if { ac_try='${CC-cc} $CFLAGS -DCHECK__register_frame
-nostdlib -nostartfiles
- -o conftest conftest.c -lgcc >&5'; { (eval echo configure:2582: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
+ -o conftest conftest.c -lgcc >&5'; { (eval echo configure:2615: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
libc_cv_gcc_dwarf2_unwind_info=yes
else
libc_cv_gcc_dwarf2_unwind_info=no
@@ -2652,7 +2685,7 @@ if test "$uname" = "sysdeps/generic"; then
fi
echo $ac_n "checking OS release for uname""... $ac_c" 1>&6
-echo "configure:2656: checking OS release for uname" >&5
+echo "configure:2689: checking OS release for uname" >&5
if eval "test \"`echo '$''{'libc_cv_uname_release'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2674,7 +2707,7 @@ echo "$ac_t""$libc_cv_uname_release" 1>&6
uname_release="$libc_cv_uname_release"
echo $ac_n "checking OS version for uname""... $ac_c" 1>&6
-echo "configure:2678: checking OS version for uname" >&5
+echo "configure:2711: checking OS version for uname" >&5
if eval "test \"`echo '$''{'libc_cv_uname_version'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2696,7 +2729,7 @@ else
fi
echo $ac_n "checking stdio selection""... $ac_c" 1>&6
-echo "configure:2700: checking stdio selection" >&5
+echo "configure:2733: checking stdio selection" >&5
case $stdio in
libio) cat >> confdefs.h <<\EOF
@@ -2708,7 +2741,7 @@ esac
echo "$ac_t""$stdio" 1>&6
echo $ac_n "checking ldap selection""... $ac_c" 1>&6
-echo "configure:2712: checking ldap selection" >&5
+echo "configure:2745: checking ldap selection" >&5
case $add_ons in
*ldap*)
@@ -2759,7 +2792,7 @@ if test $shared = default; then
fi
echo $ac_n "checking whether -fPIC is default""... $ac_c" 1>&6
-echo "configure:2763: checking whether -fPIC is default" >&5
+echo "configure:2796: checking whether -fPIC is default" >&5
if eval "test \"`echo '$''{'pic_default'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2961,6 +2994,7 @@ s%@BASH@%$BASH%g
s%@libc_cv_have_bash2@%$libc_cv_have_bash2%g
s%@KSH@%$KSH%g
s%@libc_cv_have_ksh@%$libc_cv_have_ksh%g
+s%@AWK@%$AWK%g
s%@PERL@%$PERL%g
s%@VERSIONING@%$VERSIONING%g
s%@libc_cv_have_initfini@%$libc_cv_have_initfini%g
diff --git a/configure.in b/configure.in
index aca7dd1031..b7727c3459 100644
--- a/configure.in
+++ b/configure.in
@@ -557,6 +557,7 @@ else
fi
AC_SUBST(libc_cv_have_ksh)
+AC_PROG_AWK
AC_PATH_PROGS(PERL, perl, no)
AC_SUBST(PERL)
diff --git a/csu/Makefile b/csu/Makefile
index 7482cafc9c..da17b2c301 100644
--- a/csu/Makefile
+++ b/csu/Makefile
@@ -85,7 +85,7 @@ $(objpfx)crtn.S: $(objpfx)initfini.s
$(objpfx)defs.h: $(objpfx)initfini.s
sed -n -e '/@TESTS_BEGIN/,/@TESTS_END/p' $< | \
- awk -f defs.awk > $@
+ $(AWK) -f defs.awk > $@
endif
diff --git a/elf/Makefile b/elf/Makefile
index 8ad8d98f10..9ce3ac51e2 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -146,7 +146,7 @@ $(objpfx)trusted-dirs.h: Makefile $(..)Makeconfig
mv -f $@T $@
$(objpfx)rtldtbl.h: Makefile $(..)Makeconfig genrtldtbl.awk
$(make-target-directory)
- echo "$(default-rpath)" | awk -f genrtldtbl.awk > $@T
+ echo "$(default-rpath)" | $(AWK) -f genrtldtbl.awk > $@T
mv -f $@T $@
CPPFLAGS-dl-load.c = -I$(objpfx).
CFLAGS-dl-load.c += -Wno-uninitialized
diff --git a/elf/dl-minimal.c b/elf/dl-minimal.c
index 70b5aeeeac..249ff71225 100644
--- a/elf/dl-minimal.c
+++ b/elf/dl-minimal.c
@@ -233,6 +233,7 @@ __strtol_internal (const char *nptr, char **endptr, int base, int group)
}
assert (base == 0);
+ base = 10;
if (*nptr == '0')
{
if (nptr[1] == 'x' || nptr[1] == 'X')
@@ -243,8 +244,6 @@ __strtol_internal (const char *nptr, char **endptr, int base, int group)
else
base = 8;
}
- else
- base = 10;
while (*nptr >= '0' && *nptr <= '9')
{
@@ -257,8 +256,9 @@ __strtol_internal (const char *nptr, char **endptr, int base, int group)
errno = ERANGE;
return sign > 0 ? LONG_MAX : LONG_MIN;
}
- result *= 10;
+ result *= base;
result += digval;
+ ++nptr;
}
return (long int) result * sign;
@@ -295,6 +295,7 @@ __strtoul_internal (const char *nptr, char **endptr, int base, int group)
}
assert (base == 0);
+ base = 10;
if (*nptr == '0')
{
if (nptr[1] == 'x' || nptr[1] == 'X')
@@ -305,8 +306,6 @@ __strtoul_internal (const char *nptr, char **endptr, int base, int group)
else
base = 8;
}
- else
- base = 10;
while (*nptr >= '0' && *nptr <= '9')
{
@@ -317,8 +316,9 @@ __strtoul_internal (const char *nptr, char **endptr, int base, int group)
errno = ERANGE;
return ULONG_MAX;
}
- result *= 10;
+ result *= base;
result += digval;
+ ++nptr;
}
return result * sign;
diff --git a/elf/rtld.c b/elf/rtld.c
index b07a076b69..6b1a5c2b73 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -287,6 +287,7 @@ dl_main (const ElfW(Phdr) *phdr,
char *file;
int has_interp = 0;
unsigned int i;
+ int paths_initialized = 0;
/* Process the environment variable which control the behaviour. */
process_envvars (&mode, &lazy);
@@ -376,6 +377,7 @@ of this helper program; chances are you did not intend to run this program.\n\
/* Initialize the data structures for the search paths for shared
objects. */
_dl_init_paths (library_path);
+ paths_initialized = 1;
if (mode == verify)
{
@@ -493,7 +495,7 @@ of this helper program; chances are you did not intend to run this program.\n\
_exit (0);
}
- if (*user_entry != (ElfW(Addr)) &ENTRY_POINT)
+ if (! paths_initialized)
/* Initialize the data structures for the search paths for shared
objects. */
_dl_init_paths (library_path);
diff --git a/iconv/gconv.c b/iconv/gconv.c
index aa58bdba7d..24dc21e2c2 100644
--- a/iconv/gconv.c
+++ b/iconv/gconv.c
@@ -51,19 +51,9 @@ __gconv (gconv_t cd, const char **inbuf, const char *inbufend, char **outbuf,
do
{
- /* See whether the input size is reasoable for the output
- size. If not adjust it. */
- size_t inlen = ((inbufend - *inbuf) / cd->steps->max_needed_from
- * cd->steps->max_needed_from);
-
- if (cd->nsteps > 1)
- inlen = MIN (inlen, (((outbufend - cd->data[last_step].outbuf)
- / cd->steps[last_step].max_needed_to)
- * cd->steps[last_step].max_needed_to));
-
last_start = *inbuf;
- result = (*cd->steps->fct) (cd->steps, cd->data, inbuf,
- *inbuf + inlen, converted, 0);
+ result = (*cd->steps->fct) (cd->steps, cd->data, inbuf, inbufend,
+ converted, 0);
}
while (result == GCONV_EMPTY_INPUT && last_start != *inbuf
&& *inbuf + cd->steps->min_needed_from <= inbufend);
diff --git a/iconv/gconv_open.c b/iconv/gconv_open.c
index 831794fc22..d7e0191cca 100644
--- a/iconv/gconv_open.c
+++ b/iconv/gconv_open.c
@@ -71,14 +71,16 @@ __gconv_open (const char *toset, const char *fromset, gconv_t *handle)
/* Allocate the buffer. */
if (!data[cnt].is_last)
{
- data[cnt].outbuf =
- (char *) malloc (GCONV_NCHAR_GOAL
- * steps[cnt].max_needed_to);
+ size_t size = (GCONV_NCHAR_GOAL
+ * steps[cnt].max_needed_to);
+
+ data[cnt].outbuf = (char *) malloc (size);
if (data[cnt].outbuf == NULL)
{
res = GCONV_NOMEM;
break;
}
+ data[cnt].outbufend = data[cnt].outbuf + size;
}
}
}
diff --git a/iconv/gconv_simple.c b/iconv/gconv_simple.c
index f2fec12fb8..95b4a66daf 100644
--- a/iconv/gconv_simple.c
+++ b/iconv/gconv_simple.c
@@ -181,7 +181,7 @@ internal_ucs4_loop (const unsigned char **inptrp, const unsigned char *inend,
#define LOOPFCT FROM_LOOP
#define BODY \
{ \
- if (*((uint32_t *) inptr) > '\x7f') \
+ if (*((uint32_t *) inptr) > 0x7f) \
{ \
/* This is no correct ANSI_X3.4-1968 character. */ \
result = GCONV_ILLEGAL_INPUT; \
@@ -208,6 +208,7 @@ internal_ucs4_loop (const unsigned char **inptrp, const unsigned char *inend,
#define MIN_NEEDED_INPUT MIN_NEEDED_FROM
#define MIN_NEEDED_OUTPUT MIN_NEEDED_TO
+#define MAX_NEEDED_OUTPUT MAX_NEEDED_TO
#define LOOPFCT FROM_LOOP
#define BODY \
{ \
@@ -266,6 +267,7 @@ internal_ucs4_loop (const unsigned char **inptrp, const unsigned char *inend,
#define FUNCTION_NAME __gconv_transform_utf8_internal
#define MIN_NEEDED_INPUT MIN_NEEDED_FROM
+#define MAX_NEEDED_INPUT MAX_NEEDED_FROM
#define MIN_NEEDED_OUTPUT MIN_NEEDED_TO
#define LOOPFCT FROM_LOOP
#define BODY \
@@ -278,69 +280,75 @@ internal_ucs4_loop (const unsigned char **inptrp, const unsigned char *inend,
ch = *inptr; \
\
if (ch < 0x80) \
- /* One byte sequence. */ \
- cnt = 1; \
- else if ((ch & 0xe0) == 0xc0) \
{ \
- cnt = 2; \
- ch &= 0x1f; \
- } \
- else if ((ch & 0xf0) == 0xe0) \
- { \
- /* We expect three bytes. */ \
- cnt = 3; \
- ch &= 0x0f; \
- } \
- else if ((ch & 0xf8) == 0xf0) \
- { \
- /* We expect four bytes. */ \
- cnt = 4; \
- ch &= 0x07; \
- } \
- else if ((ch & 0xfc) == 0xf8) \
- { \
- /* We expect five bytes. */ \
- cnt = 5; \
- ch &= 0x03; \
- } \
- else if ((ch & 0xfe) == 0xfc) \
- { \
- /* We expect six bytes. */ \
- cnt = 6; \
- ch &= 0x01; \
+ /* One byte sequence. */ \
+ cnt = 1; \
+ ++inptr; \
} \
else \
{ \
- /* This is an illegal encoding. */ \
- result = GCONV_ILLEGAL_INPUT; \
- break; \
- } \
- \
- if (NEED_LENGTH_TEST && inptr + cnt >= inend) \
- { \
- /* We don't have enough input. */ \
- result = GCONV_INCOMPLETE_INPUT; \
- break; \
- } \
- \
- /* Read the possible remaining bytes. */ \
- for (i = 1; i < cnt; ++i) \
- { \
- uint32_t byte = inptr[i]; \
- \
- if ((byte & 0xc0) != 0x80) \
+ if ((ch & 0xe0) == 0xc0) \
+ { \
+ cnt = 2; \
+ ch &= 0x1f; \
+ } \
+ else if ((ch & 0xf0) == 0xe0) \
+ { \
+ /* We expect three bytes. */ \
+ cnt = 3; \
+ ch &= 0x0f; \
+ } \
+ else if ((ch & 0xf8) == 0xf0) \
+ { \
+ /* We expect four bytes. */ \
+ cnt = 4; \
+ ch &= 0x07; \
+ } \
+ else if ((ch & 0xfc) == 0xf8) \
+ { \
+ /* We expect five bytes. */ \
+ cnt = 5; \
+ ch &= 0x03; \
+ } \
+ else if ((ch & 0xfe) == 0xfc) \
+ { \
+ /* We expect six bytes. */ \
+ cnt = 6; \
+ ch &= 0x01; \
+ } \
+ else \
{ \
/* This is an illegal encoding. */ \
result = GCONV_ILLEGAL_INPUT; \
break; \
} \
\
- ch <<= 6; \
- ch |= byte & 0x3f; \
+ if (NEED_LENGTH_TEST && inptr + cnt > inend) \
+ { \
+ /* We don't have enough input. */ \
+ result = GCONV_INCOMPLETE_INPUT; \
+ break; \
+ } \
+ \
+ /* Read the possible remaining bytes. */ \
+ for (i = 1; i < cnt; ++i) \
+ { \
+ uint32_t byte = inptr[i]; \
+ \
+ if ((byte & 0xc0) != 0x80) \
+ { \
+ /* This is an illegal encoding. */ \
+ result = GCONV_ILLEGAL_INPUT; \
+ break; \
+ } \
+ \
+ ch <<= 6; \
+ ch |= byte & 0x3f; \
+ } \
+ inptr += cnt; \
} \
\
/* Now adjust the pointers and store the result. */ \
- inptr += cnt; \
*((uint32_t *) outptr)++ = ch; \
}
#include <iconv/loop.c>
diff --git a/iconv/loop.c b/iconv/loop.c
index b8657d574c..e1c1ab6e49 100644
--- a/iconv/loop.c
+++ b/iconv/loop.c
@@ -32,8 +32,6 @@
bytes needed. It defaults to MIN_NEEDED_INPUT
MAX_NEEDED_OUTPUT likewise for output bytes.
- Both values have a default of 1.
-
LOOPFCT name of the function created. If not specified
the name is `loop' but this prevents the use
of multiple functions in the same file.
@@ -55,7 +53,7 @@
/* We need at least one byte for the next round. */
#ifndef MIN_NEEDED_INPUT
-# define MIN_NEEDED_INPUT 1
+# error "MIN_NEEDED_INPUT definition missing"
#endif
/* Let's see how many bytes we produce. */
@@ -65,7 +63,7 @@
/* We produce at least one byte in the next round. */
#ifndef MIN_NEEDED_OUTPUT
-# define MIN_NEEDED_OUTPUT 1
+# error "MIN_NEEDED_OUTPUT definition missing"
#endif
/* Let's see how many bytes we produce. */
diff --git a/iconv/skeleton.c b/iconv/skeleton.c
index 3582f14110..f905bcdaea 100644
--- a/iconv/skeleton.c
+++ b/iconv/skeleton.c
@@ -196,6 +196,7 @@ FUNCTION_NAME (struct gconv_step *step, struct gconv_step_data *data,
/* This variable is used to count the number of characters we
actually converted. */
size_t converted = 0;
+ size_t last_converted;
/* We preserve the initial values of the pointer variables. */
const char *inptr = *inbuf;
@@ -211,6 +212,7 @@ FUNCTION_NAME (struct gconv_step *step, struct gconv_step_data *data,
outptr = outbuf;
/* Save the state. */
+ last_converted = converted;
#ifdef SAVE_RESET_STATE
SAVE_RESET_STATE (1);
#endif
@@ -242,7 +244,7 @@ FUNCTION_NAME (struct gconv_step *step, struct gconv_step_data *data,
/* Write out all output which was produced. */
if (outbuf > outptr)
{
- const char *outerr = outbuf;
+ const char *outerr = data->outbuf;
int result;
result = (*fct) (next_step, next_data, &outerr, outbuf,
@@ -264,6 +266,7 @@ FUNCTION_NAME (struct gconv_step *step, struct gconv_step_data *data,
outbuf = outptr;
/* Reset the state. */
+ converted = last_converted;
# ifdef SAVE_RESET_STATE
SAVE_RESET_STATE (0);
# endif
@@ -287,8 +290,8 @@ FUNCTION_NAME (struct gconv_step *step, struct gconv_step_data *data,
/* We must run out of output buffer space in this
rerun. */
- assert (nstatus == GCONV_FULL_OUTPUT
- && outbuf == outerr);
+ assert (outbuf == outerr);
+ assert (nstatus == GCONV_FULL_OUTPUT);
#endif /* reset input buffer */
}
diff --git a/iconvdata/Makefile b/iconvdata/Makefile
index 69576859ec..c590ab20b4 100644
--- a/iconvdata/Makefile
+++ b/iconvdata/Makefile
@@ -211,7 +211,7 @@ endif
include ../Rules
.PHONY: do-iconv-test
-#tests: do-iconv-test
+tests: do-iconv-test
do-iconv-test: run-iconv-test.sh $(objpfx)gconv-modules \
$(addprefix $(objpfx),$(modules.so)) \
diff --git a/iconvdata/TESTS b/iconvdata/TESTS
index 41d7edcaf1..c37381e70d 100644
--- a/iconvdata/TESTS
+++ b/iconvdata/TESTS
@@ -18,22 +18,24 @@
# write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
-# Each line consists of at least three entries:
+# Each line consists of at least four entries:
# 1. input file name.
# 2. output file name; this is different from the input file name only for
# conversions which do not produce the same output when the transformation
# is applied back and forth.
-# 3.
+# 3. Y or N depending of whether the character set contains ASCII as a
+# subset or not.
+# 4.
# ...
# N. target coded character set.
-ISO-8859-1 ISO-8859-1 UTF8
-ISO-8859-2 ISO-8859-2 UCS4 UTF8
-ISO-8859-3 ISO-8859-3 UTF8
-ISO-8859-4 ISO-8859-4 UTF8
-ISO-8859-5 ISO-8859-5 UTF8
-ISO-8859-6 ISO-8859-6 UTF8
-ISO-8859-7 ISO-8859-7 UTF8
-ISO-8859-8 ISO-8859-8 UTF8
-ISO-8859-9 ISO-8859-9 UTF8
-ISO-8859-10 ISO-8859-10 UCS2 UTF8
+ISO-8859-1 ISO-8859-1 Y UTF8
+ISO-8859-2 ISO-8859-2 Y UCS4 UTF8
+ISO-8859-3 ISO-8859-3 Y UTF8
+ISO-8859-4 ISO-8859-4 Y UTF8
+ISO-8859-5 ISO-8859-5 Y UTF8
+ISO-8859-6 ISO-8859-6 Y UTF8
+ISO-8859-7 ISO-8859-7 Y UTF8
+ISO-8859-8 ISO-8859-8 Y UTF8
+ISO-8859-9 ISO-8859-9 Y UTF8
+ISO-8859-10 ISO-8859-10 Y UCS2 UTF8
diff --git a/iconvdata/big5.c b/iconvdata/big5.c
index 2962712167..d4d89a04ff 100644
--- a/iconvdata/big5.c
+++ b/iconvdata/big5.c
@@ -8431,7 +8431,7 @@ static const char from_ucs4_tab13[][2] =
{ \
uint32_t ch = *inptr; \
\
- if (ch >= '\xa1' && ch <= '\xff') \
+ if (ch >= 0xa1 && ch <= 0xff) \
{ \
/* Two-byte character. First test whether the next character \
is also available. */ \
@@ -8448,9 +8448,9 @@ static const char from_ucs4_tab13[][2] =
idx = (ch - 0xa1) * 157; \
ch2 = inptr[1]; \
/* See whether the second byte is in the correct range. */ \
- if (ch2 >= '\x40' && ch2 <= '\x7e') \
+ if (ch2 >= 0x40 && ch2 <= 0x7e) \
idx += ch2 - 0x40; \
- else if (ch2 >= '\xa1' && ch2 <= '\xfe') \
+ else if (ch2 >= 0xa1 && ch2 <= 0xfe) \
idx += 0x3f + (ch2 - 0xa1); \
else \
{ \
@@ -8463,7 +8463,7 @@ static const char from_ucs4_tab13[][2] =
ch = big5_to_ucs[idx]; \
\
/* Is this character defined? */ \
- if (ch == L'\0' && *inptr != '\0') \
+ if (ch == 0 && *inptr != '\0') \
{ \
/* This is an illegal character. */ \
result = GCONV_ILLEGAL_INPUT; \
diff --git a/iconvdata/iso8859-1.c b/iconvdata/iso8859-1.c
index 3e50b79f17..c7b35b37dc 100644
--- a/iconvdata/iso8859-1.c
+++ b/iconvdata/iso8859-1.c
@@ -39,8 +39,8 @@
/* Next, define the other direction. */
-#define MIN_NEEDED_INPUT MIN_NEEDED_FROM
-#define MIN_NEEDED_OUTPUT MIN_NEEDED_TO
+#define MIN_NEEDED_INPUT MIN_NEEDED_TO
+#define MIN_NEEDED_OUTPUT MIN_NEEDED_FROM
#define LOOPFCT TO_LOOP
#define BODY \
{ \
diff --git a/iconvdata/run-iconv-test.sh b/iconvdata/run-iconv-test.sh
index af6a136c4a..45061373cf 100755
--- a/iconvdata/run-iconv-test.sh
+++ b/iconvdata/run-iconv-test.sh
@@ -37,37 +37,50 @@ ICONV="$codir/elf/ld.so --library-path $codir $codir/iconv/iconv_prog"
# We read the file named TESTS. All non-empty lines not starting with
# `#' are interpreted as commands.
-while read from to targets; do
+failed=0
+while read from to subset targets; do
# Ignore empty and comment lines.
if test -z "$targets" || test "$from" = '#'; then continue; fi
for t in $targets; do
$ICONV -f $from -t $t testdata/$from > $temp1 ||
- { echo "*** conversion from $from to $t failed"; exit 1; }
+ { echo "*** conversion from $from to $t failed"; failed=1; }
if test -s testdata/$from..$t; then
cmp $temp1 testdata/$from..$t >& /dev/null ||
- { echo "*** $from -> $t conversion failed"; exit 1; }
+ { echo "*** $from -> $t conversion failed"; failed=1; }
fi
$ICONV -f $t -t $to -o $temp2 $temp1 ||
- { echo "*** conversion from $t to $to failed"; exit 1; }
+ { echo "*** conversion from $t to $to failed"; failed=1; }
test -s $temp1 && cmp testdata/$from $temp2 >& /dev/null ||
- { echo "*** $from -> t -> $to conversion failed"; exit 1; }
+ { echo "*** $from -> t -> $to conversion failed"; failed=1; }
rm -f $temp1 $temp2
- # Now test some bigger text, entirely in ASCII.
- $ICONV -f $from -t $t testdata/suntzus |
- $ICONV -f $t -t $to > $temp1 ||
- { echo "*** conversion $from->$t->$to of suntzus failed"; exit 1; }
- cmp testdata/suntzus.txt $temp1 ||
- { echo "*** conversion $from->$t->$to of suntzus incorrect"; exit 1; }
+ # Now test some bigger text, entirely in ASCII. If ASCII is no subset
+ # of the coded character set we test we convert the test to this
+ # coded character set. Otherwise we convert to all the TARGETS.
+ if test $subset = Y; then
+ $ICONV -f $from -t $t testdata/suntzus |
+ $ICONV -f $t -t $to > $temp1 ||
+ { echo "*** conversion $from->$t->$to of suntzus failed"; failed=1; }
+ cmp testdata/suntzus $temp1 ||
+ { echo "*** conversion $from->$t->$to of suntzus incorrect";
+ failed=1; }
+ else
+ $ICONV -f ASCII -t $to testdata/suntzus |
+ $ICONV -f $to -f ASCII > $temp1 ||
+ { echo "*** conversion ASCII->$to->ASCII of suntzus failed";
+ failed=1; }
+ cmp testdata/suntzus $temp1 ||
+ { echo "*** conversion ASCII->$to->ASCII of suntzus incorrect";
+ failed=1; }
+ fi
rm -f $temp1
-
# All tests ok.
echo "$from -> $t -> $to ok"
done
done < TESTS
-exit $?
+exit $failed
# Local Variables:
# mode:shell-script
# End:
diff --git a/iconvdata/testdata/suntzus b/iconvdata/testdata/suntzus
new file mode 100644
index 0000000000..4432c05674
--- /dev/null
+++ b/iconvdata/testdata/suntzus
@@ -0,0 +1,1693 @@
+
+
+
+
+ SUN TZU ON THE ART OF WAR
+ THE OLDEST MILITARY TREATISE IN THE WORLD
+
+ Translated from the Chinese
+ By LIONEL GILES, M.A. (1910)
+
+
+
+[This is the basic text of Sun Tzu on the Art of War. It was
+extracted from Mr. Giles' complete work as titled above. The
+commentary itself, which, of course includes this work embedded
+within it, has been released as suntzu10.txt (or suntzu10.zip).
+This is being released only as an adjunct to that work, which
+contains a wealth of commentary upon this text.]
+
+
+
+
+I. LAYING PLANS
+
+
+ 1. Sun Tzu said: The art of war is of vital importance
+ to the State.
+
+ 2. It is a matter of life and death, a road either
+ to safety or to ruin. Hence it is a subject of inquiry
+ which can on no account be neglected.
+
+ 3. The art of war, then, is governed by five constant
+ factors, to be taken into account in one's deliberations,
+ when seeking to determine the conditions obtaining in the field.
+
+ 4. These are: (1) The Moral Law; (2) Heaven; (3) Earth;
+ (4) The Commander; (5) Method and discipline.
+
+5,6. The Moral Law causes the people to be in complete
+ accord with their ruler, so that they will follow him
+ regardless of their lives, undismayed by any danger.
+
+ 7. Heaven signifies night and day, cold and heat,
+ times and seasons.
+
+ 8. Earth comprises distances, great and small;
+ danger and security; open ground and narrow passes;
+ the chances of life and death.
+
+ 9. The Commander stands for the virtues of wisdom,
+ sincerely, benevolence, courage and strictness.
+
+10. By method and discipline are to be understood
+ the marshaling of the army in its proper subdivisions,
+ the graduations of rank among the officers, the maintenance
+ of roads by which supplies may reach the army, and the
+ control of military expenditure.
+
+11. These five heads should be familiar to every general:
+ he who knows them will be victorious; he who knows them
+ not will fail.
+
+12. Therefore, in your deliberations, when seeking
+ to determine the military conditions, let them be made
+ the basis of a comparison, in this wise:--
+
+13. (1) Which of the two sovereigns is imbued
+ with the Moral law?
+ (2) Which of the two generals has most ability?
+ (3) With whom lie the advantages derived from Heaven
+ and Earth?
+ (4) On which side is discipline most rigorously enforced?
+ (5) Which army is stronger?
+ (6) On which side are officers and men more highly trained?
+ (7) In which army is there the greater constancy
+ both in reward and punishment?
+
+14. By means of these seven considerations I can
+ forecast victory or defeat.
+
+15. The general that hearkens to my counsel and acts
+ upon it, will conquer: let such a one be retained in command!
+ The general that hearkens not to my counsel nor acts upon it,
+ will suffer defeat:--let such a one be dismissed!
+
+16. While heading the profit of my counsel,
+ avail yourself also of any helpful circumstances
+ over and beyond the ordinary rules.
+
+17. According as circumstances are favorable,
+ one should modify one's plans.
+
+18. All warfare is based on deception.
+
+19. Hence, when able to attack, we must seem unable;
+ when using our forces, we must seem inactive; when we
+ are near, we must make the enemy believe we are far away;
+ when far away, we must make him believe we are near.
+
+20. Hold out baits to entice the enemy. Feign disorder,
+ and crush him.
+
+21. If he is secure at all points, be prepared for him.
+ If he is in superior strength, evade him.
+
+22. If your opponent is of choleric temper, seek to
+ irritate him. Pretend to be weak, that he may grow arrogant.
+
+23. If he is taking his ease, give him no rest.
+ If his forces are united, separate them.
+
+24. Attack him where he is unprepared, appear where
+ you are not expected.
+
+25. These military devices, leading to victory,
+ must not be divulged beforehand.
+
+26. Now the general who wins a battle makes many
+ calculations in his temple ere the battle is fought.
+ The general who loses a battle makes but few
+ calculations beforehand. Thus do many calculations
+ lead to victory, and few calculations to defeat:
+ how much more no calculation at all! It is by attention
+ to this point that I can foresee who is likely to win or lose.
+
+
+II. WAGING WAR
+
+
+ 1. Sun Tzu said: In the operations of war,
+ where there are in the field a thousand swift chariots,
+ as many heavy chariots, and a hundred thousand
+ mail-clad soldiers, with provisions enough to carry them
+ a thousand li, the expenditure at home and at the front,
+ including entertainment of guests, small items such as
+ glue and paint, and sums spent on chariots and armor,
+ will reach the total of a thousand ounces of silver per day.
+ Such is the cost of raising an army of 100,000 men.
+
+ 2. When you engage in actual fighting, if victory
+ is long in coming, then men's weapons will grow dull and
+ their ardor will be damped. If you lay siege to a town,
+ you will exhaust your strength.
+ 3. Again, if the campaign is protracted, the resources
+ of the State will not be equal to the strain.
+
+ 4. Now, when your weapons are dulled, your ardor damped,
+ your strength exhausted and your treasure spent,
+ other chieftains will spring up to take advantage
+ of your extremity. Then no man, however wise,
+ will be able to avert the consequences that must ensue.
+
+ 5. Thus, though we have heard of stupid haste in war,
+ cleverness has never been seen associated with long delays.
+
+ 6. There is no instance of a country having benefited
+ from prolonged warfare.
+
+ 7. It is only one who is thoroughly acquainted
+ with the evils of war that can thoroughly understand
+ the profitable way of carrying it on.
+
+ 8. The skillful soldier does not raise a second levy,
+ neither are his supply-wagons loaded more than twice.
+
+ 9. Bring war material with you from home, but forage
+ on the enemy. Thus the army will have food enough
+ for its needs.
+
+10. Poverty of the State exchequer causes an army
+ to be maintained by contributions from a distance.
+ Contributing to maintain an army at a distance causes
+ the people to be impoverished.
+
+11. On the other hand, the proximity of an army causes
+ prices to go up; and high prices cause the people's
+ substance to be drained away.
+
+12. When their substance is drained away, the peasantry
+ will be afflicted by heavy exactions.
+
+13,14. With this loss of substance and exhaustion
+ of strength, the homes of the people will be stripped bare,
+ and three-tenths of their income will be dissipated;
+ while government expenses for broken chariots, worn-out horses,
+ breast-plates and helmets, bows and arrows, spears and shields,
+ protective mantles, draught-oxen and heavy wagons,
+ will amount to four-tenths of its total revenue.
+
+15. Hence a wise general makes a point of foraging
+ on the enemy. One cartload of the enemy's provisions
+ is equivalent to twenty of one's own, and likewise
+ a single picul of his provender is equivalent to twenty
+ from one's own store.
+
+16. Now in order to kill the enemy, our men must
+ be roused to anger; that there may be advantage from
+ defeating the enemy, they must have their rewards.
+
+17. Therefore in chariot fighting, when ten or more chariots
+ have been taken, those should be rewarded who took the first.
+ Our own flags should be substituted for those of the enemy,
+ and the chariots mingled and used in conjunction with ours.
+ The captured soldiers should be kindly treated and kept.
+
+18. This is called, using the conquered foe to augment
+ one's own strength.
+
+19. In war, then, let your great object be victory,
+ not lengthy campaigns.
+
+20. Thus it may be known that the leader of armies
+ is the arbiter of the people's fate, the man on whom it
+ depends whether the nation shall be in peace or in peril.
+
+
+III. ATTACK BY STRATAGEM
+
+
+ 1. Sun Tzu said: In the practical art of war, the best
+ thing of all is to take the enemy's country whole and intact;
+ to shatter and destroy it is not so good. So, too, it is
+ better to recapture an army entire than to destroy it,
+ to capture a regiment, a detachment or a company entire
+ than to destroy them.
+
+ 2. Hence to fight and conquer in all your battles
+ is not supreme excellence; supreme excellence consists
+ in breaking the enemy's resistance without fighting.
+
+ 3. Thus the highest form of generalship is to
+ balk the enemy's plans; the next best is to prevent
+ the junction of the enemy's forces; the next in
+ order is to attack the enemy's army in the field;
+ and the worst policy of all is to besiege walled cities.
+
+ 4. The rule is, not to besiege walled cities if it
+ can possibly be avoided. The preparation of mantlets,
+ movable shelters, and various implements of war, will take
+ up three whole months; and the piling up of mounds over
+ against the walls will take three months more.
+
+ 5. The general, unable to control his irritation,
+ will launch his men to the assault like swarming ants,
+ with the result that one-third of his men are slain,
+ while the town still remains untaken. Such are the disastrous
+ effects of a siege.
+
+ 6. Therefore the skillful leader subdues the enemy's
+ troops without any fighting; he captures their cities
+ without laying siege to them; he overthrows their kingdom
+ without lengthy operations in the field.
+
+ 7. With his forces intact he will dispute the mastery
+ of the Empire, and thus, without losing a man, his triumph
+ will be complete. This is the method of attacking by stratagem.
+
+ 8. It is the rule in war, if our forces are ten
+ to the enemy's one, to surround him; if five to one,
+ to attack him; if twice as numerous, to divide our army
+ into two.
+
+ 9. If equally matched, we can offer battle;
+ if slightly inferior in numbers, we can avoid the enemy;
+ if quite unequal in every way, we can flee from him.
+
+10. Hence, though an obstinate fight may be made
+ by a small force, in the end it must be captured
+ by the larger force.
+
+11. Now the general is the bulwark of the State;
+ if the bulwark is complete at all points; the State will
+ be strong; if the bulwark is defective, the State will
+ be weak.
+
+12. There are three ways in which a ruler can bring
+ misfortune upon his army:--
+
+13. (1) By commanding the army to advance or to retreat,
+ being ignorant of the fact that it cannot obey.
+ This is called hobbling the army.
+
+14. (2) By attempting to govern an army in the
+ same way as he administers a kingdom, being ignorant
+ of the conditions which obtain in an army. This causes
+ restlessness in the soldier's minds.
+
+15. (3) By employing the officers of his army
+ without discrimination, through ignorance of the
+ military principle of adaptation to circumstances.
+ This shakes the confidence of the soldiers.
+
+16. But when the army is restless and distrustful,
+ trouble is sure to come from the other feudal princes.
+ This is simply bringing anarchy into the army, and flinging
+ victory away.
+
+17. Thus we may know that there are five essentials
+ for victory:
+ (1) He will win who knows when to fight and when
+ not to fight.
+ (2) He will win who knows how to handle both superior
+ and inferior forces.
+ (3) He will win whose army is animated by the same
+ spirit throughout all its ranks.
+ (4) He will win who, prepared himself, waits to take
+ the enemy unprepared.
+ (5) He will win who has military capacity and is
+ not interfered with by the sovereign.
+
+18. Hence the saying: If you know the enemy
+ and know yourself, you need not fear the result of a
+ hundred battles. If you know yourself but not the enemy,
+ for every victory gained you will also suffer a defeat.
+ If you know neither the enemy nor yourself, you will
+ succumb in every battle.
+
+
+IV. TACTICAL DISPOSITIONS
+
+
+ 1. Sun Tzu said: The good fighters of old first put
+ themselves beyond the possibility of defeat, and then
+ waited for an opportunity of defeating the enemy.
+
+ 2. To secure ourselves against defeat lies in our
+ own hands, but the opportunity of defeating the enemy
+ is provided by the enemy himself.
+ 3. Thus the good fighter is able to secure himself against defeat,
+ but cannot make certain of defeating the enemy.
+
+ 4. Hence the saying: One may know how to conquer
+ without being able to do it.
+
+ 5. Security against defeat implies defensive tactics;
+ ability to defeat the enemy means taking the offensive.
+
+ 6. Standing on the defensive indicates insufficient
+ strength; attacking, a superabundance of strength.
+
+ 7. The general who is skilled in defense hides in the
+ most secret recesses of the earth; he who is skilled in
+ attack flashes forth from the topmost heights of heaven.
+ Thus on the one hand we have ability to protect ourselves;
+ on the other, a victory that is complete.
+
+ 8. To see victory only when it is within the ken
+ of the common herd is not the acme of excellence.
+
+ 9. Neither is it the acme of excellence if you fight
+ and conquer and the whole Empire says, "Well done!"
+
+10. To lift an autumn hair is no sign of great strength;
+ to see the sun and moon is no sign of sharp sight;
+ to hear the noise of thunder is no sign of a quick ear.
+
+11. What the ancients called a clever fighter is
+ one who not only wins, but excels in winning with ease.
+
+12. Hence his victories bring him neither reputation
+ for wisdom nor credit for courage.
+
+13. He wins his battles by making no mistakes.
+ Making no mistakes is what establishes the certainty
+ of victory, for it means conquering an enemy that is
+ already defeated.
+
+14. Hence the skillful fighter puts himself into
+ a position which makes defeat impossible, and does
+ not miss the moment for defeating the enemy.
+
+15. Thus it is that in war the victorious strategist
+ only seeks battle after the victory has been won,
+ whereas he who is destined to defeat first fights
+ and afterwards looks for victory.
+
+16. The consummate leader cultivates the moral law,
+ and strictly adheres to method and discipline; thus it is
+ in his power to control success.
+
+17. In respect of military method, we have,
+ firstly, Measurement; secondly, Estimation of quantity;
+ thirdly, Calculation; fourthly, Balancing of chances;
+ fifthly, Victory.
+
+18. Measurement owes its existence to Earth;
+ Estimation of quantity to Measurement; Calculation to
+ Estimation of quantity; Balancing of chances to Calculation;
+ and Victory to Balancing of chances.
+
+19. A victorious army opposed to a routed one, is as
+ a pound's weight placed in the scale against a single grain.
+
+20. The onrush of a conquering force is like the bursting
+ of pent-up waters into a chasm a thousand fathoms deep.
+
+
+V. ENERGY
+
+
+ 1. Sun Tzu said: The control of a large force
+ is the same principle as the control of a few men:
+ it is merely a question of dividing up their numbers.
+
+ 2. Fighting with a large army under your command
+ is nowise different from fighting with a small one:
+ it is merely a question of instituting signs and signals.
+
+ 3. To ensure that your whole host may withstand
+ the brunt of the enemy's attack and remain unshaken--
+ this is effected by maneuvers direct and indirect.
+
+ 4. That the impact of your army may be like a grindstone
+ dashed against an egg--this is effected by the science
+ of weak points and strong.
+
+ 5. In all fighting, the direct method may be used
+ for joining battle, but indirect methods will be needed
+ in order to secure victory.
+
+ 6. Indirect tactics, efficiently applied, are inexhaustible
+ as Heaven and Earth, unending as the flow of rivers and streams;
+ like the sun and moon, they end but to begin anew;
+ like the four seasons, they pass away to return once more.
+
+ 7. There are not more than five musical notes,
+ yet the combinations of these five give rise to more
+ melodies than can ever be heard.
+
+ 8. There are not more than five primary colors
+ (blue, yellow, red, white, and black), yet in combination
+ they produce more hues than can ever been seen.
+
+ 9. There are not more than five cardinal tastes
+ (sour, acrid, salt, sweet, bitter), yet combinations
+ of them yield more flavors than can ever be tasted.
+
+10. In battle, there are not more than two methods
+ of attack--the direct and the indirect; yet these two
+ in combination give rise to an endless series of maneuvers.
+
+11. The direct and the indirect lead on to each other in turn.
+ It is like moving in a circle--you never come to an end.
+ Who can exhaust the possibilities of their combination?
+
+12. The onset of troops is like the rush of a torrent
+ which will even roll stones along in its course.
+
+13. The quality of decision is like the well-timed
+ swoop of a falcon which enables it to strike and destroy
+ its victim.
+
+14. Therefore the good fighter will be terrible
+ in his onset, and prompt in his decision.
+
+15. Energy may be likened to the bending of a crossbow;
+ decision, to the releasing of a trigger.
+
+16. Amid the turmoil and tumult of battle, there may
+ be seeming disorder and yet no real disorder at all;
+ amid confusion and chaos, your array may be without head
+ or tail, yet it will be proof against defeat.
+
+17. Simulated disorder postulates perfect discipline,
+ simulated fear postulates courage; simulated weakness
+ postulates strength.
+
+18. Hiding order beneath the cloak of disorder is
+ simply a question of subdivision; concealing courage under
+ a show of timidity presupposes a fund of latent energy;
+ masking strength with weakness is to be effected
+ by tactical dispositions.
+
+19. Thus one who is skillful at keeping the enemy
+ on the move maintains deceitful appearances, according to
+ which the enemy will act. He sacrifices something,
+ that the enemy may snatch at it.
+
+20. By holding out baits, he keeps him on the march;
+ then with a body of picked men he lies in wait for him.
+
+21. The clever combatant looks to the effect of combined
+ energy, and does not require too much from individuals.
+ Hence his ability to pick out the right men and utilize
+ combined energy.
+
+22. When he utilizes combined energy, his fighting
+ men become as it were like unto rolling logs or stones.
+ For it is the nature of a log or stone to remain
+ motionless on level ground, and to move when on a slope;
+ if four-cornered, to come to a standstill, but if
+ round-shaped, to go rolling down.
+
+23. Thus the energy developed by good fighting men
+ is as the momentum of a round stone rolled down a mountain
+ thousands of feet in height. So much on the subject
+ of energy.
+
+
+VI. WEAK POINTS AND STRONG
+
+
+ 1. Sun Tzu said: Whoever is first in the field and
+ awaits the coming of the enemy, will be fresh for the fight;
+ whoever is second in the field and has to hasten to battle
+ will arrive exhausted.
+
+ 2. Therefore the clever combatant imposes his will on
+ the enemy, but does not allow the enemy's will to be imposed on him.
+
+ 3. By holding out advantages to him, he can cause the enemy
+ to approach of his own accord; or, by inflicting damage,
+ he can make it impossible for the enemy to draw near.
+
+ 4. If the enemy is taking his ease, he can harass him;
+ if well supplied with food, he can starve him out;
+ if quietly encamped, he can force him to move.
+
+ 5. Appear at points which the enemy must hasten to defend;
+ march swiftly to places where you are not expected.
+
+ 6. An army may march great distances without distress,
+ if it marches through country where the enemy is not.
+
+ 7. You can be sure of succeeding in your attacks
+ if you only attack places which are undefended.You can
+ ensure the safety of your defense if you only hold
+ positions that cannot be attacked.
+
+ 8. Hence that general is skillful in attack whose
+ opponent does not know what to defend; and he is skillful
+ in defense whose opponent does not know what to attack.
+
+ 9. O divine art of subtlety and secrecy! Through you
+ we learn to be invisible, through you inaudible;
+ and hence we can hold the enemy's fate in our hands.
+
+10. You may advance and be absolutely irresistible,
+ if you make for the enemy's weak points; you may retire
+ and be safe from pursuit if your movements are more rapid
+ than those of the enemy.
+
+11. If we wish to fight, the enemy can be forced
+ to an engagement even though he be sheltered behind a high
+ rampart and a deep ditch. All we need do is attack
+ some other place that he will be obliged to relieve.
+
+12. If we do not wish to fight, we can prevent
+ the enemy from engaging us even though the lines
+ of our encampment be merely traced out on the ground.
+ All we need do is to throw something odd and unaccountable
+ in his way.
+
+13. By discovering the enemy's dispositions and remaining
+ invisible ourselves, we can keep our forces concentrated,
+ while the enemy's must be divided.
+
+14. We can form a single united body, while the
+ enemy must split up into fractions. Hence there will
+ be a whole pitted against separate parts of a whole,
+ which means that we shall be many to the enemy's few.
+
+15. And if we are able thus to attack an inferior force
+ with a superior one, our opponents will be in dire straits.
+
+16. The spot where we intend to fight must not be
+ made known; for then the enemy will have to prepare
+ against a possible attack at several different points;
+ and his forces being thus distributed in many directions,
+ the numbers we shall have to face at any given point will
+ be proportionately few.
+
+17. For should the enemy strengthen his van,
+ he will weaken his rear; should he strengthen his rear,
+ he will weaken his van; should he strengthen his left,
+ he will weaken his right; should he strengthen his right,
+ he will weaken his left. If he sends reinforcements everywhere,
+ he will everywhere be weak.
+
+18. Numerical weakness comes from having to prepare
+ against possible attacks; numerical strength, from compelling
+ our adversary to make these preparations against us.
+
+19. Knowing the place and the time of the coming battle,
+ we may concentrate from the greatest distances in order
+ to fight.
+
+20. But if neither time nor place be known,
+ then the left wing will be impotent to succor the right,
+ the right equally impotent to succor the left, the van
+ unable to relieve the rear, or the rear to support the van.
+ How much more so if the furthest portions of the army are
+ anything under a hundred LI apart, and even the nearest
+ are separated by several LI!
+
+21. Though according to my estimate the soldiers
+ of Yueh exceed our own in number, that shall advantage
+ them nothing in the matter of victory. I say then
+ that victory can be achieved.
+
+22. Though the enemy be stronger in numbers, we may
+ prevent him from fighting. Scheme so as to discover
+ his plans and the likelihood of their success.
+
+23. Rouse him, and learn the principle of his
+ activity or inactivity. Force him to reveal himself,
+ so as to find out his vulnerable spots.
+
+24. Carefully compare the opposing army with your own,
+ so that you may know where strength is superabundant
+ and where it is deficient.
+
+25. In making tactical dispositions, the highest pitch
+ you can attain is to conceal them; conceal your dispositions,
+ and you will be safe from the prying of the subtlest spies,
+ from the machinations of the wisest brains.
+
+26. How victory may be produced for them out of the enemy's
+ own tactics--that is what the multitude cannot comprehend.
+
+27. All men can see the tactics whereby I conquer,
+ but what none can see is the strategy out of which victory
+ is evolved.
+
+28. Do not repeat the tactics which have gained
+ you one victory, but let your methods be regulated
+ by the infinite variety of circumstances.
+
+29. Military tactics are like unto water; for water in its
+ natural course runs away from high places and hastens downwards.
+
+30. So in war, the way is to avoid what is strong
+ and to strike at what is weak.
+
+31. Water shapes its course according to the nature
+ of the ground over which it flows; the soldier works
+ out his victory in relation to the foe whom he is facing.
+
+32. Therefore, just as water retains no constant shape,
+ so in warfare there are no constant conditions.
+
+33. He who can modify his tactics in relation to his
+ opponent and thereby succeed in winning, may be called
+ a heaven-born captain.
+
+34. The five elements (water, fire, wood, metal, earth)
+ are not always equally predominant; the four seasons make
+ way for each other in turn. There are short days and long;
+ the moon has its periods of waning and waxing.
+
+
+VII. MANEUVERING
+
+
+ 1. Sun Tzu said: In war, the general receives his
+ commands from the sovereign.
+
+ 2. Having collected an army and concentrated his forces,
+ he must blend and harmonize the different elements thereof
+ before pitching his camp.
+
+ 3. After that, comes tactical maneuvering,
+ than which there is nothing more difficult.
+ The difficulty of tactical maneuvering consists
+ in turning the devious into the direct, and misfortune into gain.
+
+ 4. Thus, to take a long and circuitous route,
+ after enticing the enemy out of the way, and though starting
+ after him, to contrive to reach the goal before him,
+ shows knowledge of the artifice of DEVIATION.
+
+ 5. Maneuvering with an army is advantageous;
+ with an undisciplined multitude, most dangerous.
+
+ 6. If you set a fully equipped army in march in order
+ to snatch an advantage, the chances are that you will be
+ too late. On the other hand, to detach a flying column
+ for the purpose involves the sacrifice of its baggage
+ and stores.
+
+ 7. Thus, if you order your men to roll up their
+ buff-coats, and make forced marches without halting day
+ or night, covering double the usual distance at a stretch,
+ doing a hundred LI in order to wrest an advantage,
+ the leaders of all your three divisions will fall into
+ the hands of the enemy.
+
+ 8. The stronger men will be in front, the jaded
+ ones will fall behind, and on this plan only one-tenth
+ of your army will reach its destination.
+
+ 9. If you march fifty LI in order to outmaneuver
+ the enemy, you will lose the leader of your first division,
+ and only half your force will reach the goal.
+
+10. If you march thirty LI with the same object,
+ two-thirds of your army will arrive.
+
+11. We may take it then that an army without its
+ baggage-train is lost; without provisions it is lost;
+ without bases of supply it is lost.
+
+12. We cannot enter into alliances until we are
+ acquainted with the designs of our neighbors.
+
+13. We are not fit to lead an army on the march
+ unless we are familiar with the face of the country--its
+ mountains and forests, its pitfalls and precipices,
+ its marshes and swamps.
+
+14. We shall be unable to turn natural advantage
+ to account unless we make use of local guides.
+
+15. In war, practice dissimulation, and you will succeed.
+
+16. Whether to concentrate or to divide your troops,
+ must be decided by circumstances.
+
+17. Let your rapidity be that of the wind,
+ your compactness that of the forest.
+
+18. In raiding and plundering be like fire,
+ is immovability like a mountain.
+
+19. Let your plans be dark and impenetrable as night,
+ and when you move, fall like a thunderbolt.
+
+20. When you plunder a countryside, let the spoil be
+ divided amongst your men; when you capture new territory,
+ cut it up into allotments for the benefit of the soldiery.
+
+21. Ponder and deliberate before you make a move.
+
+22. He will conquer who has learnt the artifice
+ of deviation. Such is the art of maneuvering.
+
+23. The Book of Army Management says: On the field
+ of battle, the spoken word does not carry far enough:
+ hence the institution of gongs and drums. Nor can ordinary
+ objects be seen clearly enough: hence the institution
+ of banners and flags.
+
+24. Gongs and drums, banners and flags, are means
+ whereby the ears and eyes of the host may be focused
+ on one particular point.
+
+25. The host thus forming a single united body,
+ is it impossible either for the brave to advance alone,
+ or for the cowardly to retreat alone. This is the art
+ of handling large masses of men.
+
+26. In night-fighting, then, make much use of signal-fires
+ and drums, and in fighting by day, of flags and banners,
+ as a means of influencing the ears and eyes of your army.
+
+27. A whole army may be robbed of its spirit;
+ a commander-in-chief may be robbed of his presence of mind.
+
+28. Now a soldier's spirit is keenest in the morning;
+ by noonday it has begun to flag; and in the evening,
+ his mind is bent only on returning to camp.
+
+29. A clever general, therefore, avoids an army when
+ its spirit is keen, but attacks it when it is sluggish
+ and inclined to return. This is the art of studying moods.
+
+30. Disciplined and calm, to await the appearance
+ of disorder and hubbub amongst the enemy:--this is the art
+ of retaining self-possession.
+
+31. To be near the goal while the enemy is still
+ far from it, to wait at ease while the enemy is
+ toiling and struggling, to be well-fed while the enemy
+ is famished:--this is the art of husbanding one's strength.
+
+32. To refrain from intercepting an enemy whose
+ banners are in perfect order, to refrain from attacking
+ an army drawn up in calm and confident array:--this
+ is the art of studying circumstances.
+
+33. It is a military axiom not to advance uphill
+ against the enemy, nor to oppose him when he comes downhill.
+
+34. Do not pursue an enemy who simulates flight;
+ do not attack soldiers whose temper is keen.
+
+35. Do not swallow bait offered by the enemy.
+ Do not interfere with an army that is returning home.
+
+36. When you surround an army, leave an outlet free.
+ Do not press a desperate foe too hard.
+
+37. Such is the art of warfare.
+
+
+VIII. VARIATION IN TACTICS
+
+
+ 1. Sun Tzu said: In war, the general receives
+ his commands from the sovereign, collects his army
+ and concentrates his forces
+
+ 2. When in difficult country, do not encamp. In country
+ where high roads intersect, join hands with your allies.
+ Do not linger in dangerously isolated positions.
+ In hemmed-in situations, you must resort to stratagem.
+ In desperate position, you must fight.
+
+ 3. There are roads which must not be followed,
+ armies which must be not attacked, towns which must
+ be besieged, positions which must not be contested,
+ commands of the sovereign which must not be obeyed.
+
+ 4. The general who thoroughly understands the advantages
+ that accompany variation of tactics knows how to handle
+ his troops.
+
+ 5. The general who does not understand these, may be well
+ acquainted with the configuration of the country, yet he
+ will not be able to turn his knowledge to practical account.
+
+ 6. So, the student of war who is unversed in the art
+ of war of varying his plans, even though he be acquainted
+ with the Five Advantages, will fail to make the best use
+ of his men.
+
+ 7. Hence in the wise leader's plans, considerations of
+ advantage and of disadvantage will be blended together.
+
+ 8. If our expectation of advantage be tempered in
+ this way, we may succeed in accomplishing the essential
+ part of our schemes.
+
+ 9. If, on the other hand, in the midst of difficulties
+ we are always ready to seize an advantage, we may extricate
+ ourselves from misfortune.
+
+10. Reduce the hostile chiefs by inflicting damage
+ on them; and make trouble for them, and keep them
+ constantly engaged; hold out specious allurements,
+ and make them rush to any given point.
+
+11. The art of war teaches us to rely not on the
+ likelihood of the enemy's not coming, but on our own readiness
+ to receive him; not on the chance of his not attacking,
+ but rather on the fact that we have made our position unassailable.
+
+12. There are five dangerous faults which may affect
+ a general:
+ (1) Recklessness, which leads to destruction;
+ (2) cowardice, which leads to capture;
+ (3) a hasty temper, which can be provoked by insults;
+ (4) a delicacy of honor which is sensitive to shame;
+ (5) over-solicitude for his men, which exposes him
+ to worry and trouble.
+
+13. These are the five besetting sins of a general,
+ ruinous to the conduct of war.
+
+14. When an army is overthrown and its leader slain,
+ the cause will surely be found among these five
+ dangerous faults. Let them be a subject of meditation.
+
+
+IX. THE ARMY ON THE MARCH
+
+
+ 1. Sun Tzu said: We come now to the question of
+ encamping the army, and observing signs of the enemy.
+ Pass quickly over mountains, and keep in the neighborhood
+ of valleys.
+
+ 2. Camp in high places, facing the sun. Do not climb
+ heights in order to fight. So much for mountain warfare.
+
+ 3. After crossing a river, you should get far away
+ from it.
+
+ 4. When an invading force crosses a river in its
+ onward march, do not advance to meet it in mid-stream.
+ It will be best to let half the army get across,
+ and then deliver your attack.
+
+ 5. If you are anxious to fight, you should not go
+ to meet the invader near a river which he has to cross.
+
+ 6. Moor your craft higher up than the enemy, and facing
+ the sun. Do not move up-stream to meet the enemy.
+ So much for river warfare.
+
+ 7. In crossing salt-marshes, your sole concern
+ should be to get over them quickly, without any delay.
+
+ 8. If forced to fight in a salt-marsh, you should
+ have water and grass near you, and get your back
+ to a clump of trees. So much for operations in salt-marches.
+
+ 9. In dry, level country, take up an easily accessible
+ position with rising ground to your right and on your rear,
+ so that the danger may be in front, and safety lie behind.
+ So much for campaigning in flat country.
+
+10. These are the four useful branches of military
+ knowledge which enabled the Yellow Emperor to vanquish
+ four several sovereigns.
+
+11. All armies prefer high ground to low and sunny
+ places to dark.
+
+12. If you are careful of your men, and camp on hard
+ ground, the army will be free from disease of every kind,
+ and this will spell victory.
+
+13. When you come to a hill or a bank, occupy the
+ sunny side, with the slope on your right rear.
+ Thus you will at once act for the benefit of your soldiers
+ and utilize the natural advantages of the ground.
+
+14. When, in consequence of heavy rains up-country,
+ a river which you wish to ford is swollen and flecked
+ with foam, you must wait until it subsides.
+
+15. Country in which there are precipitous cliffs
+ with torrents running between, deep natural hollows,
+ confined places, tangled thickets, quagmires and crevasses,
+ should be left with all possible speed and not approached.
+
+16. While we keep away from such places, we should
+ get the enemy to approach them; while we face them,
+ we should let the enemy have them on his rear.
+
+17. If in the neighborhood of your camp there should
+ be any hilly country, ponds surrounded by aquatic grass,
+ hollow basins filled with reeds, or woods with thick
+ undergrowth, they must be carefully routed out and searched;
+ for these are places where men in ambush or insidious
+ spies are likely to be lurking.
+
+18. When the enemy is close at hand and remains quiet,
+ he is relying on the natural strength of his position.
+
+19. When he keeps aloof and tries to provoke a battle,
+ he is anxious for the other side to advance.
+
+20. If his place of encampment is easy of access,
+ he is tendering a bait.
+
+21. Movement amongst the trees of a forest shows that the
+ enemy is advancing. The appearance of a number of screens
+ in the midst of thick grass means that the enemy wants to make us suspicious.
+
+22. The rising of birds in their flight is the sign
+ of an ambuscade. Startled beasts indicate that a sudden
+ attack is coming.
+
+23. When there is dust rising in a high column,
+ it is the sign of chariots advancing; when the dust is low,
+ but spread over a wide area, it betokens the approach
+ of infantry. When it branches out in different directions,
+ it shows that parties have been sent to collect firewood.
+ A few clouds of dust moving to and fro signify that the army
+ is encamping.
+
+24. Humble words and increased preparations are signs
+ that the enemy is about to advance. Violent language
+ and driving forward as if to the attack are signs that he
+ will retreat.
+
+25. When the light chariots come out first and take
+ up a position on the wings, it is a sign that the enemy
+ is forming for battle.
+
+26. Peace proposals unaccompanied by a sworn covenant
+ indicate a plot.
+
+27. When there is much running about and the soldiers
+ fall into rank, it means that the critical moment has come.
+
+28. When some are seen advancing and some retreating,
+ it is a lure.
+
+29. When the soldiers stand leaning on their spears,
+ they are faint from want of food.
+
+30. If those who are sent to draw water begin
+ by drinking themselves, the army is suffering from thirst.
+
+31. If the enemy sees an advantage to be gained and
+ makes no effort to secure it, the soldiers are exhausted.
+
+32. If birds gather on any spot, it is unoccupied.
+ Clamor by night betokens nervousness.
+
+33. If there is disturbance in the camp, the general's
+ authority is weak. If the banners and flags are shifted
+ about, sedition is afoot. If the officers are angry,
+ it means that the men are weary.
+
+34. When an army feeds its horses with grain and kills
+ its cattle for food, and when the men do not hang their
+ cooking-pots over the camp-fires, showing that they
+ will not return to their tents, you may know that they
+ are determined to fight to the death.
+
+35. The sight of men whispering together in small
+ knots or speaking in subdued tones points to disaffection
+ amongst the rank and file.
+
+36. Too frequent rewards signify that the enemy is
+ at the end of his resources; too many punishments betray
+ a condition of dire distress.
+
+37. To begin by bluster, but afterwards to take fright
+ at the enemy's numbers, shows a supreme lack of intelligence.
+
+38. When envoys are sent with compliments in their mouths,
+ it is a sign that the enemy wishes for a truce.
+
+39. If the enemy's troops march up angrily and remain
+ facing ours for a long time without either joining
+ battle or taking themselves off again, the situation
+ is one that demands great vigilance and circumspection.
+
+40. If our troops are no more in number than the enemy,
+ that is amply sufficient; it only means that no direct attack
+ can be made. What we can do is simply to concentrate all
+ our available strength, keep a close watch on the enemy,
+ and obtain reinforcements.
+
+41. He who exercises no forethought but makes light
+ of his opponents is sure to be captured by them.
+
+42. If soldiers are punished before they have grown
+ attached to you, they will not prove submissive; and,
+ unless submissive, then will be practically useless.
+ If, when the soldiers have become attached to you,
+ punishments are not enforced, they will still be unless.
+
+43. Therefore soldiers must be treated in the first
+ instance with humanity, but kept under control by means
+ of iron discipline. This is a certain road to victory.
+
+44. If in training soldiers commands are habitually
+ enforced, the army will be well-disciplined; if not,
+ its discipline will be bad.
+
+45. If a general shows confidence in his men but always
+ insists on his orders being obeyed, the gain will be mutual.
+
+
+X. TERRAIN
+
+
+ 1. Sun Tzu said: We may distinguish six kinds of terrain,
+ to wit: (1) Accessible ground; (2) entangling ground;
+ (3) temporizing ground; (4) narrow passes; (5) precipitous
+ heights; (6) positions at a great distance from the enemy.
+
+ 2. Ground which can be freely traversed by both sides
+ is called accessible.
+
+ 3. With regard to ground of this nature, be before
+ the enemy in occupying the raised and sunny spots,
+ and carefully guard your line of supplies. Then you
+ will be able to fight with advantage.
+
+ 4. Ground which can be abandoned but is hard
+ to re-occupy is called entangling.
+
+ 5. From a position of this sort, if the enemy
+ is unprepared, you may sally forth and defeat him.
+ But if the enemy is prepared for your coming, and you
+ fail to defeat him, then, return being impossible,
+ disaster will ensue.
+
+ 6. When the position is such that neither side will gain
+ by making the first move, it is called temporizing ground.
+
+ 7. In a position of this sort, even though the enemy
+ should offer us an attractive bait, it will be advisable
+ not to stir forth, but rather to retreat, thus enticing
+ the enemy in his turn; then, when part of his army has
+ come out, we may deliver our attack with advantage.
+
+ 8. With regard to narrow passes, if you can occupy
+ them first, let them be strongly garrisoned and await
+ the advent of the enemy.
+
+ 9. Should the army forestall you in occupying a pass,
+ do not go after him if the pass is fully garrisoned,
+ but only if it is weakly garrisoned.
+
+10. With regard to precipitous heights, if you are
+ beforehand with your adversary, you should occupy the
+ raised and sunny spots, and there wait for him to come up.
+
+11. If the enemy has occupied them before you,
+ do not follow him, but retreat and try to entice him away.
+
+12. If you are situated at a great distance from
+ the enemy, and the strength of the two armies is equal,
+ it is not easy to provoke a battle, and fighting will be
+ to your disadvantage.
+
+13. These six are the principles connected with Earth.
+ The general who has attained a responsible post must be
+ careful to study them.
+
+14. Now an army is exposed to six several calamities,
+ not arising from natural causes, but from faults
+ for which the general is responsible. These are:
+ (1) Flight; (2) insubordination; (3) collapse; (4) ruin;
+ (5) disorganization; (6) rout.
+
+15. Other conditions being equal, if one force is
+ hurled against another ten times its size, the result
+ will be the flight of the former.
+
+16. When the common soldiers are too strong and
+ their officers too weak, the result is insubordination.
+ When the officers are too strong and the common soldiers
+ too weak, the result is collapse.
+
+17. When the higher officers are angry and insubordinate,
+ and on meeting the enemy give battle on their own account
+ from a feeling of resentment, before the commander-in-chief
+ can tell whether or no he is in a position to fight,
+ the result is ruin.
+
+18. When the general is weak and without authority;
+ when his orders are not clear and distinct; when there
+ are no fixes duties assigned to officers and men,
+ and the ranks are formed in a slovenly haphazard manner,
+ the result is utter disorganization.
+
+19. When a general, unable to estimate the enemy's
+ strength, allows an inferior force to engage a larger one,
+ or hurls a weak detachment against a powerful one,
+ and neglects to place picked soldiers in the front rank,
+ the result must be rout.
+
+20. These are six ways of courting defeat, which must
+ be carefully noted by the general who has attained
+ a responsible post.
+
+21. The natural formation of the country is the soldier's
+ best ally; but a power of estimating the adversary,
+ of controlling the forces of victory, and of shrewdly
+ calculating difficulties, dangers and distances,
+ constitutes the test of a great general.
+
+22. He who knows these things, and in fighting puts
+ his knowledge into practice, will win his battles.
+ He who knows them not, nor practices them, will surely
+ be defeated.
+
+23. If fighting is sure to result in victory,
+ then you must fight, even though the ruler forbid it;
+ if fighting will not result in victory, then you must not
+ fight even at the ruler's bidding.
+
+24. The general who advances without coveting fame
+ and retreats without fearing disgrace, whose only
+ thought is to protect his country and do good service
+ for his sovereign, is the jewel of the kingdom.
+
+25. Regard your soldiers as your children, and they
+ will follow you into the deepest valleys; look upon them
+ as your own beloved sons, and they will stand by you
+ even unto death.
+
+26. If, however, you are indulgent, but unable to make
+ your authority felt; kind-hearted, but unable to enforce
+ your commands; and incapable, moreover, of quelling disorder:
+ then your soldiers must be likened to spoilt children;
+ they are useless for any practical purpose.
+
+27. If we know that our own men are in a condition
+ to attack, but are unaware that the enemy is not open
+ to attack, we have gone only halfway towards victory.
+
+28. If we know that the enemy is open to attack,
+ but are unaware that our own men are not in a condition
+ to attack, we have gone only halfway towards victory.
+
+29. If we know that the enemy is open to attack,
+ and also know that our men are in a condition to attack,
+ but are unaware that the nature of the ground makes
+ fighting impracticable, we have still gone only halfway
+ towards victory.
+
+30. Hence the experienced soldier, once in motion,
+ is never bewildered; once he has broken camp, he is never
+ at a loss.
+
+31. Hence the saying: If you know the enemy and
+ know yourself, your victory will not stand in doubt;
+ if you know Heaven and know Earth, you may make your
+ victory complete.
+
+
+XI. THE NINE SITUATIONS
+
+
+ 1. Sun Tzu said: The art of war recognizes nine varieties of ground:
+ (1) Dispersive ground; (2) facile ground; (3) contentious ground;
+ (4) open ground; (5) ground of intersecting highways;
+ (6) serious ground; (7) difficult ground; (8) hemmed-in ground;
+ (9) desperate ground.
+
+ 2. When a chieftain is fighting in his own territory,
+ it is dispersive ground.
+
+ 3. When he has penetrated into hostile territory,
+ but to no great distance, it is facile ground.
+
+ 4. Ground the possession of which imports great
+ advantage to either side, is contentious ground.
+
+ 5. Ground on which each side has liberty of movement
+ is open ground.
+
+ 6. Ground which forms the key to three contiguous states,
+ so that he who occupies it first has most of the Empire
+ at his command, is a ground of intersecting highways.
+
+ 7. When an army has penetrated into the heart of a
+ hostile country, leaving a number of fortified cities
+ in its rear, it is serious ground.
+
+ 8. Mountain forests, rugged steeps, marshes and fens--all
+ country that is hard to traverse: this is difficult ground.
+
+ 9. Ground which is reached through narrow gorges,
+ and from which we can only retire by tortuous paths,
+ so that a small number of the enemy would suffice to crush
+ a large body of our men: this is hemmed in ground.
+
+10. Ground on which we can only be saved from
+ destruction by fighting without delay, is desperate ground.
+
+11. On dispersive ground, therefore, fight not.
+ On facile ground, halt not. On contentious ground,
+ attack not.
+
+12. On open ground, do not try to block the enemy's way.
+ On the ground of intersecting highways, join hands
+ with your allies.
+
+13. On serious ground, gather in plunder.
+ In difficult ground, keep steadily on the march.
+
+14. On hemmed-in ground, resort to stratagem.
+ On desperate ground, fight.
+
+15. Those who were called skillful leaders of old knew
+ how to drive a wedge between the enemy's front and rear;
+ to prevent co-operation between his large and small divisions;
+ to hinder the good troops from rescuing the bad,
+ the officers from rallying their men.
+
+16. When the enemy's men were united, they managed
+ to keep them in disorder.
+
+17. When it was to their advantage, they made
+ a forward move; when otherwise, they stopped still.
+
+18. If asked how to cope with a great host of the enemy
+ in orderly array and on the point of marching to the attack,
+ I should say: "Begin by seizing something which your
+ opponent holds dear; then he will be amenable to your will."
+
+19. Rapidity is the essence of war: take advantage of
+ the enemy's unreadiness, make your way by unexpected routes,
+ and attack unguarded spots.
+
+20. The following are the principles to be observed
+ by an invading force: The further you penetrate into
+ a country, the greater will be the solidarity of your troops,
+ and thus the defenders will not prevail against you.
+
+21. Make forays in fertile country in order to supply
+ your army with food.
+
+22. Carefully study the well-being of your men,
+ and do not overtax them. Concentrate your energy and hoard
+ your strength. Keep your army continually on the move,
+ and devise unfathomable plans.
+
+23. Throw your soldiers into positions whence there
+ is no escape, and they will prefer death to flight.
+ If they will face death, there is nothing they may
+ not achieve. Officers and men alike will put forth
+ their uttermost strength.
+
+24. Soldiers when in desperate straits lose
+ the sense of fear. If there is no place of refuge,
+ they will stand firm. If they are in hostile country,
+ they will show a stubborn front. If there is no help
+ for it, they will fight hard.
+
+25. Thus, without waiting to be marshaled, the soldiers
+ will be constantly on the qui vive; without waiting to
+ be asked, they will do your will; without restrictions,
+ they will be faithful; without giving orders, they can
+ be trusted.
+
+26. Prohibit the taking of omens, and do away with
+ superstitious doubts. Then, until death itself comes,
+ no calamity need be feared.
+
+27. If our soldiers are not overburdened with money,
+ it is not because they have a distaste for riches;
+ if their lives are not unduly long, it is not because they
+ are disinclined to longevity.
+
+28. On the day they are ordered out to battle,
+ your soldiers may weep, those sitting up bedewing
+ their garments, and those lying down letting the tears run
+ down their cheeks. But let them once be brought to bay,
+ and they will display the courage of a Chu or a Kuei.
+
+29. The skillful tactician may be likened to the
+ shuai-jan. Now the shuai-jan is a snake that is found
+ in the ChUng mountains. Strike at its head, and you
+ will be attacked by its tail; strike at its tail, and you
+ will be attacked by its head; strike at its middle,
+ and you will be attacked by head and tail both.
+
+30. Asked if an army can be made to imitate the shuai-jan,
+ I should answer, Yes. For the men of Wu and the men
+ of Yueh are enemies; yet if they are crossing a river
+ in the same boat and are caught by a storm, they will come
+ to each other's assistance just as the left hand helps the right.
+
+31. Hence it is not enough to put one's trust
+ in the tethering of horses, and the burying of chariot
+ wheels in the ground
+
+32. The principle on which to manage an army is to set
+ up one standard of courage which all must reach.
+
+33. How to make the best of both strong and weak--that
+ is a question involving the proper use of ground.
+
+34. Thus the skillful general conducts his army just
+ as though he were leading a single man, willy-nilly, by
+ the hand.
+
+35. It is the business of a general to be quiet and thus
+ ensure secrecy; upright and just, and thus maintain order.
+
+36. He must be able to mystify his officers and men
+ by false reports and appearances, and thus keep them
+ in total ignorance.
+
+37. By altering his arrangements and changing
+ his plans, he keeps the enemy without definite knowledge.
+ By shifting his camp and taking circuitous routes,
+ he prevents the enemy from anticipating his purpose.
+
+38. At the critical moment, the leader of an army
+ acts like one who has climbed up a height and then kicks
+ away the ladder behind him. He carries his men deep
+ into hostile territory before he shows his hand.
+
+39. He burns his boats and breaks his cooking-pots;
+ like a shepherd driving a flock of sheep, he drives
+ his men this way and that, and nothing knows whither he
+ is going.
+
+40. To muster his host and bring it into danger:--this
+ may be termed the business of the general.
+
+41. The different measures suited to the nine
+ varieties of ground; the expediency of aggressive or
+ defensive tactics; and the fundamental laws of human nature:
+ these are things that must most certainly be studied.
+
+42. When invading hostile territory, the general
+ principle is, that penetrating deeply brings cohesion;
+ penetrating but a short way means dispersion.
+
+43. When you leave your own country behind, and take
+ your army across neighborhood territory, you find yourself
+ on critical ground. When there are means of communication
+ on all four sides, the ground is one of intersecting highways.
+
+44. When you penetrate deeply into a country, it is
+ serious ground. When you penetrate but a little way,
+ it is facile ground.
+
+45. When you have the enemy's strongholds on your rear,
+ and narrow passes in front, it is hemmed-in ground.
+ When there is no place of refuge at all, it is desperate ground.
+
+46. Therefore, on dispersive ground, I would inspire
+ my men with unity of purpose. On facile ground, I would
+ see that there is close connection between all parts
+ of my army.
+
+47. On contentious ground, I would hurry up my rear.
+
+48. On open ground, I would keep a vigilant eye
+ on my defenses. On ground of intersecting highways,
+ I would consolidate my alliances.
+
+49. On serious ground, I would try to ensure
+ a continuous stream of supplies. On difficult ground,
+ I would keep pushing on along the road.
+
+50. On hemmed-in ground, I would block any way
+ of retreat. On desperate ground, I would proclaim
+ to my soldiers the hopelessness of saving their lives.
+
+51. For it is the soldier's disposition to offer
+ an obstinate resistance when surrounded, to fight hard
+ when he cannot help himself, and to obey promptly when he
+ has fallen into danger.
+
+52. We cannot enter into alliance with neighboring
+ princes until we are acquainted with their designs. We are
+ not fit to lead an army on the march unless we are familiar
+ with the face of the country--its mountains and forests,
+ its pitfalls and precipices, its marshes and swamps.
+ We shall be unable to turn natural advantages to account
+ unless we make use of local guides.
+
+53. To be ignored of any one of the following four
+ or five principles does not befit a warlike prince.
+
+54. When a warlike prince attacks a powerful state,
+ his generalship shows itself in preventing the concentration
+ of the enemy's forces. He overawes his opponents,
+ and their allies are prevented from joining against him.
+
+55. Hence he does not strive to ally himself with all
+ and sundry, nor does he foster the power of other states.
+ He carries out his own secret designs, keeping his
+ antagonists in awe. Thus he is able to capture their
+ cities and overthrow their kingdoms.
+
+56. Bestow rewards without regard to rule,
+ issue orders without regard to previous arrangements;
+ and you will be able to handle a whole army as though
+ you had to do with but a single man.
+
+57. Confront your soldiers with the deed itself;
+ never let them know your design. When the outlook is bright,
+ bring it before their eyes; but tell them nothing when
+ the situation is gloomy.
+
+58. Place your army in deadly peril, and it will survive;
+ plunge it into desperate straits, and it will come off
+ in safety.
+
+59. For it is precisely when a force has fallen into
+ harm's way that is capable of striking a blow for victory.
+
+60. Success in warfare is gained by carefully
+ accommodating ourselves to the enemy's purpose.
+
+61. By persistently hanging on the enemy's flank, we shall
+ succeed in the long run in killing the commander-in-chief.
+
+62. This is called ability to accomplish a thing
+ by sheer cunning.
+
+63. On the day that you take up your command,
+ block the frontier passes, destroy the official tallies,
+ and stop the passage of all emissaries.
+
+64. Be stern in the council-chamber, so that you
+ may control the situation.
+
+65. If the enemy leaves a door open, you must rush in.
+
+66. Forestall your opponent by seizing what he holds dear,
+ and subtly contrive to time his arrival on the ground.
+
+67. Walk in the path defined by rule, and accommodate
+ yourself to the enemy until you can fight a decisive battle.
+
+68. At first, then, exhibit the coyness of a maiden,
+ until the enemy gives you an opening; afterwards emulate
+ the rapidity of a running hare, and it will be too late
+ for the enemy to oppose you.
+
+
+XII. THE ATTACK BY FIRE
+
+
+ 1. Sun Tzu said: There are five ways of attacking
+ with fire. The first is to burn soldiers in their camp;
+ the second is to burn stores; the third is to burn
+ baggage trains; the fourth is to burn arsenals and magazines;
+ the fifth is to hurl dropping fire amongst the enemy.
+
+ 2. In order to carry out an attack, we must have
+ means available. The material for raising fire should
+ always be kept in readiness.
+
+ 3. There is a proper season for making attacks with fire,
+ and special days for starting a conflagration.
+
+ 4. The proper season is when the weather is very dry;
+ the special days are those when the moon is in the
+ constellations of the Sieve, the Wall, the Wing
+ or the Cross-bar; for these four are all days of rising wind.
+
+ 5. In attacking with fire, one should be prepared
+ to meet five possible developments:
+
+ 6. (1) When fire breaks out inside to enemy's camp,
+ respond at once with an attack from without.
+
+ 7. (2) If there is an outbreak of fire, but the enemy's
+ soldiers remain quiet, bide your time and do not attack.
+
+ 8. (3) When the force of the flames has reached its height,
+ follow it up with an attack, if that is practicable;
+ if not, stay where you are.
+
+ 9. (4) If it is possible to make an assault with fire
+ from without, do not wait for it to break out within,
+ but deliver your attack at a favorable moment.
+
+10. (5) When you start a fire, be to windward of it.
+ Do not attack from the leeward.
+
+11. A wind that rises in the daytime lasts long,
+ but a night breeze soon falls.
+
+12. In every army, the five developments connected with
+ fire must be known, the movements of the stars calculated,
+ and a watch kept for the proper days.
+
+13. Hence those who use fire as an aid to the attack show intelligence;
+ those who use water as an aid to the attack gain an accession of strength.
+
+14. By means of water, an enemy may be intercepted,
+ but not robbed of all his belongings.
+
+15. Unhappy is the fate of one who tries to win his
+ battles and succeed in his attacks without cultivating
+ the spirit of enterprise; for the result is waste of time
+ and general stagnation.
+
+16. Hence the saying: The enlightened ruler lays his
+ plans well ahead; the good general cultivates his resources.
+
+17. Move not unless you see an advantage; use not
+ your troops unless there is something to be gained;
+ fight not unless the position is critical.
+
+18. No ruler should put troops into the field merely
+ to gratify his own spleen; no general should fight
+ a battle simply out of pique.
+
+19. If it is to your advantage, make a forward move;
+ if not, stay where you are.
+
+20. Anger may in time change to gladness; vexation may
+ be succeeded by content.
+
+21. But a kingdom that has once been destroyed can
+ never come again into being; nor can the dead ever
+ be brought back to life.
+
+22. Hence the enlightened ruler is heedful,
+ and the good general full of caution. This is the way
+ to keep a country at peace and an army intact.
+
+
+XIII. THE USE OF SPIES
+
+
+ 1. Sun Tzu said: Raising a host of a hundred thousand
+ men and marching them great distances entails heavy loss
+ on the people and a drain on the resources of the State.
+ The daily expenditure will amount to a thousand ounces
+ of silver. There will be commotion at home and abroad,
+ and men will drop down exhausted on the highways.
+ As many as seven hundred thousand families will be impeded
+ in their labor.
+
+ 2. Hostile armies may face each other for years,
+ striving for the victory which is decided in a single day.
+ This being so, to remain in ignorance of the enemy's
+ condition simply because one grudges the outlay of a hundred
+ ounces of silver in honors and emoluments, is the height
+ of inhumanity.
+
+ 3. One who acts thus is no leader of men, no present
+ help to his sovereign, no master of victory.
+
+ 4. Thus, what enables the wise sovereign and the good
+ general to strike and conquer, and achieve things beyond
+ the reach of ordinary men, is foreknowledge.
+
+ 5. Now this foreknowledge cannot be elicited from spirits;
+ it cannot be obtained inductively from experience,
+ nor by any deductive calculation.
+
+ 6. Knowledge of the enemy's dispositions can only
+ be obtained from other men.
+
+ 7. Hence the use of spies, of whom there are five classes:
+ (1) Local spies; (2) inward spies; (3) converted spies;
+ (4) doomed spies; (5) surviving spies.
+
+ 8. When these five kinds of spy are all at work,
+ none can discover the secret system. This is called "divine
+ manipulation of the threads." It is the sovereign's
+ most precious faculty.
+
+ 9. Having local spies means employing the services
+ of the inhabitants of a district.
+
+10. Having inward spies, making use of officials
+ of the enemy.
+
+11. Having converted spies, getting hold of the enemy's
+ spies and using them for our own purposes.
+
+12. Having doomed spies, doing certain things openly
+ for purposes of deception, and allowing our spies to know
+ of them and report them to the enemy.
+
+13. Surviving spies, finally, are those who bring
+ back news from the enemy's camp.
+
+14. Hence it is that which none in the whole army are
+ more intimate relations to be maintained than with spies.
+ None should be more liberally rewarded. In no other
+ business should greater secrecy be preserved.
+
+15. Spies cannot be usefully employed without a certain
+ intuitive sagacity.
+
+16. They cannot be properly managed without benevolence
+ and straightforwardness.
+
+17. Without subtle ingenuity of mind, one cannot make
+ certain of the truth of their reports.
+
+18. Be subtle! be subtle! and use your spies for every
+ kind of business.
+
+19. If a secret piece of news is divulged by a spy
+ before the time is ripe, he must be put to death together
+ with the man to whom the secret was told.
+
+20. Whether the object be to crush an army, to storm
+ a city, or to assassinate an individual, it is always
+ necessary to begin by finding out the names of the attendants,
+ the aides-de-camp, and door-keepers and sentries of the general
+ in command. Our spies must be commissioned to ascertain these.
+
+21. The enemy's spies who have come to spy on us
+ must be sought out, tempted with bribes, led away and
+ comfortably housed. Thus they will become converted
+ spies and available for our service.
+
+22. It is through the information brought by the
+ converted spy that we are able to acquire and employ
+ local and inward spies.
+
+23. It is owing to his information, again, that we can
+ cause the doomed spy to carry false tidings to the enemy.
+
+24. Lastly, it is by his information that the surviving
+ spy can be used on appointed occasions.
+
+25. The end and aim of spying in all its five varieties
+ is knowledge of the enemy; and this knowledge can only
+ be derived, in the first instance, from the converted spy.
+ Hence it is essential that the converted spy be treated
+ with the utmost liberality.
+
+26. Of old, the rise of the Yin dynasty was due to I
+ Chih who had served under the Hsia. Likewise, the rise
+ of the Chou dynasty was due to Lu Ya who had served
+ under the Yin.
+
+27. Hence it is only the enlightened ruler and the
+ wise general who will use the highest intelligence of
+ the army for purposes of spying and thereby they achieve
+ great results. Spies are a most important element in water,
+ because on them depends an army's ability to move.
+
+
diff --git a/mach/Makefile b/mach/Makefile
index c5ce28b6df..12de148cfe 100644
--- a/mach/Makefile
+++ b/mach/Makefile
@@ -75,7 +75,7 @@ $(objpfx)mach-syscalls.mk: syscalls.awk Makefile
$(CC) $(CPPFLAGS) -E -x c-header - \
-D_MACH_`echo $(base-machine) | tr a-z A-Z`_SYSCALL_SW_H_=1 | \
sed -n -e 's/^kernel_trap(\(.*\),\([-0-9]*\),\([0-9]*\))$$/\1 \2 \3/p'\
- | awk -f $< > $@-new
+ | $(AWK) -f $< > $@-new
cat $@-dep >> $@-new; rm -f $@-dep
mv $@-new $@
generated += mach-syscalls.mk
@@ -117,8 +117,8 @@ mach/mach_interface.uh mach/mach_host.uh mach/mach_port.uh: $(objpfx)mach-syscal
ifdef mach-shortcuts
$(mach-shortcuts:%=$(objpfx)%.c): $(objpfx)%.c: shortcut.awk \
$(objpfx)RPC_%_rpc.c
- gawk -v alias=$* -v call=__$* -v rpc=__$*_rpc -v syscall=__syscall_$* \
- -f $^ > $@-new
+ $(AWK) -v alias=$* -v call=__$* -v rpc=__$*_rpc \
+ -v syscall=__syscall_$* -f $^ > $@-new
mv $@-new $@
generated += $(mach-shortcuts:%=%.c)
endif # mach-shortcuts
@@ -148,5 +148,5 @@ include ../Rules
generated += errsystems.c
$(objpfx)errsystems.c: errsystems.awk err_*.sub \
$(wildcard $(addsuffix /err_*.sub,$(+sysdep_dirs)))
- gawk -v subsys='$(filter-out $<,$^)' -f $^ > $@.n
+ $(AWK) -v subsys='$(filter-out $<,$^)' -f $^ > $@.n
mv $@.n $@
diff --git a/manual/Makefile b/manual/Makefile
index e4efe73ae5..d4c33e68a9 100644
--- a/manual/Makefile
+++ b/manual/Makefile
@@ -21,8 +21,6 @@
subdir := manual
export subdir := $(subdir)
-# We need GNU awk for the xtract-typefun script.
-GAWK = gawk
# Allow override
INSTALL_INFO = install-info
@@ -62,7 +60,7 @@ chapters-incl := $(chapters-incl1) $(chapters-incl2)
define find-includes
(echo '$(@F) :=' \\ ;\
- awk '$$1 == "@include" { print $$2 " \\" }' $^) > $@.new
+ $(AWK) '$$1 == "@include" { print $$2 " \\" }' $^) > $@.new
mv -f $@.new $@
endef
@@ -78,7 +76,7 @@ libc.dvi: texinfo.tex
# Generate the summary from the Texinfo source files for each chapter.
summary.texi: stamp-summary ;
stamp-summary: summary.awk $(chapters) $(chapters-incl)
- awk -f $^ \
+ $(AWK) -f $^ \
| sort -df +1 -2 | tr '\014' '\012' > summary-tmp
./move-if-change summary-tmp summary.texi
# touch is broken on our machines. Sigh.
@@ -88,10 +86,10 @@ stamp-summary: summary.awk $(chapters) $(chapters-incl)
# access to the documentation of the function, variables, and other
# definitions.
dir-add.texinfo: xtract-typefun.awk $(chapters) $(chapters-incl)
- (echo "@dircategory GNU C library functions"; \
+ $(SHELL) -c '(echo "@dircategory GNU C library functions"; \
echo "@direntry"; \
- $(GAWK) -f $^ | sort; \
- echo "@end direntry";) > $@.new
+ $(AWK) -f $^; \
+ echo "@end direntry";)' > $@.new
mv -f $@.new $@
# Generate Texinfo files from the C source for the example programs.
diff --git a/manual/users.texi b/manual/users.texi
index 5ee2e64deb..d2b3b8de76 100644
--- a/manual/users.texi
+++ b/manual/users.texi
@@ -289,7 +289,7 @@ include the header files @file{sys/types.h} and @file{unistd.h}.
@comment unistd.h
@comment POSIX.1
-@deftypefun int seteuid(uid_t @var{neweuid})
+@deftypefun int seteuid (uid_t @var{neweuid})
This function sets the effective user ID of a process to @var{newuid},
provided that the process is allowed to change its effective user ID. A
privileged process (effective user ID zero) can change its effective
diff --git a/manual/xtract-typefun.awk b/manual/xtract-typefun.awk
index 2f0bbc748e..3fccd8000e 100644
--- a/manual/xtract-typefun.awk
+++ b/manual/xtract-typefun.awk
@@ -4,23 +4,38 @@ BEGIN {
}
/^@node/ {
- last_node = gensub (/@node +([^@,]+).*/, "\\1", 1);
+ name = $0;
+ sub(/^@node +/, "", name);
+ sub(/[@,].*$/, "", name);
+ last_node = name;
}
-/^@deftypefun/ {
- printf ("* %s: (libc)%s.\n",
- gensub (/@deftypefunx? +([^{ ]+|\{[^}]+\}) +([[:alpha:]_][[:alnum:]_]*).*/, "\\2", 1),
- last_node);
-}
+/^@deftype(fn|vr)/ {
+# The string we want is $4, except that if there were brace blocks
+# before that point then it gets shifted to the right, since awk
+# doesn't know from brace blocks.
+ id = 4; check = 2; squig = 0;
+ while(check < id)
+ {
+ if($check ~ /{/) squig++;
+ if($check ~ /}/) squig--;
+ if(squig) id++;
+ check++;
+ }
-/^@deftypevr/ {
- printf ("* %s: (libc)%s.\n",
- gensub (/@deftypevrx? +([^{ ]+|\{[^}]+\}) +([^{ ]+|\{[^}]+\}) +([[:alpha:]_][[:alnum:]_]*).*/, "\\3", 1),
- last_node);
+ printf ("* %s: (libc)%s.\n", $id, last_node);
}
-/^@deftypefn/ {
- printf ("* %s: (libc)%s.\n",
- gensub (/@deftypefnx? +([^{ ]+|\{[^}]+\}) +[^{ ]*(\{[^}]+\})? +([[:alpha:]_][[:alnum:]_]*).*/, "\\3", 1),
- last_node);
+/^@deftypefun/ {
+# Likewise, except it's $3 theoretically.
+ id = 3; check = 2; squig = 0;
+ while(check < id)
+ {
+ if($check ~ /{/) squig++;
+ if($check ~ /}/) squig--;
+ if(squig) id++;
+ check++;
+ }
+
+ printf ("* %s: (libc)%s.\n", $id, last_node);
}
diff --git a/sysdeps/generic/dl-sysdep.c b/sysdeps/generic/dl-sysdep.c
index 58c093e268..90beb8f269 100644
--- a/sysdeps/generic/dl-sysdep.c
+++ b/sysdeps/generic/dl-sysdep.c
@@ -38,7 +38,7 @@ extern char **_dl_argv;
extern char **_environ;
extern size_t _dl_pagesize;
extern const char *_dl_platform;
-extern unsigned long _dl_hwcap;
+extern unsigned long int _dl_hwcap;
extern size_t _dl_platformlen;
extern void _end;
extern void ENTRY_POINT (void);
@@ -48,7 +48,6 @@ int __libc_enable_secure;
int __libc_multiple_libcs; /* Defining this here avoids the inclusion
of init-first. */
static ElfW(auxv_t) *_dl_auxv;
-static unsigned long int hwcap;
unsigned long int _dl_hwcap_mask = HWCAP_IMPORTANT;
@@ -241,10 +240,11 @@ _dl_show_auxv (void)
_dl_sysdep_message ("AT_PLATFORM: ", av->a_un.a_ptr, "\n", NULL);
break;
case AT_HWCAP:
- hwcap = av->a_un.a_val;
- if (_dl_procinfo (hwcap) < 0)
+ _dl_hwcap = av->a_un.a_val;
+ if (_dl_procinfo (_dl_hwcap) < 0)
_dl_sysdep_message ("AT_HWCAP: ",
- _itoa_word (hwcap, buf + sizeof buf - 1, 16, 0),
+ _itoa_word (_dl_hwcap, buf + sizeof buf - 1,
+ 16, 0),
"\n", NULL);
break;
}
@@ -284,7 +284,7 @@ _dl_important_hwcaps (const char *platform, size_t platform_len, size_t *sz,
size_t *max_capstrlen)
{
/* Determine how many important bits are set. */
- unsigned long int mask = _dl_hwcap_mask;
+ unsigned long int masked = _dl_hwcap & _dl_hwcap_mask;
size_t cnt = platform != NULL;
size_t n, m;
size_t total;
@@ -293,8 +293,9 @@ _dl_important_hwcaps (const char *platform, size_t platform_len, size_t *sz,
struct r_strlenpair *rp;
char *cp;
- for (n = 0; (~((1UL << n) - 1) & mask) != 0; ++n)
- if ((mask & (1UL << n)) != 0)
+ /* Count the number of bits set in the masked value. */
+ for (n = 0; (~((1UL << n) - 1) & masked) != 0; ++n)
+ if ((masked & (1UL << n)) != 0)
++cnt;
if (cnt == 0)
@@ -318,12 +319,12 @@ _dl_important_hwcaps (const char *platform, size_t platform_len, size_t *sz,
/* Create temporary data structure to generate result table. */
temp = (struct r_strlenpair *) alloca (cnt * sizeof (*temp));
m = 0;
- for (n = 0; mask != 0; ++n)
- if ((mask & (1UL << n)) != 0)
+ for (n = 0; masked != 0; ++n)
+ if ((masked & (1UL << n)) != 0)
{
temp[m].str = _dl_hwcap_string (n);
temp[m].len = strlen (temp[m].str);
- mask ^= 1UL << n;
+ masked ^= 1UL << n;
++m;
}
if (platform != NULL)
diff --git a/sysdeps/gnu/Makefile b/sysdeps/gnu/Makefile
index 762f79b866..77f0b230fd 100644
--- a/sysdeps/gnu/Makefile
+++ b/sysdeps/gnu/Makefile
@@ -21,7 +21,7 @@
$(..)sysdeps/gnu/errlist.c: $(..)sysdeps/gnu/errlist.awk \
$(..)manual/errno.texi
- awk -f $^ > $@-tmp
+ $(AWK) -f $^ > $@-tmp
# Make it unwritable so noone will edit it by mistake.
-chmod a-w $@-tmp
mv -f $@-tmp $@
diff --git a/sysdeps/gnu/errlist.awk b/sysdeps/gnu/errlist.awk
index a14c29cf98..b40606a696 100644
--- a/sysdeps/gnu/errlist.awk
+++ b/sysdeps/gnu/errlist.awk
@@ -34,9 +34,14 @@ BEGIN {
print "";
print "#ifndef SYS_ERRLIST";
print "# define SYS_ERRLIST _sys_errlist";
+ print "# define SYS_ERRLIST_ALIAS sys_errlist";
print "#endif";
print "#ifndef SYS_NERR";
print "# define SYS_NERR _sys_nerr";
+ print "# define SYS_NERR_ALIAS sys_nerr";
+ print "#endif";
+ print "#ifndef ERR_REMAP";
+ print "# define ERR_REMAP(n) n";
print "#endif";
print "";
print "const char *const SYS_ERRLIST[] =";
@@ -70,7 +75,7 @@ errnoh == 3 && $1 == "@comment" && $2 == "errno" \
errnoh == 4 && $1 == "@end" && $2 == "deftypevr" \
{
printf "/*%s */\n", desc;
- printf " [%s] = N_(\"%s\"),\n", e, etext;
+ printf " [ERR_REMAP (%s)] = N_(\"%s\"),\n", e, etext;
print "#endif";
errnoh = 0;
next;
@@ -85,8 +90,10 @@ END {
print " };";
print "";
print "const int SYS_NERR = sizeof SYS_ERRLIST / sizeof SYS_ERRLIST [0];";
- print "#if !defined HAVE_ELF || !defined PIC || !defined DO_VERSIONING";
- print "weak_alias (_sys_errlist, sys_errlist)";
- print "weak_alias (_sys_nerr, sys_nerr)";
+ print "#ifdef SYS_ERRLIST_ALIAS";
+ print "weak_alias (_sys_errlist, SYS_ERRLIST_ALIAS)";
+ print "#endif";
+ print "#ifdef SYS_NERR_ALIAS";
+ print "weak_alias (_sys_nerr, SYS_NERR_ALIAS)";
print "#endif";
}
diff --git a/sysdeps/mach/hurd/Dist b/sysdeps/mach/hurd/Dist
index 084c314649..03f422d794 100644
--- a/sysdeps/mach/hurd/Dist
+++ b/sysdeps/mach/hurd/Dist
@@ -1,3 +1,4 @@
+errlist.c
errnos.awk
err_hurd.sub
libc-ldscript
diff --git a/sysdeps/mach/hurd/Makefile b/sysdeps/mach/hurd/Makefile
index 454ac8f98c..b3161ca195 100644
--- a/sysdeps/mach/hurd/Makefile
+++ b/sysdeps/mach/hurd/Makefile
@@ -87,7 +87,7 @@ $(common-objpfx)errnos.d: $(mach-errnos-deps)
$(hurd)/errnos.h: $(common-objpfx)stamp-errnos ;
$(common-objpfx)stamp-errnos: $(hurd)/errnos.awk $(errno.texinfo) \
$(mach-errnos-deps)
- gawk -f $^ > $(hurd)/errnos.h-tmp
+ $(AWK) -f $^ > $(hurd)/errnos.h-tmp
# Make it unwritable so noone will edit it by mistake.
-chmod a-w $(hurd)/errnos.h-tmp
./$(..)move-if-change $(hurd)/errnos.h-tmp $(hurd)/errnos.h
diff --git a/sysdeps/mach/hurd/errlist.c b/sysdeps/mach/hurd/errlist.c
new file mode 100644
index 0000000000..5cbc543ed1
--- /dev/null
+++ b/sysdeps/mach/hurd/errlist.c
@@ -0,0 +1,26 @@
+/* Copyright (C) 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/* SYS_ERRLIST cannot have Unix semantics on the Hurd, so it is easier
+ just to rename it. We also need to remap error codes to array
+ indices by taking their subcode. */
+#define SYS_ERRLIST _hurd_errlist
+#define SYS_NERR _hurd_nerr
+#define ERR_REMAP(n) (n & 0x3fff)
+
+#include <sysdeps/gnu/errlist.c>
diff --git a/sysdeps/unix/Makefile b/sysdeps/unix/Makefile
index 4863556332..234caee5d4 100644
--- a/sysdeps/unix/Makefile
+++ b/sysdeps/unix/Makefile
@@ -54,7 +54,7 @@ $(common-objpfx)sys/param.h: $(sysincludedir)/sys/param.h
(echo '#ifndef _SYS_PARAM_H'; \
echo '#define _SYS_PARAM_H 1'; \
echo '#include <endian.h>'; \
- awk < $< \
+ $(AWK) < $< \
'/^#define[ ]*NULL/ { print "#ifndef NULL"; \
print $$0; \
print "#endif"; \
@@ -142,7 +142,7 @@ $(common-objpfx)make-errnos: $(common-objpfx)make-errnos.c
$(common-objpfx)make-errnos.c: $(sysdep_dir)/unix/errnos-tmpl.c \
$(sysdep_dir)/unix/errnos.awk $(common-objpfx)errnos
- awk -f $(word 2,$^) errnos="`tr '\012' ' ' < $(word 3,$^)`" $< > $@T
+ $(AWK) -f $(word 2,$^) errnos="`tr '\012' ' ' < $(word 3,$^)`" $< > $@T
mv $@T $@
$(common-objpfx)errnos: $(wildcard $(sysincludedir)/errno.h \
@@ -176,7 +176,7 @@ $(common-objpfx)make-ioctls: $(common-objpfx)make-ioctls.c
$(common-objpfx)make-ioctls.c: $(sysdep_dir)/unix/ioctls-tmpl.c \
$(sysdep_dir)/unix/ioctls.awk \
$(common-objpfx)ioctls
- awk -f $(word 2,$^) requests="`cat $(word 3,$^)`" $< > $@T
+ $(AWK) -f $(word 2,$^) requests="`cat $(word 3,$^)`" $< > $@T
mv $@T $@
diff --git a/time/strftime.c b/time/strftime.c
index 7bb0810547..f0be6b646d 100644
--- a/time/strftime.c
+++ b/time/strftime.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
+/* Copyright (C) 1991,92,93,94,95,96,97,98 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -480,7 +480,7 @@ my_strftime (s, maxsize, format, tp)
for (f = format; *f != '\0'; ++f)
{
- int pad; /* Padding for number ('-', '_', or 0). */
+ int pad = 0; /* Padding for number ('-', '_', or 0). */
int modifier; /* Field modifier ('E', 'O', or 0). */
int digits; /* Max digits for numeric format. */
int number_value; /* Numeric value to be printed. */
@@ -570,7 +570,6 @@ my_strftime (s, maxsize, format, tp)
#endif /* ! DO_MULTIBYTE */
/* Check for flags that can modify a format. */
- pad = 0;
while (1)
{
switch (*++f)
diff --git a/timezone/Makefile b/timezone/Makefile
index 3d05109916..1c28d86d2b 100644
--- a/timezone/Makefile
+++ b/timezone/Makefile
@@ -89,7 +89,7 @@ $(tzfiles:%=$(objpfx)z.%): $(objpfx)z.%: % Makefile
# The extra kludge for the $(tzlinks) files is necessary since running zic
# this file requires all other files to exist. Blech!
(echo 'define $*-zones' ;\
- awk '$$1 == "Zone" { print $$2 } $$1 == "Link" { print $$3 }' $^ ;\
+ $(AWK) '$$1 == "Zone" { print $$2 } $$1 == "Link" { print $$3 }' $^ ;\
echo 'endef' ;\
echo '$*-zones := $$(subst $$(nl), ,$$($*-zones))' ;\
echo 'ifdef $*-zones' ;\
diff --git a/wcsmbs/btowc.c b/wcsmbs/btowc.c
index b40a98f65b..3ca5af2782 100644
--- a/wcsmbs/btowc.c
+++ b/wcsmbs/btowc.c
@@ -31,7 +31,7 @@ __btowc (c)
char buf[sizeof (wchar_t)];
struct gconv_step_data data;
char inbuf[1];
- char *inptr = inbuf;
+ const char *inptr = inbuf;
size_t converted;
int status;
diff --git a/wcsmbs/wcsnrtombs.c b/wcsmbs/wcsnrtombs.c
index 4b6232a182..37b525b7eb 100644
--- a/wcsmbs/wcsnrtombs.c
+++ b/wcsmbs/wcsnrtombs.c
@@ -46,7 +46,7 @@ __wcsnrtombs (dst, src, nwc, len, ps)
struct gconv_step_data data;
const wchar_t *srcend;
int status;
- size_t result;
+ size_t result = 0;
/* Tell where we want the result. */
data.is_last = 1;
diff --git a/wcsmbs/wcsrtombs.c b/wcsmbs/wcsrtombs.c
index 428ef3d4dd..b055a09d03 100644
--- a/wcsmbs/wcsrtombs.c
+++ b/wcsmbs/wcsrtombs.c
@@ -42,7 +42,7 @@ __wcsrtombs (dst, src, len, ps)
{
struct gconv_step_data data;
int status;
- size_t result;
+ size_t result = 0;
/* Tell where we want the result. */
data.is_last = 1;