+2021-08-24 Paul Eggert <eggert@cs.ucla.edu>
+
+ dfa: prefer idx_t to ptrdiff_t for nonnegative
+ * lib/dfa.c (struct dfa, dfaexec_main, dfaexec_mb, dfaexec_sb)
+ (dfaexec_noop, dfaexec):
+ * lib/dfa.h (dfaparse, dfacomp, dfaexec):
+ Prefer idx_t to ptrdiff_t for counts, which should be nonnegative.
+ * lib/dfa.h: Include idx.h.
+
2021-08-22 Bruno Haible <bruno@clisp.org>
snippet/unused-parameter: Mark unused module obsolete.
/* dfaexec implementation. */
char *(*dfaexec) (struct dfa *, char const *, char *,
- bool, ptrdiff_t *, bool *);
+ bool, idx_t *, bool *);
/* Other cached information derived from the locale. */
struct localeinfo localeinfo;
static inline char *
dfaexec_main (struct dfa *d, char const *begin, char *end, bool allow_nl,
- ptrdiff_t *count, bool multibyte)
+ idx_t *count, bool multibyte)
{
if (MAX_TRCOUNT <= d->sindex)
{
static char *
dfaexec_mb (struct dfa *d, char const *begin, char *end,
- bool allow_nl, ptrdiff_t *count, bool *backref)
+ bool allow_nl, idx_t *count, bool *backref)
{
return dfaexec_main (d, begin, end, allow_nl, count, true);
}
static char *
dfaexec_sb (struct dfa *d, char const *begin, char *end,
- bool allow_nl, ptrdiff_t *count, bool *backref)
+ bool allow_nl, idx_t *count, bool *backref)
{
return dfaexec_main (d, begin, end, allow_nl, count, false);
}
any regexp that uses a construct not supported by this code. */
static char *
dfaexec_noop (struct dfa *d, char const *begin, char *end,
- bool allow_nl, ptrdiff_t *count, bool *backref)
+ bool allow_nl, idx_t *count, bool *backref)
{
*backref = true;
return (char *) begin;
char *
dfaexec (struct dfa *d, char const *begin, char *end,
- bool allow_nl, ptrdiff_t *count, bool *backref)
+ bool allow_nl, idx_t *count, bool *backref)
{
return d->dfaexec (d, begin, end, allow_nl, count, backref);
}
#ifndef DFA_H_
#define DFA_H_
+#include "idx.h"
#include <regex.h>
#include <stdbool.h>
#include <stddef.h>
extern void dfacopysyntax (struct dfa *, struct dfa const *);
/* Parse the given string of given length into the given struct dfa. */
-extern void dfaparse (char const *, ptrdiff_t, struct dfa *);
+extern void dfaparse (char const *, idx_t, struct dfa *);
struct dfamust;
The last argument says whether to build a searching or an exact matcher.
A null first argument means the struct dfa has already been
initialized by dfaparse; the second argument is ignored. */
-extern void dfacomp (char const *, ptrdiff_t, struct dfa *, bool);
+extern void dfacomp (char const *, idx_t, struct dfa *, bool);
/* Search through a buffer looking for a match to the given struct dfa.
Find the first occurrence of a string matching the regexp in the
encountered a back-reference. The caller can use this to decide
whether to fall back on a backtracking matcher. */
extern char *dfaexec (struct dfa *d, char const *begin, char *end,
- bool allow_nl, ptrdiff_t *count, bool *backref);
+ bool allow_nl, idx_t *count, bool *backref);
/* Return a superset for D. The superset matches everything that D
matches, along with some other strings (though the latter should be