1997-02-10 04:19:57 +01:00
|
|
|
/* Determine whether string value is affirmation or negative response
|
|
|
|
according to current locale's data.
|
|
|
|
This file is part of the GNU C Library.
|
2003-06-12 01:22:36 +02:00
|
|
|
Copyright (C) 1996, 1997, 2000, 2003 Free Software Foundation, Inc.
|
1996-03-25 18:48:26 +01:00
|
|
|
|
1997-02-10 04:19:57 +01:00
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
2001-07-06 06:58:11 +02:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
1996-03-25 18:48:26 +01:00
|
|
|
|
1997-02-10 04:19:57 +01:00
|
|
|
The GNU C Library 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
|
2001-07-06 06:58:11 +02:00
|
|
|
Lesser General Public License for more details.
|
1996-03-25 18:48:26 +01:00
|
|
|
|
2001-07-06 06:58:11 +02:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-02-10 00:18:22 +01:00
|
|
|
License along with the GNU C Library; if not, see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
1996-03-25 18:48:26 +01:00
|
|
|
|
|
|
|
#include <langinfo.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <regex.h>
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
rpmatch (response)
|
|
|
|
const char *response;
|
|
|
|
{
|
|
|
|
/* Match against one of the response patterns, compiling the pattern
|
|
|
|
first if necessary. */
|
2003-06-12 01:22:36 +02:00
|
|
|
auto int try (const int tag, const int match, const int nomatch,
|
|
|
|
const char **lastp, regex_t *re);
|
2000-12-27 21:18:52 +01:00
|
|
|
|
2003-06-12 01:22:36 +02:00
|
|
|
int try (const int tag, const int match, const int nomatch,
|
|
|
|
const char **lastp, regex_t *re)
|
1996-03-25 18:48:26 +01:00
|
|
|
{
|
|
|
|
const char *pattern = nl_langinfo (tag);
|
|
|
|
if (pattern != *lastp)
|
|
|
|
{
|
|
|
|
/* The pattern has changed. */
|
|
|
|
if (*lastp)
|
|
|
|
{
|
|
|
|
/* Free the old compiled pattern. */
|
2000-08-21 06:18:25 +02:00
|
|
|
__regfree (re);
|
1996-03-25 18:48:26 +01:00
|
|
|
*lastp = NULL;
|
|
|
|
}
|
|
|
|
/* Compile the pattern and cache it for future runs. */
|
2000-08-21 06:18:25 +02:00
|
|
|
if (__regcomp (re, pattern, REG_EXTENDED) != 0)
|
1996-03-25 18:48:26 +01:00
|
|
|
return -1;
|
|
|
|
*lastp = pattern;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Try the pattern. */
|
2000-08-21 06:18:25 +02:00
|
|
|
return __regexec (re, response, 0, NULL, 0) == 0 ? match : nomatch;
|
1996-03-25 18:48:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* We cache the response patterns and compiled regexps here. */
|
|
|
|
static const char *yesexpr, *noexpr;
|
|
|
|
static regex_t yesre, nore;
|
|
|
|
|
Fri Apr 19 00:49:44 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* stdlib/rpmatch.c (rpmatch: try): Take new arg NOMATCH, return value
for nonmatching nonerror (instead of !MATCH).
(rpmatch): Use it, so we return -1 when NOEXPR doesn't match either.
* resolv/getnetnamadr.c (getnetbyaddr): Use u_int32_t instead of
unsigned long for variable NET2.
* time/etcetera, time/europe, time/solar89: Updated from ADO's 96e.
Tue Apr 9 14:37:31 1996 Ulrich Drepper <drepper@cygnus.com>
* catgets/Makefile, catgets/catgets.c, catgets/catgetsinfo.h,
catgets/config.h, catgets/gencat.c, catgets/nl_types.h,
catgets/open_catalog.c: New files. Implementation of XPG4
compliant catgets() function and needed tools.
* Makefile (subdirs): Add catgets.
Thu Apr 18 23:36:11 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* math/Makefile (CPPFLAGS): Append -D__NO_MATH_INLINES.
Wed Apr 10 20:48:43 1996 Ulrich Drepper <drepper@cygnus.com>
* stdio-common/vfprintf.c: Correct some typos.
* sysdeps/libm-ieee754/w_gammaf.c, sysdeps/libm-ieee754/w_lgamma.c,
sysdeps/libm-ieee754/w_lgammaf.c: Reference signgam instead of
__signgam.
Thu Apr 18 21:07:27 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* Makerules (no-whole-archive): New variable.
(build-shlib): Use it.
* elf/Makefile (libdl.so): Use it.
* configure.in (libc_cv_ld_no_whole_archive): New check for
--no-whole-archive.
* config.make.in (have-no-whole-archive): New variable.
* stdio-common/printf_fp.c: Increase fudge factor for BIGNUM_SIZE calc
from 3 to 4.
* Make-dist: Include version.mk.
(version, release): Variables removed.
* Makeconfig (version.mk): New target.
Fri Apr 19 01:42:18 1996 Ulrich Drepper <drepper@cygnus.com>
* locale/Makefile (headers): Add langinfo.h.
(CPPFLAGS): Remove -Iliblib.
1996-04-20 02:05:25 +02:00
|
|
|
return (try (YESEXPR, 1, 0, &yesexpr, &yesre) ?:
|
|
|
|
try (NOEXPR, 0, -1, &noexpr, &nore));
|
1996-03-25 18:48:26 +01:00
|
|
|
}
|