Blame misc/regexp.c

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