From 1b26801391ff8981c211d55f462cf6a6294a8ed8 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 10 Aug 2004 05:43:11 +0000 Subject: Sync with gnulib. --- lib/ChangeLog | 11 +++++++++++ lib/Makefile.am | 1 + lib/getpass.c | 4 ++++ lib/getpass.h | 31 +++++++++++++++++++++++++++++++ lib/obstack.c | 11 ++++++++--- lib/obstack.h | 10 ++++++++-- 6 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 lib/getpass.h (limited to 'lib') diff --git a/lib/ChangeLog b/lib/ChangeLog index a4cb4918d..62987b82e 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,5 +1,16 @@ 2004-08-09 Paul Eggert + * 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 + . + * 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. diff --git a/lib/Makefile.am b/lib/Makefile.am index ec6f4645b..386194c65 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -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 \ diff --git a/lib/getpass.c b/lib/getpass.c index 8a993d3e0..9ac01f227 100644 --- a/lib/getpass.c +++ b/lib/getpass.c @@ -19,6 +19,10 @@ # include #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 index 000000000..dec2a36e3 --- /dev/null +++ b/lib/getpass.h @@ -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 , 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 + +# 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 */ diff --git a/lib/obstack.c b/lib/obstack.c index 52946d26d..8ce49ad8c 100644 --- a/lib/obstack.c +++ b/lib/obstack.c @@ -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); diff --git a/lib/obstack.h b/lib/obstack.h index d46b0544a..46a1cb781 100644 --- a/lib/obstack.h +++ b/lib/obstack.h @@ -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 -- cgit v1.2.3-54-g00ecf