diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | build-aux/ChangeLog | 4 | ||||
-rw-r--r-- | build-aux/config.guess | 12 | ||||
-rw-r--r-- | build-aux/config.sub | 45 | ||||
-rw-r--r-- | build-aux/depcomp | 47 | ||||
-rw-r--r-- | build-aux/texinfo.tex | 63 | ||||
-rw-r--r-- | lib/ChangeLog | 9 | ||||
-rw-r--r-- | lib/localcharset.c | 14 | ||||
-rw-r--r-- | lib/md5.c | 195 | ||||
-rw-r--r-- | lib/md5.h | 46 | ||||
-rw-r--r-- | lib/savedir.c | 40 | ||||
-rw-r--r-- | lib/savedir.h | 5 | ||||
-rw-r--r-- | lib/sha1.c | 38 | ||||
-rw-r--r-- | lib/sha1.h | 20 | ||||
-rw-r--r-- | lib/sha256.c | 42 | ||||
-rw-r--r-- | lib/sha256.h | 8 | ||||
-rw-r--r-- | lib/sha512.c | 44 | ||||
-rw-r--r-- | lib/sha512.h | 11 | ||||
-rw-r--r-- | lib/strcasecmp.c | 9 | ||||
-rw-r--r-- | lib/strncasecmp.c | 11 | ||||
-rw-r--r-- | lib/verify.h | 47 | ||||
-rw-r--r-- | m4/ChangeLog | 4 | ||||
-rw-r--r-- | m4/getaddrinfo.m4 | 28 | ||||
-rw-r--r-- | m4/localcharset.m4 | 5 | ||||
-rw-r--r-- | m4/md5.m4 | 5 | ||||
-rw-r--r-- | src/system.h | 8 |
26 files changed, 461 insertions, 306 deletions
@@ -1,7 +1,12 @@ -2006-01-08 Jim Meyering <jim@meyering.net> +2006-01-10 Paul Eggert <eggert@cs.ucla.edu> * Version 6.0-cvs. + * src/system.h (X2NREALLOC, X2REALLOC, DECIMAL_DIGIT_ACCUMULATE): + Use verify_true instead of verify_expr, to sync with gnulib. + +2006-01-08 Jim Meyering <jim@meyering.net> + * src/date.c (usage): Adjust the formatting of the entries for %::z and %:::z (separate with two spaces, not one) so that help2man formats them properly. Reported by Philip Rowlands. diff --git a/build-aux/ChangeLog b/build-aux/ChangeLog index 83a726577..a0fe8ef37 100644 --- a/build-aux/ChangeLog +++ b/build-aux/ChangeLog @@ -1,3 +1,7 @@ +2006-01-10 Paul Eggert <eggert@cs.ucla.edu> + + * config.guess, config.sub, depcomp, texinfo.tex: Sync from gnulib. + 2005-12-13 Paul Eggert <eggert@cs.ucla.edu> * config.guess: Sync from gnulib. diff --git a/build-aux/config.guess b/build-aux/config.guess index e3ef63f6c..17690aea3 100644 --- a/build-aux/config.guess +++ b/build-aux/config.guess @@ -3,7 +3,7 @@ # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. -timestamp='2005-12-13' +timestamp='2006-01-02' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -206,6 +206,9 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; + *:SolidBSD:*:*) + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + exit ;; macppc:MirBSD:*:*) echo powerppc-unknown-mirbsd${UNAME_RELEASE} exit ;; @@ -764,7 +767,12 @@ EOF echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + case ${UNAME_MACHINE} in + pc98) + echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin diff --git a/build-aux/config.sub b/build-aux/config.sub index 1c366dfde..a4e8a94a3 100644 --- a/build-aux/config.sub +++ b/build-aux/config.sub @@ -3,7 +3,7 @@ # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. -timestamp='2005-07-08' +timestamp='2006-01-02' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software @@ -119,8 +119,9 @@ esac # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in - nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \ - kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) + nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ + uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ + storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; @@ -171,6 +172,10 @@ case $os in -hiux*) os=-hiuxwe2 ;; + -sco6) + os=-sco5v6 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` @@ -187,6 +192,10 @@ case $os in # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` @@ -239,7 +248,7 @@ case $basic_machine in | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ - | m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \ + | m32r | m32rle | m68000 | m68k | m88k | maxq | mb | microblaze | mcore \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ @@ -257,7 +266,7 @@ case $basic_machine in | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ - | ms1 \ + | mt \ | msp430 \ | ns16k | ns32k \ | or32 \ @@ -286,6 +295,9 @@ case $basic_machine in ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; + ms1) + basic_machine=mt-unknown + ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and @@ -336,7 +348,7 @@ case $basic_machine in | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ - | ms1-* \ + | mt-* \ | msp430-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | orion-* \ @@ -696,6 +708,9 @@ case $basic_machine in basic_machine=i386-pc os=-msdos ;; + ms1-*) + basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + ;; mvs) basic_machine=i370-ibm os=-mvs @@ -803,6 +818,12 @@ case $basic_machine in pc532 | pc532-*) basic_machine=ns32k-pc532 ;; + pc98) + basic_machine=i386-pc + ;; + pc98-*) + basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; @@ -859,6 +880,10 @@ case $basic_machine in basic_machine=i586-unknown os=-pw32 ;; + rdos) + basic_machine=i386-pc + os=-rdos + ;; rom68k) basic_machine=m68k-rom68k os=-coff @@ -1174,21 +1199,23 @@ case $os in | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \ + | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku*) + | -skyos* | -haiku* | -rdos*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) diff --git a/build-aux/depcomp b/build-aux/depcomp index 04701da53..cc4f869d3 100644 --- a/build-aux/depcomp +++ b/build-aux/depcomp @@ -1,9 +1,10 @@ #! /bin/sh # depcomp - compile a program generating dependencies as side-effects -scriptversion=2005-07-09.11 +scriptversion=2006-01-05.21 -# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. +# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software +# Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -276,6 +277,46 @@ icc) rm -f "$tmpdepfile" ;; +ia64hp) + # The "hp" stanza above does not work with HP's ia64 compilers, + # which have integrated preprocessors. The correct option to use + # with these is +Maked; it writes dependencies to a file named + # 'foo.d', which lands next to the object file, wherever that + # happens to be. + # Much of this is similar to the tru64 case; see comments there. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + if test "$libtool" = yes; then + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir.libs/$base.d + "$@" -Wc,+Maked + else + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir$base.d + "$@" +Maked + fi + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" + # Add `dependent.h:' lines. + sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile" + else + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" "$tmpdepfile2" + ;; + tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. @@ -288,7 +329,7 @@ tru64) if test "$libtool" = yes; then # With Tru64 cc, shared objects can also be used to make a - # static library. This mecanism is used in libtool 1.4 series to + # static library. This mechanism is used in libtool 1.4 series to # handle both shared and static libraries in a single compilation. # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. # diff --git a/build-aux/texinfo.tex b/build-aux/texinfo.tex index da2d3a829..e52d59b99 100644 --- a/build-aux/texinfo.tex +++ b/build-aux/texinfo.tex @@ -3,11 +3,11 @@ % Load plain if necessary, i.e., if running under initex. \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi % -\def\texinfoversion{2005-10-10.17} +\def\texinfoversion{2006-01-08.14} % % Copyright (C) 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995, -% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software -% Foundation, Inc. +% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free +% Software Foundation, Inc. % % This texinfo.tex file is free software; you can redistribute it and/or % modify it under the terms of the GNU General Public License as @@ -293,6 +293,13 @@ % before the \shipout runs. % \indexdummies % don't expand commands in the output. + \normalturnoffactive % \ in index entries must not stay \, e.g., if + % the page break happens to be in the middle of an example. + % We don't want .vr (or whatever) entries like this: + % \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}} + % "\acronym" won't work when it's read back in; + % it needs to be + % {\code {{\tt \backslashcurfont }acronym} \shipout\vbox{% % Do this early so pdf references go to the beginning of the page. \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi @@ -1385,9 +1392,17 @@ where each line of input produces a line of output.} \else \let \startlink \pdfstartlink \fi + % make a live url in pdf output. \def\pdfurl#1{% \begingroup - \normalturnoffactive\def\@{@}% + % it seems we really need yet another set of dummies; have not + % tried to figure out what each command should do in the context + % of @url. for now, just make @/ a no-op, that's the only one + % people have actually reported a problem with. + % + \normalturnoffactive + \def\@{@}% + \let\/=\empty \makevalueexpandable \leavevmode\Red \startlink attr{/Border [0 0 0]}% @@ -2963,8 +2978,11 @@ where each line of input produces a line of output.} % #1 contains the command name as a string, e.g., `ifinfo'. % % Define a command to find the next `@end #1', which must be on a line - % by itself. - \long\def\doignoretext##1^^M@end #1{\doignoretextyyy##1^^M@#1\_STOP_}% + % by itself. Ignore anything after the `#1'; this matters in + % verbatim environments, where otherwise the newline after an + % ignored conditional would result in a blank line in the output. + \long\def\doignoretext##1^^M@end #1##2^^M{% + \doignoretextyyy##1^^M@#1\_STOP_}% % And this command to find another #1 command, at the beginning of a % line. (Otherwise, we would consider a line `@c @ifset', for % example, to count as an @ifset for nesting.) @@ -7102,22 +7120,6 @@ should work if nowhere else does.} % \otherifyactive is called near the end of this file. \def\otherifyactive{\catcode`+=\other \catcode`\_=\other} -% Same as @turnoffactive below, but backslash retains it's normal definition. -% (Before 2005-08-15, this macro explicitly assigned @let\=@normalbackslash, -% but it doesn't seem to be necessary. --kasal) -\def\normalturnoffactive{% - \let"=\normaldoublequote - \let~=\normaltilde - \let^=\normalcaret - \let_=\normalunderscore - \let|=\normalverticalbar - \let<=\normalless - \let>=\normalgreater - \let+=\normalplus - \let$=\normaldollar %$ font-lock fix - \unsepspaces -} - % Used sometimes to turn off (effectively) the active characters even after % parsing them. \def\turnoffactive{% @@ -7149,6 +7151,23 @@ should work if nowhere else does.} @gdef@rawbackslash{@let\=@backslashcurfont} @gdef@otherbackslash{@let\=@realbackslash} +% Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of +% the literal character `\'. +% +@def@normalturnoffactive{% + @let\=@normalbackslash + @let"=@normaldoublequote + @let~=@normaltilde + @let^=@normalcaret + @let_=@normalunderscore + @let|=@normalverticalbar + @let<=@normalless + @let>=@normalgreater + @let+=@normalplus + @let$=@normaldollar %$ font-lock fix + @unsepspaces +} + % Make _ and + \other characters, temporarily. % This is canceled by @fixbackslash. @otherifyactive diff --git a/lib/ChangeLog b/lib/ChangeLog index 80082355c..588c037b9 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,12 @@ +2006-01-10 Paul Eggert <eggert@cs.ucla.edu> + + * localcharset.c, md5.c, md5.h, savedir.c, savedir.h, sha1.c, sha1.h + * lib/strcasecmp.c, lib/strncasecmp.c, lib/verify.h: + Sync from gnulib. + * sha256.c, sha256.h, sha512.c, sha512.h: + Replace all instances of md5_uint32_t with uint32_t, to accommodate + gnulib change. + 2006-01-10 Jim Meyering <jim@meyering.net> Avoid the double-free (first in fts_read, second in fts_close) that diff --git a/lib/localcharset.c b/lib/localcharset.c index 5c257a670..d03ab79d0 100644 --- a/lib/localcharset.c +++ b/lib/localcharset.c @@ -1,6 +1,6 @@ /* Determine a canonical name for the current locale's character encoding. - Copyright (C) 2000-2004 Free Software Foundation, Inc. + Copyright (C) 2000-2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -248,6 +248,7 @@ get_charset_aliases (void) "CP1361" "\0" "JOHAB" "\0" "CP20127" "\0" "ASCII" "\0" "CP20866" "\0" "KOI8-R" "\0" + "CP20936" "\0" "GB2312" "\0" "CP21866" "\0" "KOI8-RU" "\0" "CP28591" "\0" "ISO-8859-1" "\0" "CP28592" "\0" "ISO-8859-2" "\0" @@ -258,7 +259,14 @@ get_charset_aliases (void) "CP28597" "\0" "ISO-8859-7" "\0" "CP28598" "\0" "ISO-8859-8" "\0" "CP28599" "\0" "ISO-8859-9" "\0" - "CP28605" "\0" "ISO-8859-15" "\0"; + "CP28605" "\0" "ISO-8859-15" "\0" + "CP38598" "\0" "ISO-8859-8" "\0" + "CP51932" "\0" "EUC-JP" "\0" + "CP51936" "\0" "GB2312" "\0" + "CP51949" "\0" "EUC-KR" "\0" + "CP51950" "\0" "EUC-TW" "\0" + "CP54936" "\0" "GB18030" "\0" + "CP65001" "\0" "UTF-8" "\0"; # endif #endif @@ -278,7 +286,7 @@ get_charset_aliases (void) STATIC #endif const char * -locale_charset () +locale_charset (void) { const char *codeset; const char *aliases; @@ -1,8 +1,8 @@ -/* md5.c - Functions to compute MD5 message digest of files or memory blocks +/* Functions to compute MD5 message digest of files or memory blocks. according to the definition of MD5 in RFC 1321 from April 1992. - Copyright (C) 1995, 1996, 2001, 2003, 2004, 2005 Free Software Foundation, Inc. - NOTE: The canonical source of this file is maintained with the GNU C - Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu. + Copyright (C) 1995,1996,1997,1999,2000,2001,2005 + Free Software Foundation, Inc. + This file is part of the GNU C Library. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -27,7 +27,9 @@ #include "md5.h" #include <stddef.h> +#include <stdlib.h> #include <string.h> +#include <sys/types.h> #if USE_UNLOCKED_IO # include "unlocked-io.h" @@ -88,10 +90,10 @@ md5_init_ctx (struct md5_ctx *ctx) void * md5_read_ctx (const struct md5_ctx *ctx, void *resbuf) { - ((md5_uint32 *) resbuf)[0] = SWAP (ctx->A); - ((md5_uint32 *) resbuf)[1] = SWAP (ctx->B); - ((md5_uint32 *) resbuf)[2] = SWAP (ctx->C); - ((md5_uint32 *) resbuf)[3] = SWAP (ctx->D); + ((uint32_t *) resbuf)[0] = SWAP (ctx->A); + ((uint32_t *) resbuf)[1] = SWAP (ctx->B); + ((uint32_t *) resbuf)[2] = SWAP (ctx->C); + ((uint32_t *) resbuf)[3] = SWAP (ctx->D); return resbuf; } @@ -105,24 +107,22 @@ void * md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) { /* Take yet unprocessed bytes into account. */ - md5_uint32 bytes = ctx->buflen; - size_t pad; + uint32_t bytes = ctx->buflen; + size_t size = (bytes < 56) ? 64 / 4 : 64 * 2 / 4; /* Now count remaining bytes. */ ctx->total[0] += bytes; if (ctx->total[0] < bytes) ++ctx->total[1]; - pad = bytes >= 56 ? 64 + 56 - bytes : 56 - bytes; - memcpy (&ctx->buffer[bytes], fillbuf, pad); - /* Put the 64-bit file length in *bits* at the end of the buffer. */ - *(md5_uint32 *) &ctx->buffer[bytes + pad] = SWAP (ctx->total[0] << 3); - *(md5_uint32 *) &ctx->buffer[bytes + pad + 4] = SWAP ((ctx->total[1] << 3) | - (ctx->total[0] >> 29)); + ctx->buffer[size - 2] = SWAP (ctx->total[0] << 3); + ctx->buffer[size - 1] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29)); + + memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes); /* Process last bytes. */ - md5_process_block (ctx->buffer, bytes + pad + 8, ctx); + md5_process_block (ctx->buffer, size * 4, ctx); return md5_read_ctx (ctx, resbuf); } @@ -144,8 +144,8 @@ md5_stream (FILE *stream, void *resblock) while (1) { /* We read the file in blocks of BLOCKSIZE bytes. One call of the - computation function processes the whole buffer so that with the - next round of the loop another block can be read. */ + computation function processes the whole buffer so that with the + next round of the loop another block can be read. */ size_t n; sum = 0; @@ -162,8 +162,8 @@ md5_stream (FILE *stream, void *resblock) if (n == 0) { /* Check for the error flag IFF N == 0, so that we don't - exit the loop after a partial read due to e.g., EAGAIN - or EWOULDBLOCK. */ + exit the loop after a partial read due to e.g., EAGAIN + or EWOULDBLOCK. */ if (ferror (stream)) return 1; goto process_partial_block; @@ -177,12 +177,12 @@ md5_stream (FILE *stream, void *resblock) } /* Process buffer with BLOCKSIZE bytes. Note that - BLOCKSIZE % 64 == 0 + BLOCKSIZE % 64 == 0 */ md5_process_block (buffer, BLOCKSIZE, &ctx); } - process_partial_block:; +process_partial_block: /* Process any remaining bytes. */ if (sum > 0) @@ -223,7 +223,7 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx) size_t left_over = ctx->buflen; size_t add = 128 - left_over > len ? len : 128 - left_over; - memcpy (&ctx->buffer[left_over], buffer, add); + memcpy (&((char *) ctx->buffer)[left_over], buffer, add); ctx->buflen += add; if (ctx->buflen > 64) @@ -232,7 +232,8 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx) ctx->buflen &= 63; /* The regions in the following copy operation cannot overlap. */ - memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~63], + memcpy (ctx->buffer, + &((char *) ctx->buffer)[(left_over + add) & ~63], ctx->buflen); } @@ -244,8 +245,14 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx) if (len >= 64) { #if !_STRING_ARCH_unaligned -# define alignof(type) offsetof (struct { char c; type x; }, x) -# define UNALIGNED_P(p) (((size_t) p) % alignof (md5_uint32) != 0) +/* To check alignment gcc has an appropriate operator. Other + compilers don't. */ +# if __GNUC__ >= 2 +# define UNALIGNED_P(p) (((uintptr_t) p) % __alignof__ (uint32_t) != 0) +# else +# define alignof(type) offsetof (struct { char c; type x; }, x) +# define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0) +# endif if (UNALIGNED_P (buffer)) while (len > 64) { @@ -267,13 +274,13 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx) { size_t left_over = ctx->buflen; - memcpy (&ctx->buffer[left_over], buffer, len); + memcpy (&((char *) ctx->buffer)[left_over], buffer, len); left_over += len; if (left_over >= 64) { md5_process_block (ctx->buffer, 64, ctx); left_over -= 64; - memcpy (ctx->buffer, &ctx->buffer[64], left_over); + memcpy (ctx->buffer, &ctx->buffer[16], left_over); } ctx->buflen = left_over; } @@ -295,14 +302,14 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx) void md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx) { - md5_uint32 correct_words[16]; - const md5_uint32 *words = buffer; - size_t nwords = len / sizeof (md5_uint32); - const md5_uint32 *endp = words + nwords; - md5_uint32 A = ctx->A; - md5_uint32 B = ctx->B; - md5_uint32 C = ctx->C; - md5_uint32 D = ctx->D; + uint32_t correct_words[16]; + const uint32_t *words = buffer; + size_t nwords = len / sizeof (uint32_t); + const uint32_t *endp = words + nwords; + uint32_t A = ctx->A; + uint32_t B = ctx->B; + uint32_t C = ctx->C; + uint32_t D = ctx->D; /* First increment the byte count. RFC 1321 specifies the possible length of the file up to 2^64 bits. Here we only compute the @@ -315,18 +322,18 @@ md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx) the loop. */ while (words < endp) { - md5_uint32 *cwp = correct_words; - md5_uint32 A_save = A; - md5_uint32 B_save = B; - md5_uint32 C_save = C; - md5_uint32 D_save = D; + uint32_t *cwp = correct_words; + uint32_t A_save = A; + uint32_t B_save = B; + uint32_t C_save = C; + uint32_t D_save = D; /* First round: using the given function, the context and a constant - the next context is computed. Because the algorithms processing - unit is a 32-bit word and it is determined to work on words in - little endian byte order we perhaps have to change the byte order - before the computation. To reduce the work for the next steps - we store the swapped words in the array CORRECT_WORDS. */ + the next context is computed. Because the algorithms processing + unit is a 32-bit word and it is determined to work on words in + little endian byte order we perhaps have to change the byte order + before the computation. To reduce the work for the next steps + we store the swapped words in the array CORRECT_WORDS. */ #define OP(a, b, c, d, s, T) \ do \ @@ -339,43 +346,43 @@ md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx) while (0) /* It is unfortunate that C does not provide an operator for - cyclic rotation. Hope the C compiler is smart enough. */ + cyclic rotation. Hope the C compiler is smart enough. */ #define CYCLIC(w, s) (w = (w << s) | (w >> (32 - s))) /* Before we start, one word to the strange constants. - They are defined in RFC 1321 as + They are defined in RFC 1321 as - T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64 + T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64 - Here is an equivalent invocation using Perl: + Here is an equivalent invocation using Perl: - perl -e 'foreach(1..64){printf "0x%08x\n", int (4294967296 * abs (sin $_))}' + perl -e 'foreach(1..64){printf "0x%08x\n", int (4294967296 * abs (sin $_))}' */ /* Round 1. */ - OP (A, B, C, D, 7, 0xd76aa478); + OP (A, B, C, D, 7, 0xd76aa478); OP (D, A, B, C, 12, 0xe8c7b756); OP (C, D, A, B, 17, 0x242070db); OP (B, C, D, A, 22, 0xc1bdceee); - OP (A, B, C, D, 7, 0xf57c0faf); + OP (A, B, C, D, 7, 0xf57c0faf); OP (D, A, B, C, 12, 0x4787c62a); OP (C, D, A, B, 17, 0xa8304613); OP (B, C, D, A, 22, 0xfd469501); - OP (A, B, C, D, 7, 0x698098d8); + OP (A, B, C, D, 7, 0x698098d8); OP (D, A, B, C, 12, 0x8b44f7af); OP (C, D, A, B, 17, 0xffff5bb1); OP (B, C, D, A, 22, 0x895cd7be); - OP (A, B, C, D, 7, 0x6b901122); + OP (A, B, C, D, 7, 0x6b901122); OP (D, A, B, C, 12, 0xfd987193); OP (C, D, A, B, 17, 0xa679438e); OP (B, C, D, A, 22, 0x49b40821); /* For the second to fourth round we have the possibly swapped words - in CORRECT_WORDS. Redefine the macro to take an additional first - argument specifying the function to use. */ + in CORRECT_WORDS. Redefine the macro to take an additional first + argument specifying the function to use. */ #undef OP #define OP(f, a, b, c, d, k, s, T) \ - do \ + do \ { \ a += f (b, c, d) + correct_words[k] + T; \ CYCLIC (a, s); \ @@ -384,58 +391,58 @@ md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx) while (0) /* Round 2. */ - OP (FG, A, B, C, D, 1, 5, 0xf61e2562); - OP (FG, D, A, B, C, 6, 9, 0xc040b340); + OP (FG, A, B, C, D, 1, 5, 0xf61e2562); + OP (FG, D, A, B, C, 6, 9, 0xc040b340); OP (FG, C, D, A, B, 11, 14, 0x265e5a51); - OP (FG, B, C, D, A, 0, 20, 0xe9b6c7aa); - OP (FG, A, B, C, D, 5, 5, 0xd62f105d); - OP (FG, D, A, B, C, 10, 9, 0x02441453); + OP (FG, B, C, D, A, 0, 20, 0xe9b6c7aa); + OP (FG, A, B, C, D, 5, 5, 0xd62f105d); + OP (FG, D, A, B, C, 10, 9, 0x02441453); OP (FG, C, D, A, B, 15, 14, 0xd8a1e681); - OP (FG, B, C, D, A, 4, 20, 0xe7d3fbc8); - OP (FG, A, B, C, D, 9, 5, 0x21e1cde6); - OP (FG, D, A, B, C, 14, 9, 0xc33707d6); - OP (FG, C, D, A, B, 3, 14, 0xf4d50d87); - OP (FG, B, C, D, A, 8, 20, 0x455a14ed); - OP (FG, A, B, C, D, 13, 5, 0xa9e3e905); - OP (FG, D, A, B, C, 2, 9, 0xfcefa3f8); - OP (FG, C, D, A, B, 7, 14, 0x676f02d9); + OP (FG, B, C, D, A, 4, 20, 0xe7d3fbc8); + OP (FG, A, B, C, D, 9, 5, 0x21e1cde6); + OP (FG, D, A, B, C, 14, 9, 0xc33707d6); + OP (FG, C, D, A, B, 3, 14, 0xf4d50d87); + OP (FG, B, C, D, A, 8, 20, 0x455a14ed); + OP (FG, A, B, C, D, 13, 5, 0xa9e3e905); + OP (FG, D, A, B, C, 2, 9, 0xfcefa3f8); + OP (FG, C, D, A, B, 7, 14, 0x676f02d9); OP (FG, B, C, D, A, 12, 20, 0x8d2a4c8a); /* Round 3. */ - OP (FH, A, B, C, D, 5, 4, 0xfffa3942); - OP (FH, D, A, B, C, 8, 11, 0x8771f681); + OP (FH, A, B, C, D, 5, 4, 0xfffa3942); + OP (FH, D, A, B, C, 8, 11, 0x8771f681); OP (FH, C, D, A, B, 11, 16, 0x6d9d6122); OP (FH, B, C, D, A, 14, 23, 0xfde5380c); - OP (FH, A, B, C, D, 1, 4, 0xa4beea44); - OP (FH, D, A, B, C, 4, 11, 0x4bdecfa9); - OP (FH, C, D, A, B, 7, 16, 0xf6bb4b60); + OP (FH, A, B, C, D, 1, 4, 0xa4beea44); + OP (FH, D, A, B, C, 4, 11, 0x4bdecfa9); + OP (FH, C, D, A, B, 7, 16, 0xf6bb4b60); OP (FH, B, C, D, A, 10, 23, 0xbebfbc70); - OP (FH, A, B, C, D, 13, 4, 0x289b7ec6); - OP (FH, D, A, B, C, 0, 11, 0xeaa127fa); - OP (FH, C, D, A, B, 3, 16, 0xd4ef3085); - OP (FH, B, C, D, A, 6, 23, 0x04881d05); - OP (FH, A, B, C, D, 9, 4, 0xd9d4d039); + OP (FH, A, B, C, D, 13, 4, 0x289b7ec6); + OP (FH, D, A, B, C, 0, 11, 0xeaa127fa); + OP (FH, C, D, A, B, 3, 16, 0xd4ef3085); + OP (FH, B, C, D, A, 6, 23, 0x04881d05); + OP (FH, A, B, C, D, 9, 4, 0xd9d4d039); OP (FH, D, A, B, C, 12, 11, 0xe6db99e5); OP (FH, C, D, A, B, 15, 16, 0x1fa27cf8); - OP (FH, B, C, D, A, 2, 23, 0xc4ac5665); + OP (FH, B, C, D, A, 2, 23, 0xc4ac5665); /* Round 4. */ - OP (FI, A, B, C, D, 0, 6, 0xf4292244); - OP (FI, D, A, B, C, 7, 10, 0x432aff97); + OP (FI, A, B, C, D, 0, 6, 0xf4292244); + OP (FI, D, A, B, C, 7, 10, 0x432aff97); OP (FI, C, D, A, B, 14, 15, 0xab9423a7); - OP (FI, B, C, D, A, 5, 21, 0xfc93a039); - OP (FI, A, B, C, D, 12, 6, 0x655b59c3); - OP (FI, D, A, B, C, 3, 10, 0x8f0ccc92); + OP (FI, B, C, D, A, 5, 21, 0xfc93a039); + OP (FI, A, B, C, D, 12, 6, 0x655b59c3); + OP (FI, D, A, B, C, 3, 10, 0x8f0ccc92); OP (FI, C, D, A, B, 10, 15, 0xffeff47d); - OP (FI, B, C, D, A, 1, 21, 0x85845dd1); - OP (FI, A, B, C, D, 8, 6, 0x6fa87e4f); + OP (FI, B, C, D, A, 1, 21, 0x85845dd1); + OP (FI, A, B, C, D, 8, 6, 0x6fa87e4f); OP (FI, D, A, B, C, 15, 10, 0xfe2ce6e0); - OP (FI, C, D, A, B, 6, 15, 0xa3014314); + OP (FI, C, D, A, B, 6, 15, 0xa3014314); OP (FI, B, C, D, A, 13, 21, 0x4e0811a1); - OP (FI, A, B, C, D, 4, 6, 0xf7537e82); + OP (FI, A, B, C, D, 4, 6, 0xf7537e82); OP (FI, D, A, B, C, 11, 10, 0xbd3af235); - OP (FI, C, D, A, B, 2, 15, 0x2ad7d2bb); - OP (FI, B, C, D, A, 9, 21, 0xeb86d391); + OP (FI, C, D, A, B, 2, 15, 0x2ad7d2bb); + OP (FI, B, C, D, A, 9, 21, 0xeb86d391); /* Add the starting values of the context. */ A += A_save; @@ -1,9 +1,8 @@ /* Declaration of functions and data types used for MD5 sum computing library functions. - Copyright (C) 1995-1997,1999-2005 Free Software Foundation, Inc. - - NOTE: The canonical source of this file is maintained with the GNU C - Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu. + Copyright (C) 1995-1997,1999,2000,2001,2004,2005 + Free Software Foundation, Inc. + This file is part of the GNU C Library. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -23,18 +22,15 @@ #define _MD5_H 1 #include <stdio.h> +#include <stdint.h> -#if HAVE_INTTYPES_H -# include <inttypes.h> -#endif -#if HAVE_STDINT_H || _LIBC -# include <stdint.h> -#endif +#define MD5_DIGEST_SIZE 16 +#define MD5_BLOCK_SIZE 64 #ifndef __GNUC_PREREQ # if defined __GNUC__ && defined __GNUC_MINOR__ -# define __GNUC_PREREQ(maj, min) \ - ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +# define __GNUC_PREREQ(maj, min) \ + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) # else # define __GNUC_PREREQ(maj, min) 0 # endif @@ -64,19 +60,17 @@ # define __md5_stream md5_stream #endif -typedef uint32_t md5_uint32; - /* Structure to save state of computation between the single steps. */ struct md5_ctx { - md5_uint32 A; - md5_uint32 B; - md5_uint32 C; - md5_uint32 D; - - md5_uint32 total[2]; - md5_uint32 buflen; - char buffer[128] __attribute__ ((__aligned__ (__alignof__ (md5_uint32)))); + uint32_t A; + uint32_t B; + uint32_t C; + uint32_t D; + + uint32_t total[2]; + uint32_t buflen; + uint32_t buffer[32]; }; /* @@ -107,8 +101,8 @@ extern void __md5_process_bytes (const void *buffer, size_t len, endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. - IMPORTANT: On some systems it is required that RESBUF be correctly - aligned for a 32 bits value. */ + IMPORTANT: On some systems, RESBUF must be aligned to a 32-bit + boundary. */ extern void *__md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) __THROW; @@ -116,8 +110,8 @@ extern void *__md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) __THROW; always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. - IMPORTANT: On some systems it is required that RESBUF is correctly - aligned for a 32 bits value. */ + IMPORTANT: On some systems, RESBUF must be aligned to a 32-bit + boundary. */ extern void *__md5_read_ctx (const struct md5_ctx *ctx, void *resbuf) __THROW; diff --git a/lib/savedir.c b/lib/savedir.c index 86930eb56..b08f32b79 100644 --- a/lib/savedir.c +++ b/lib/savedir.c @@ -55,27 +55,27 @@ #include <stdlib.h> #include <string.h> +#include "openat.h" #include "xalloc.h" -/* Return a freshly allocated string containing the file names - in directory DIR, separated by '\0' characters; - the end is marked by two '\0' characters in a row. - Return NULL (setting errno) if DIR cannot be opened, read, or closed. */ - #ifndef NAME_SIZE_DEFAULT # define NAME_SIZE_DEFAULT 512 #endif -char * -savedir (const char *dir) +/* Return a freshly allocated string containing the file names + in directory DIRP, separated by '\0' characters; + the end is marked by two '\0' characters in a row. + Return NULL (setting errno) if DIRP cannot be read or closed. + If DIRP is NULL, return NULL without affecting errno. */ + +static char * +savedirstream (DIR *dirp) { - DIR *dirp; char *name_space; size_t allocated = NAME_SIZE_DEFAULT; size_t used = 0; int save_errno; - dirp = opendir (dir); if (dirp == NULL) return NULL; @@ -127,3 +127,25 @@ savedir (const char *dir) } return name_space; } + +/* Return a freshly allocated string containing the file names + in directory DIR, separated by '\0' characters; + the end is marked by two '\0' characters in a row. + Return NULL (setting errno) if DIR cannot be opened, read, or closed. */ + +char * +savedir (char const *dir) +{ + return savedirstream (opendir (dir)); +} + +/* Return a freshly allocated string containing the file names + in directory FD, separated by '\0' characters; + the end is marked by two '\0' characters in a row. + Return NULL (setting errno) if FD cannot be read or closed. */ + +char * +fdsavedir (int fd) +{ + return savedirstream (fdopendir (fd)); +} diff --git a/lib/savedir.h b/lib/savedir.h index 4828b1bec..7809d2392 100644 --- a/lib/savedir.h +++ b/lib/savedir.h @@ -1,6 +1,6 @@ /* Save the list of files in a directory in a string. - Copyright 1997, 1999, 2001, 2003 Free Software Foundation, Inc. + Copyright 1997, 1999, 2001, 2003, 2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,6 +21,7 @@ #if !defined SAVEDIR_H_ # define SAVEDIR_H_ -char *savedir (const char *dir); +char *savedir (char const *dir); +char *fdsavedir (int fd); #endif diff --git a/lib/sha1.c b/lib/sha1.c index e8949bdcc..09198f334 100644 --- a/lib/sha1.c +++ b/lib/sha1.c @@ -81,11 +81,11 @@ sha1_init_ctx (struct sha1_ctx *ctx) void * sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf) { - ((md5_uint32 *) resbuf)[0] = SWAP (ctx->A); - ((md5_uint32 *) resbuf)[1] = SWAP (ctx->B); - ((md5_uint32 *) resbuf)[2] = SWAP (ctx->C); - ((md5_uint32 *) resbuf)[3] = SWAP (ctx->D); - ((md5_uint32 *) resbuf)[4] = SWAP (ctx->E); + ((uint32_t *) resbuf)[0] = SWAP (ctx->A); + ((uint32_t *) resbuf)[1] = SWAP (ctx->B); + ((uint32_t *) resbuf)[2] = SWAP (ctx->C); + ((uint32_t *) resbuf)[3] = SWAP (ctx->D); + ((uint32_t *) resbuf)[4] = SWAP (ctx->E); return resbuf; } @@ -99,7 +99,7 @@ void * sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf) { /* Take yet unprocessed bytes into account. */ - md5_uint32 bytes = ctx->buflen; + uint32_t bytes = ctx->buflen; size_t pad; /* Now count remaining bytes. */ @@ -111,8 +111,8 @@ sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf) memcpy (&ctx->buffer[bytes], fillbuf, pad); /* Put the 64-bit file length in *bits* at the end of the buffer. */ - *(md5_uint32 *) &ctx->buffer[bytes + pad + 4] = SWAP (ctx->total[0] << 3); - *(md5_uint32 *) &ctx->buffer[bytes + pad] = SWAP ((ctx->total[1] << 3) | + *(uint32_t *) &ctx->buffer[bytes + pad + 4] = SWAP (ctx->total[0] << 3); + *(uint32_t *) &ctx->buffer[bytes + pad] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29)); /* Process last bytes. */ @@ -238,7 +238,7 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx) { #if !_STRING_ARCH_unaligned # define alignof(type) offsetof (struct { char c; type x; }, x) -# define UNALIGNED_P(p) (((size_t) p) % alignof (md5_uint32) != 0) +# define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0) if (UNALIGNED_P (buffer)) while (len > 64) { @@ -293,15 +293,15 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx) void sha1_process_block (const void *buffer, size_t len, struct sha1_ctx *ctx) { - const md5_uint32 *words = buffer; - size_t nwords = len / sizeof (md5_uint32); - const md5_uint32 *endp = words + nwords; - md5_uint32 x[16]; - md5_uint32 a = ctx->A; - md5_uint32 b = ctx->B; - md5_uint32 c = ctx->C; - md5_uint32 d = ctx->D; - md5_uint32 e = ctx->E; + const uint32_t *words = buffer; + size_t nwords = len / sizeof (uint32_t); + const uint32_t *endp = words + nwords; + uint32_t x[16]; + uint32_t a = ctx->A; + uint32_t b = ctx->B; + uint32_t c = ctx->C; + uint32_t d = ctx->D; + uint32_t e = ctx->E; /* First increment the byte count. RFC 1321 specifies the possible length of the file up to 2^64 bits. Here we only compute the @@ -325,7 +325,7 @@ sha1_process_block (const void *buffer, size_t len, struct sha1_ctx *ctx) while (words < endp) { - md5_uint32 tm; + uint32_t tm; int t; for (t = 0; t < 16; t++) { diff --git a/lib/sha1.h b/lib/sha1.h index bb48855b8..a3ab132e8 100644 --- a/lib/sha1.h +++ b/lib/sha1.h @@ -20,20 +20,20 @@ # define SHA1_H 1 # include <stdio.h> -# include "md5.h" +# include <stdint.h> /* Structure to save state of computation between the single steps. */ struct sha1_ctx { - md5_uint32 A; - md5_uint32 B; - md5_uint32 C; - md5_uint32 D; - md5_uint32 E; - - md5_uint32 total[2]; - md5_uint32 buflen; - char buffer[128] __attribute__ ((__aligned__ (__alignof__ (md5_uint32)))); + uint32_t A; + uint32_t B; + uint32_t C; + uint32_t D; + uint32_t E; + + uint32_t total[2]; + uint32_t buflen; + char buffer[128] __attribute__ ((__aligned__ (__alignof__ (uint32_t)))); }; diff --git a/lib/sha256.c b/lib/sha256.c index 03c05281a..39ae13a51 100644 --- a/lib/sha256.c +++ b/lib/sha256.c @@ -105,7 +105,7 @@ sha256_read_ctx (const struct sha256_ctx *ctx, void *resbuf) int i; for ( i=0 ; i<8 ; i++ ) - ((md5_uint32 *) resbuf)[i] = NOTSWAP (ctx->state[i]); + ((uint32_t *) resbuf)[i] = NOTSWAP (ctx->state[i]); return resbuf; } @@ -116,7 +116,7 @@ sha224_read_ctx (const struct sha256_ctx *ctx, void *resbuf) int i; for ( i=0 ; i<7 ; i++ ) - ((md5_uint32 *) resbuf)[i] = NOTSWAP (ctx->state[i]); + ((uint32_t *) resbuf)[i] = NOTSWAP (ctx->state[i]); return resbuf; } @@ -130,7 +130,7 @@ static void sha256_conclude_ctx (struct sha256_ctx *ctx) { /* Take yet unprocessed bytes into account. */ - md5_uint32 bytes = ctx->buflen; + uint32_t bytes = ctx->buflen; size_t pad; /* Now count remaining bytes. */ @@ -142,8 +142,8 @@ sha256_conclude_ctx (struct sha256_ctx *ctx) memcpy (&ctx->buffer[bytes], fillbuf, pad); /* Put the 64-bit file length in *bits* at the end of the buffer. */ - *(md5_uint32 *) &ctx->buffer[bytes + pad + 4] = NOTSWAP (ctx->total[0] << 3); - *(md5_uint32 *) &ctx->buffer[bytes + pad] = NOTSWAP ((ctx->total[1] << 3) | + *(uint32_t *) &ctx->buffer[bytes + pad + 4] = NOTSWAP (ctx->total[0] << 3); + *(uint32_t *) &ctx->buffer[bytes + pad] = NOTSWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29)); /* Process last bytes. */ @@ -360,7 +360,7 @@ sha256_process_bytes (const void *buffer, size_t len, struct sha256_ctx *ctx) { #if !_STRING_ARCH_unaligned # define alignof(type) offsetof (struct { char c; type x; }, x) -# define UNALIGNED_P(p) (((size_t) p) % alignof (md5_uint32) != 0) +# define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0) if (UNALIGNED_P (buffer)) while (len > 64) { @@ -398,7 +398,7 @@ sha256_process_bytes (const void *buffer, size_t len, struct sha256_ctx *ctx) /* SHA256 round constants */ #define K(I) sha256_round_constants[I] -static const md5_uint32 sha256_round_constants[64] = { +static const uint32_t sha256_round_constants[64] = { 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, 0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL, @@ -428,18 +428,18 @@ static const md5_uint32 sha256_round_constants[64] = { void sha256_process_block (const void *buffer, size_t len, struct sha256_ctx *ctx) { - const md5_uint32 *words = buffer; - size_t nwords = len / sizeof (md5_uint32); - const md5_uint32 *endp = words + nwords; - md5_uint32 x[16]; - md5_uint32 a = ctx->state[0]; - md5_uint32 b = ctx->state[1]; - md5_uint32 c = ctx->state[2]; - md5_uint32 d = ctx->state[3]; - md5_uint32 e = ctx->state[4]; - md5_uint32 f = ctx->state[5]; - md5_uint32 g = ctx->state[6]; - md5_uint32 h = ctx->state[7]; + const uint32_t *words = buffer; + size_t nwords = len / sizeof (uint32_t); + const uint32_t *endp = words + nwords; + uint32_t x[16]; + uint32_t a = ctx->state[0]; + uint32_t b = ctx->state[1]; + uint32_t c = ctx->state[2]; + uint32_t d = ctx->state[3]; + uint32_t e = ctx->state[4]; + uint32_t f = ctx->state[5]; + uint32_t g = ctx->state[6]; + uint32_t h = ctx->state[7]; /* First increment the byte count. FIPS PUB 180-2 specifies the possible length of the file up to 2^64 bits. Here we only compute the @@ -468,8 +468,8 @@ sha256_process_block (const void *buffer, size_t len, struct sha256_ctx *ctx) while (words < endp) { - md5_uint32 tm; - md5_uint32 t0, t1; + uint32_t tm; + uint32_t t0, t1; int t; /* FIXME: see sha1.c for a better implementation. */ for (t = 0; t < 16; t++) diff --git a/lib/sha256.h b/lib/sha256.h index 34c3756ca..11be3adf1 100644 --- a/lib/sha256.h +++ b/lib/sha256.h @@ -1,6 +1,6 @@ /* Declarations of functions and data types used for SHA256 and SHA224 sum library functions. - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -25,10 +25,10 @@ /* Structure to save state of computation between the single steps. */ struct sha256_ctx { - md5_uint32 state[8]; + uint32_t state[8]; - md5_uint32 total[2]; - md5_uint32 buflen; + uint32_t total[2]; + uint32_t buflen; char buffer[128]; }; diff --git a/lib/sha512.c b/lib/sha512.c index 0e0597397..11c3b1d16 100644 --- a/lib/sha512.c +++ b/lib/sha512.c @@ -1,7 +1,7 @@ /* sha512.c - Functions to compute SHA512 and SHA384 message digest of files or memory blocks according to the NIST specification FIPS-180-2. - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -107,7 +107,7 @@ sha512_read_ctx (const struct sha512_ctx *ctx, void *resbuf) int i; for ( i=0 ; i<8 ; i++ ) - ((sha512_uint64 *) resbuf)[i] = NOTSWAP (ctx->state[i]); + ((uint64_t *) resbuf)[i] = NOTSWAP (ctx->state[i]); return resbuf; } @@ -118,7 +118,7 @@ sha384_read_ctx (const struct sha512_ctx *ctx, void *resbuf) int i; for ( i=0 ; i<6 ; i++ ) - ((sha512_uint64 *) resbuf)[i] = NOTSWAP (ctx->state[i]); + ((uint64_t *) resbuf)[i] = NOTSWAP (ctx->state[i]); return resbuf; } @@ -132,7 +132,7 @@ static void sha512_conclude_ctx (struct sha512_ctx *ctx) { /* Take yet unprocessed bytes into account. */ - sha512_uint64 bytes = ctx->buflen; + uint64_t bytes = ctx->buflen; size_t pad; /* Now count remaining bytes. */ @@ -144,8 +144,8 @@ sha512_conclude_ctx (struct sha512_ctx *ctx) memcpy (&ctx->buffer[bytes], fillbuf, pad); /* Put the 64-bit file length in *bits* at the end of the buffer. */ - *(sha512_uint64 *) &ctx->buffer[bytes + pad + 8] = NOTSWAP (ctx->total[0] << 3); - *(sha512_uint64 *) &ctx->buffer[bytes + pad] = NOTSWAP ((ctx->total[1] << 3) | + *(uint64_t *) &ctx->buffer[bytes + pad + 8] = NOTSWAP (ctx->total[0] << 3); + *(uint64_t *) &ctx->buffer[bytes + pad] = NOTSWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 61)); /* Process last bytes. */ @@ -362,7 +362,7 @@ sha512_process_bytes (const void *buffer, size_t len, struct sha512_ctx *ctx) { #if !_STRING_ARCH_unaligned # define alignof(type) offsetof (struct { char c; type x; }, x) -# define UNALIGNED_P(p) (((size_t) p) % alignof (sha512_uint64) != 0) +# define UNALIGNED_P(p) (((size_t) p) % alignof (uint64_t) != 0) if (UNALIGNED_P (buffer)) while (len > 128) { @@ -400,7 +400,7 @@ sha512_process_bytes (const void *buffer, size_t len, struct sha512_ctx *ctx) /* SHA512 round constants */ #define K(I) sha512_round_constants[I] -static const sha512_uint64 sha512_round_constants[80] = { +static const uint64_t sha512_round_constants[80] = { 0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, 0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL, 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL, 0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL, 0xd807aa98a3030242ULL, 0x12835b0145706fbeULL, 0x243185be4ee4b28cULL, 0x550c7dc3d5ffb4e2ULL, 0x72be5d74f27b896fULL, 0x80deb1fe3b1696b1ULL, 0x9bdc06a725c71235ULL, 0xc19bf174cf692694ULL, 0xe49b69c19ef14ad2ULL, 0xefbe4786384f25e3ULL, 0x0fc19dc68b8cd5b5ULL, 0x240ca1cc77ac9c65ULL, 0x2de92c6f592b0275ULL, 0x4a7484aa6ea6e483ULL, 0x5cb0a9dcbd41fbd4ULL, 0x76f988da831153b5ULL, @@ -424,18 +424,18 @@ static const sha512_uint64 sha512_round_constants[80] = { void sha512_process_block (const void *buffer, size_t len, struct sha512_ctx *ctx) { - const sha512_uint64 *words = buffer; - size_t nwords = len / sizeof (sha512_uint64); - const sha512_uint64 *endp = words + nwords; - sha512_uint64 x[16]; - sha512_uint64 a = ctx->state[0]; - sha512_uint64 b = ctx->state[1]; - sha512_uint64 c = ctx->state[2]; - sha512_uint64 d = ctx->state[3]; - sha512_uint64 e = ctx->state[4]; - sha512_uint64 f = ctx->state[5]; - sha512_uint64 g = ctx->state[6]; - sha512_uint64 h = ctx->state[7]; + const uint64_t *words = buffer; + size_t nwords = len / sizeof (uint64_t); + const uint64_t *endp = words + nwords; + uint64_t x[16]; + uint64_t a = ctx->state[0]; + uint64_t b = ctx->state[1]; + uint64_t c = ctx->state[2]; + uint64_t d = ctx->state[3]; + uint64_t e = ctx->state[4]; + uint64_t f = ctx->state[5]; + uint64_t g = ctx->state[6]; + uint64_t h = ctx->state[7]; /* First increment the byte count. FIPS PUB 180-2 specifies the possible length of the file up to 2^128 bits. Here we only compute the @@ -463,8 +463,8 @@ sha512_process_block (const void *buffer, size_t len, struct sha512_ctx *ctx) while (words < endp) { - sha512_uint64 tm; - sha512_uint64 t0, t1; + uint64_t tm; + uint64_t t0, t1; int t; /* FIXME: see sha1.c for a better implementation. */ for (t = 0; t < 16; t++) diff --git a/lib/sha512.h b/lib/sha512.h index 5a2b5ce35..3740de9c5 100644 --- a/lib/sha512.h +++ b/lib/sha512.h @@ -1,6 +1,6 @@ /* Declarations of functions and data types used for SHA512 and SHA384 sum library functions. - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -28,16 +28,13 @@ # include <stdint.h> # endif -typedef uint64_t sha512_uint64; - - /* Structure to save state of computation between the single steps. */ struct sha512_ctx { - sha512_uint64 state[8]; + uint64_t state[8]; - sha512_uint64 total[2]; - sha512_uint64 buflen; + uint64_t total[2]; + uint64_t buflen; char buffer[256]; }; diff --git a/lib/strcasecmp.c b/lib/strcasecmp.c index 71f2eca7c..c1bac0a5a 100644 --- a/lib/strcasecmp.c +++ b/lib/strcasecmp.c @@ -25,6 +25,7 @@ #include "strcase.h" #include <ctype.h> +#include <limits.h> #if HAVE_MBRTOWC # include "mbuiter.h" @@ -93,6 +94,12 @@ strcasecmp (const char *s1, const char *s2) } while (c1 == c2); - return c1 - c2; + if (UCHAR_MAX <= INT_MAX) + return c1 - c2; + else + /* On machines where 'char' and 'int' are types of the same size, the + difference of two 'unsigned char' values - including the sign bit - + doesn't fit in an 'int'. */ + return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0); } } diff --git a/lib/strncasecmp.c b/lib/strncasecmp.c index 72ead013b..0209c39ea 100644 --- a/lib/strncasecmp.c +++ b/lib/strncasecmp.c @@ -1,5 +1,5 @@ /* strncasecmp.c -- case insensitive string comparator - Copyright (C) 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,6 +23,7 @@ #include "strcase.h" #include <ctype.h> +#include <limits.h> #define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch)) @@ -54,5 +55,11 @@ strncasecmp (const char *s1, const char *s2, size_t n) } while (c1 == c2); - return c1 - c2; + if (UCHAR_MAX <= INT_MAX) + return c1 - c2; + else + /* On machines where 'char' and 'int' are types of the same size, the + difference of two 'unsigned char' values - including the sign bit - + doesn't fit in an 'int'. */ + return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0); } diff --git a/lib/verify.h b/lib/verify.h index fbabd82c0..328980fa3 100644 --- a/lib/verify.h +++ b/lib/verify.h @@ -23,24 +23,33 @@ /* Each of these macros verifies that its argument R is a nonzero constant expression. To be portable, R's type must be integer (or - boolean). Unlike assert, there is no run-time overhead. */ - -/* A type that is valid if and only if R is a nonzero constant expression. - The symbols verify_type__ and verify_error_if_negative_size__ are - private to this header file. */ - -# define verify_type__(R) \ - struct { unsigned int verify_error_if_negative_size__ : (R) ? 1 : -1; } - -/* Verify requirement R at compile-time, as a declaration. */ - -# define verify(R) \ - extern int (* verify_function__ (void)) [sizeof (verify_type__ (R))] - -/* Verify requirement R at compile-time, as an expression. - This macro can be used in some contexts where verify cannot, and vice versa. - Return void. */ - -# define verify_expr(R) ((void) ((verify_type__ (R) *) 0)) + boolean). Unlike assert, there is no run-time overhead. + + There are two macros, since no single macro can be used in all + contexts in C. verify_true (R) is for scalar contexts, where it + may be cast to void if need be. verify (R) is for declaration + contexts, e.g., the top level. + + The symbols verify_error_if_negative_size__ and verify_function__ + are private to this header. */ + +/* Verify requirement R at compile-time, as an integer constant expression. + Return true. */ + +# ifdef __cplusplus +template <int w> + struct verify_type__ { unsigned int verify_error_if_negative_size__: w; }; +# define verify_true(R) \ + (!!sizeof (verify_type__<(R) ? 1 : -1>)) +# else +# define verify_true(R) \ + (!!sizeof \ + (struct { unsigned int verify_error_if_negative_size__: (R) ? 1 : -1; })) +# endif + +/* Verify requirement R at compile-time, as a declaration without a + trailing ';'. */ + +# define verify(R) extern int (* verify_function__ (void)) [verify_true (R)] #endif diff --git a/m4/ChangeLog b/m4/ChangeLog index 85ca5d93a..8e8c8d771 100644 --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,7 @@ +2006-01-10 Paul Eggert <eggert@cs.ucla.edu> + + * getaddrinfo.m4, localcharset.m4, md5.m4: Sync from gnulib. + 2006-01-10 Jim Meyering <jim@meyering.net> * fpending.m4: Also include <stdio.h>, for Dragonfly. diff --git a/m4/getaddrinfo.m4 b/m4/getaddrinfo.m4 index be44232d7..b3b7b0736 100644 --- a/m4/getaddrinfo.m4 +++ b/m4/getaddrinfo.m4 @@ -1,4 +1,4 @@ -# getaddrinfo.m4 serial 6 +# getaddrinfo.m4 serial 7 dnl Copyright (C) 2004, 2005 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -19,30 +19,18 @@ AC_DEFUN([gl_PREREQ_GETADDRINFO], [ AC_REQUIRE([gl_SOCKET_FAMILIES]) AC_REQUIRE([AC_C_INLINE]) AC_REQUIRE([AC_GNU_SOURCE]) - AC_CHECK_HEADERS_ONCE(sys/socket.h netdb.h sys/types.h netinet/in.h) + AC_CHECK_HEADERS_ONCE(netinet/in.h) AC_CHECK_DECLS([getaddrinfo, freeaddrinfo, gai_strerror],,,[ /* sys/types.h is not needed according to POSIX, but the sys/socket.h in i386-unknown-freebsd4.10 and powerpc-apple-darwin5.5 required it. */ -#ifdef HAVE_SYS_TYPES_H -# include <sys/types.h> -#endif -#ifdef HAVE_SYS_SOCKET_H -# include <sys/socket.h> -#endif -#ifdef HAVE_NETDB_H -# include <netdb.h> -#endif +#include <sys/types.h> +#include <sys/socket.h> +#include <netdb.h> ]) AC_CHECK_TYPES([struct addrinfo],,,[ -#ifdef HAVE_SYS_TYPES_H -# include <sys/types.h> -#endif -#ifdef HAVE_SYS_SOCKET_H -# include <sys/socket.h> -#endif -#ifdef HAVE_NETDB_H -# include <netdb.h> -#endif +#include <sys/types.h> +#include <sys/socket.h> +#include <netdb.h> ]) ]) diff --git a/m4/localcharset.m4 b/m4/localcharset.m4 index c92e1bb82..6863d3225 100644 --- a/m4/localcharset.m4 +++ b/m4/localcharset.m4 @@ -1,5 +1,5 @@ -# localcharset.m4 serial 2 -dnl Copyright (C) 2002 Free Software Foundation, Inc. +# localcharset.m4 serial 3 +dnl Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -9,6 +9,7 @@ AC_DEFUN([gl_LOCALCHARSET], dnl Prerequisites of lib/localcharset.c. AC_CHECK_HEADERS_ONCE(stddef.h stdlib.h string.h) AC_REQUIRE([AM_LANGINFO_CODESET]) + AC_CHECK_DECLS_ONCE(getc_unlocked) AC_CHECK_FUNCS_ONCE(setlocale) dnl Prerequisites of the lib/Makefile.am snippet. @@ -1,4 +1,4 @@ -# md5.m4 serial 7 +# md5.m4 serial 8 dnl Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -9,9 +9,6 @@ AC_DEFUN([gl_MD5], AC_LIBSOURCES([md5.c, md5.h]) AC_LIBOBJ([md5]) - dnl Prerequisites of lib/md5.h. - AC_REQUIRE([gl_AC_TYPE_UINT32_T]) - dnl Prerequisites of lib/md5.c. AC_REQUIRE([AC_C_BIGENDIAN]) : diff --git a/src/system.h b/src/system.h index db3d3489f..d447494e3 100644 --- a/src/system.h +++ b/src/system.h @@ -513,14 +513,14 @@ uid_t getuid (); the third argument to x2nrealloc would be `sizeof *(P)'. Ensure that sizeof *(P) is *not* 1. In that case, it'd be better to use X2REALLOC, although not strictly necessary. */ -#define X2NREALLOC(P, PN) (verify_expr (sizeof *(P) != 1), \ +#define X2NREALLOC(P, PN) (verify_true (sizeof *(P) != 1), \ x2nrealloc (P, PN, sizeof *(P))) /* Using x2realloc (when appropriate) usually makes your code more readable than using x2nrealloc, but it also makes it so your code will malfunction if sizeof *(P) ever becomes 2 or greater. So use this macro instead of using x2realloc directly. */ -#define X2REALLOC(P, PN) (verify_expr (sizeof *(P) == 1), x2realloc (P, PN)) +#define X2REALLOC(P, PN) (verify_true (sizeof *(P) == 1), x2realloc (P, PN)) #if ! defined HAVE_MEMPCPY && ! defined mempcpy /* Be CAREFUL that there are no side effects in N. */ @@ -800,8 +800,8 @@ ptr_align (void const *ptr, size_t alignment) #define DECIMAL_DIGIT_ACCUMULATE(Accum, Digit_val, Type) \ ( \ (void) (&(Accum) == (Type *) NULL), /* The type matches. */ \ - verify_expr (! TYPE_SIGNED (Type)), /* The type is unsigned. */ \ - verify_expr (sizeof (Accum) == sizeof (Type)), /* Added check. */ \ + verify_true (! TYPE_SIGNED (Type)), /* The type is unsigned. */ \ + verify_true (sizeof (Accum) == sizeof (Type)), /* Added check. */ \ (((Type) -1 / 10 < (Accum) \ || (Type) ((Accum) * 10 + (Digit_val)) < (Accum)) \ ? false : (((Accum) = (Accum) * 10 + (Digit_val)), true)) \ |