From 53b74c0c4c6d1b6e76d0816613dab5258ff9430d Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 3 Aug 2001 08:09:03 +0000 Subject: [PATCH] * lib/strspn.c: New. --- ChangeLog | 4 ++++ THANKS | 1 + aclocal.m4 | 63 +++++++++++++++++++++++++++++++++---------------- config.hin | 12 ++++++++++ configure.in | 4 ++-- lib/Makefile.in | 12 ++++++---- lib/strspn.c | 59 +++++++++++++++++++++++++++++++++++++++++++++ src/Makefile.in | 4 +++- 8 files changed, 131 insertions(+), 28 deletions(-) create mode 100644 lib/strspn.c diff --git a/ChangeLog b/ChangeLog index 799ddbe5..610b3ee1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2001-08-03 Akim Demaille + + * lib/strspn.c: New. + 2001-08-01 Marc Autret * doc/bison.texinfo: Update. diff --git a/THANKS b/THANKS index 5bef583f..82eb848b 100644 --- a/THANKS +++ b/THANKS @@ -7,6 +7,7 @@ Hans Aberg haberg@matematik.su.se Jesse Thilo jthilo@gnu.org Jim Meyering meyering@gnu.org Laurent Mascherpa laurent.mascherpa@epita.fr +Marc Autret autret_m@epita.fr Neil Booth NeilB@earthling.net Noah Friedman friedman@gnu.org Paul Eggert eggert@twinsun.com diff --git a/aclocal.m4 b/aclocal.m4 index 9e517238..7dc4b2bf 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -527,11 +527,13 @@ fi # Ulrich Drepper , 1995. # # This file can be copied and used freely without restrictions. It can -# be used in projects which are not available under the GNU Public License -# but which still want to provide support for the GNU gettext functionality. -# Please note that the actual code is *not* freely available. +# be used in projects which are not available under the GNU General Public +# License but which still want to provide support for the GNU gettext +# functionality. +# Please note that the actual code of GNU gettext is covered by the GNU +# General Public License and is *not* in the public domain. -# serial 9 +# serial 10 dnl Usage: AM_WITH_NLS([TOOLSYMBOL], [NEEDSYMBOL], [LIBDIR]). dnl If TOOLSYMBOL is specified and is 'use-libtool', then a libtool library @@ -642,14 +644,14 @@ return (int) gettext ("")]ifelse([$2], need-ngettext, [ + (int) ngettext ("", "" AC_CHECK_FUNCS(dcgettext) LIBS="$gt_save_LIBS" + dnl Search for GNU msgfmt in the PATH. AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, - [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl - if test "$MSGFMT" != "no"; then - AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT) - fi + [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1], :) + AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT) + dnl Search for GNU xgettext in the PATH. AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, - [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :) + [$ac_dir/$ac_word --omit-header /dev/null >/dev/null 2>&1], :) CATOBJEXT=.gmo fi @@ -666,10 +668,10 @@ return (int) gettext ("")]ifelse([$2], need-ngettext, [ + (int) ngettext ("", "" dnl Mark actions used to generate GNU NLS library. INTLOBJS="\$(GETTOBJS)" AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, - [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt) + [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1], :) AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT) AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, - [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :) + [$ac_dir/$ac_word --omit-header /dev/null >/dev/null 2>&1], :) AC_SUBST(MSGFMT) BUILD_INCLUDED_LIBINTL=yes USE_INCLUDED_LIBINTL=yes @@ -678,11 +680,26 @@ return (int) gettext ("")]ifelse([$2], need-ngettext, [ + (int) ngettext ("", "" LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'` fi + dnl This could go away some day; the PATH_PROG_WITH_TEST already does it. + dnl Test whether we really found GNU msgfmt. + if test "$GMSGFMT" != ":"; then + dnl If it is no GNU msgfmt we define it as : so that the + dnl Makefiles still can work. + if $GMSGFMT --statistics /dev/null >/dev/null 2>&1; then + : ; + else + AC_MSG_RESULT( + [found msgfmt program is not GNU msgfmt; ignore it]) + GMSGFMT=":" + fi + fi + + dnl This could go away some day; the PATH_PROG_WITH_TEST already does it. dnl Test whether we really found GNU xgettext. if test "$XGETTEXT" != ":"; then dnl If it is no GNU xgettext we define it as : so that the dnl Makefiles still can work. - if $XGETTEXT --omit-header /dev/null 2> /dev/null; then + if $XGETTEXT --omit-header /dev/null >/dev/null 2>&1; then : ; else AC_MSG_RESULT( @@ -706,6 +723,8 @@ return (int) gettext ("")]ifelse([$2], need-ngettext, [ + (int) ngettext ("", "" ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`" ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` + # In autoconf-2.13 it is called $ac_given_srcdir. + # In autoconf-2.50 it is called $srcdir. test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" case "$ac_given_srcdir" in .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; @@ -877,11 +896,13 @@ strdup strtoul tsearch __argz_count __argz_stringify __argz_next]) # Ulrich Drepper , 1996. # # This file can be copied and used freely without restrictions. It can -# be used in projects which are not available under the GNU Public License -# but which still want to provide support for the GNU gettext functionality. -# Please note that the actual code is *not* freely available. +# be used in projects which are not available under the GNU General Public +# License but which still want to provide support for the GNU gettext +# functionality. +# Please note that the actual code of GNU gettext is covered by the GNU +# General Public License and is *not* in the public domain. -# serial 1 +# serial 2 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR, dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]]) @@ -913,7 +934,7 @@ ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" ;; esac])dnl $1="$ac_cv_path_$1" -if test -n "[$]$1"; then +if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then AC_MSG_RESULT([$]$1) else AC_MSG_RESULT(no) @@ -1040,9 +1061,11 @@ AC_DEFUN([AM_LANGINFO_CODESET], # Ulrich Drepper , 1995. # # This file can be copied and used freely without restrictions. It can -# be used in projects which are not available under the GNU Public License -# but which still want to provide support for the GNU gettext functionality. -# Please note that the actual code is *not* freely available. +# be used in projects which are not available under the GNU General Public +# License but which still want to provide support for the GNU gettext +# functionality. +# Please note that the actual code of GNU gettext is covered by the GNU +# General Public License and is *not* in the public domain. # serial 2 diff --git a/config.hin b/config.hin index 3a2dda6c..36dba9f1 100644 --- a/config.hin +++ b/config.hin @@ -149,6 +149,9 @@ /* Define if you have the header file. */ #undef HAVE_STDDEF_H +/* Define if you have the header file. */ +#undef HAVE_STDINT_H + /* Define if you have the header file. */ #undef HAVE_STDLIB_H @@ -182,12 +185,21 @@ /* Define if you have the `strnlen' function. */ #undef HAVE_STRNLEN +/* Define if you have the `strspn' function. */ +#undef HAVE_STRSPN + /* Define if you have the `strtoul' function. */ #undef HAVE_STRTOUL /* Define if you have the header file. */ #undef HAVE_SYS_PARAM_H +/* Define if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_TYPES_H + /* Define if you have the `tsearch' function. */ #undef HAVE_TSEARCH diff --git a/configure.in b/configure.in index cc2ebc6a..24731a41 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ # Process this file with autoconf to produce a configure script. -AC_PREREQ(2.50) +AC_PREREQ(2.52) AC_INIT(bison, 1.28a, bug-bison@gnu.org) AC_CONFIG_AUX_DIR(config) AM_INIT_AUTOMAKE(bison, 1.28a) @@ -63,7 +63,7 @@ AM_C_PROTOTYPES AC_FUNC_ALLOCA AC_CHECK_FUNCS(mkstemp setlocale) AC_CHECK_DECLS([stpcpy, strndup, strnlen, memchr]) -AC_REPLACE_FUNCS(stpcpy strndup strnlen memchr) +AC_REPLACE_FUNCS(stpcpy strndup strnlen strspn memchr) jm_FUNC_MALLOC jm_FUNC_REALLOC jm_PREREQ_QUOTEARG diff --git a/lib/Makefile.in b/lib/Makefile.in index 41418dad..44d90518 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -129,7 +129,7 @@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CF CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ DIST_COMMON = Makefile.am Makefile.in alloca.c ansi2knr.1 ansi2knr.c \ -memchr.c stpcpy.c strndup.c strnlen.c +memchr.c stpcpy.c strndup.c strnlen.c strspn.c DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) @@ -138,8 +138,8 @@ TAR = tar GZIP_ENV = --best DEP_FILES = .deps/alloca.P .deps/error.P .deps/getopt.P .deps/getopt1.P \ .deps/memchr.P .deps/obstack.P .deps/quote.P .deps/quotearg.P \ -.deps/stpcpy.P .deps/strndup.P .deps/strnlen.P .deps/xmalloc.P \ -.deps/xstrdup.P +.deps/stpcpy.P .deps/strndup.P .deps/strnlen.P .deps/strspn.P \ +.deps/xmalloc.P .deps/xstrdup.P SOURCES = $(libbison_a_SOURCES) OBJECTS = $(libbison_a_OBJECTS) @@ -227,13 +227,15 @@ strndup_.c: strndup.c $(ANSI2KNR) $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strndup.c; then echo $(srcdir)/strndup.c; else echo strndup.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strndup_.c strnlen_.c: strnlen.c $(ANSI2KNR) $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strnlen.c; then echo $(srcdir)/strnlen.c; else echo strnlen.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strnlen_.c +strspn_.c: strspn.c $(ANSI2KNR) + $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strspn.c; then echo $(srcdir)/strspn.c; else echo strspn.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strspn_.c xmalloc_.c: xmalloc.c $(ANSI2KNR) $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/xmalloc.c; then echo $(srcdir)/xmalloc.c; else echo xmalloc.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > xmalloc_.c xstrdup_.c: xstrdup.c $(ANSI2KNR) $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/xstrdup.c; then echo $(srcdir)/xstrdup.c; else echo xstrdup.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > xstrdup_.c alloca_.o error_.o getopt_.o getopt1_.o memchr_.o obstack_.o quote_.o \ -quotearg_.o stpcpy_.o strndup_.o strnlen_.o xmalloc_.o xstrdup_.o : \ -$(ANSI2KNR) +quotearg_.o stpcpy_.o strndup_.o strnlen_.o strspn_.o xmalloc_.o \ +xstrdup_.o : $(ANSI2KNR) tags: TAGS diff --git a/lib/strspn.c b/lib/strspn.c new file mode 100644 index 00000000..399d5402 --- /dev/null +++ b/lib/strspn.c @@ -0,0 +1,59 @@ +/* Copyright (C) 1991, 1997 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. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License + as published by the Free Software Foundation; either version 2 of + the License, 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - + Suite 330, Boston, MA 02111-1307, USA. */ + +#if HAVE_CONFIG_H +# include +#endif + +#if defined _LIBC || HAVE_STRING_H +# include +#else +# include +# ifndef strchr +# define strchr index +# endif +#endif + +#undef strspn + +/* Return the length of the maximum initial segment + of S which contains only characters in ACCEPT. */ +size_t +strspn (s, accept) + const char *s; + const char *accept; +{ + const char *p; + const char *a; + size_t count = 0; + + for (p = s; *p != '\0'; ++p) + { + for (a = accept; *a != '\0'; ++a) + if (*p == *a) + break; + if (*a == '\0') + return count; + else + ++count; + } + + return count; +} diff --git a/src/Makefile.in b/src/Makefile.in index d412aac5..d2aca762 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -265,6 +265,8 @@ strndup_.c: strndup.c $(ANSI2KNR) $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strndup.c; then echo $(srcdir)/strndup.c; else echo strndup.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strndup_.c strnlen_.c: strnlen.c $(ANSI2KNR) $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strnlen.c; then echo $(srcdir)/strnlen.c; else echo strnlen.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strnlen_.c +strspn_.c: strspn.c $(ANSI2KNR) + $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strspn.c; then echo $(srcdir)/strspn.c; else echo strspn.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strspn_.c symtab_.c: symtab.c $(ANSI2KNR) $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/symtab.c; then echo $(srcdir)/symtab.c; else echo symtab.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > symtab_.c vmsgetargs_.c: vmsgetargs.c $(ANSI2KNR) @@ -274,7 +276,7 @@ warshall_.c: warshall.c $(ANSI2KNR) LR0_.o alloca_.o closure_.o complain_.o conflicts_.o derives_.o \ files_.o getargs_.o gram_.o lalr_.o lex_.o main_.o memchr_.o \ nullable_.o output_.o print_.o reader_.o reduce_.o stpcpy_.o strndup_.o \ -strnlen_.o symtab_.o vmsgetargs_.o warshall_.o : $(ANSI2KNR) +strnlen_.o strspn_.o symtab_.o vmsgetargs_.o warshall_.o : $(ANSI2KNR) install-pkgdataDATA: $(pkgdata_DATA) @$(NORMAL_INSTALL) -- 2.47.2