+2025-06-26 Bruno Haible <bruno@clisp.org>
+
+ kwset: Add specification comments in .h file.
+ * lib/kwset.h (kwsalloc, kwsincr, kwsprep, kwsexec, kwsfree): Move
+ specification to here...
+ * lib/kwset.c (kwsalloc, kwsincr, kwsprep, kwsexec, kwsfree): ...from
+ here.
+
2025-06-26 Paul Eggert <eggert@cs.ucla.edu>
regex: fix parse_bracket_exp double-free
static ptrdiff_t bmexec (kwset_t, char const *, idx_t,
struct kwsmatch *, bool);
-/* Return a newly allocated keyword set. A nonnull TRANS specifies a
- table of character translations to be applied to all pattern and
- search text. */
kwset_t
kwsalloc (char const *trans)
{
exact for CHAR_BIT in { 4..11, 13, 15, 17, 19 }. */
enum { DEPTH_SIZE = CHAR_BIT + CHAR_BIT / 2 };
-/* Add the given string to the contents of the keyword set. */
void
kwsincr (kwset_t kwset, char const *text, idx_t len)
{
next[tree->label] = tree->trie;
}
-/* Prepare a built keyword set for use. */
void
kwsprep (kwset_t kwset)
{
: acexec_trans (kwset, text, size, kwsmatch, longest)));
}
-/* Find the first instance of a KWSET member in TEXT, which has SIZE bytes.
- Return the offset (into TEXT) of the first byte of the matching substring,
- or -1 if no match is found.
- Upon a match:
- - Store details in *KWSMATCH: index of matched keyword, start offset
- (same as the return value), and length.
- - If LONGEST, find the longest match that starts at this offset;
- otherwise any match that starts at this offset will do.
- NOTE! LONGEST does *not* mean to search for the longest KWSET member
- across the entire string. */
ptrdiff_t
kwsexec (kwset_t kwset, char const *text, idx_t size,
struct kwsmatch *kwsmatch, bool longest)
return kwset->kwsexec (kwset, text, size, kwsmatch, longest);
}
-/* Free the components of the given keyword set. */
void
kwsfree (kwset_t kwset)
{
struct kwset;
typedef struct kwset *kwset_t;
-extern kwset_t kwsalloc (char const *);
-extern void kwsincr (kwset_t, char const *, idx_t);
-extern idx_t kwswords (kwset_t) _GL_ATTRIBUTE_PURE;
-extern void kwsprep (kwset_t);
-extern ptrdiff_t kwsexec (kwset_t, char const *, idx_t,
- struct kwsmatch *, bool)
+/* Return a newly allocated keyword set. A nonnull TRANS specifies a
+ table of character translations to be applied to all pattern and
+ search text. */
+extern kwset_t kwsalloc (char const *trans);
+
+/* Add the given string to the contents of the keyword set. */
+extern void kwsincr (kwset_t kwset, char const *text, idx_t len);
+
+extern idx_t kwswords (kwset_t kwset) _GL_ATTRIBUTE_PURE;
+
+/* Prepare a built keyword set for use. */
+extern void kwsprep (kwset_t kwset);
+
+/* Find the first instance of a KWSET member in TEXT, which has SIZE bytes.
+ Return the offset (into TEXT) of the first byte of the matching substring,
+ or -1 if no match is found.
+ Upon a match:
+ - Store details in *MATCH: index of matched keyword, start offset
+ (same as the return value), and length.
+ - If LONGEST, find the longest match that starts at this offset;
+ otherwise any match that starts at this offset will do.
+ NOTE! LONGEST does *not* mean to search for the longest KWSET member
+ across the entire string. */
+extern ptrdiff_t kwsexec (kwset_t kwset, char const *text, idx_t size,
+ struct kwsmatch *match, bool longest)
_GL_ARG_NONNULL ((4));
-extern void kwsfree (kwset_t);
+
+/* Free the components of the given keyword set. */
+extern void kwsfree (kwset_t kwset);
#ifdef __cplusplus
}