Blame misc/regexp.c

Packit Service 82fcde
/* Compatibility symbols for the obsolete <regexp.h> interface.
Packit Service 82fcde
   Copyright (C) 1996-2018 Free Software Foundation, Inc.
Packit Service 82fcde
   This file is part of the GNU C Library.
Packit Service 82fcde
   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is free software; you can redistribute it and/or
Packit Service 82fcde
   modify it under the terms of the GNU Lesser General Public
Packit Service 82fcde
   License as published by the Free Software Foundation; either
Packit Service 82fcde
   version 2.1 of the License, or (at your option) any later version.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service 82fcde
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 82fcde
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 82fcde
   Lesser General Public License for more details.
Packit Service 82fcde
Packit Service 82fcde
   You should have received a copy of the GNU Lesser General Public
Packit Service 82fcde
   License along with the GNU C Library; if not, see
Packit Service 82fcde
   <http://www.gnu.org/licenses/>.  */
Packit Service 82fcde
Packit Service 82fcde
/* regexp.h now contains only an #error directive, so it cannot be
Packit Service 82fcde
   used in this file.
Packit Service 82fcde
Packit Service 82fcde
   The function that would produce an 'expbuf' to use as the second
Packit Service 82fcde
   argument to 'step' and 'advance' was defined only in regexp.h,
Packit Service 82fcde
   as its definition depended on macros defined by the user.  */
Packit Service 82fcde
Packit Service 82fcde
#include <regex.h>
Packit Service 82fcde
#include <shlib-compat.h>
Packit Service 82fcde
Packit Service 82fcde
#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)
Packit Service 82fcde
Packit Service 82fcde
/* Define the variables used for the interface.  Avoid .symver on common
Packit Service 82fcde
   symbol, which just creates a new common symbol, not an alias.  */
Packit Service 82fcde
char *loc1 __attribute__ ((nocommon));
Packit Service 82fcde
char *loc2 __attribute__ ((nocommon));
Packit Service 82fcde
compat_symbol (libc, loc1, loc1, GLIBC_2_0);
Packit Service 82fcde
compat_symbol (libc, loc2, loc2, GLIBC_2_0);
Packit Service 82fcde
Packit Service 82fcde
/* Although we do not support the use we define this variable as well.  */
Packit Service 82fcde
char *locs __attribute__ ((nocommon));
Packit Service 82fcde
compat_symbol (libc, locs, locs, GLIBC_2_0);
Packit Service 82fcde
Packit Service 82fcde
Packit Service 82fcde
/* Find the next match in STRING.  The compiled regular expression is
Packit Service 82fcde
   found in the buffer starting at EXPBUF.  `loc1' will return the
Packit Service 82fcde
   first character matched and `loc2' points to the next unmatched
Packit Service 82fcde
   character.  */
Packit Service 82fcde
int
Packit Service 82fcde
weak_function attribute_compat_text_section
Packit Service 82fcde
step (const char *string, const char *expbuf)
Packit Service 82fcde
{
Packit Service 82fcde
  regmatch_t match;	/* We only need info about the full match.  */
Packit Service 82fcde
Packit Service 82fcde
  expbuf += __alignof (regex_t *);
Packit Service 82fcde
  expbuf -= (expbuf - ((const char *) 0)) % __alignof__ (regex_t *);
Packit Service 82fcde
Packit Service 82fcde
  if (__regexec ((const regex_t *) expbuf, string, 1, &match, REG_NOTEOL)
Packit Service 82fcde
      == REG_NOMATCH)
Packit Service 82fcde
    return 0;
Packit Service 82fcde
Packit Service 82fcde
  loc1 = (char *) string + match.rm_so;
Packit Service 82fcde
  loc2 = (char *) string + match.rm_eo;
Packit Service 82fcde
  return 1;
Packit Service 82fcde
}
Packit Service 82fcde
compat_symbol (libc, step, step, GLIBC_2_0);
Packit Service 82fcde
Packit Service 82fcde
Packit Service 82fcde
/* Match the beginning of STRING with the compiled regular expression
Packit Service 82fcde
   in EXPBUF.  If the match is successful `loc2' will contain the
Packit Service 82fcde
   position of the first unmatched character.  */
Packit Service 82fcde
int
Packit Service 82fcde
weak_function attribute_compat_text_section
Packit Service 82fcde
advance (const char *string, const char *expbuf)
Packit Service 82fcde
{
Packit Service 82fcde
  regmatch_t match;	/* We only need info about the full match.  */
Packit Service 82fcde
Packit Service 82fcde
  expbuf += __alignof__ (regex_t *);
Packit Service 82fcde
  expbuf -= (expbuf - ((const char *) 0)) % __alignof__ (regex_t *);
Packit Service 82fcde
Packit Service 82fcde
  if (__regexec ((const regex_t *) expbuf, string, 1, &match, REG_NOTEOL)
Packit Service 82fcde
      == REG_NOMATCH
Packit Service 82fcde
      /* We have to check whether the check is at the beginning of the
Packit Service 82fcde
	 buffer.  */
Packit Service 82fcde
      || match.rm_so != 0)
Packit Service 82fcde
    return 0;
Packit Service 82fcde
Packit Service 82fcde
  loc2 = (char *) string + match.rm_eo;
Packit Service 82fcde
  return 1;
Packit Service 82fcde
}
Packit Service 82fcde
compat_symbol (libc, advance, advance, GLIBC_2_0);
Packit Service 82fcde
Packit Service 82fcde
Packit Service 82fcde
#endif /* SHLIB_COMPAT (2.0, 2.23) */