Blame src/search.h

Packit 709fb3
/* search.c - searching subroutines using dfa, kwset and regex for grep.
Packit 709fb3
   Copyright 1992, 1998, 2000, 2007, 2009-2017 Free Software Foundation, Inc.
Packit 709fb3
Packit 709fb3
   This program is free software; you can redistribute it and/or modify
Packit 709fb3
   it under the terms of the GNU General Public License as published by
Packit 709fb3
   the Free Software Foundation; either version 3, or (at your option)
Packit 709fb3
   any later version.
Packit 709fb3
Packit 709fb3
   This program is distributed in the hope that it will be useful,
Packit 709fb3
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 709fb3
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 709fb3
   GNU General Public License for more details.
Packit 709fb3
Packit 709fb3
   You should have received a copy of the GNU General Public License
Packit 709fb3
   along with this program; if not, write to the Free Software
Packit 709fb3
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
Packit 709fb3
   02110-1301, USA.  */
Packit 709fb3
Packit 709fb3
#ifndef GREP_SEARCH_H
Packit 709fb3
#define GREP_SEARCH_H 1
Packit 709fb3
Packit 709fb3
#include <config.h>
Packit 709fb3
Packit 709fb3
#include <sys/types.h>
Packit 709fb3
#include <stdint.h>
Packit 709fb3
#include <wchar.h>
Packit 709fb3
#include <wctype.h>
Packit 709fb3
#include <regex.h>
Packit 709fb3
Packit 709fb3
#include "system.h"
Packit 709fb3
#include "grep.h"
Packit 709fb3
#include "dfa.h"
Packit 709fb3
#include "kwset.h"
Packit 709fb3
#include "xalloc.h"
Packit 709fb3
#include "localeinfo.h"
Packit 709fb3
Packit 709fb3
_GL_INLINE_HEADER_BEGIN
Packit 709fb3
#ifndef SEARCH_INLINE
Packit 709fb3
# define SEARCH_INLINE _GL_INLINE
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
/* This must be a signed type.  Each value is the difference in the size
Packit 709fb3
   of a character (in bytes) induced by converting to lower case.
Packit 709fb3
   The vast majority of values are 0, but a few are 1 or -1, so
Packit 709fb3
   technically, two bits may be sufficient.  */
Packit 709fb3
typedef signed char mb_len_map_t;
Packit 709fb3
Packit 709fb3
/* searchutils.c */
Packit 709fb3
extern void wordinit (void);
Packit 709fb3
extern kwset_t kwsinit (bool);
Packit 709fb3
extern size_t wordchars_size (char const *, char const *) _GL_ATTRIBUTE_PURE;
Packit 709fb3
extern size_t wordchar_next (char const *, char const *) _GL_ATTRIBUTE_PURE;
Packit 709fb3
extern size_t wordchar_prev (char const *, char const *, char const *)
Packit 709fb3
  _GL_ATTRIBUTE_PURE;
Packit 709fb3
extern ptrdiff_t mb_goback (char const **, char const *, char const *);
Packit 709fb3
Packit 709fb3
/* dfasearch.c */
Packit 709fb3
extern void *GEAcompile (char *, size_t, reg_syntax_t);
Packit 709fb3
extern size_t EGexecute (void *, char const *, size_t, size_t *, char const *);
Packit 709fb3
Packit 709fb3
/* kwsearch.c */
Packit 709fb3
extern void *Fcompile (char *, size_t, reg_syntax_t);
Packit 709fb3
extern size_t Fexecute (void *, char const *, size_t, size_t *, char const *);
Packit 709fb3
Packit 709fb3
/* pcresearch.c */
Packit 709fb3
extern void *Pcompile (char *, size_t, reg_syntax_t);
Packit 709fb3
extern size_t Pexecute (void *, char const *, size_t, size_t *, char const *);
Packit 709fb3
Packit 709fb3
/* grep.c */
Packit 709fb3
extern struct localeinfo localeinfo;
Packit 709fb3
extern void fgrep_to_grep_pattern (char **, size_t *);
Packit 709fb3
Packit 709fb3
/* Return the number of bytes in the character at the start of S, which
Packit 709fb3
   is of size N.  N must be positive.  MBS is the conversion state.
Packit 709fb3
   This acts like mbrlen, except it returns 1 when mbrlen would return 0,
Packit 709fb3
   and it is typically faster because of the cache.  */
Packit 709fb3
SEARCH_INLINE size_t
Packit 709fb3
mb_clen (char const *s, size_t n, mbstate_t *mbs)
Packit 709fb3
{
Packit 709fb3
  size_t len = localeinfo.sbclen[to_uchar (*s)];
Packit 709fb3
  return len == (size_t) -2 ? mbrlen (s, n, mbs) : len;
Packit 709fb3
}
Packit 709fb3
Packit 709fb3
_GL_INLINE_HEADER_END
Packit 709fb3
Packit 709fb3
#endif /* GREP_SEARCH_H */