Sync with gnulib.
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 10 Aug 2004 05:43:11 +0000 (05:43 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 10 Aug 2004 05:43:11 +0000 (05:43 +0000)
lib/ChangeLog
lib/Makefile.am
lib/getpass.c
lib/getpass.h [new file with mode: 0644]
lib/obstack.c
lib/obstack.h
m4/ChangeLog
m4/fnmatch.m4
m4/getpass.m4

index a4cb491..62987b8 100644 (file)
@@ -1,5 +1,16 @@
 2004-08-09  Paul Eggert  <eggert@cs.ucla.edu>
 
+       * Makefile.am (libfetish_a_SOURCES): Add getpass.h.
+       * getpass.h: New file.
+       * .cpp-disable: Add it.
+       * getpass.c [!_LIBC]: Include it.
+
+       * obstack.h (obstack_empty_p):
+       Don't assume that chunk->contents is suitably aligned.
+       * obstack.c (_obstack_begin, _obstack_begin_1, _obstack_newchunk):
+       Likewise. Problem reported by Benno in
+       <http://sources.redhat.com/ml/libc-alpha/2004-08/msg00055.html>.
+
        * chown.c (rpl_chown): Work even if the file is writeable but not
        readable.  This could be improved further but it'd take some work.
        * fts.c (diropen): New function.
index ec6f464..386194c 100644 (file)
@@ -66,6 +66,7 @@ libfetish_a_SOURCES = \
   full-write.c full-write.h \
   getline.h \
   getpagesize.h \
+  getpass.h \
   gettime.c \
   gettext.h \
   getugroups.c \
index 8a993d3..9ac01f2 100644 (file)
 # include <config.h>
 #endif
 
+#if !_LIBC
+# include "getpass.h"
+#endif
+
 #if _LIBC
 # define HAVE_STDIO_EXT_H 1
 #endif
diff --git a/lib/getpass.h b/lib/getpass.h
new file mode 100644 (file)
index 0000000..dec2a36
--- /dev/null
@@ -0,0 +1,31 @@
+/* getpass.h -- Read a password of arbitrary length from /dev/tty or stdin.
+   Copyright (C) 2004 Free Software Foundation, Inc.
+   Contributed by Simon Josefsson <jas@extundo.com>, 2004.
+
+   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 Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#ifndef GETPASS_H
+# define GETPASS_H
+
+/* Get getpass declaration, if available.  */
+# include <unistd.h>
+
+# if defined HAVE_DECL_GETPASS && !HAVE_DECL_GETPASS
+/* Read a password of arbitrary length from /dev/tty or stdin.  */
+char *getpass (const char *prompt);
+
+# endif
+
+#endif /* GETPASS_H */
index 52946d2..8ce49ad 100644 (file)
@@ -173,7 +173,8 @@ _obstack_begin (struct obstack *h,
   chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size);
   if (!chunk)
     (*obstack_alloc_failed_handler) ();
-  h->next_free = h->object_base = chunk->contents;
+  h->next_free = h->object_base = __PTR_ALIGN ((char *) chunk, chunk->contents,
+                                              alignment - 1);
   h->chunk_limit = chunk->limit
     = (char *) chunk + h->chunk_size;
   chunk->prev = 0;
@@ -220,7 +221,8 @@ _obstack_begin_1 (struct obstack *h, int size, int alignment,
   chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size);
   if (!chunk)
     (*obstack_alloc_failed_handler) ();
-  h->next_free = h->object_base = chunk->contents;
+  h->next_free = h->object_base = __PTR_ALIGN ((char *) chunk, chunk->contents,
+                                              alignment - 1);
   h->chunk_limit = chunk->limit
     = (char *) chunk + h->chunk_size;
   chunk->prev = 0;
@@ -287,7 +289,10 @@ _obstack_newchunk (struct obstack *h, int length)
   /* If the object just copied was the only data in OLD_CHUNK,
      free that chunk and remove it from the chain.
      But not if that chunk might contain an empty object.  */
-  if (h->object_base == old_chunk->contents && ! h->maybe_empty_object)
+  if (! h->maybe_empty_object
+      && (h->object_base
+         == __PTR_ALIGN ((char *) old_chunk, old_chunk->contents,
+                         h->alignment_mask)))
     {
       new_chunk->prev = old_chunk->prev;
       CALL_FREEFUN (h, old_chunk);
index d46b054..46a1cb7 100644 (file)
@@ -287,7 +287,10 @@ __extension__                                                              \
 # define obstack_empty_p(OBSTACK)                                      \
   __extension__                                                                \
   ({ struct obstack const *__o = (OBSTACK);                            \
-     (__o->chunk->prev == 0 && __o->next_free - __o->chunk->contents == 0); })
+     (__o->chunk->prev == 0                                            \
+      && __o->next_free == __PTR_ALIGN ((char *) __o->chunk,           \
+                                       __o->chunk->contents,           \
+                                       __o->alignment_mask)); })
 
 # define obstack_grow(OBSTACK,where,length)                            \
 __extension__                                                          \
@@ -411,7 +414,10 @@ __extension__                                                              \
  (unsigned) ((h)->chunk_limit - (h)->next_free)
 
 # define obstack_empty_p(h) \
- ((h)->chunk->prev == 0 && (h)->next_free - (h)->chunk->contents == 0)
+ ((h)->chunk->prev == 0                                                        \
+  && (h)->next_free == __PTR_ALIGN ((char *) (h)->chunk,               \
+                                   (h)->chunk->contents,               \
+                                   (h)->alignment_mask))
 
 /* Note that the call to _obstack_newchunk is enclosed in (..., 0)
    so that we can avoid having void expressions
index 2bf789c..b367e1e 100644 (file)
@@ -3,6 +3,11 @@
        * sha1.m4: Renamed from sha.m4.
        (gl_SHA1): Renamed from gl_SHA.  All uses changed.
 
+2004-08-08  Simon Josefsson  <jas@extundo.com>
+
+       * getpass.m4 (gl_FUNC_GETPASS, gl_FUNC_GETPASS_GNU):
+       Check getpass declaration.
+
 2004-08-07  Paul Eggert  <eggert@cs.ucla.edu>
 
        * canonicalize.m4, getcwd-path-max.m4, strdup.m4: Merge from gnulib.
index ab7765b..f96ecc1 100644 (file)
@@ -28,10 +28,10 @@ AC_DEFUN([_AC_FUNC_FNMATCH_IF],
 [AC_CACHE_CHECK(
    [for working $1 fnmatch],
    [$2],
-  [# Some versions of Solaris, SCO, and the GNU C Library
-   # have a broken or incompatible fnmatch.
-   # So we run a test program.  If we are cross-compiling, take no chance.
-   # Thanks to John Oleynick, François Pinard, and Paul Eggert for this test.
+  [dnl Some versions of Solaris, SCO, and the GNU C Library
+   dnl have a broken or incompatible fnmatch.
+   dnl So we run a test program.  If we are cross-compiling, take no chance.
+   dnl Thanks to John Oleynick, François Pinard, and Paul Eggert for this test.
    AC_RUN_IFELSE(
       [AC_LANG_PROGRAM(
         [
index 4449bc5..0c4d805 100644 (file)
@@ -1,4 +1,4 @@
-# getpass.m4 serial 3
+# getpass.m4 serial 4
 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
@@ -10,6 +10,7 @@ dnl the same distribution terms as the rest of that program.
 AC_DEFUN([gl_FUNC_GETPASS],
 [
   AC_REPLACE_FUNCS(getpass)
+  AC_CHECK_DECLS_ONCE(getpass)
   if test $ac_cv_func_getpass = no; then
     gl_PREREQ_GETPASS
   fi
@@ -19,6 +20,7 @@ AC_DEFUN([gl_FUNC_GETPASS],
 # arbitrary length (not just 8 bytes as on HP-UX).
 AC_DEFUN([gl_FUNC_GETPASS_GNU],
 [
+  AC_CHECK_DECLS_ONCE(getpass)
   dnl TODO: Detect when GNU getpass() is already found in glibc.
   AC_LIBOBJ(getpass)
   gl_PREREQ_GETPASS