Commit dafd0440 dafd044063fc411ada8fd1a77e4ff6d7993b1c14 by Sergey Poznyakoff

Updated by gnulib-sync

1 parent 3e718271
......@@ -17,7 +17,7 @@
If not, write to the Free Software Foundation,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
......
/* Copyright (C) 1992-2001, 2003, 2004 Free Software Foundation, Inc.
/* Copyright (C) 1992-2001, 2003, 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
......@@ -15,47 +15,32 @@
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#if !_LIBC
# include "getpass.h"
#endif
#include "getpass.h"
#if _LIBC
# define HAVE_STDIO_EXT_H 1
#endif
#include <stdio.h>
#if !defined _WIN32
#include <stdbool.h>
#include <stdio.h>
#if HAVE_STDIO_EXT_H
# include <stdio_ext.h>
#else
# define __fsetlocking(stream, type) /* empty */
#endif
#if !_LIBC
# include "getline.h"
#if !HAVE___FSETLOCKING
# define __fsetlocking(stream, type) /* empty */
#endif
#include <termios.h>
#include <unistd.h>
#if _LIBC
# include <wchar.h>
#if HAVE_TERMIOS_H
# include <termios.h>
#endif
#if _LIBC
# define NOTCANCEL_MODE "c"
#else
# define NOTCANCEL_MODE
#endif
#include "getline.h"
#if _LIBC
# define flockfile(s) _IO_flockfile (s)
# define funlockfile(s) _IO_funlockfile (s)
#elif USE_UNLOCKED_IO
#if USE_UNLOCKED_IO
# include "unlocked-io.h"
#else
# if !HAVE_DECL_FFLUSH_UNLOCKED
......@@ -80,18 +65,6 @@
# endif
#endif
#if _LIBC
# include <bits/libc-lock.h>
#else
# define __libc_cleanup_push(function, arg) /* empty */
# define __libc_cleanup_pop(execute) /* empty */
#endif
#if !_LIBC
# define __getline getline
# define __tcgetattr tcgetattr
#endif
/* It is desirable to use this bit on systems that have it.
The only bit of terminal state we want to twiddle is echoing, which is
done in software; there is no need to change the state of the terminal
......@@ -114,7 +87,7 @@ getpass (const char *prompt)
FILE *tty;
FILE *in, *out;
struct termios s, t;
bool tty_changed;
bool tty_changed = false;
static char *buf;
static size_t bufsize;
ssize_t nread;
......@@ -122,7 +95,7 @@ getpass (const char *prompt)
/* Try to write to and read from the terminal if we can.
If we can't open the terminal, use stderr and stdin. */
tty = fopen ("/dev/tty", "w+" NOTCANCEL_MODE);
tty = fopen ("/dev/tty", "w+");
if (tty == NULL)
{
in = stdin;
......@@ -136,39 +109,26 @@ getpass (const char *prompt)
out = in = tty;
}
/* Make sure the stream we opened is closed even if the thread is
canceled. */
__libc_cleanup_push (call_fclose, tty);
flockfile (out);
/* Turn echoing off if it is on now. */
if (__tcgetattr (fileno (in), &t) == 0)
#if HAVE_TCGETATTR
if (tcgetattr (fileno (in), &t) == 0)
{
/* Save the old one. */
s = t;
/* Tricky, tricky. */
t.c_lflag &= ~(ECHO|ISIG);
tty_changed = (tcsetattr (fileno (in), TCSAFLUSH|TCSASOFT, &t) == 0);
t.c_lflag &= ~(ECHO | ISIG);
tty_changed = (tcsetattr (fileno (in), TCSAFLUSH | TCSASOFT, &t) == 0);
}
else
tty_changed = false;
#endif
/* Write the prompt. */
#ifdef USE_IN_LIBIO
if (_IO_fwide (out, 0) > 0)
__fwprintf (out, L"%s", prompt);
else
#endif
fputs_unlocked (prompt, out);
fputs_unlocked (prompt, out);
fflush_unlocked (out);
/* Read the password. */
nread = __getline (&buf, &bufsize, in);
#if !_LIBC
/* As far as is known, glibc doesn't need this no-op fseek. */
nread = getline (&buf, &bufsize, in);
/* According to the C standard, input may not be followed by output
on the same stream without an intervening call to a file
......@@ -180,7 +140,6 @@ getpass (const char *prompt)
from POSIX version to POSIX version, so play it safe and invoke
fseek even if in != out. */
fseek (out, 0, SEEK_CUR);
#endif
if (buf != NULL)
{
......@@ -193,25 +152,75 @@ getpass (const char *prompt)
if (tty_changed)
{
/* Write the newline that was not echoed. */
#ifdef USE_IN_LIBIO
if (_IO_fwide (out, 0) > 0)
putwc_unlocked (L'\n', out);
else
#endif
putc_unlocked ('\n', out);
putc_unlocked ('\n', out);
}
}
}
/* Restore the original setting. */
#if HAVE_TCSETATTR
if (tty_changed)
(void) tcsetattr (fileno (in), TCSAFLUSH|TCSASOFT, &s);
tcsetattr (fileno (in), TCSAFLUSH | TCSASOFT, &s);
#endif
funlockfile (out);
__libc_cleanup_pop (0);
call_fclose (tty);
return buf;
}
#else /* WIN32 */
/* Windows implementation by Martin Lambers <marlam@marlam.de>,
improved by Simon Josefsson. */
/* For PASS_MAX. */
#include <limits.h>
#ifndef PASS_MAX
# define PASS_MAX 512
#endif
char *
getpass (const char *prompt)
{
char getpassbuf[PASS_MAX + 1];
size_t i = 0;
int c;
if (prompt)
{
fputs (prompt, stderr);
fflush (stderr);
}
for (;;)
{
c = _getch ();
if (c == '\r')
{
getpassbuf[i] = '\0';
break;
}
else if (i < PASS_MAX)
{
getpassbuf[i++] = c;
}
if (i >= PASS_MAX)
{
getpassbuf[i] = '\0';
break;
}
}
if (prompt)
{
fputs ("\r\n", stderr);
fflush (stderr);
}
return strdup (getpassbuf);
}
#endif
......
......@@ -53,12 +53,25 @@
? (t) -1 \
: ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))
/* Return zero if T can be determined to be an unsigned type.
Otherwise, return 1.
When compiling with GCC, INT_STRLEN_BOUND uses this macro to obtain a
tighter bound. Otherwise, it overestimates the true bound by one byte
when applied to unsigned types of size 2, 4, 16, ... bytes.
The symbol signed_type_or_expr__ is private to this header file. */
#if __GNUC__ >= 2
# define signed_type_or_expr__(t) TYPE_SIGNED (__typeof__ (t))
#else
# define signed_type_or_expr__(t) 1
#endif
/* Bound on length of the string representing an integer type or expression T.
Subtract 1 for the sign bit if t is signed; log10 (2.0) < 146/485;
Subtract 1 for the sign bit if T is signed; log10 (2.0) < 146/485;
add 1 for integer division truncation; add 1 more for a minus sign
if needed. */
#define INT_STRLEN_BOUND(t) \
((sizeof (t) * CHAR_BIT - 1) * 146 / 485 + 2)
((sizeof (t) * CHAR_BIT - signed_type_or_expr__ (t)) * 146 / 485 \
+ signed_type_or_expr__ (t) + 1)
/* Bound on buffer size needed to represent an integer type or expression T,
including the terminating null. */
......
......@@ -51,10 +51,6 @@
# endif
#endif
#if defined _LIBC && defined USE_IN_LIBIO
# include <wchar.h>
#endif
#include <stddef.h>
#ifndef ELIDE_CODE
......@@ -433,12 +429,11 @@ print_and_abort (void)
happen because the "memory exhausted" message appears in other places
like this and the translation should be reused instead of creating
a very similar string which requires a separate translation. */
# if defined _LIBC && defined USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0)
__fwprintf (stderr, L"%s\n", _("memory exhausted"));
else
# ifdef _LIBC
(void) __fxprintf (NULL, "%s\n", _("memory exhausted"));
# else
fprintf (stderr, "%s\n", _("memory exhausted"));
# endif
fprintf (stderr, "%s\n", _("memory exhausted"));
exit (obstack_exit_failure);
}
......
/* obstack.h - object stack macros
Copyright (C) 1988-1994,1996-1999,2003,2004 Free Software Foundation, Inc.
This file is part of the GNU C Library. Its master source is NOT part of
the C library, however. The master source lives in /gd/gnu/lib.
NOTE: The canonical source of this file is maintained with the GNU C Library.
Bugs can be reported to bug-glibc@gnu.org.
Copyright (C) 1988-1994,1996-1999,2003,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
......@@ -464,7 +460,7 @@ __extension__ \
(((const void **) ((h)->next_free += sizeof (void *)))[-1] = (aptr))
# define obstack_int_grow_fast(h,aint) \
(((int *) ((h)->next_free += sizeof (int)))[-1] = (aptr))
(((int *) ((h)->next_free += sizeof (int)))[-1] = (aint))
# define obstack_blank(h,length) \
( (h)->temp.tempint = (length), \
......
......@@ -17,7 +17,7 @@
/* written by Jim Meyering */
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#undef realloc
......
......@@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
......
......@@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
......
......@@ -19,7 +19,7 @@
/* Written by Jim Meyering. */
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
......
......@@ -3,7 +3,8 @@
# This is a modified version of autoconf's AC_FUNC_FNMATCH.
# This file should be simplified after Autoconf 2.57 is required.
# Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software
# Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
......@@ -27,9 +28,15 @@ AC_DEFUN([_AC_FUNC_FNMATCH_IF],
# include <fnmatch.h>
# define y(a, b, c) (fnmatch (a, b, c) == 0)
# define n(a, b, c) (fnmatch (a, b, c) == FNM_NOMATCH)
static int
fnm (char const *pattern, char const *string, int flags)
{
return fnmatch (pattern, string, flags);
}
],
[exit
(!(y ("a*", "abc", 0)
(!((fnm ? fnm : fnmatch) ("a*", "", 0) == FNM_NOMATCH
&& y ("a*", "abc", 0)
&& n ("d*/*1", "d/s/1", FNM_PATHNAME)
&& y ("a\\\\bc", "abc", 0)
&& n ("a\\\\bc", "abc", FNM_NOESCAPE)
......@@ -50,19 +57,19 @@ AS_IF([test $$2 = yes], [$3], [$4])
])# _AC_FUNC_FNMATCH_IF
# _AC_LIBOBJ_FNMATCH
# _MU_LIBOBJ_FNMATCH
# ------------------
# Prepare the replacement of fnmatch.
AC_DEFUN([_AC_LIBOBJ_FNMATCH],
AC_DEFUN([_MU_LIBOBJ_FNMATCH],
[AC_REQUIRE([AC_C_CONST])dnl
AC_REQUIRE([AC_FUNC_ALLOCA])dnl
AC_REQUIRE([AC_TYPE_MBSTATE_T])dnl
AC_CHECK_DECLS([getenv])
AC_CHECK_FUNCS([btowc mbsrtowcs mempcpy wmemchr wmemcpy wmempcpy])
AC_CHECK_HEADERS([wchar.h wctype.h])
AC_LIBOBJ([fnmatch])
MU_LIBOBJ([fnmatch])
FNMATCH_H=fnmatch.h
])# _AC_LIBOBJ_FNMATCH
])# _MU_LIBOBJ_FNMATCH
AC_DEFUN([gl_FUNC_FNMATCH_POSIX],
......@@ -70,7 +77,7 @@ AC_DEFUN([gl_FUNC_FNMATCH_POSIX],
FNMATCH_H=
_AC_FUNC_FNMATCH_IF([POSIX], [ac_cv_func_fnmatch_posix],
[rm -f lib/fnmatch.h],
[_AC_LIBOBJ_FNMATCH])
[_MU_LIBOBJ_FNMATCH])
if test $ac_cv_func_fnmatch_posix != yes; then
dnl We must choose a different name for our function, since on ELF systems
dnl a broken fnmatch() in libc.so would override our fnmatch() if it is
......@@ -90,7 +97,7 @@ AC_DEFUN([gl_FUNC_FNMATCH_GNU],
FNMATCH_H=
_AC_FUNC_FNMATCH_IF([GNU], [ac_cv_func_fnmatch_gnu],
[rm -f lib/fnmatch.h],
[_AC_LIBOBJ_FNMATCH])
[_MU_LIBOBJ_FNMATCH])
if test $ac_cv_func_fnmatch_gnu != yes; then
dnl We must choose a different name for our function, since on ELF systems
dnl a broken fnmatch() in libc.so would override our fnmatch() if it is
......
# getopt.m4 serial 10
# getopt.m4 serial 11
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,
......@@ -27,8 +27,10 @@ AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER],
AC_DEFUN([gl_GETOPT_CHECK_HEADERS],
[
GETOPT_H=
AC_CHECK_HEADERS([getopt.h], [], [GETOPT_H=getopt.h])
if test -z "$GETOPT_H"; then
AC_CHECK_HEADERS([getopt.h], [], [GETOPT_H=getopt.h])
fi
if test -z "$GETOPT_H"; then
AC_CHECK_FUNCS([getopt_long_only], [], [GETOPT_H=getopt.h])
fi
......
......@@ -35,7 +35,7 @@ AC_DEFUN([gl_FUNC_GETPASS_GNU],
# Prerequisites of lib/getpass.c.
AC_DEFUN([gl_PREREQ_GETPASS], [
AC_CHECK_HEADERS_ONCE(stdio_ext.h)
AC_CHECK_HEADERS_ONCE(stdio_ext.h termios.h)
AC_CHECK_FUNCS_ONCE(__fsetlocking tcgetattr tcsetattr)
AC_CHECK_DECLS_ONCE([fflush_unlocked flockfile fputs_unlocked funlockfile putc_unlocked])
:
])
......
# inttypes.m4 serial 1 (gettext-0.11.4)
dnl Copyright (C) 1997-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
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.
dnl From Paul Eggert.
......
# longdouble.m4 serial 1 (gettext-0.12)
dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
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.
dnl From Bruno Haible.
dnl Test whether the compiler supports the 'long double' type.
......
# mbchar.m4 serial 1
# mbchar.m4 serial 2
dnl Copyright (C) 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,
......@@ -10,5 +10,11 @@ dnl From Bruno Haible.
AC_DEFUN([gl_MBCHAR],
[
AC_REQUIRE([AC_GNU_SOURCE])
:
dnl The following line is that so the user can test
dnl HAVE_WCHAR_H && HAVE_WCTYPE_H before #include "mbchar.h".
AC_CHECK_HEADERS_ONCE(wchar.h wctype.h)
dnl Compile mbchar.c only if HAVE_WCHAR_H && HAVE_WCTYPE_H.
if test $ac_cv_header_wchar_h = yes && test $ac_cv_header_wctype_h = yes; then
MU_LIBOBJ([mbchar])
fi
])
......
# 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],
MU_LIBSOURCES([md5.c, md5.h])
MU_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])
:
......
# minmax.m4 serial 1
# minmax.m4 serial 2
dnl Copyright (C) 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,
dnl with or without modifications, as long as this notice is preserved.
AC_PREREQ(2.52)
AC_DEFUN([gl_MINMAX],
[
AC_REQUIRE([gl_PREREQ_MINMAX])
......@@ -17,12 +19,13 @@ AC_DEFUN([gl_PREREQ_MINMAX],
])
dnl gl_MINMAX_IN_HEADER(HEADER)
dnl The parameter has to be a literal header name; it cannot be macro,
dnl nor a shell variable. (Because autoheader collects only AC_DEFINE
dnl invocations with a literal macro name.)
AC_DEFUN([gl_MINMAX_IN_HEADER],
[
define([header],[translit([$1],[./-],
[___])])
define([HEADER],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
m4_pushdef([header], AS_TR_SH([$1]))
m4_pushdef([HEADER], AS_TR_CPP([$1]))
AC_CACHE_CHECK([whether <$1> defines MIN and MAX],
[gl_cv_minmax_in_]header,
[AC_TRY_COMPILE([#include <$1>
......@@ -33,6 +36,6 @@ int x = MIN (42, 17);], [],
AC_DEFINE([HAVE_MINMAX_IN_]HEADER, 1,
[Define to 1 if <$1> defines the MIN and MAX macros.])
fi
undefine([HEADER])
undefine([header])
m4_popdef([HEADER])
m4_popdef([header])
])
......
#serial 24
#serial 30
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005 Free
# Software Foundation, Inc.
......@@ -10,121 +10,155 @@
dnl Initially derived from code in GNU grep.
dnl Mostly written by Jim Meyering.
AC_PREREQ([2.50])
AC_DEFUN([gl_REGEX],
[
gl_INCLUDED_REGEX([lib/regex.c])
])
dnl Usage: gl_INCLUDED_REGEX([lib/regex.c])
dnl
AC_DEFUN([gl_INCLUDED_REGEX],
[
MU_LIBSOURCES(
[regcomp.c, regex.c, regex.h,
regex_internal.c, regex_internal.h, regexec.c])
dnl Even packages that don't use regex.c can use this macro.
dnl Of course, for them it doesn't do anything.
# Assume we'll default to using the included regex.c.
ac_use_included_regex=yes
# However, if the system regex support is good enough that it passes the
# the following run test, then default to *not* using the included regex.c.
AC_REQUIRE([AC_SYS_LARGEFILE]) dnl for a sufficently-wide off_t
AC_DEFINE([_REGEX_LARGE_OFFSETS], 1,
[Define if you want regoff_t to be at least as wide POSIX requires.])
MU_LIBSOURCES(
[regcomp.c, regex.c, regex.h,
regex_internal.c, regex_internal.h, regexec.c])
AC_ARG_WITH([included-regex],
[AC_HELP_STRING([--without-included-regex],
[don't compile regex; this is the default on
systems with recent-enough versions of the GNU C
Library (use with caution on other systems)])])
case $with_included_regex in
yes|no) ac_use_included_regex=$with_included_regex
;;
'')
# If the system regex support is good enough that it passes the the
# following run test, then default to *not* using the included regex.c.
# If cross compiling, assume the test would fail and use the included
# regex.c. The first failing regular expression is from `Spencer ere
# test #75' in grep-2.3.
AC_CACHE_CHECK([for working re_compile_pattern],
[gl_cv_func_working_re_compile_pattern],
[gl_cv_func_re_compile_pattern_broken],
[AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[AC_INCLUDES_DEFAULT
#include <regex.h>],
[[static struct re_pattern_buffer regex;
const char *s;
struct re_registers regs;
re_set_syntax (RE_SYNTAX_POSIX_EGREP);
memset (&regex, 0, sizeof (regex));
s = re_compile_pattern ("a[:@:>@:]b\n", 9, &regex);
/* This should fail with _Invalid character class name_ error. */
if (!s)
exit (1);
/* This should succeed, but does not for e.g. glibc-2.1.3. */
memset (&regex, 0, sizeof (regex));
s = re_compile_pattern ("{1", 2, &regex);
if (s)
exit (1);
/* The following example is derived from a problem report
against gawk from Jorge Stolfi <stolfi@ic.unicamp.br>. */
memset (&regex, 0, sizeof (regex));
s = re_compile_pattern ("[an\371]*n", 7, &regex);
if (s)
exit (1);
/* This should match, but does not for e.g. glibc-2.2.1. */
if (re_match (&regex, "an", 2, 0, &regs) != 2)
exit (1);
memset (&regex, 0, sizeof (regex));
s = re_compile_pattern ("x", 1, &regex);
if (s)
exit (1);
/* The version of regex.c in e.g. GNU libc-2.2.93 did not
work with a negative RANGE argument. */
if (re_search (&regex, "wxy", 3, 2, -2, &regs) != 1)
exit (1);
/* The version of regex.c in older versions of gnulib
* ignored RE_ICASE. Detect that problem too. */
memset (&regex, 0, sizeof (regex));
re_set_syntax(RE_SYNTAX_EMACS|RE_ICASE);
s = re_compile_pattern ("x", 1, &regex);
if (s)
exit (1);
if (re_search (&regex, "WXY", 3, 0, 3, &regs) < 0)
exit (1);
/* REG_STARTEND was added to glibc on 2004-01-15.
Reject older versions. */
if (! REG_STARTEND)
exit (1);
exit (0);]])],
[gl_cv_func_working_re_compile_pattern=yes],
[gl_cv_func_working_re_compile_pattern=no],
dnl When crosscompiling, assume it is broken.
[gl_cv_func_working_re_compile_pattern=no])])
if test $gl_cv_func_working_re_compile_pattern = yes; then
ac_use_included_regex=no
fi
test -n "$1" || AC_MSG_ERROR([missing argument])
m4_syscmd([test -f '$1'])
ifelse(m4_sysval, 0,
[
AC_ARG_WITH([included-regex],
[ --without-included-regex don't compile regex; this is the default on
systems with recent-enough versions of the GNU C
Library (use with caution on other systems)],
[gl_with_regex=$withval],
[gl_with_regex=$ac_use_included_regex])
if test "X$gl_with_regex" = Xyes; then
MU_LIBOBJ([regex])
gl_PREREQ_REGEX
fi
],
)
]
)
[AC_LANG_PROGRAM(
[AC_INCLUDES_DEFAULT
#include <regex.h>],
[[static struct re_pattern_buffer regex;
const char *s;
struct re_registers regs;
/* Use the POSIX-compliant spelling with leading REG_,
rather than the traditional GNU spelling with leading RE_,
so that we reject older libc implementations. */
re_set_syntax (REG_SYNTAX_POSIX_EGREP);
memset (&regex, 0, sizeof (regex));
s = re_compile_pattern ("a[:@:>@:]b\n", 9, &regex);
/* This should fail with _Invalid character class name_ error. */
if (!s)
exit (1);
/* This should succeed, but does not for e.g. glibc-2.1.3. */
memset (&regex, 0, sizeof (regex));
s = re_compile_pattern ("{1", 2, &regex);
if (s)
exit (1);
/* The following example is derived from a problem report
against gawk from Jorge Stolfi <stolfi@ic.unicamp.br>. */
memset (&regex, 0, sizeof (regex));
s = re_compile_pattern ("[an\371]*n", 7, &regex);
if (s)
exit (1);
/* This should match, but does not for e.g. glibc-2.2.1. */
if (re_match (&regex, "an", 2, 0, &regs) != 2)
exit (1);
memset (&regex, 0, sizeof (regex));
s = re_compile_pattern ("x", 1, &regex);
if (s)
exit (1);
/* The version of regex.c in e.g. GNU libc-2.2.93 did not
work with a negative RANGE argument. */
if (re_search (&regex, "wxy", 3, 2, -2, &regs) != 1)
exit (1);
/* The version of regex.c in older versions of gnulib
ignored REG_IGNORE_CASE (which was then called RE_ICASE).
Detect that problem too. */
memset (&regex, 0, sizeof (regex));
re_set_syntax (REG_SYNTAX_EMACS | REG_IGNORE_CASE);
s = re_compile_pattern ("x", 1, &regex);
if (s)
exit (1);
if (re_search (&regex, "WXY", 3, 0, 3, &regs) < 0)
exit (1);
/* REG_STARTEND was added to glibc on 2004-01-15.
Reject older versions. */
if (! REG_STARTEND)
exit (1);
/* Reject hosts whose regoff_t values are too narrow.
These include glibc 2.3.5 on hosts with 64-bit off_t
and 32-bit int, and Solaris 10 on hosts with 32-bit int
and _FILE_OFFSET_BITS=64. */
if (sizeof (regoff_t) < sizeof (off_t))
exit (1);
exit (0);]])],
[gl_cv_func_re_compile_pattern_broken=no],
[gl_cv_func_re_compile_pattern_broken=yes],
dnl When crosscompiling, assume it is broken.
[gl_cv_func_re_compile_pattern_broken=yes])])
ac_use_included_regex=$gl_cv_func_re_compile_pattern_broken
;;
*) AC_MSG_ERROR([Invalid value for --with-included-regex: $with_included_regex])
;;
esac
if test $ac_use_included_regex = yes; then
AC_DEFINE([re_syntax_options], [rpl_re_syntax_options],
[Define to rpl_re_syntax_options if the replacement should be used.])
AC_DEFINE([re_set_syntax], [rpl_re_set_syntax],
[Define to rpl_re_set_syntax if the replacement should be used.])
AC_DEFINE([re_compile_pattern], [rpl_re_compile_pattern],
[Define to rpl_re_compile_pattern if the replacement should be used.])
AC_DEFINE([re_compile_fastmap], [rpl_re_compile_fastmap],
[Define to rpl_re_compile_fastmap if the replacement should be used.])
AC_DEFINE([re_search], [rpl_re_search],
[Define to rpl_re_search if the replacement should be used.])
AC_DEFINE([re_search_2], [rpl_re_search_2],
[Define to rpl_re_search_2 if the replacement should be used.])
AC_DEFINE([re_match], [rpl_re_match],
[Define to rpl_re_match if the replacement should be used.])
AC_DEFINE([re_match_2], [rpl_re_match_2],
[Define to rpl_re_match_2 if the replacement should be used.])
AC_DEFINE([re_set_registers], [rpl_re_set_registers],
[Define to rpl_re_set_registers if the replacement should be used.])
AC_DEFINE([re_comp], [rpl_re_comp],
[Define to rpl_re_comp if the replacement should be used.])
AC_DEFINE([re_exec], [rpl_re_exec],
[Define to rpl_re_exec if the replacement should be used.])
AC_DEFINE([regcomp], [rpl_regcomp],
[Define to rpl_regcomp if the replacement should be used.])
AC_DEFINE([regexec], [rpl_regexec],
[Define to rpl_regexec if the replacement should be used.])
AC_DEFINE([regerror], [rpl_regerror],
[Define to rpl_regerror if the replacement should be used.])
AC_DEFINE([regfree], [rpl_regfree],
[Define to rpl_regfree if the replacement should be used.])
MU_LIBOBJ([regex])
gl_PREREQ_REGEX
fi
])
# Prerequisites of lib/regex.c and lib/regex_internal.c.
AC_DEFUN([gl_PREREQ_REGEX],
[
AC_REQUIRE([AC_GNU_SOURCE])
AC_REQUIRE([gl_C_RESTRICT])
AC_REQUIRE([AM_LANGINFO_CODESET])
AC_CHECK_HEADERS_ONCE([locale.h wchar.h wctype.h])
......
# signed.m4 serial 1 (gettext-0.10.40)
dnl Copyright (C) 2001-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
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.
dnl From Bruno Haible.
......
# size_max.m4 serial 2
dnl Copyright (C) 2003 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
# size_max.m4 serial 3
dnl Copyright (C) 2003, 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,
dnl with or without modifications, as long as this notice is preserved.
dnl From Bruno Haible.
......@@ -28,9 +26,9 @@ Found it
dnl than the type 'unsigned long'.
dnl The _AC_COMPUTE_INT macro works up to LONG_MAX, since it uses 'expr',
dnl which is guaranteed to work from LONG_MIN to LONG_MAX.
_AC_COMPUTE_INT([~(size_t)0 / 10], res_hi,
_AC_COMPUTE_INT([(size_t)~(size_t)0 / 10], res_hi,
[#include <stddef.h>], result=?)
_AC_COMPUTE_INT([~(size_t)0 % 10], res_lo,
_AC_COMPUTE_INT([(size_t)~(size_t)0 % 10], res_lo,
[#include <stddef.h>], result=?)
_AC_COMPUTE_INT([sizeof (size_t) <= sizeof (unsigned int)], fits_in_uint,
[#include <stddef.h>], result=?)
......@@ -50,7 +48,7 @@ Found it
fi
else
dnl Shouldn't happen, but who knows...
result='~(size_t)0'
result='((size_t)~(size_t)0)'
fi
fi
AC_MSG_RESULT([$result])
......
# Check for stdbool.h that conforms to C99.
dnl Copyright (C) 2002-2004 Free Software Foundation, Inc.
dnl Copyright (C) 2002-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,
dnl with or without modifications, as long as this notice is preserved.
......@@ -28,6 +28,9 @@ AC_DEFUN([AM_STDBOOL_H],
AC_SUBST([HAVE__BOOL])
])
# AM_STDBOOL_H will be renamed to gl_STDBOOL_H in the future.
AC_DEFUN([gl_STDBOOL_H], [AM_STDBOOL_H])
# This macro is only needed in autoconf <= 2.59. Newer versions of autoconf
# have this macro built-in.
......@@ -70,10 +73,12 @@ AC_DEFUN([AC_HEADER_STDBOOL],
enum { j = false, k = true, l = false * true, m = true * 256 };
_Bool n[m];
char o[sizeof n == m * sizeof n[0] ? 1 : -1];
char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
],
[
return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !j + !k + !l
+ !m + !n + !o);
/* Refer to every declared value, to avoid compiler optimizations. */
return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
+ !m + !n + !o + !p);
],
[ac_cv_header_stdbool_h=yes],
[ac_cv_header_stdbool_h=no])])
......
# strcase.m4 serial 2
# strcase.m4 serial 3
dnl Copyright (C) 2002, 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,
......@@ -29,7 +29,8 @@ AC_DEFUN([gl_FUNC_STRNCASECMP],
# Prerequisites of lib/strcasecmp.c.
AC_DEFUN([gl_PREREQ_STRCASECMP], [
gl_FUNC_MBRTOWC
AC_REQUIRE([gl_FUNC_MBRTOWC])
:
])
# Prerequisites of lib/strncasecmp.c.
......
# wchar_t.m4 serial 1 (gettext-0.12)
dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
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.
dnl From Bruno Haible.
dnl Test whether <stddef.h> has the 'wchar_t' type.
......
# wint_t.m4 serial 1 (gettext-0.12)
dnl Copyright (C) 2003 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
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.
dnl From Bruno Haible.
dnl Test whether <wchar.h> has the 'wint_t' type.
......
# xsize.m4 serial 2
dnl Copyright (C) 2003 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
# xsize.m4 serial 3
dnl Copyright (C) 2003-2004 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.
AC_DEFUN([gl_XSIZE],
[
dnl Prerequisites of lib/xsize.h.
AC_REQUIRE([gl_SIZE_MAX])
AC_REQUIRE([AC_C_INLINE])
AC_CHECK_HEADERS(stdint.h)
])
......
......@@ -15,10 +15,10 @@
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
# include <config.h>
#endif
#include <sysexits.h>
......
......@@ -21,7 +21,7 @@
don't have that. */
#ifdef HAVE_CONFIG_H
#include <config.h>
# include <config.h>
#endif
#include <stdlib.h>
......
......@@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
/* This package emulates glibc `line_wrap_stream' semantics for systems that
don't have that. If the system does have it, it is just a wrapper for
......@@ -25,10 +25,6 @@
#ifndef _ARGP_FMTSTREAM_H
#define _ARGP_FMTSTREAM_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <string.h>
#include <unistd.h>
......
......@@ -15,10 +15,10 @@
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
# include <config.h>
#endif
#define ARGP_FS_EI
......
......@@ -22,7 +22,7 @@
#endif
#ifdef HAVE_CONFIG_H
#include <config.h>
# include <config.h>
#endif
#include <alloca.h>
......
......@@ -18,7 +18,7 @@
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
# include <config.h>
#endif
#include <alloca.h>
......@@ -81,8 +81,8 @@ static const struct argp_option argp_default_options[] =
{
{"help", '?', 0, 0, N_("Give this help list"), -1},
{"usage", OPT_USAGE, 0, 0, N_("Give a short usage message"), 0},
{"program-name",OPT_PROGNAME,"NAME", OPTION_HIDDEN, N_("Set the program name"), 0},
{"HANG", OPT_HANG, "SECS", OPTION_ARG_OPTIONAL | OPTION_HIDDEN,
{"program-name",OPT_PROGNAME,N_("NAME"), OPTION_HIDDEN, N_("Set the program name"), 0},
{"HANG", OPT_HANG, N_("SECS"), OPTION_ARG_OPTIONAL | OPTION_HIDDEN,
N_("Hang for SECS seconds (default 3600)"), 0},
{NULL, 0, 0, 0, NULL, 0}
};
......
......@@ -18,7 +18,7 @@
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
# include <config.h>
#endif
#include "argp.h"
......
......@@ -15,10 +15,10 @@
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
# include <config.h>
#endif
#if defined _LIBC || defined HAVE_FEATURES_H
......
......@@ -19,15 +19,22 @@
/* Ported from glibc by Simon Josefsson. */
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "getdelim.h"
#include <limits.h>
#include <stdlib.h>
#include <errno.h>
#include "getdelim.h"
#ifndef SIZE_MAX
# define SIZE_MAX ((size_t) -1)
#endif
#ifndef SSIZE_MAX
# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
#endif
#if !HAVE_FLOCKFILE
# undef flockfile
# define flockfile(x) ((void) 0)
......@@ -46,9 +53,8 @@
ssize_t
getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
{
int result;
ssize_t cur_len = 0;
ssize_t len;
ssize_t result;
size_t cur_len = 0;
if (lineptr == NULL || n == NULL || fp == NULL)
{
......@@ -71,20 +77,26 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
for (;;)
{
char *t;
int i;
i = getc (fp);
if (i == EOF)
break;
{
result = -1;
break;
}
/* Make enough space for len+1 (for final NUL) bytes. */
if (cur_len + 1 >= *n)
{
size_t needed = 2 * (cur_len + 1) + 1; /* Be generous. */
size_t needed_max =
SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX;
size_t needed = 2 * *n + 1; /* Be generous. */
char *new_lineptr;
if (needed < cur_len)
if (needed_max < needed)
needed = needed_max;
if (cur_len + 1 >= needed)
{
result = -1;
goto unlock_return;
......@@ -108,7 +120,7 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
break;
}
(*lineptr)[cur_len] = '\0';
result = cur_len;
result = cur_len ? cur_len : result;
unlock_return:
funlockfile (fp);
......
......@@ -18,7 +18,7 @@
/* Written by Simon Josefsson. */
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
......
......@@ -18,7 +18,7 @@
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
# include <config.h>
#endif
#ifdef _LIBC
......
/* Declarations for getopt.
Copyright (C) 1989-1994,1996-1999,2001,2003,2004
Copyright (C) 1989-1994,1996-1999,2001,2003,2004,2005
Free Software Foundation, Inc.
This file is part of the GNU C Library.
......@@ -34,9 +34,7 @@
#if defined __GETOPT_PREFIX && !defined __need_getopt
# include <stdlib.h>
# include <stdio.h>
# if HAVE_UNISTD_H
# include <unistd.h>
# endif
# include <unistd.h>
# undef __need_getopt
# undef getopt
# undef getopt_long
......
......@@ -182,21 +182,29 @@ typedef struct mbchar mbchar_t;
#define mb_iseq(mbc, sc) ((mbc).wc_valid && (mbc).wc == (sc))
#define mb_isnul(mbc) ((mbc).wc_valid && (mbc).wc == 0)
#define mb_cmp(mbc1, mbc2) \
((mbc1).wc_valid && (mbc2).wc_valid \
? (int) (mbc1).wc - (int) (mbc2).wc \
: (mbc1).bytes == (mbc2).bytes \
? memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) \
: (mbc1).bytes < (mbc2).bytes \
? (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) > 0 ? 1 : -1) \
: (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc2).bytes) >= 0 ? 1 : -1))
((mbc1).wc_valid \
? ((mbc2).wc_valid \
? (int) (mbc1).wc - (int) (mbc2).wc \
: -1) \
: ((mbc2).wc_valid \
? 1 \
: (mbc1).bytes == (mbc2).bytes \
? memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) \
: (mbc1).bytes < (mbc2).bytes \
? (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) > 0 ? 1 : -1) \
: (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc2).bytes) >= 0 ? 1 : -1)))
#define mb_casecmp(mbc1, mbc2) \
((mbc1).wc_valid && (mbc2).wc_valid \
? (int) towlower ((mbc1).wc) - (int) towlower ((mbc2).wc) \
: (mbc1).bytes == (mbc2).bytes \
? memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) \
: (mbc1).bytes < (mbc2).bytes \
? (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) > 0 ? 1 : -1) \
: (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc2).bytes) >= 0 ? 1 : -1))
((mbc1).wc_valid \
? ((mbc2).wc_valid \
? (int) towlower ((mbc1).wc) - (int) towlower ((mbc2).wc) \
: -1) \
: ((mbc2).wc_valid \
? 1 \
: (mbc1).bytes == (mbc2).bytes \
? memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) \
: (mbc1).bytes < (mbc2).bytes \
? (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc1).bytes) > 0 ? 1 : -1) \
: (memcmp ((mbc1).ptr, (mbc2).ptr, (mbc2).bytes) >= 0 ? 1 : -1)))
#define mb_equal(mbc1, mbc2) \
((mbc1).wc_valid && (mbc2).wc_valid \
? (mbc1).wc == (mbc2).wc \
......
/* md5.h - Declaration of functions and data types used for MD5 sum
computing library functions.
Copyright (C) 1995, 1996, 1999, 2000, 2003, 2004 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.
/* Declaration of functions and data types used for MD5 sum computing
library functions.
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
......@@ -25,27 +22,55 @@
#define _MD5_H 1
#include <stdio.h>
#include <stdint.h>
#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))
# else
# define __GNUC_PREREQ(maj, min) 0
# endif
#endif
#if HAVE_INTTYPES_H
# include <inttypes.h>
#ifndef __THROW
# if defined __cplusplus && __GNUC_PREREQ (2,8)
# define __THROW throw ()
# else
# define __THROW
# endif
#endif
#if HAVE_STDINT_H || _LIBC
# include <stdint.h>
#ifndef __attribute__
# if ! __GNUC_PREREQ (2,8) || __STRICT_ANSI__
# define __attribute__(x)
# endif
#endif
typedef uint32_t md5_uint32;
#ifndef _LIBC
# define __md5_buffer md5_buffer
# define __md5_finish_ctx md5_finish_ctx
# define __md5_init_ctx md5_init_ctx
# define __md5_process_block md5_process_block
# define __md5_process_bytes md5_process_bytes
# define __md5_read_ctx md5_read_ctx
# define __md5_stream md5_stream
#endif
/* 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];
uint32_t A;
uint32_t B;
uint32_t C;
uint32_t D;
uint32_t total[2];
uint32_t buflen;
uint32_t buffer[32];
};
/*
......@@ -55,52 +80,51 @@ struct md5_ctx
/* Initialize structure containing state of computation.
(RFC 1321, 3.3: Step 3) */
extern void md5_init_ctx (struct md5_ctx *ctx);
extern void __md5_init_ctx (struct md5_ctx *ctx) __THROW;
/* Starting with the result of former calls of this function (or the
initialization function update the context for the next LEN bytes
starting at BUFFER.
It is necessary that LEN is a multiple of 64!!! */
extern void md5_process_block (const void *buffer, size_t len,
struct md5_ctx *ctx);
extern void __md5_process_block (const void *buffer, size_t len,
struct md5_ctx *ctx) __THROW;
/* Starting with the result of former calls of this function (or the
initialization function update the context for the next LEN bytes
starting at BUFFER.
It is NOT required that LEN is a multiple of 64. */
extern void md5_process_bytes (const void *buffer, size_t len,
struct md5_ctx *ctx);
extern void __md5_process_bytes (const void *buffer, size_t len,
struct md5_ctx *ctx) __THROW;
/* Process the remaining bytes in the buffer and put result from CTX
in first 16 bytes following RESBUF. The result is 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 be correctly
aligned for a 32 bits value. */
extern void *md5_finish_ctx (struct md5_ctx *ctx, void *resbuf);
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;
/* Put result from CTX in first 16 bytes following RESBUF. The result is
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. */
extern void *md5_read_ctx (const struct md5_ctx *ctx, void *resbuf);
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;
/* Compute MD5 message digest for bytes read from STREAM. The
resulting message digest number will be written into the 16 bytes
beginning at RESBLOCK. */
extern int md5_stream (FILE *stream, void *resblock);
extern int __md5_stream (FILE *stream, void *resblock) __THROW;
/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The
result is always in little endian byte order, so that a byte-wise
output yields to the wanted ASCII representation of the message
digest. */
extern void *md5_buffer (const char *buffer, size_t len, void *resblock);
#define rol(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) )
extern void *__md5_buffer (const char *buffer, size_t len,
void *resblock) __THROW;
#endif
#endif /* md5.h */
......
......@@ -21,9 +21,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA. */
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
......
......@@ -18,31 +18,7 @@
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef _AIX
#pragma alloca
#else
# ifndef allocax /* predefined by HP cc +Olibcalls */
# ifdef __GNUC__
# define alloca(size) __builtin_alloca (size)
# else
# if HAVE_ALLOCA_H
# include <alloca.h>
# else
# ifdef __hpux
void *alloca ();
# else
# if !defined __OS2__ && !defined WIN32
char *alloca ();
# else
# include <malloc.h> /* OS/2 defines alloca in here */
# endif
# endif
# endif
# endif
# endif
# include <config.h>
#endif
#ifdef _LIBC
......@@ -70,10 +46,6 @@
# include "../locale/localeinfo.h"
#endif
/* POSIX says that <sys/types.h> must be included (by the caller) before
<regex.h>. */
#include <sys/types.h>
/* On some systems, limits.h sets RE_DUP_MAX to a lower value than
GNU regex allows. Include it before <regex.h>, which correctly
#undefs RE_DUP_MAX and sets it to the right value. */
......
......@@ -25,119 +25,10 @@
#include "strcase.h"
#include <ctype.h>
#include <limits.h>
#if HAVE_MBRTOWC
#include "strnlen1.h"
/* Like mbiter.h, except it doesn't look at the entire string. */
#include "mbchar.h"
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
#include <wchar.h>
#include <wctype.h>
struct mbiter_multi
{
bool at_end; /* true if the end of the string has been reached */
bool in_shift; /* true if next byte may not be interpreted as ASCII */
mbstate_t state; /* if in_shift: current shift state */
bool next_done; /* true if mbi_avail has already filled the following */
struct mbchar cur; /* the current character:
const char *cur.ptr pointer to current character
The following are only valid after mbi_avail.
size_t cur.bytes number of bytes of current character
bool cur.wc_valid true if wc is a valid wide character
wchar_t cur.wc if wc_valid: the current character
*/
};
static inline void
mbiter_multi_next (struct mbiter_multi *iter)
{
if (iter->next_done)
return;
if (iter->in_shift)
goto with_shift;
/* Handle most ASCII characters quickly, without calling mbrtowc(). */
if (is_basic (*iter->cur.ptr))
{
/* These characters are part of the basic character set. ISO C 99
guarantees that their wide character code is identical to their
char code. */
iter->cur.bytes = 1;
iter->cur.wc = *iter->cur.ptr;
iter->cur.wc_valid = true;
}
else
{
assert (mbsinit (&iter->state));
iter->in_shift = true;
with_shift:
iter->cur.bytes = mbrtowc (&iter->cur.wc, iter->cur.ptr,
strnlen1 (iter->cur.ptr, MB_CUR_MAX),
&iter->state);
if (iter->cur.bytes == (size_t) -1)
{
/* An invalid multibyte sequence was encountered. */
iter->cur.bytes = 1;
iter->cur.wc_valid = false;
/* Whether to set iter->in_shift = false and reset iter->state
or not is not very important; the string is bogus anyway. */
}
else if (iter->cur.bytes == (size_t) -2)
{
/* An incomplete multibyte character at the end. */
iter->cur.bytes = strlen (iter->cur.ptr) + 1;
iter->cur.wc_valid = false;
/* Whether to set iter->in_shift = false and reset iter->state
or not is not important; the string end is reached anyway. */
}
else
{
if (iter->cur.bytes == 0)
{
/* A null wide character was encountered. */
iter->cur.bytes = 1;
assert (*iter->cur.ptr == '\0');
assert (iter->cur.wc == 0);
}
iter->cur.wc_valid = true;
/* When in the initial state, we can go back treating ASCII
characters more quickly. */
if (mbsinit (&iter->state))
iter->in_shift = false;
}
}
iter->next_done = true;
}
static inline void
mbiter_multi_reloc (struct mbiter_multi *iter, ptrdiff_t ptrdiff)
{
iter->cur.ptr += ptrdiff;
}
/* Iteration macros. */
typedef struct mbiter_multi mbi_iterator_t;
#define mbi_init(iter, startptr) \
((iter).cur.ptr = (startptr), (iter).at_end = false, \
(iter).in_shift = false, memset (&(iter).state, '\0', sizeof (mbstate_t)), \
(iter).next_done = false)
#define mbi_avail(iter) \
(!(iter).at_end && (mbiter_multi_next (&(iter)), true))
#define mbi_advance(iter) \
((mb_isnul ((iter).cur) ? ((iter).at_end = true) : 0), \
(iter).cur.ptr += (iter).cur.bytes, (iter).next_done = false)
/* Access to the current character. */
#define mbi_cur(iter) (iter).cur
#define mbi_cur_ptr(iter) (iter).cur.ptr
# include "mbuiter.h"
#endif
#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
......@@ -159,59 +50,26 @@ strcasecmp (const char *s1, const char *s2)
#if HAVE_MBRTOWC
if (MB_CUR_MAX > 1)
{
mbi_iterator_t iter1;
mbi_iterator_t iter2;
mbui_iterator_t iter1;
mbui_iterator_t iter2;
mbi_init (iter1, s1);
mbi_init (iter2, s2);
mbui_init (iter1, s1);
mbui_init (iter2, s2);
while (mbi_avail (iter1) && mbi_avail (iter2))
while (mbui_avail (iter1) && mbui_avail (iter2))
{
/* Sort invalid characters after all valid ones. */
if (!mbi_cur (iter1).wc_valid)
{
if (!mbi_cur (iter2).wc_valid)
{
/* Compare two invalid characters. */
int cmp;
if (mbi_cur (iter1).bytes > mbi_cur (iter2).bytes)
return 1;
if (mbi_cur (iter1).bytes < mbi_cur (iter2).bytes)
return -1;
cmp = memcmp (mbi_cur_ptr (iter1), mbi_cur_ptr (iter2),
mbi_cur (iter1).bytes);
if (cmp != 0)
return cmp;
}
else
/* mbi_cur (iter1) invalid, mbi_cur (iter2) valid. */
return 1;
}
else
{
if (!mbi_cur (iter2).wc_valid)
/* mbi_cur (iter1) valid, mbi_cur (iter2) invalid. */
return -1;
else
{
/* Compare two valid characters. */
wchar_t c1 = towlower (mbi_cur (iter1).wc);
wchar_t c2 = towlower (mbi_cur (iter2).wc);
if (c1 > c2)
return 1;
if (c1 < c2)
return -1;
}
}
mbi_advance (iter1);
mbi_advance (iter2);
int cmp = mb_casecmp (mbui_cur (iter1), mbui_cur (iter2));
if (cmp != 0)
return cmp;
mbui_advance (iter1);
mbui_advance (iter2);
}
if (mbi_avail (iter1))
if (mbui_avail (iter1))
/* s2 terminated before s1. */
return 1;
if (mbi_avail (iter2))
if (mbui_avail (iter2))
/* s1 terminated before s2. */
return -1;
return 0;
......@@ -236,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);
}
}
......
/* 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
......@@ -15,7 +15,7 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
......@@ -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);
}
......
......@@ -18,7 +18,7 @@
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifdef HAVE_CONFIG_H
# include "config.h"
# include <config.h>
#endif
#include <stdlib.h>
......
......@@ -16,7 +16,7 @@
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#undef strnlen
......
......@@ -16,7 +16,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA. */
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
......