]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Update.
authorUlrich Drepper <drepper@redhat.com>
Tue, 21 Apr 1998 18:15:51 +0000 (18:15 +0000)
committerUlrich Drepper <drepper@redhat.com>
Tue, 21 Apr 1998 18:15:51 +0000 (18:15 +0000)
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.

* 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.

36 files changed:
ChangeLog
Makefile
config.make.in
configure
configure.in
csu/Makefile
elf/Makefile
elf/dl-minimal.c
elf/rtld.c
iconv/gconv.c
iconv/gconv_open.c
iconv/gconv_simple.c
iconv/loop.c
iconv/skeleton.c
iconvdata/Makefile
iconvdata/TESTS
iconvdata/big5.c
iconvdata/iso8859-1.c
iconvdata/run-iconv-test.sh
iconvdata/testdata/suntzus [new file with mode: 0644]
mach/Makefile
manual/Makefile
manual/users.texi
manual/xtract-typefun.awk
sysdeps/generic/dl-sysdep.c
sysdeps/gnu/Makefile
sysdeps/gnu/errlist.awk
sysdeps/mach/hurd/Dist
sysdeps/mach/hurd/Makefile
sysdeps/mach/hurd/errlist.c [new file with mode: 0644]
sysdeps/unix/Makefile
time/strftime.c
timezone/Makefile
wcsmbs/btowc.c
wcsmbs/wcsnrtombs.c
wcsmbs/wcsrtombs.c

index 105bed4c21aa17392fc69f152b6d3934d59078d3..8672e03dcd8b04b333ad279996b90c314071c4ad 100644 (file)
--- 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
        (_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.
 
index 923a81ec815b08c597edec41f9fd6ed7f1e27012..1de8be7008d19026822beba444007045f50515a3 100644 (file)
--- 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
index 0a2c873e7adb9ef59ee42a0b6ad64a913e058348..ecad392a7f1c2fc61367eba156bb9e7bd5351cf8 100644 (file)
@@ -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.
index 083cca461d42c8d88cee2ea12f4243d5f3795500..474b21ef6747b2e05d14cb7f2d7d3ebb0feda335 100755 (executable)
--- 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
index aca7dd1031a71296ebb2d6042ff277fc6849b711..b7727c3459b4d1de07beadec9cf4f25b12f9bce6 100644 (file)
@@ -557,6 +557,7 @@ else
 fi
 AC_SUBST(libc_cv_have_ksh)
 
+AC_PROG_AWK
 AC_PATH_PROGS(PERL, perl, no)
 AC_SUBST(PERL)
 
index 7482cafc9ce816aabecdd11e16735702c33e6f41..da17b2c301b677b6c4fe6de4dea258fb9ea29976 100644 (file)
@@ -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
 
index 8ad8d98f10161fbba9144ba9706a8f0f85cfbef7..9ce3ac51e24232e9e180ed9292cefa157b23b411 100644 (file)
@@ -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
index 70b5aeeeac62d98c1894c3ef572f20eeb23621b9..249ff712254acdf3163ae1d252dbdd02109af71d 100644 (file)
@@ -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;
index b07a076b69ca41bb98d8eda7d806eb081e5f0cec..6b1a5c2b73282ea8434d42d6ae5b1edb4decb686 100644 (file)
@@ -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);
index aa58bdba7d3e70aae52737e38c4aa788d7ae9abc..24dc21e2c298d8cce4575d5a380dc45be1b79576 100644 (file)
@@ -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);
index 831794fc22eb1af4a953a666e70eac6a500a0784..d7e0191cca563cb579abb715d69bc56ffc3b9dc0 100644 (file)
@@ -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;
                    }
                }
            }
index f2fec12fb88bc059980e41407960e6d7e8f1168b..95b4a66daf1d36ac3c8bf96da5ba0c565a8ff24b 100644 (file)
@@ -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>
index b8657d574cf16dd305ba5f425dd79133ff016b2b..e1c1ab6e49a6afcd5c4e2dda485be9a00f3c6c3f 100644 (file)
@@ -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.  */
index 3582f14110407ae586a5365d8f67680ddfc8fb2b..f905bcdaea536a349adf925d0b79070cefc7800e 100644 (file)
@@ -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 */
                    }
 
index 69576859eceb6a3443214a0866ad746fc068c015..c590ab20b440bf57ea651132f82872a9133d654a 100644 (file)
@@ -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)) \
index 41d7edcaf194ff2f5f8137506fb631ca06c17700..c37381e70db2b8eeed737b90d7dc42cd73e463fd 100644 (file)
 # 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
index 296271216779616e763847c3af4f2803d053146d..d4d89a04fffea9a162a4811f3e0367d8fea93146 100644 (file)
@@ -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;                                     \
index 3e50b79f17f33bfb859630dc32fad1972d88d2c3..c7b35b37dc8bb547ebda75a06c8133eeb670cc39 100644 (file)
@@ -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 \
   {                                                                          \
index af6a136c4a3008b445612a8837d0861a77c4777d..45061373cf07e8d9cb41a713782e1977fcd9e915 100755 (executable)
@@ -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 (file)
index 0000000..4432c05
--- /dev/null
@@ -0,0 +1,1693 @@
+\r
+\r
+\r
+\r
+                     SUN TZU ON THE ART OF WAR \r
+            THE OLDEST MILITARY TREATISE IN THE WORLD \r
+\r
+                    Translated from the Chinese \r
+                    By LIONEL GILES, M.A. (1910)\r
+\r
+\r
+\r
+[This is the basic text of Sun Tzu on the Art of War.  It was\r
+extracted from Mr. Giles' complete work as titled above.  The\r
+commentary itself, which, of course includes this work embedded\r
+within it, has been released as suntzu10.txt (or suntzu10.zip).\r
+This is being released only as an adjunct to that work, which\r
+contains a wealth of commentary upon this text.]\r
+\r
+\r
+\r
+\r
+I. LAYING PLANS\r
+\r
+\r
+ 1. Sun Tzu said:  The art of war is of vital importance\r
+    to the State.\r
+\r
+ 2. It is a matter of life and death, a road either\r
+    to safety or to ruin.  Hence it is a subject of inquiry\r
+    which can on no account be neglected.\r
+\r
+ 3. The art of war, then, is governed by five constant\r
+    factors, to be taken into account in one's deliberations,\r
+    when seeking to determine the conditions obtaining in the field.\r
+\r
+ 4. These are:  (1) The Moral Law; (2) Heaven; (3) Earth;\r
+    (4) The Commander; (5) Method and discipline.\r
+\r
+5,6. The Moral Law causes the people to be in complete\r
+    accord with their ruler, so that they will follow him\r
+    regardless of their lives, undismayed by any danger.\r
+\r
+ 7. Heaven signifies night and day, cold and heat,\r
+    times and seasons.\r
+\r
+ 8. Earth comprises distances, great and small;\r
+    danger and security; open ground and narrow passes;\r
+    the chances of life and death.\r
+\r
+ 9. The Commander stands for the virtues of wisdom,\r
+    sincerely, benevolence, courage and strictness.\r
+\r
+10. By method and discipline are to be understood\r
+    the marshaling of the army in its proper subdivisions,\r
+    the graduations of rank among the officers, the maintenance\r
+    of roads by which supplies may reach the army, and the\r
+    control of military expenditure.\r
+\r
+11. These five heads should be familiar to every general: \r
+    he who knows them will be victorious; he who knows them\r
+    not will fail.\r
+\r
+12. Therefore, in your deliberations, when seeking\r
+    to determine the military conditions, let them be made\r
+    the basis of a comparison, in this wise:--\r
+\r
+13. (1) Which of the two sovereigns is imbued\r
+        with the Moral law?\r
+    (2) Which of the two generals has most ability?\r
+    (3) With whom lie the advantages derived from Heaven\r
+        and Earth?\r
+    (4) On which side is discipline most rigorously enforced?\r
+    (5) Which army is stronger?\r
+    (6) On which side are officers and men more highly trained?\r
+    (7) In which army is there the greater constancy\r
+        both in reward and punishment?\r
+\r
+14. By means of these seven considerations I can\r
+    forecast victory or defeat.\r
+\r
+15. The general that hearkens to my counsel and acts\r
+    upon it, will conquer:  let such a one be retained in command! \r
+    The general that hearkens not to my counsel nor acts upon it,\r
+    will suffer defeat:--let such a one be dismissed!\r
+\r
+16. While heading the profit of my counsel,\r
+    avail yourself also of any helpful circumstances\r
+    over and beyond the ordinary rules.\r
+\r
+17. According as circumstances are favorable,\r
+    one should modify one's plans.\r
+\r
+18. All warfare is based on deception.\r
+\r
+19. Hence, when able to attack, we must seem unable;\r
+    when using our forces, we must seem inactive; when we\r
+    are near, we must make the enemy believe we are far away;\r
+    when far away, we must make him believe we are near.\r
+\r
+20. Hold out baits to entice the enemy.  Feign disorder,\r
+    and crush him.\r
+\r
+21. If he is secure at all points, be prepared for him. \r
+    If he is in superior strength, evade him.\r
+\r
+22. If your opponent is of choleric temper, seek to\r
+    irritate him.  Pretend to be weak, that he may grow arrogant.\r
+\r
+23. If he is taking his ease, give him no rest. \r
+    If his forces are united, separate them.\r
+\r
+24. Attack him where he is unprepared, appear where\r
+    you are not expected.\r
+\r
+25. These military devices, leading to victory,\r
+    must not be divulged beforehand.\r
+\r
+26. Now the general who wins a battle makes many\r
+    calculations in his temple ere the battle is fought. \r
+    The general who loses a battle makes but few\r
+    calculations beforehand.  Thus do many calculations\r
+    lead to victory, and few calculations to defeat: \r
+    how much more no calculation at all!  It is by attention\r
+    to this point that I can foresee who is likely to win or lose.\r
+\r
+\r
+II. WAGING WAR\r
+\r
+\r
+ 1. Sun Tzu said:  In the operations of war,\r
+    where there are in the field a thousand swift chariots,\r
+    as many heavy chariots, and a hundred thousand\r
+    mail-clad soldiers, with provisions enough to carry them\r
+    a thousand li, the expenditure at home and at the front,\r
+    including entertainment of guests, small items such as\r
+    glue and paint, and sums spent on chariots and armor,\r
+    will reach the total of a thousand ounces of silver per day. \r
+    Such is the cost of raising an army of 100,000 men.\r
+\r
+ 2. When you engage in actual fighting, if victory\r
+    is long in coming, then men's weapons will grow dull and\r
+    their ardor will be damped.  If you lay siege to a town,\r
+    you will exhaust your strength.\r
+ 3. Again, if the campaign is protracted, the resources\r
+    of the State will not be equal to the strain.\r
+\r
+ 4. Now, when your weapons are dulled, your ardor damped,\r
+    your strength exhausted and your treasure spent,\r
+    other chieftains will spring up to take advantage\r
+    of your extremity.  Then no man, however wise,\r
+    will be able to avert the consequences that must ensue.\r
+\r
+ 5. Thus, though we have heard of stupid haste in war,\r
+    cleverness has never been seen associated with long delays.\r
+\r
+ 6. There is no instance of a country having benefited\r
+    from prolonged warfare.\r
+\r
+ 7. It is only one who is thoroughly acquainted\r
+    with the evils of war that can thoroughly understand\r
+    the profitable way of carrying it on.\r
+\r
+ 8. The skillful soldier does not raise a second levy,\r
+    neither are his supply-wagons loaded more than twice.\r
+\r
+ 9. Bring war material with you from home, but forage\r
+    on the enemy.  Thus the army will have food enough\r
+    for its needs.\r
+\r
+10. Poverty of the State exchequer causes an army\r
+    to be maintained by contributions from a distance. \r
+    Contributing to maintain an army at a distance causes\r
+    the people to be impoverished.\r
+\r
+11. On the other hand, the proximity of an army causes\r
+    prices to go up; and high prices cause the people's\r
+    substance to be drained away.\r
+\r
+12. When their substance is drained away, the peasantry\r
+    will be afflicted by heavy exactions.\r
+\r
+13,14. With this loss of substance and exhaustion\r
+    of strength, the homes of the people will be stripped bare,\r
+    and three-tenths of their income will be dissipated;\r
+    while government expenses for broken chariots, worn-out horses,\r
+    breast-plates and helmets, bows and arrows, spears and shields,\r
+    protective mantles, draught-oxen and heavy wagons,\r
+    will amount to four-tenths of its total revenue.\r
+\r
+15. Hence a wise general makes a point of foraging\r
+    on the enemy.  One cartload of the enemy's provisions\r
+    is equivalent to twenty of one's own, and likewise\r
+    a single picul of his provender is equivalent to twenty\r
+    from one's own store.\r
+\r
+16. Now in order to kill the enemy, our men must\r
+    be roused to anger; that there may be advantage from\r
+    defeating the enemy, they must have their rewards.\r
+\r
+17. Therefore in chariot fighting, when ten or more chariots\r
+    have been taken, those should be rewarded who took the first. \r
+    Our own flags should be substituted for those of the enemy,\r
+    and the chariots mingled and used in conjunction with ours. \r
+    The captured soldiers should be kindly treated and kept.\r
+\r
+18. This is called, using the conquered foe to augment\r
+    one's own strength.\r
+\r
+19. In war, then, let your great object be victory,\r
+    not lengthy campaigns.\r
+\r
+20. Thus it may be known that the leader of armies\r
+    is the arbiter of the people's fate, the man on whom it\r
+    depends whether the nation shall be in peace or in peril.\r
+\r
+\r
+III. ATTACK BY STRATAGEM\r
+\r
+\r
+ 1. Sun Tzu said:  In the practical art of war, the best\r
+    thing of all is to take the enemy's country whole and intact;\r
+    to shatter and destroy it is not so good.  So, too, it is\r
+    better to recapture an army entire than to destroy it,\r
+    to capture a regiment, a detachment or a company entire\r
+    than to destroy them.\r
+\r
+ 2. Hence to fight and conquer in all your battles\r
+    is not supreme excellence; supreme excellence consists\r
+    in breaking the enemy's resistance without fighting.\r
+\r
+ 3. Thus the highest form of generalship is to\r
+    balk the enemy's plans; the next best is to prevent\r
+    the junction of the enemy's forces; the next in\r
+    order is to attack the enemy's army in the field;\r
+    and the worst policy of all is to besiege walled cities.\r
+\r
+ 4. The rule is, not to besiege walled cities if it\r
+    can possibly be avoided.  The preparation of mantlets,\r
+    movable shelters, and various implements of war, will take\r
+    up three whole months; and the piling up of mounds over\r
+    against the walls will take three months more.\r
+\r
+ 5. The general, unable to control his irritation,\r
+    will launch his men to the assault like swarming ants,\r
+    with the result that one-third of his men are slain,\r
+    while the town still remains untaken.  Such are the disastrous\r
+    effects of a siege.\r
+\r
+ 6. Therefore the skillful leader subdues the enemy's\r
+    troops without any fighting; he captures their cities\r
+    without laying siege to them; he overthrows their kingdom\r
+    without lengthy operations in the field.\r
+\r
+ 7. With his forces intact he will dispute the mastery\r
+    of the Empire, and thus, without losing a man, his triumph\r
+    will be complete.  This is the method of attacking by stratagem.\r
+\r
+ 8. It is the rule in war, if our forces are ten\r
+    to the enemy's one, to surround him; if five to one,\r
+    to attack him; if twice as numerous, to divide our army\r
+    into two.\r
+\r
+ 9. If equally matched, we can offer battle;\r
+    if slightly inferior in numbers, we can avoid the enemy;\r
+    if quite unequal in every way, we can flee from him.\r
+\r
+10. Hence, though an obstinate fight may be made\r
+    by a small force, in the end it must be captured\r
+    by the larger force.\r
+\r
+11. Now the general is the bulwark of the State;\r
+    if the bulwark is complete at all points; the State will\r
+    be strong; if the bulwark is defective, the State will\r
+    be weak.\r
+\r
+12. There are three ways in which a ruler can bring\r
+    misfortune upon his army:--\r
+\r
+13. (1) By commanding the army to advance or to retreat,\r
+    being ignorant of the fact that it cannot obey. \r
+    This is called hobbling the army.\r
+\r
+14. (2) By attempting to govern an army in the\r
+    same way as he administers a kingdom, being ignorant\r
+    of the conditions which obtain in an army.  This causes\r
+    restlessness in the soldier's minds.\r
+\r
+15. (3) By employing the officers of his army\r
+    without discrimination, through ignorance of the\r
+    military principle of adaptation to circumstances. \r
+    This shakes the confidence of the soldiers.\r
+\r
+16. But when the army is restless and distrustful,\r
+    trouble is sure to come from the other feudal princes. \r
+    This is simply bringing anarchy into the army, and flinging\r
+    victory away.\r
+\r
+17. Thus we may know that there are five essentials\r
+    for victory:\r
+    (1) He will win who knows when to fight and when\r
+        not to fight.\r
+    (2) He will win who knows how to handle both superior\r
+        and inferior forces.\r
+    (3) He will win whose army is animated by the same\r
+        spirit throughout all its ranks.\r
+    (4) He will win who, prepared himself, waits to take\r
+        the enemy unprepared.\r
+    (5) He will win who has military capacity and is\r
+        not interfered with by the sovereign.\r
+\r
+18. Hence the saying:  If you know the enemy\r
+    and know yourself, you need not fear the result of a\r
+    hundred battles.  If you know yourself but not the enemy,\r
+    for every victory gained you will also suffer a defeat. \r
+    If you know neither the enemy nor yourself, you will\r
+    succumb in every battle.\r
+\r
+\r
+IV. TACTICAL DISPOSITIONS\r
+\r
+\r
+ 1. Sun Tzu said:  The good fighters of old first put\r
+    themselves beyond the possibility of defeat, and then\r
+    waited for an opportunity of defeating the enemy.\r
+\r
+ 2. To secure ourselves against defeat lies in our\r
+    own hands, but the opportunity of defeating the enemy\r
+    is provided by the enemy himself.\r
+ 3. Thus the good fighter is able to secure himself against defeat,\r
+    but cannot make certain of defeating the enemy.\r
+\r
+ 4. Hence the saying:  One may know how to conquer\r
+    without being able to do it.\r
+\r
+ 5. Security against defeat implies defensive tactics;\r
+    ability to defeat the enemy means taking the offensive.\r
+\r
+ 6. Standing on the defensive indicates insufficient\r
+    strength; attacking, a superabundance of strength.\r
+\r
+ 7. The general who is skilled in defense hides in the\r
+    most secret recesses of the earth; he who is skilled in\r
+    attack flashes forth from the topmost heights of heaven. \r
+    Thus on the one hand we have ability to protect ourselves;\r
+    on the other, a victory that is complete.\r
+\r
+ 8. To see victory only when it is within the ken\r
+    of the common herd is not the acme of excellence.\r
+\r
+ 9. Neither is it the acme of excellence if you fight\r
+    and conquer and the whole Empire says, "Well done!"\r
+\r
+10. To lift an autumn hair is no sign of great strength;\r
+    to see the sun and moon is no sign of sharp sight;\r
+    to hear the noise of thunder is no sign of a quick ear.\r
+\r
+11. What the ancients called a clever fighter is\r
+    one who not only wins, but excels in winning with ease.\r
+\r
+12. Hence his victories bring him neither reputation\r
+    for wisdom nor credit for courage.\r
+\r
+13. He wins his battles by making no mistakes. \r
+    Making no mistakes is what establishes the certainty\r
+    of victory, for it means conquering an enemy that is\r
+    already defeated.\r
+\r
+14. Hence the skillful fighter puts himself into\r
+    a position which makes defeat impossible, and does\r
+    not miss the moment for defeating the enemy.\r
+\r
+15. Thus it is that in war the victorious strategist\r
+    only seeks battle after the victory has been won,\r
+    whereas he who is destined to defeat first fights\r
+    and afterwards looks for victory.\r
+\r
+16. The consummate leader cultivates the moral law,\r
+    and strictly adheres to method and discipline; thus it is\r
+    in his power to control success.\r
+\r
+17. In respect of military method, we have,\r
+    firstly, Measurement; secondly, Estimation of quantity;\r
+    thirdly, Calculation; fourthly, Balancing of chances;\r
+    fifthly, Victory.\r
+\r
+18. Measurement owes its existence to Earth;\r
+    Estimation of quantity to Measurement; Calculation to\r
+    Estimation of quantity; Balancing of chances to Calculation;\r
+    and Victory to Balancing of chances.\r
+\r
+19. A victorious army opposed to a routed one, is as\r
+    a pound's weight placed in the scale against a single grain.\r
+\r
+20. The onrush of a conquering force is like the bursting\r
+    of pent-up waters into a chasm a thousand fathoms deep.\r
+\r
+\r
+V. ENERGY\r
+\r
+\r
+ 1. Sun Tzu said:  The control of a large force\r
+    is the same principle as the control of a few men: \r
+    it is merely a question of dividing up their numbers.\r
+\r
+ 2. Fighting with a large army under your command\r
+    is nowise different from fighting with a small one: \r
+    it is merely a question of instituting signs and signals.\r
+\r
+ 3. To ensure that your whole host may withstand\r
+    the brunt of the enemy's attack and remain unshaken--\r
+    this is effected by maneuvers direct and indirect.\r
+\r
+ 4. That the impact of your army may be like a grindstone\r
+    dashed against an egg--this is effected by the science\r
+    of weak points and strong.\r
+\r
+ 5. In all fighting, the direct method may be used\r
+    for joining battle, but indirect methods will be needed\r
+    in order to secure victory.\r
+\r
+ 6. Indirect tactics, efficiently applied, are inexhaustible\r
+    as Heaven and Earth, unending as the flow of rivers and streams;\r
+    like the sun and moon, they end but to begin anew;\r
+    like the four seasons, they pass away to return once more.\r
+\r
+ 7. There are not more than five musical notes,\r
+    yet the combinations of these five give rise to more\r
+    melodies than can ever be heard.\r
+\r
+ 8. There are not more than five primary colors\r
+    (blue, yellow, red, white, and black), yet in combination\r
+    they produce more hues than can ever been seen.\r
+\r
+ 9. There are not more than five cardinal tastes\r
+    (sour, acrid, salt, sweet, bitter), yet combinations\r
+    of them yield more flavors than can ever be tasted.\r
+\r
+10. In battle, there are not more than two methods\r
+    of attack--the direct and the indirect; yet these two\r
+    in combination give rise to an endless series of maneuvers.\r
+\r
+11. The direct and the indirect lead on to each other in turn. \r
+    It is like moving in a circle--you never come to an end. \r
+    Who can exhaust the possibilities of their combination?\r
+\r
+12. The onset of troops is like the rush of a torrent\r
+    which will even roll stones along in its course.\r
+\r
+13. The quality of decision is like the well-timed\r
+    swoop of a falcon which enables it to strike and destroy\r
+    its victim.\r
+\r
+14. Therefore the good fighter will be terrible\r
+    in his onset, and prompt in his decision.\r
+\r
+15. Energy may be likened to the bending of a crossbow;\r
+    decision, to the releasing of a trigger.\r
+\r
+16. Amid the turmoil and tumult of battle, there may\r
+    be seeming disorder and yet no real disorder at all;\r
+    amid confusion and chaos, your array may be without head\r
+    or tail, yet it will be proof against defeat.\r
+\r
+17. Simulated disorder postulates perfect discipline,\r
+    simulated fear postulates courage; simulated weakness\r
+    postulates strength.\r
+\r
+18. Hiding order beneath the cloak of disorder is\r
+    simply a question of subdivision; concealing courage under\r
+    a show of timidity presupposes a fund of latent energy;\r
+    masking strength with weakness is to be effected\r
+    by tactical dispositions.\r
+\r
+19. Thus one who is skillful at keeping the enemy\r
+    on the move maintains deceitful appearances, according to\r
+    which the enemy will act.  He sacrifices something,\r
+    that the enemy may snatch at it.\r
+\r
+20. By holding out baits, he keeps him on the march;\r
+    then with a body of picked men he lies in wait for him.\r
+\r
+21. The clever combatant looks to the effect of combined\r
+    energy, and does not require too much from individuals. \r
+    Hence his ability to pick out the right men and utilize\r
+    combined energy.\r
+\r
+22. When he utilizes combined energy, his fighting\r
+    men become as it were like unto rolling logs or stones. \r
+    For it is the nature of a log or stone to remain\r
+    motionless on level ground, and to move when on a slope;\r
+    if four-cornered, to come to a standstill, but if\r
+    round-shaped, to go rolling down.\r
+\r
+23. Thus the energy developed by good fighting men\r
+    is as the momentum of a round stone rolled down a mountain\r
+    thousands of feet in height.  So much on the subject\r
+    of energy.\r
+\r
+\r
+VI. WEAK POINTS AND STRONG\r
+\r
+\r
+ 1. Sun Tzu said:  Whoever is first in the field and\r
+    awaits the coming of the enemy, will be fresh for the fight;\r
+    whoever is second in the field and has to hasten to battle\r
+    will arrive exhausted.\r
+\r
+ 2. Therefore the clever combatant imposes his will on\r
+    the enemy, but does not allow the enemy's will to be imposed on him.\r
+\r
+ 3. By holding out advantages to him, he can cause the enemy\r
+    to approach of his own accord; or, by inflicting damage,\r
+    he can make it impossible for the enemy to draw near.\r
+\r
+ 4. If the enemy is taking his ease, he can harass him;\r
+    if well supplied with food, he can starve him out;\r
+    if quietly encamped, he can force him to move.\r
+\r
+ 5. Appear at points which the enemy must hasten to defend;\r
+    march swiftly to places where you are not expected.\r
+\r
+ 6. An army may march great distances without distress,\r
+    if it marches through country where the enemy is not.\r
+\r
+ 7. You can be sure of succeeding in your attacks\r
+    if you only attack places which are undefended.You can\r
+    ensure the safety of your defense if you only hold\r
+    positions that cannot be attacked.\r
+\r
+ 8. Hence that general is skillful in attack whose\r
+    opponent does not know what to defend; and he is skillful\r
+    in defense whose opponent does not know what to attack.\r
+\r
+ 9. O divine art of subtlety and secrecy!  Through you\r
+    we learn to be invisible, through you inaudible;\r
+    and hence we can hold the enemy's fate in our hands.\r
+\r
+10. You may advance and be absolutely irresistible,\r
+    if you make for the enemy's weak points; you may retire\r
+    and be safe from pursuit if your movements are more rapid\r
+    than those of the enemy.\r
+\r
+11. If we wish to fight, the enemy can be forced\r
+    to an engagement even though he be sheltered behind a high\r
+    rampart and a deep ditch.  All we need do is attack\r
+    some other place that he will be obliged to relieve.\r
+\r
+12. If we do not wish to fight, we can prevent\r
+    the enemy from engaging us even though the lines\r
+    of our encampment be merely traced out on the ground. \r
+    All we need do is to throw something odd and unaccountable\r
+    in his way.\r
+\r
+13. By discovering the enemy's dispositions and remaining\r
+    invisible ourselves, we can keep our forces concentrated,\r
+    while the enemy's must be divided.\r
+\r
+14. We can form a single united body, while the\r
+    enemy must split up into fractions.  Hence there will\r
+    be a whole pitted against separate parts of a whole,\r
+    which means that we shall be many to the enemy's few.\r
+\r
+15. And if we are able thus to attack an inferior force\r
+    with a superior one, our opponents will be in dire straits.\r
+\r
+16. The spot where we intend to fight must not be\r
+    made known; for then the enemy will have to prepare\r
+    against a possible attack at several different points;\r
+    and his forces being thus distributed in many directions,\r
+    the numbers we shall have to face at any given point will\r
+    be proportionately few.\r
+\r
+17. For should the enemy strengthen his van,\r
+    he will weaken his rear; should he strengthen his rear,\r
+    he will weaken his van; should he strengthen his left,\r
+    he will weaken his right; should he strengthen his right,\r
+    he will weaken his left.  If he sends reinforcements everywhere,\r
+    he will everywhere be weak.\r
+\r
+18. Numerical weakness comes from having to prepare\r
+    against possible attacks; numerical strength, from compelling\r
+    our adversary to make these preparations against us.\r
+\r
+19. Knowing the place and the time of the coming battle,\r
+    we may concentrate from the greatest distances in order\r
+    to fight.\r
+\r
+20. But if neither time nor place be known,\r
+    then the left wing will be impotent to succor the right,\r
+    the right equally impotent to succor the left, the van\r
+    unable to relieve the rear, or the rear to support the van. \r
+    How much more so if the furthest portions of the army are\r
+    anything under a hundred LI apart, and even the nearest\r
+    are separated by several LI!\r
+\r
+21. Though according to my estimate the soldiers\r
+    of Yueh exceed our own in number, that shall advantage\r
+    them nothing in the matter of victory.  I say then\r
+    that victory can be achieved.\r
+\r
+22. Though the enemy be stronger in numbers, we may\r
+    prevent him from fighting.  Scheme so as to discover\r
+    his plans and the likelihood of their success.\r
+\r
+23. Rouse him, and learn the principle of his\r
+    activity or inactivity.  Force him to reveal himself,\r
+    so as to find out his vulnerable spots.\r
+\r
+24. Carefully compare the opposing army with your own,\r
+    so that you may know where strength is superabundant\r
+    and where it is deficient.\r
+\r
+25. In making tactical dispositions, the highest pitch\r
+    you can attain is to conceal them; conceal your dispositions,\r
+    and you will be safe from the prying of the subtlest spies,\r
+    from the machinations of the wisest brains.\r
+\r
+26. How victory may be produced for them out of the enemy's\r
+    own tactics--that is what the multitude cannot comprehend.\r
+\r
+27. All men can see the tactics whereby I conquer,\r
+    but what none can see is the strategy out of which victory\r
+    is evolved.\r
+\r
+28. Do not repeat the tactics which have gained\r
+    you one victory, but let your methods be regulated\r
+    by the infinite variety of circumstances.\r
+\r
+29. Military tactics are like unto water; for water in its\r
+    natural course runs away from high places and hastens downwards.\r
+\r
+30. So in war, the way is to avoid what is strong\r
+    and to strike at what is weak.\r
+\r
+31. Water shapes its course according to the nature\r
+    of the ground over which it flows; the soldier works\r
+    out his victory in relation to the foe whom he is facing.\r
+\r
+32. Therefore, just as water retains no constant shape,\r
+    so in warfare there are no constant conditions.\r
+\r
+33. He who can modify his tactics in relation to his\r
+    opponent and thereby succeed in winning, may be called\r
+    a heaven-born captain.\r
+\r
+34. The five elements (water, fire, wood, metal, earth)\r
+    are not always equally predominant; the four seasons make\r
+    way for each other in turn.  There are short days and long;\r
+    the moon has its periods of waning and waxing.\r
+\r
+\r
+VII. MANEUVERING\r
+\r
+\r
+ 1. Sun Tzu said:  In war, the general receives his\r
+    commands from the sovereign.\r
+\r
+ 2. Having collected an army and concentrated his forces,\r
+    he must blend and harmonize the different elements thereof\r
+    before pitching his camp.\r
+\r
+ 3. After that, comes tactical maneuvering,\r
+    than which there is nothing more difficult. \r
+    The difficulty of tactical maneuvering consists\r
+    in turning the devious into the direct, and misfortune into gain.\r
+\r
+ 4. Thus, to take a long and circuitous route,\r
+    after enticing the enemy out of the way, and though starting\r
+    after him, to contrive to reach the goal before him,\r
+    shows knowledge of the artifice of DEVIATION.\r
+\r
+ 5. Maneuvering with an army is advantageous;\r
+    with an undisciplined multitude, most dangerous.\r
+\r
+ 6. If you set a fully equipped army in march in order\r
+    to snatch an advantage, the chances are that you will be\r
+    too late.  On the other hand, to detach a flying column\r
+    for the purpose involves the sacrifice of its baggage\r
+    and stores.\r
+\r
+ 7. Thus, if you order your men to roll up their\r
+    buff-coats, and make forced marches without halting day\r
+    or night, covering double the usual distance at a stretch,\r
+    doing a hundred LI in order to wrest an advantage,\r
+    the leaders of all your three divisions will fall into\r
+    the hands of the enemy.\r
+\r
+ 8. The stronger men will be in front, the jaded\r
+    ones will fall behind, and on this plan only one-tenth\r
+    of your army will reach its destination.\r
+\r
+ 9. If you march fifty LI in order to outmaneuver\r
+    the enemy, you will lose the leader of your first division,\r
+    and only half your force will reach the goal.\r
+\r
+10. If you march thirty LI with the same object,\r
+    two-thirds of your army will arrive.\r
+\r
+11. We may take it then that an army without its\r
+    baggage-train is lost; without provisions it is lost;\r
+    without bases of supply it is lost.\r
+\r
+12. We cannot enter into alliances until we are\r
+    acquainted with the designs of our neighbors.\r
+\r
+13. We are not fit to lead an army on the march\r
+    unless we are familiar with the face of the country--its\r
+    mountains and forests, its pitfalls and precipices,\r
+    its marshes and swamps.\r
+\r
+14. We shall be unable to turn natural advantage\r
+    to account unless we make use of local guides.\r
+\r
+15. In war, practice dissimulation, and you will succeed.\r
+\r
+16. Whether to concentrate or to divide your troops,\r
+    must be decided by circumstances.\r
+\r
+17. Let your rapidity be that of the wind,\r
+    your compactness that of the forest.\r
+\r
+18. In raiding and plundering be like fire,\r
+    is immovability like a mountain.\r
+\r
+19. Let your plans be dark and impenetrable as night,\r
+    and when you move, fall like a thunderbolt.\r
+\r
+20. When you plunder a countryside, let the spoil be\r
+    divided amongst your men; when you capture new territory,\r
+    cut it up into allotments for the benefit of the soldiery.\r
+\r
+21. Ponder and deliberate before you make a move.\r
+\r
+22. He will conquer who has learnt the artifice\r
+    of deviation.  Such is the art of maneuvering.\r
+\r
+23. The Book of Army Management says:  On the field\r
+    of battle, the spoken word does not carry far enough: \r
+    hence the institution of gongs and drums.  Nor can ordinary\r
+    objects be seen clearly enough:  hence the institution\r
+    of banners and flags.\r
+\r
+24. Gongs and drums, banners and flags, are means\r
+    whereby the ears and eyes of the host may be focused\r
+    on one particular point.\r
+\r
+25. The host thus forming a single united body,\r
+    is it impossible either for the brave to advance alone,\r
+    or for the cowardly to retreat alone.  This is the art\r
+    of handling large masses of men.\r
+\r
+26. In night-fighting, then, make much use of signal-fires\r
+    and drums, and in fighting by day, of flags and banners,\r
+    as a means of influencing the ears and eyes of your army.\r
+\r
+27. A whole army may be robbed of its spirit;\r
+    a commander-in-chief may be robbed of his presence of mind.\r
+\r
+28. Now a soldier's spirit is keenest in the morning;\r
+    by noonday it has begun to flag; and in the evening,\r
+    his mind is bent only on returning to camp.\r
+\r
+29. A clever general, therefore, avoids an army when\r
+    its spirit is keen, but attacks it when it is sluggish\r
+    and inclined to return.  This is the art of studying moods.\r
+\r
+30. Disciplined and calm, to await the appearance\r
+    of disorder and hubbub amongst the enemy:--this is the art\r
+    of retaining self-possession.\r
+\r
+31. To be near the goal while the enemy is still\r
+    far from it, to wait at ease while the enemy is\r
+    toiling and struggling, to be well-fed while the enemy\r
+    is famished:--this is the art of husbanding one's strength.\r
+\r
+32. To refrain from intercepting an enemy whose\r
+    banners are in perfect order, to refrain from attacking\r
+    an army drawn up in calm and confident array:--this\r
+    is the art of studying circumstances.\r
+\r
+33. It is a military axiom not to advance uphill\r
+    against the enemy, nor to oppose him when he comes downhill.\r
+\r
+34. Do not pursue an enemy who simulates flight;\r
+    do not attack soldiers whose temper is keen.\r
+\r
+35. Do not swallow bait offered by the enemy. \r
+    Do not interfere with an army that is returning home.\r
+\r
+36. When you surround an army, leave an outlet free. \r
+    Do not press a desperate foe too hard.\r
+\r
+37. Such is the art of warfare.\r
+\r
+\r
+VIII. VARIATION IN TACTICS\r
+\r
+\r
+ 1. Sun Tzu said:  In war, the general receives\r
+    his commands from the sovereign, collects his army\r
+    and concentrates his forces\r
+\r
+ 2. When in difficult country, do not encamp.  In country\r
+    where high roads intersect, join hands with your allies. \r
+    Do not linger in dangerously isolated positions. \r
+    In hemmed-in situations, you must resort to stratagem. \r
+    In desperate position, you must fight.\r
+\r
+ 3. There are roads which must not be followed,\r
+    armies which must be not attacked, towns which must\r
+    be besieged, positions which must not be contested,\r
+    commands of the sovereign which must not be obeyed.\r
+\r
+ 4. The general who thoroughly understands the advantages\r
+    that accompany variation of tactics knows how to handle\r
+    his troops.\r
+\r
+ 5. The general who does not understand these, may be well\r
+    acquainted with the configuration of the country, yet he\r
+    will not be able to turn his knowledge to practical account.\r
+\r
+ 6. So, the student of war who is unversed in the art\r
+    of war of varying his plans, even though he be acquainted\r
+    with the Five Advantages, will fail to make the best use\r
+    of his men.\r
+\r
+ 7. Hence in the wise leader's plans, considerations of\r
+    advantage and of disadvantage will be blended together.\r
+\r
+ 8. If our expectation of advantage be tempered in\r
+    this way, we may succeed in accomplishing the essential\r
+    part of our schemes.\r
+\r
+ 9. If, on the other hand, in the midst of difficulties\r
+    we are always ready to seize an advantage, we may extricate\r
+    ourselves from misfortune.\r
+\r
+10. Reduce the hostile chiefs by inflicting damage\r
+    on them; and make trouble for them, and keep them\r
+    constantly engaged; hold out specious allurements,\r
+    and make them rush to any given point.\r
+\r
+11. The art of war teaches us to rely not on the\r
+    likelihood of the enemy's not coming, but on our own readiness\r
+    to receive him; not on the chance of his not attacking,\r
+    but rather on the fact that we have made our position unassailable.\r
+\r
+12. There are five dangerous faults which may affect\r
+    a general:\r
+    (1) Recklessness, which leads to destruction;\r
+    (2) cowardice, which leads to capture;\r
+    (3) a hasty temper, which can be provoked by insults;\r
+    (4) a delicacy of honor which is sensitive to shame;\r
+    (5) over-solicitude for his men, which exposes him\r
+        to worry and trouble.\r
+\r
+13. These are the five besetting sins of a general,\r
+    ruinous to the conduct of war.\r
+\r
+14. When an army is overthrown and its leader slain,\r
+    the cause will surely be found among these five\r
+    dangerous faults.  Let them be a subject of meditation.\r
+\r
+\r
+IX.  THE ARMY ON THE MARCH\r
+\r
+\r
+ 1. Sun Tzu said:  We come now to the question of\r
+    encamping the army, and observing signs of the enemy. \r
+    Pass quickly over mountains, and keep in the neighborhood\r
+    of valleys.\r
+\r
+ 2. Camp in high places, facing the sun.  Do not climb\r
+    heights in order to fight.  So much for mountain warfare.\r
+\r
+ 3. After crossing a river, you should get far away\r
+    from it.\r
+\r
+ 4. When an invading force crosses a river in its\r
+    onward march, do not advance to meet it in mid-stream.\r
+    It will be best to let half the army get across,\r
+    and then deliver your attack.\r
+\r
+ 5. If you are anxious to fight, you should not go\r
+    to meet the invader near a river which he has to cross.\r
+\r
+ 6. Moor your craft higher up than the enemy, and facing\r
+    the sun.  Do not move up-stream to meet the enemy. \r
+    So much for river warfare.\r
+\r
+ 7. In crossing salt-marshes, your sole concern\r
+    should be to get over them quickly, without any delay.\r
+\r
+ 8. If forced to fight in a salt-marsh, you should\r
+    have water and grass near you, and get your back\r
+    to a clump of trees.  So much for operations in salt-marches.\r
+\r
+ 9. In dry, level country, take up an easily accessible\r
+    position with rising ground to your right and on your rear,\r
+    so that the danger may be in front, and safety lie behind. \r
+    So much for campaigning in flat country.\r
+\r
+10. These are the four useful branches of military\r
+    knowledge which enabled the Yellow Emperor to vanquish\r
+    four several sovereigns.\r
+\r
+11. All armies prefer high ground to low and sunny\r
+    places to dark.\r
+\r
+12. If you are careful of your men, and camp on hard\r
+    ground, the army will be free from disease of every kind,\r
+    and this will spell victory.\r
+\r
+13. When you come to a hill or a bank, occupy the\r
+    sunny side, with the slope on your right rear. \r
+    Thus you will at once act for the benefit of your soldiers\r
+    and utilize the natural advantages of the ground.\r
+\r
+14. When, in consequence of heavy rains up-country,\r
+    a river which you wish to ford is swollen and flecked\r
+    with foam, you must wait until it subsides.\r
+\r
+15. Country in which there are precipitous cliffs\r
+    with torrents running between, deep natural hollows,\r
+    confined places, tangled thickets, quagmires and crevasses,\r
+    should be left with all possible speed and not approached.\r
+\r
+16. While we keep away from such places, we should\r
+    get the enemy to approach them; while we face them,\r
+    we should let the enemy have them on his rear.\r
+\r
+17. If in the neighborhood of your camp there should\r
+    be any hilly country, ponds surrounded by aquatic grass,\r
+    hollow basins filled with reeds, or woods with thick\r
+    undergrowth, they must be carefully routed out and searched;\r
+    for these are places where men in ambush or insidious\r
+    spies are likely to be lurking.\r
+\r
+18. When the enemy is close at hand and remains quiet,\r
+    he is relying on the natural strength of his position.\r
+\r
+19. When he keeps aloof and tries to provoke a battle,\r
+    he is anxious for the other side to advance.\r
+\r
+20. If his place of encampment is easy of access,\r
+    he is tendering a bait.\r
+\r
+21. Movement amongst the trees of a forest shows that the\r
+    enemy is advancing.  The appearance of a number of screens\r
+    in the midst of thick grass means that the enemy wants to make us suspicious.\r
+\r
+22. The rising of birds in their flight is the sign\r
+    of an ambuscade.  Startled beasts indicate that a sudden\r
+    attack is coming.\r
+\r
+23. When there is dust rising in a high column,\r
+    it is the sign of chariots advancing; when the dust is low,\r
+    but spread over a wide area, it betokens the approach\r
+    of infantry.  When it branches out in different directions,\r
+    it shows that parties have been sent to collect firewood. \r
+    A few clouds of dust moving to and fro signify that the army\r
+    is encamping.\r
+\r
+24. Humble words and increased preparations are signs\r
+    that the enemy is about to advance.  Violent language\r
+    and driving forward as if to the attack are signs that he\r
+    will retreat.\r
+\r
+25. When the light chariots come out first and take\r
+    up a position on the wings, it is a sign that the enemy\r
+    is forming for battle.\r
+\r
+26. Peace proposals unaccompanied by a sworn covenant\r
+    indicate a plot.\r
+\r
+27. When there is much running about and the soldiers\r
+    fall into rank, it means that the critical moment has come.\r
+\r
+28. When some are seen advancing and some retreating,\r
+    it is a lure.\r
+\r
+29. When the soldiers stand leaning on their spears,\r
+    they are faint from want of food.\r
+\r
+30. If those who are sent to draw water begin\r
+    by drinking themselves, the army is suffering from thirst.\r
+\r
+31. If the enemy sees an advantage to be gained and\r
+    makes no effort to secure it, the soldiers are exhausted.\r
+\r
+32. If birds gather on any spot, it is unoccupied. \r
+    Clamor by night betokens nervousness.\r
+\r
+33. If there is disturbance in the camp, the general's\r
+    authority is weak.  If the banners and flags are shifted\r
+    about, sedition is afoot.  If the officers are angry,\r
+    it means that the men are weary.\r
+\r
+34. When an army feeds its horses with grain and kills\r
+    its cattle for food, and when the men do not hang their\r
+    cooking-pots over the camp-fires, showing that they\r
+    will not return to their tents, you may know that they\r
+    are determined to fight to the death.\r
+\r
+35. The sight of men whispering together in small\r
+    knots or speaking in subdued tones points to disaffection\r
+    amongst the rank and file.\r
+\r
+36. Too frequent rewards signify that the enemy is\r
+    at the end of his resources; too many punishments betray\r
+    a condition of dire distress.\r
+\r
+37. To begin by bluster, but afterwards to take fright\r
+    at the enemy's numbers, shows a supreme lack of intelligence.\r
+\r
+38. When envoys are sent with compliments in their mouths,\r
+    it is a sign that the enemy wishes for a truce.\r
+\r
+39. If the enemy's troops march up angrily and remain\r
+    facing ours for a long time without either joining\r
+    battle or taking themselves off again, the situation\r
+    is one that demands great vigilance and circumspection.\r
+\r
+40. If our troops are no more in number than the enemy,\r
+    that is amply sufficient; it only means that no direct attack\r
+    can be made.  What we can do is simply to concentrate all\r
+    our available strength, keep a close watch on the enemy,\r
+    and obtain reinforcements.\r
+\r
+41. He who exercises no forethought but makes light\r
+    of his opponents is sure to be captured by them.\r
+\r
+42. If soldiers are punished before they have grown\r
+    attached to you, they will not prove submissive; and,\r
+    unless submissive, then will be practically useless. \r
+    If, when the soldiers have become attached to you,\r
+    punishments are not enforced, they will still be unless.\r
+\r
+43. Therefore soldiers must be treated in the first\r
+    instance with humanity, but kept under control by means\r
+    of iron discipline.  This is a certain road to victory.\r
+\r
+44. If in training soldiers commands are habitually\r
+    enforced, the army will be well-disciplined; if not,\r
+    its discipline will be bad.\r
+\r
+45. If a general shows confidence in his men but always\r
+    insists on his orders being obeyed, the gain will be mutual.\r
+\r
+\r
+X. TERRAIN\r
+\r
+\r
+ 1. Sun Tzu said:  We may distinguish six kinds of terrain,\r
+    to wit:  (1) Accessible ground; (2) entangling ground;\r
+    (3) temporizing ground; (4) narrow passes; (5) precipitous\r
+    heights; (6) positions at a great distance from the enemy.\r
+\r
+ 2. Ground which can be freely traversed by both sides\r
+    is called accessible.\r
+\r
+ 3. With regard to ground of this nature, be before\r
+    the enemy in occupying the raised and sunny spots,\r
+    and carefully guard your line of supplies.  Then you\r
+    will be able to fight with advantage.\r
+\r
+ 4. Ground which can be abandoned but is hard\r
+    to re-occupy is called entangling.\r
+\r
+ 5. From a position of this sort, if the enemy\r
+    is unprepared, you may sally forth and defeat him. \r
+    But if the enemy is prepared for your coming, and you\r
+    fail to defeat him, then, return being impossible,\r
+    disaster will ensue.\r
+\r
+ 6. When the position is such that neither side will gain\r
+    by making the first move, it is called temporizing ground.\r
+\r
+ 7. In a position of this sort, even though the enemy\r
+    should offer us an attractive bait, it will be advisable\r
+    not to stir forth, but rather to retreat, thus enticing\r
+    the enemy in his turn; then, when part of his army has\r
+    come out, we may deliver our attack with advantage.\r
+\r
+ 8. With regard to narrow passes, if you can occupy\r
+    them first, let them be strongly garrisoned and await\r
+    the advent of the enemy.\r
+\r
+ 9. Should the army forestall you in occupying a pass,\r
+    do not go after him if the pass is fully garrisoned,\r
+    but only if it is weakly garrisoned.\r
+\r
+10. With regard to precipitous heights, if you are\r
+    beforehand with your adversary, you should occupy the\r
+    raised and sunny spots, and there wait for him to come up.\r
+\r
+11. If the enemy has occupied them before you,\r
+    do not follow him, but retreat and try to entice him away.\r
+\r
+12. If you are situated at a great distance from\r
+    the enemy, and the strength of the two armies is equal,\r
+    it is not easy to provoke a battle, and fighting will be\r
+    to your disadvantage.\r
+\r
+13. These six are the principles connected with Earth. \r
+    The general who has attained a responsible post must be\r
+    careful to study them.\r
+\r
+14. Now an army is exposed to six several calamities,\r
+    not arising from natural causes, but from faults\r
+    for which the general is responsible.  These are: \r
+    (1) Flight; (2) insubordination; (3) collapse; (4) ruin;\r
+    (5) disorganization; (6) rout.\r
+\r
+15. Other conditions being equal, if one force is\r
+    hurled against another ten times its size, the result\r
+    will be the flight of the former.\r
+\r
+16. When the common soldiers are too strong and\r
+    their officers too weak, the result is insubordination. \r
+    When the officers are too strong and the common soldiers\r
+    too weak, the result is collapse.\r
+\r
+17. When the higher officers are angry and insubordinate,\r
+    and on meeting the enemy give battle on their own account\r
+    from a feeling of resentment, before the commander-in-chief\r
+    can tell whether or no he is in a position to fight,\r
+    the result is ruin.\r
+\r
+18. When the general is weak and without authority;\r
+    when his orders are not clear and distinct; when there\r
+    are no fixes duties assigned to officers and men,\r
+    and the ranks are formed in a slovenly haphazard manner,\r
+    the result is utter disorganization.\r
+\r
+19. When a general, unable to estimate the enemy's\r
+    strength, allows an inferior force to engage a larger one,\r
+    or hurls a weak detachment against a powerful one,\r
+    and neglects to place picked soldiers in the front rank,\r
+    the result must be rout.\r
+\r
+20. These are six ways of courting defeat, which must\r
+    be carefully noted by the general who has attained\r
+    a responsible post.\r
+\r
+21. The natural formation of the country is the soldier's\r
+    best ally; but a power of estimating the adversary,\r
+    of controlling the forces of victory, and of shrewdly\r
+    calculating difficulties, dangers and distances,\r
+    constitutes the test of a great general.\r
+\r
+22. He who knows these things, and in fighting puts\r
+    his knowledge into practice, will win his battles. \r
+    He who knows them not, nor practices them, will surely\r
+    be defeated.\r
+\r
+23. If fighting is sure to result in victory,\r
+    then you must fight, even though the ruler forbid it;\r
+    if fighting will not result in victory, then you must not\r
+    fight even at the ruler's bidding.\r
+\r
+24. The general who advances without coveting fame\r
+    and retreats without fearing disgrace, whose only\r
+    thought is to protect his country and do good service\r
+    for his sovereign, is the jewel of the kingdom.\r
+\r
+25. Regard your soldiers as your children, and they\r
+    will follow you into the deepest valleys; look upon them\r
+    as your own beloved sons, and they will stand by you\r
+    even unto death.\r
+\r
+26. If, however, you are indulgent, but unable to make\r
+    your authority felt; kind-hearted, but unable to enforce\r
+    your commands; and incapable, moreover, of quelling disorder: \r
+    then your soldiers must be likened to spoilt children;\r
+    they are useless for any practical purpose.\r
+\r
+27. If we know that our own men are in a condition\r
+    to attack, but are unaware that the enemy is not open\r
+    to attack, we have gone only halfway towards victory.\r
+\r
+28. If we know that the enemy is open to attack,\r
+    but are unaware that our own men are not in a condition\r
+    to attack, we have gone only halfway towards victory.\r
+\r
+29. If we know that the enemy is open to attack,\r
+    and also know that our men are in a condition to attack,\r
+    but are unaware that the nature of the ground makes\r
+    fighting impracticable, we have still gone only halfway\r
+    towards victory.\r
+\r
+30. Hence the experienced soldier, once in motion,\r
+    is never bewildered; once he has broken camp, he is never\r
+    at a loss.\r
+\r
+31. Hence the saying:  If you know the enemy and\r
+    know yourself, your victory will not stand in doubt;\r
+    if you know Heaven and know Earth, you may make your\r
+    victory complete.\r
+\r
+\r
+XI. THE NINE SITUATIONS\r
+\r
+\r
+ 1. Sun Tzu said:  The art of war recognizes nine varieties of ground:\r
+    (1) Dispersive ground; (2) facile ground; (3) contentious ground;\r
+    (4) open ground; (5) ground of intersecting highways;\r
+    (6) serious ground; (7) difficult ground; (8) hemmed-in ground;\r
+    (9) desperate ground.\r
+\r
+ 2. When a chieftain is fighting in his own territory,\r
+    it is dispersive ground.\r
+\r
+ 3. When he has penetrated into hostile territory,\r
+    but to no great distance, it is facile ground.\r
+\r
+ 4. Ground the possession of which imports great\r
+    advantage to either side, is contentious ground.\r
+\r
+ 5. Ground on which each side has liberty of movement\r
+    is open ground.\r
+\r
+ 6. Ground which forms the key to three contiguous states,\r
+    so that he who occupies it first has most of the Empire\r
+    at his command, is a ground of intersecting highways.\r
+\r
+ 7. When an army has penetrated into the heart of a\r
+    hostile country, leaving a number of fortified cities\r
+    in its rear, it is serious ground.\r
+\r
+ 8. Mountain forests, rugged steeps, marshes and fens--all\r
+    country that is hard to traverse:  this is difficult ground.\r
+\r
+ 9. Ground which is reached through narrow gorges,\r
+    and from which we can only retire by tortuous paths,\r
+    so that a small number of the enemy would suffice to crush\r
+    a large body of our men:  this is hemmed in ground.\r
+\r
+10. Ground on which we can only be saved from\r
+    destruction by fighting without delay, is desperate ground.\r
+\r
+11. On dispersive ground, therefore, fight not. \r
+    On facile ground, halt not.  On contentious ground,\r
+    attack not.\r
+\r
+12. On open ground, do not try to block the enemy's way. \r
+    On the ground of intersecting highways, join hands\r
+    with your allies.\r
+\r
+13. On serious ground, gather in plunder. \r
+    In difficult ground, keep steadily on the march.\r
+\r
+14. On hemmed-in ground, resort to stratagem. \r
+    On desperate ground, fight.\r
+\r
+15. Those who were called skillful leaders of old knew\r
+    how to drive a wedge between the enemy's front and rear;\r
+    to prevent co-operation between his large and small divisions;\r
+    to hinder the good troops from rescuing the bad,\r
+    the officers from rallying their men.\r
+\r
+16. When the enemy's men were united, they managed\r
+    to keep them in disorder.\r
+\r
+17. When it was to their advantage, they made\r
+    a forward move; when otherwise, they stopped still.\r
+\r
+18. If asked how to cope with a great host of the enemy\r
+    in orderly array and on the point of marching to the attack,\r
+    I should say:  "Begin by seizing something which your\r
+    opponent holds dear; then he will be amenable to your will."\r
+\r
+19. Rapidity is the essence of war:  take advantage of\r
+    the enemy's unreadiness, make your way by unexpected routes,\r
+    and attack unguarded spots.\r
+\r
+20. The following are the principles to be observed\r
+    by an invading force:  The further you penetrate into\r
+    a country, the greater will be the solidarity of your troops,\r
+    and thus the defenders will not prevail against you.\r
+\r
+21. Make forays in fertile country in order to supply\r
+    your army with food.\r
+\r
+22. Carefully study the well-being of your men,\r
+    and do not overtax them.  Concentrate your energy and hoard\r
+    your strength.  Keep your army continually on the move,\r
+    and devise unfathomable plans.\r
+\r
+23. Throw your soldiers into positions whence there\r
+    is no escape, and they will prefer death to flight. \r
+    If they will face death, there is nothing they may\r
+    not achieve.  Officers and men alike will put forth\r
+    their uttermost strength.\r
+\r
+24. Soldiers when in desperate straits lose\r
+    the sense of fear.  If there is no place of refuge,\r
+    they will stand firm.  If they are in hostile country,\r
+    they will show a stubborn front.  If there is no help\r
+    for it, they will fight hard.\r
+\r
+25. Thus, without waiting to be marshaled, the soldiers\r
+    will be constantly on the qui vive; without waiting to\r
+    be asked, they will do your will; without restrictions,\r
+    they will be faithful; without giving orders, they can\r
+    be trusted.\r
+\r
+26. Prohibit the taking of omens, and do away with\r
+    superstitious doubts.  Then, until death itself comes,\r
+    no calamity need be feared.\r
+\r
+27. If our soldiers are not overburdened with money,\r
+    it is not because they have a distaste for riches;\r
+    if their lives are not unduly long, it is not because they\r
+    are disinclined to longevity.\r
+\r
+28. On the day they are ordered out to battle,\r
+    your soldiers may weep, those sitting up bedewing\r
+    their garments, and those lying down letting the tears run\r
+    down their cheeks.  But let them once be brought to bay,\r
+    and they will display the courage of a Chu or a Kuei.\r
+\r
+29. The skillful tactician may be likened to the\r
+    shuai-jan. Now the shuai-jan is a snake that is found\r
+    in the ChUng mountains.  Strike at its head, and you\r
+    will be attacked by its tail; strike at its tail, and you\r
+    will be attacked by its head; strike at its middle,\r
+    and you will be attacked by head and tail both.\r
+\r
+30. Asked if an army can be made to imitate the shuai-jan,\r
+    I should answer, Yes.  For the men of Wu and the men\r
+    of Yueh are enemies; yet if they are crossing a river\r
+    in the same boat and are caught by a storm, they will come\r
+    to each other's assistance just as the left hand helps the right.\r
+\r
+31. Hence it is not enough to put one's trust\r
+    in the tethering of horses, and the burying of chariot\r
+    wheels in the ground\r
+\r
+32. The principle on which to manage an army is to set\r
+    up one standard of courage which all must reach.\r
+\r
+33. How to make the best of both strong and weak--that\r
+    is a question involving the proper use of ground.\r
+\r
+34. Thus the skillful general conducts his army just\r
+    as though he were leading a single man, willy-nilly, by\r
+    the hand.\r
+\r
+35. It is the business of a general to be quiet and thus\r
+    ensure secrecy; upright and just, and thus maintain order.\r
+\r
+36. He must be able to mystify his officers and men\r
+    by false reports and appearances, and thus keep them\r
+    in total ignorance.\r
+\r
+37. By altering his arrangements and changing\r
+    his plans, he keeps the enemy without definite knowledge. \r
+    By shifting his camp and taking circuitous routes,\r
+    he prevents the enemy from anticipating his purpose.\r
+\r
+38. At the critical moment, the leader of an army\r
+    acts like one who has climbed up a height and then kicks\r
+    away the ladder behind him.  He carries his men deep\r
+    into hostile territory before he shows his hand.\r
+\r
+39. He burns his boats and breaks his cooking-pots;\r
+    like a shepherd driving a flock of sheep, he drives\r
+    his men this way and that, and nothing knows whither he\r
+    is going.\r
+\r
+40. To muster his host and bring it into danger:--this\r
+    may be termed the business of the general.\r
+\r
+41. The different measures suited to the nine\r
+    varieties of ground; the expediency of aggressive or\r
+    defensive tactics; and the fundamental laws of human nature: \r
+    these are things that must most certainly be studied.\r
+\r
+42. When invading hostile territory, the general\r
+    principle is, that penetrating deeply brings cohesion;\r
+    penetrating but a short way means dispersion.\r
+\r
+43. When you leave your own country behind, and take\r
+    your army across neighborhood territory, you find yourself\r
+    on critical ground.  When there are means of communication\r
+    on all four sides, the ground is one of intersecting highways.\r
+\r
+44. When you penetrate deeply into a country, it is\r
+    serious ground.  When you penetrate but a little way,\r
+    it is facile ground.\r
+\r
+45. When you have the enemy's strongholds on your rear,\r
+    and narrow passes in front, it is hemmed-in ground. \r
+    When there is no place of refuge at all, it is desperate ground.\r
+\r
+46. Therefore, on dispersive ground, I would inspire\r
+    my men with unity of purpose.  On facile ground, I would\r
+    see that there is close connection between all parts\r
+    of my army.\r
+\r
+47. On contentious ground, I would hurry up my rear.\r
+\r
+48. On open ground, I would keep a vigilant eye\r
+    on my defenses.  On ground of intersecting highways,\r
+    I would consolidate my alliances.\r
+\r
+49. On serious ground, I would try to ensure\r
+    a continuous stream of supplies.  On difficult ground,\r
+    I would keep pushing on along the road.\r
+\r
+50. On hemmed-in ground, I would block any way\r
+    of retreat.  On desperate ground, I would proclaim\r
+    to my soldiers the hopelessness of saving their lives.\r
+\r
+51. For it is the soldier's disposition to offer\r
+    an obstinate resistance when surrounded, to fight hard\r
+    when he cannot help himself, and to obey promptly when he\r
+    has fallen into danger.\r
+\r
+52. We cannot enter into alliance with neighboring\r
+    princes until we are acquainted with their designs.  We are\r
+    not fit to lead an army on the march unless we are familiar\r
+    with the face of the country--its mountains and forests,\r
+    its pitfalls and precipices, its marshes and swamps. \r
+    We shall be unable to turn natural advantages to account\r
+    unless we make use of local guides.\r
+\r
+53. To be ignored of any one of the following four\r
+    or five principles does not befit a warlike prince.\r
+\r
+54. When a warlike prince attacks a powerful state,\r
+    his generalship shows itself in preventing the concentration\r
+    of the enemy's forces.  He overawes his opponents,\r
+    and their allies are prevented from joining against him.\r
+\r
+55. Hence he does not strive to ally himself with all\r
+    and sundry, nor does he foster the power of other states. \r
+    He carries out his own secret designs, keeping his\r
+    antagonists in awe.  Thus he is able to capture their\r
+    cities and overthrow their kingdoms.\r
+\r
+56. Bestow rewards without regard to rule,\r
+    issue orders without regard to previous arrangements;\r
+    and you will be able to handle a whole army as though\r
+    you had to do with but a single man.\r
+\r
+57. Confront your soldiers with the deed itself;\r
+    never let them know your design.  When the outlook is bright,\r
+    bring it before their eyes; but tell them nothing when\r
+    the situation is gloomy.\r
+\r
+58. Place your army in deadly peril, and it will survive;\r
+    plunge it into desperate straits, and it will come off\r
+    in safety.\r
+\r
+59. For it is precisely when a force has fallen into\r
+    harm's way that is capable of striking a blow for victory.\r
+\r
+60. Success in warfare is gained by carefully\r
+    accommodating ourselves to the enemy's purpose.\r
+\r
+61. By persistently hanging on the enemy's flank, we shall\r
+    succeed in the long run in killing the commander-in-chief.\r
+\r
+62. This is called ability to accomplish a thing\r
+    by sheer cunning.\r
+\r
+63. On the day that you take up your command,\r
+    block the frontier passes, destroy the official tallies,\r
+    and stop the passage of all emissaries.\r
+\r
+64. Be stern in the council-chamber, so that you\r
+    may control the situation.\r
+\r
+65. If the enemy leaves a door open, you must rush in.\r
+\r
+66. Forestall your opponent by seizing what he holds dear,\r
+    and subtly contrive to time his arrival on the ground.\r
+\r
+67. Walk in the path defined by rule, and accommodate\r
+    yourself to the enemy until you can fight a decisive battle.\r
+\r
+68. At first, then, exhibit the coyness of a maiden,\r
+    until the enemy gives you an opening; afterwards emulate\r
+    the rapidity of a running hare, and it will be too late\r
+    for the enemy to oppose you.\r
+\r
+\r
+XII. THE ATTACK BY FIRE\r
+\r
+\r
+ 1. Sun Tzu said:  There are five ways of attacking\r
+    with fire.  The first is to burn soldiers in their camp;\r
+    the second is to burn stores; the third is to burn\r
+    baggage trains; the fourth is to burn arsenals and magazines;\r
+    the fifth is to hurl dropping fire amongst the enemy.\r
+\r
+ 2. In order to carry out an attack, we must have\r
+    means available.  The material for raising fire should\r
+    always be kept in readiness.\r
+\r
+ 3. There is a proper season for making attacks with fire,\r
+    and special days for starting a conflagration.\r
+\r
+ 4. The proper season is when the weather is very dry;\r
+    the special days are those when the moon is in the\r
+    constellations of the Sieve, the Wall, the Wing\r
+    or the Cross-bar; for these four are all days of rising wind.\r
+\r
+ 5. In attacking with fire, one should be prepared\r
+    to meet five possible developments:\r
+\r
+ 6. (1) When fire breaks out inside to enemy's camp,\r
+    respond at once with an attack from without.\r
+\r
+ 7. (2) If there is an outbreak of fire, but the enemy's\r
+    soldiers remain quiet, bide your time and do not attack.\r
+\r
+ 8. (3) When the force of the flames has reached its height,\r
+    follow it up with an attack, if that is practicable;\r
+    if not, stay where you are.\r
+\r
+ 9. (4) If it is possible to make an assault with fire\r
+    from without, do not wait for it to break out within,\r
+    but deliver your attack at a favorable moment.\r
+\r
+10. (5) When you start a fire, be to windward of it. \r
+    Do not attack from the leeward.\r
+\r
+11. A wind that rises in the daytime lasts long,\r
+    but a night breeze soon falls.\r
+\r
+12. In every army, the five developments connected with\r
+    fire must be known, the movements of the stars calculated,\r
+    and a watch kept for the proper days.\r
+\r
+13. Hence those who use fire as an aid to the attack show intelligence;\r
+    those who use water as an aid to the attack gain an accession of strength.\r
+\r
+14. By means of water, an enemy may be intercepted,\r
+    but not robbed of all his belongings.\r
+\r
+15. Unhappy is the fate of one who tries to win his\r
+    battles and succeed in his attacks without cultivating\r
+    the spirit of enterprise; for the result is waste of time\r
+    and general stagnation.\r
+\r
+16. Hence the saying:  The enlightened ruler lays his\r
+    plans well ahead; the good general cultivates his resources.\r
+\r
+17. Move not unless you see an advantage; use not\r
+    your troops unless there is something to be gained;\r
+    fight not unless the position is critical.\r
+\r
+18. No ruler should put troops into the field merely\r
+    to gratify his own spleen; no general should fight\r
+    a battle simply out of pique.\r
+\r
+19. If it is to your advantage, make a forward move;\r
+    if not, stay where you are.\r
+\r
+20. Anger may in time change to gladness; vexation may\r
+    be succeeded by content.\r
+\r
+21. But a kingdom that has once been destroyed can\r
+    never come again into being; nor can the dead ever\r
+    be brought back to life.\r
+\r
+22. Hence the enlightened ruler is heedful,\r
+    and the good general full of caution.  This is the way\r
+    to keep a country at peace and an army intact.\r
+\r
+\r
+XIII. THE USE OF SPIES\r
+\r
+\r
+ 1. Sun Tzu said:  Raising a host of a hundred thousand\r
+    men and marching them great distances entails heavy loss\r
+    on the people and a drain on the resources of the State. \r
+    The daily expenditure will amount to a thousand ounces\r
+    of silver.  There will be commotion at home and abroad,\r
+    and men will drop down exhausted on the highways. \r
+    As many as seven hundred thousand families will be impeded\r
+    in their labor.\r
+\r
+ 2. Hostile armies may face each other for years,\r
+    striving for the victory which is decided in a single day. \r
+    This being so, to remain in ignorance of the enemy's\r
+    condition simply because one grudges the outlay of a hundred\r
+    ounces of silver in honors and emoluments, is the height\r
+    of inhumanity.\r
+\r
+ 3. One who acts thus is no leader of men, no present\r
+    help to his sovereign, no master of victory.\r
+\r
+ 4. Thus, what enables the wise sovereign and the good\r
+    general to strike and conquer, and achieve things beyond\r
+    the reach of ordinary men, is foreknowledge.\r
+\r
+ 5. Now this foreknowledge cannot be elicited from spirits;\r
+    it cannot be obtained inductively from experience,\r
+    nor by any deductive calculation.\r
+\r
+ 6. Knowledge of the enemy's dispositions can only\r
+    be obtained from other men.\r
+\r
+ 7. Hence the use of spies, of whom there are five classes: \r
+    (1) Local spies; (2) inward spies; (3) converted spies;\r
+    (4) doomed spies; (5) surviving spies.\r
+\r
+ 8. When these five kinds of spy are all at work,\r
+    none can discover the secret system.  This is called "divine\r
+    manipulation of the threads."  It is the sovereign's\r
+    most precious faculty.\r
+\r
+ 9. Having local spies means employing the services\r
+    of the inhabitants of a district.\r
+\r
+10. Having inward spies, making use of officials\r
+    of the enemy.\r
+\r
+11. Having converted spies, getting hold of the enemy's\r
+    spies and using them for our own purposes.\r
+\r
+12. Having doomed spies, doing certain things openly\r
+    for purposes of deception, and allowing our spies to know\r
+    of them and report them to the enemy.\r
+\r
+13. Surviving spies, finally, are those who bring\r
+    back news from the enemy's camp.\r
+\r
+14. Hence it is that which none in the whole army are\r
+    more intimate relations to be maintained than with spies. \r
+    None should be more liberally rewarded.  In no other\r
+    business should greater secrecy be preserved.\r
+\r
+15. Spies cannot be usefully employed without a certain\r
+    intuitive sagacity.\r
+\r
+16. They cannot be properly managed without benevolence\r
+    and straightforwardness.\r
+\r
+17. Without subtle ingenuity of mind, one cannot make\r
+    certain of the truth of their reports.\r
+\r
+18. Be subtle! be subtle! and use your spies for every\r
+    kind of business.\r
+\r
+19. If a secret piece of news is divulged by a spy\r
+    before the time is ripe, he must be put to death together\r
+    with the man to whom the secret was told.\r
+\r
+20. Whether the object be to crush an army, to storm\r
+    a city, or to assassinate an individual, it is always\r
+    necessary to begin by finding out the names of the attendants,\r
+    the aides-de-camp, and door-keepers and sentries of the general\r
+    in command.  Our spies must be commissioned to ascertain these.\r
+\r
+21. The enemy's spies who have come to spy on us\r
+    must be sought out, tempted with bribes, led away and\r
+    comfortably housed.  Thus they will become converted\r
+    spies and available for our service.\r
+\r
+22. It is through the information brought by the\r
+    converted spy that we are able to acquire and employ\r
+    local and inward spies.\r
+\r
+23. It is owing to his information, again, that we can\r
+    cause the doomed spy to carry false tidings to the enemy.\r
+\r
+24. Lastly, it is by his information that the surviving\r
+    spy can be used on appointed occasions.\r
+\r
+25. The end and aim of spying in all its five varieties\r
+    is knowledge of the enemy; and this knowledge can only\r
+    be derived, in the first instance, from the converted spy. \r
+    Hence it is essential that the converted spy be treated\r
+    with the utmost liberality.\r
+\r
+26. Of old, the rise of the Yin dynasty was due to I\r
+    Chih who had served under the Hsia.  Likewise, the rise\r
+    of the Chou dynasty was due to Lu Ya who had served\r
+    under the Yin.\r
+\r
+27. Hence it is only the enlightened ruler and the\r
+    wise general who will use the highest intelligence of\r
+    the army for purposes of spying and thereby they achieve\r
+    great results.  Spies are a most important element in water,\r
+    because on them depends an army's ability to move.\r
+\r
+\r
index c5ce28b6dfced2ad80e7f68e17775e7540cef2b7..12de148cfe890e32087b8fb831ecedd085acc8e9 100644 (file)
@@ -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 $@
index e4efe73ae5de116ad6f7fd81995c7a3c4ff96a00..d4c33e68a9ef851d9a82c4e03951415a20ede90f 100644 (file)
@@ -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.
index 5ee2e64deb4279ab9eb26591cda07dcf86e5c9da..d2b3b8de76343ba47afcd941789d4b829dc12e7c 100644 (file)
@@ -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
index 2f0bbc748e4b981b532f1e5c8db52506be56fd2c..3fccd8000ee42f615e0587e528de88b553848685 100644 (file)
@@ -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);
 }
index 58c093e268fe100bf148ebba95bdd0f99891437d..90beb8f269c218415477da85a2304033f5a4192b 100644 (file)
@@ -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)
index 762f79b866cfae67c1c3cb0aa4cc4c19d0a93ac7..77f0b230fd7760d23427adc6ad7a3f93f41ac27b 100644 (file)
@@ -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 $@
index a14c29cf9875829166ed96ae45f765cb8938284a..b40606a696551477312299490ec8bea3460d4919 100644 (file)
@@ -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";
   }
index 084c314649066ac453b76a217497ba5da27cb970..03f422d79445342d6402eb3aac81cccb79856744 100644 (file)
@@ -1,3 +1,4 @@
+errlist.c
 errnos.awk
 err_hurd.sub
 libc-ldscript
index 454ac8f98c3631b50d68c64beac9626371694925..b3161ca1950bedc444d4c83ae54547a23dfe988d 100644 (file)
@@ -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 (file)
index 0000000..5cbc543
--- /dev/null
@@ -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>
index 48635563324c3ea88405b4f78a6cde06971b08e4..234caee5d45148942acd43bf1d5e444d99d9ed66 100644 (file)
@@ -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 $@
 
 
index 7bb081054713bdb5139e4a0273722bced0ea866c..f0be6b646d2d3edfbbab7192213eed0f830fd4e2 100644 (file)
@@ -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)
index 3d05109916e249951f2fdc967fba5ffbeacf30aa..1c28d86d2b85e6feb93922af19687bf68fe37589 100644 (file)
@@ -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'                                              ;\
index b40a98f65b5a05c695a283e5f9a8b6f087bc1fa2..3ca5af278278fe8c064160c814ec4e856575a8b6 100644 (file)
@@ -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;
 
index 4b6232a182f4d17f4146ad32c31cb9f70e8b4ffa..37b525b7ebc8712d31b21bba17b9c89b77fc8ed6 100644 (file)
@@ -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;
index 428ef3d4ddcd95d5952ba96e8c884562602f5a50..b055a09d03ed6a945b763823a8e0dced2d807968 100644 (file)
@@ -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;