From 29cdc8da201865264b8344b68517e1cc405628fc Mon Sep 17 00:00:00 2001 From: hniksic Date: Wed, 1 Nov 2000 13:51:25 -0800 Subject: [PATCH] [svn] Updated long_to_string(); enhanced opt.downloaded to use 64-bit types where available. Published in and . --- ChangeLog | 4 + configure | 218 +++++++++++++++++++++++++++++++++--------------- configure.in | 4 + src/ChangeLog | 24 ++++++ src/config.h.in | 11 +++ src/main.c | 3 +- src/options.h | 2 +- src/sysdep.h | 16 +++- src/utils.c | 102 +++++++++++++++------- src/utils.h | 1 + 10 files changed, 282 insertions(+), 103 deletions(-) diff --git a/ChangeLog b/ChangeLog index 709d9064..651881bf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2000-11-01 Hrvoje Niksic + + * configure.in: Check for size of long and long long. + 2000-10-30 Dan Harkless * NEWS: Hrvoje pointed out that relative URL grokking deserves mention. diff --git a/configure b/configure index b4f73a38..3f7f1970 100755 --- a/configure +++ b/configure @@ -1542,21 +1542,101 @@ EOF fi +# Check size of long. +echo $ac_n "checking size of long""... $ac_c" 1>&6 +echo "configure:1548: checking size of long" >&5 +if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext < +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof(long)); + exit(0); +} +EOF +if { (eval echo configure:1567: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_sizeof_long=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_sizeof_long=0 +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_sizeof_long" 1>&6 +cat >> confdefs.h <&6 +echo "configure:1587: checking size of long long" >&5 +if eval "test \"`echo '$''{'ac_cv_sizeof_long_long'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext < +main() +{ + FILE *f=fopen("conftestval", "w"); + if (!f) exit(1); + fprintf(f, "%d\n", sizeof(long long)); + exit(0); +} +EOF +if { (eval echo configure:1606: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_sizeof_long_long=`cat conftestval` +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_sizeof_long_long=0 +fi +rm -fr conftest* +fi + +fi +echo "$ac_t""$ac_cv_sizeof_long_long" 1>&6 +cat >> confdefs.h <&6 -echo "configure:1550: checking for $ac_hdr" >&5 +echo "configure:1630: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1560: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1640: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1586,17 +1666,17 @@ for ac_hdr in sys/select.h sys/utsname.h pwd.h signal.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1590: checking for $ac_hdr" >&5 +echo "configure:1670: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1600: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1680: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1623,12 +1703,12 @@ fi done echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 -echo "configure:1627: checking whether time.h and sys/time.h may both be included" >&5 +echo "configure:1707: checking whether time.h and sys/time.h may both be included" >&5 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1637,7 +1717,7 @@ int main() { struct tm *tp; ; return 0; } EOF -if { (eval echo configure:1641: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1721: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_time=yes else @@ -1659,12 +1739,12 @@ fi echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6 -echo "configure:1663: checking return type of signal handlers" >&5 +echo "configure:1743: checking return type of signal handlers" >&5 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1681,7 +1761,7 @@ int main() { int i; ; return 0; } EOF -if { (eval echo configure:1685: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1765: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_type_signal=void else @@ -1701,10 +1781,10 @@ EOF echo $ac_n "checking for struct utimbuf""... $ac_c" 1>&6 -echo "configure:1705: checking for struct utimbuf" >&5 +echo "configure:1785: checking for struct utimbuf" >&5 if test x"$ac_cv_header_utime_h" = xyes; then cat > conftest.$ac_ext < EOF @@ -1729,19 +1809,19 @@ fi # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6 -echo "configure:1733: checking for working alloca.h" >&5 +echo "configure:1813: checking for working alloca.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { char *p = alloca(2 * sizeof(int)); ; return 0; } EOF -if { (eval echo configure:1745: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1825: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_header_alloca_h=yes else @@ -1762,12 +1842,12 @@ EOF fi echo $ac_n "checking for alloca""... $ac_c" 1>&6 -echo "configure:1766: checking for alloca" >&5 +echo "configure:1846: checking for alloca" >&5 if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1879: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_func_alloca_works=yes else @@ -1827,12 +1907,12 @@ EOF echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6 -echo "configure:1831: checking whether alloca needs Cray hooks" >&5 +echo "configure:1911: checking whether alloca needs Cray hooks" >&5 if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&6 if test $ac_cv_os_cray = yes; then for ac_func in _getb67 GETB67 getb67; do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1861: checking for $ac_func" >&5 +echo "configure:1941: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1969: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -1912,7 +1992,7 @@ done fi echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6 -echo "configure:1916: checking stack direction for C alloca" >&5 +echo "configure:1996: checking stack direction for C alloca" >&5 if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1920,7 +2000,7 @@ else ac_cv_c_stack_direction=0 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2023: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_c_stack_direction=1 else @@ -1963,12 +2043,12 @@ fi for ac_func in strdup strstr strcasecmp strncasecmp do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1967: checking for $ac_func" >&5 +echo "configure:2047: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2075: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2018,12 +2098,12 @@ done for ac_func in gettimeofday mktime strptime do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2022: checking for $ac_func" >&5 +echo "configure:2102: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2130: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2073,12 +2153,12 @@ done for ac_func in strerror vsnprintf select signal symlink access isatty do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2077: checking for $ac_func" >&5 +echo "configure:2157: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2185: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2128,12 +2208,12 @@ done for ac_func in uname gethostname do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2132: checking for $ac_func" >&5 +echo "configure:2212: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2240: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2184,12 +2264,12 @@ done for ac_func in gethostbyname do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2188: checking for $ac_func" >&5 +echo "configure:2268: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2296: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2234,7 +2314,7 @@ EOF else echo "$ac_t""no" 1>&6 echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6 -echo "configure:2238: checking for gethostbyname in -lnsl" >&5 +echo "configure:2318: checking for gethostbyname in -lnsl" >&5 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2242,7 +2322,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2337: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2287,7 +2367,7 @@ done echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6 -echo "configure:2291: checking for socket in -lsocket" >&5 +echo "configure:2371: checking for socket in -lsocket" >&5 ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2295,7 +2375,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lsocket $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2390: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2337,7 +2417,7 @@ fi if test "x${with_socks}" = xyes then echo $ac_n "checking for main in -lresolv""... $ac_c" 1>&6 -echo "configure:2341: checking for main in -lresolv" >&5 +echo "configure:2421: checking for main in -lresolv" >&5 ac_lib_var=`echo resolv'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2345,14 +2425,14 @@ else ac_save_LIBS="$LIBS" LIBS="-lresolv $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2436: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2380,7 +2460,7 @@ else fi echo $ac_n "checking for Rconnect in -lsocks""... $ac_c" 1>&6 -echo "configure:2384: checking for Rconnect in -lsocks" >&5 +echo "configure:2464: checking for Rconnect in -lsocks" >&5 ac_lib_var=`echo socks'_'Rconnect | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2388,7 +2468,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lsocks $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2483: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2431,7 +2511,7 @@ fi ALL_LINGUAS="cs de hr it no pl pt_BR ru" echo $ac_n "checking whether NLS is requested""... $ac_c" 1>&6 -echo "configure:2435: checking whether NLS is requested" >&5 +echo "configure:2515: checking whether NLS is requested" >&5 # Check whether --enable-nls or --disable-nls was given. if test "${enable_nls+set}" = set; then enableval="$enable_nls" @@ -2448,7 +2528,7 @@ fi # Extract the first word of "msgfmt", so it can be a program name with args. set dummy msgfmt; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2452: checking for $ac_word" >&5 +echo "configure:2532: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_MSGFMT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2482,7 +2562,7 @@ fi # Extract the first word of "xgettext", so it can be a program name with args. set dummy xgettext; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2486: checking for $ac_word" >&5 +echo "configure:2566: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_XGETTEXT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2517,7 +2597,7 @@ fi # Extract the first word of "gmsgfmt", so it can be a program name with args. set dummy gmsgfmt; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2521: checking for $ac_word" >&5 +echo "configure:2601: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_GMSGFMT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2567,17 +2647,17 @@ fi do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2571: checking for $ac_hdr" >&5 +echo "configure:2651: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2581: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2661: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2607,12 +2687,12 @@ done for ac_func in gettext do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2611: checking for $ac_func" >&5 +echo "configure:2691: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2719: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2657,7 +2737,7 @@ EOF else echo "$ac_t""no" 1>&6 echo $ac_n "checking for gettext in -lintl""... $ac_c" 1>&6 -echo "configure:2661: checking for gettext in -lintl" >&5 +echo "configure:2741: checking for gettext in -lintl" >&5 ac_lib_var=`echo intl'_'gettext | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2665,7 +2745,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lintl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2760: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2744,7 +2824,7 @@ 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:2748: checking for $ac_word" >&5 +echo "configure:2828: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_MAKEINFO'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else diff --git a/configure.in b/configure.in index d16399f2..bd7d2898 100644 --- a/configure.in +++ b/configure.in @@ -136,6 +136,10 @@ AC_TYPE_PID_T dnl #### This generates a warning. What do I do to shut it up? AC_C_BIGENDIAN +# Check size of long. +AC_CHECK_SIZEOF(long) +AC_CHECK_SIZEOF(long long) + dnl dnl Checks for headers dnl diff --git a/src/ChangeLog b/src/ChangeLog index 7bb0d9e4..d62a181f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,27 @@ +2000-11-01 Hrvoje Niksic + + * main.c (main): Use legible_very_long() for printing + opt.downloaded. + + * utils.c (legible_1): New function that operates on strings and + does the brunt of legible()'s work. + (legible): Use legible_1(). + (legible_very_long): New function; dump the argument with + sprintf(), and call legible_1(). + + * options.h (struct options): Use VERY_LONG_TYPE for + opt.downloaded. + + * sysdep.h (VERY_LONG_TYPE): Define it to have a 64-bit or greater + type. + + * config.h.in: Make sure that SIZEOF_LONG and SIZEOF_LONG_LONG get + defined. Define HAVE_LONG_LONG if long long is available. + +2000-11-01 Hrvoje Niksic + + * utils.c (long_to_string): Update with a later, better version. + 2000-11-01 Hrvoje Niksic * url.c (path_simplify_with_kludge): New function. diff --git a/src/config.h.in b/src/config.h.in index 633e8bf1..9854f579 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -66,6 +66,17 @@ char *alloca (); significant byte first). */ #undef WORDS_BIGENDIAN +/* Define to the length of long. */ +#undef SIZEOF_LONG + +/* Define to the length of long long. */ +#undef SIZEOF_LONG_LONG + +#undef HAVE_LONG_LONG +#if SIZEOF_LONG_LONG != 0 +# define HAVE_LONG_LONG +#endif + /* Define this if you want the NLS support. */ #undef HAVE_NLS diff --git a/src/main.c b/src/main.c index 8bda521b..3bb6b14f 100644 --- a/src/main.c +++ b/src/main.c @@ -771,7 +771,8 @@ Can't timestamp and not clobber old files at the same time.\n")); { logprintf (LOG_NOTQUIET, _("\nFINISHED --%s--\nDownloaded: %s bytes in %d files\n"), - time_str (NULL), legible (opt.downloaded), opt.numurls); + time_str (NULL), legible_very_long (opt.downloaded), + opt.numurls); /* Print quota warning, if exceeded. */ if (opt.quota && opt.downloaded > opt.quota) logprintf (LOG_NOTQUIET, diff --git a/src/options.h b/src/options.h index 8c2ab176..a11de0e4 100644 --- a/src/options.h +++ b/src/options.h @@ -104,7 +104,7 @@ struct options long quota; /* Maximum number of bytes to retrieve. */ - long downloaded; /* How much we downloaded already. */ + VERY_LONG_TYPE downloaded; /* How much we downloaded already. */ int numurls; /* Number of successfully downloaded URLs */ diff --git a/src/sysdep.h b/src/sysdep.h index 1a837306..8bfdbfa5 100644 --- a/src/sysdep.h +++ b/src/sysdep.h @@ -97,8 +97,22 @@ do { \ DEBUGP (("Closing fd %d\n", x)); \ } while (0) +/* Define a "very long" type useful for storing large non-negative + integers, e.g. the total number of bytes downloaded. This needs to + be an integral type at least 64 bits wide. On the machines where + `long' is 64-bit, we use long. Otherwise, we check whether `long + long' is available and if yes, use that. Otherwise, we give up and + just use `long'. */ +#if (SIZEOF_LONG >= 8) || !defined(HAVE_LONG_LONG) +# define VERY_LONG_TYPE unsigned long +# define VERY_LONG_FORMAT "%lu" +#else /* long is smaller than 8 bytes, but long long is available. */ +# define VERY_LONG_TYPE unsigned long long +# define VERY_LONG_FORMAT "%llu" +#endif /* use long long */ + /* OK, now define a decent interface to ctype macros. The regular - ones misfire when you feed them chars >= 127, as they understand + ones misfire when you feed them chars > 127, as they understand them as "negative", which results in out-of-bound access at table-lookup, yielding random results. This is, of course, totally bogus. One way to "solve" this is to use `unsigned char' diff --git a/src/utils.c b/src/utils.c index 31aab9c1..19240e52 100644 --- a/src/utils.c +++ b/src/utils.c @@ -896,21 +896,21 @@ free_slist (slist *l) l = n; } } + +/* Engine for legible and legible_long_long; this function works on + strings. */ -/* Legible -- return a static pointer to the legibly printed long. */ -char * -legible (long l) +static char * +legible_1 (const char *repr) { - static char outbuf[20]; - char inbuf[20]; + static char outbuf[128]; int i, i1, mod; - char *outptr, *inptr; + char *outptr; + const char *inptr; - /* Print the number into the buffer. */ - long_to_string (inbuf, l); /* Reset the pointers. */ outptr = outbuf; - inptr = inbuf; + inptr = repr; /* If the number is negative, shift the pointers. */ if (*inptr == '-') { @@ -935,6 +935,26 @@ legible (long l) return outbuf; } +/* Legible -- return a static pointer to the legibly printed long. */ +char * +legible (long l) +{ + char inbuf[24]; + /* Print the number into the buffer. */ + long_to_string (inbuf, l); + return legible_1 (inbuf); +} + +/* The same as legible(), but works on VERY_LONG_TYPE. See sysdep.h. */ +char * +legible_very_long (VERY_LONG_TYPE l) +{ + char inbuf[128]; + /* Print the number into the buffer. */ + sprintf (inbuf, VERY_LONG_FORMAT, l); + return legible_1 (inbuf); +} + /* Count the digits in a (long) integer. */ int numdigit (long a) @@ -945,34 +965,54 @@ numdigit (long a) return res; } -/* Print NUMBER to BUFFER. The digits are first written in reverse - order (the least significant digit first), and are then reversed. */ +/* Print NUMBER to BUFFER. This is equivalent to sprintf(buffer, + "%ld", number), only much faster. + + BUFFER should accept 24 bytes. This should suffice for the longest + numbers on 64-bit machines, including the `-' sign and the trailing + \0. */ void long_to_string (char *buffer, long number) { - char *p; - int i, l; +#if (SIZEOF_LONG != 4) && (SIZEOF_LONG != 8) + /* Huh? */ + sprintf (buffer, "%ld", number); +#else /* (SIZEOF_LONG == 4) || (SIZEOF_LONG == 8) */ + char *p = buffer; + int force = 0; if (number < 0) { - *buffer++ = '-'; + *p++ = '-'; number = -number; } - p = buffer; - /* Print the digits to the string. */ - do - { - *p++ = number % 10 + '0'; - number /= 10; - } - while (number); - /* And reverse them. */ - l = p - buffer - 1; - for (i = l/2; i >= 0; i--) - { - char c = buffer[i]; - buffer[i] = buffer[l - i]; - buffer[l - i] = c; - } - buffer[l + 1] = '\0'; + +#define FROB(figure) do { \ + if (force || number >= figure) \ + *p++ = number / figure + '0', number %= figure, force = 1; \ + } while (0) +#if SIZEOF_LONG == 8 + FROB (1000000000000000000L); + FROB (100000000000000000L); + FROB (10000000000000000L); + FROB (1000000000000000L); + FROB (100000000000000L); + FROB (10000000000000L); + FROB (1000000000000L); + FROB (100000000000L); + FROB (10000000000L); +#endif /* SIZEOF_LONG == 8 */ + FROB (1000000000); + FROB (100000000); + FROB (10000000); + FROB (1000000); + FROB (100000); + FROB (10000); + FROB (1000); + FROB (100); + FROB (10); +#undef FROB + *p++ = number + '0'; + *p = '\0'; +#endif /* (SIZEOF_LONG == 4) || (SIZEOF_LONG == 8) */ } diff --git a/src/utils.h b/src/utils.h index 9fe1eecf..eb3c99cc 100644 --- a/src/utils.h +++ b/src/utils.h @@ -67,6 +67,7 @@ int in_slist PARAMS ((slist *, const char *)); void free_slist PARAMS ((slist *)); char *legible PARAMS ((long)); +char *legible_very_long PARAMS ((VERY_LONG_TYPE)); int numdigit PARAMS ((long)); void long_to_string PARAMS ((char *, long)); -- 2.39.2