aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2016-07-29 16:37:37 +0300
committerSergey Poznyakoff <gray@gnu.org>2016-07-31 22:38:20 +0300
commitb9a48eae585f058d51af415625083dbca72a9697 (patch)
treeb5cedb957348624f24a5aabbc84598cf120711df /doc
parent43245ea8f3f53e5d5b4487339e84cc309573bd2c (diff)
downloaddico-b9a48eae585f058d51af415625083dbca72a9697.tar.gz
dico-b9a48eae585f058d51af415625083dbca72a9697.tar.bz2
Use Knuth-Morris-Pratt algorithm for substing look-ups
* include/dico/utf8.h (utf8_wc_strpat): New proto. * lib/utf8.c (utf8_wc_strpat): New function. (utf8_wc_strstr): Rewrite as a wrapper over utf8_wc_strpat. * lib/tests/utf8.c: Use %td specifier to print ptrdiff_t values. * doc/libdico.texi: Document string-matching functions. * lib/tests/wcstrstr.at: Add more tests. * modules/substr/substr.c (substr_sel): Use utf8_wc_strpat.
Diffstat (limited to 'doc')
-rw-r--r--doc/libdico.texi56
1 files changed, 55 insertions, 1 deletions
diff --git a/doc/libdico.texi b/doc/libdico.texi
index 0e6f3b5..3f1888f 100644
--- a/doc/libdico.texi
+++ b/doc/libdico.texi
@@ -704,7 +704,61 @@ struct utf8_iterator @{
@deftypefn Function int utf8_wc_strcmp (const unsigned *@var{a}, @
const unsigned *@var{b})
@end deftypefn
-
+
+@deftp enum utf8_strpat_result
+Integer return type for string matching functions. Defined as:
+
+@smallexample
+enum utf8_strpat_result @{
+ strpat_found,
+ strpat_not_found,
+ strpat_error
+@};
+@end smallexample
+
+Its values:
+
+@table @code
+@item strpat_found:
+Pattern was found in text.
+
+@item strpat_not_found
+Pattern was not found in text.
+
+@item strpat_error
+An error occurred. The @code{errno} variable should be examined to
+obtain more information about the error.
+@end table
+@end deftp
+
+@deftypefn Function {enum utf8_strpat_result} utf8_wc_strpat (const unsigned *@var{text},@
+ const unsigned *@var{pattern}, size_t *@var{return_offset})
+Finds the first occurrence of @var{pattern} in @var{text}. Return value:
+
+@table @code
+@item strpat_found
+Pattern was found. Unless @var{return_offset} is @code{NULL}, the
+offset of the pattern occurrence in @var{text} is stored in the memory
+location pointed to by @var{return_offset}.
+
+@item strpat_not_found
+Pattern was not found.
+
+@item strpat_error
+An error occurred. The @code{errno }variable is set to @samp{ERANGE},
+if pattern is too long, or to @samp{ENOMEM} if unable to allocate memory.
+@end table
+@end deftypefn
+
+@deftypefn Function {const unsigned *} utf8_wc_strstr( const unsigned *var{text},@
+ const unsigned *@var{pattern})
+Alternative interface to @code{utf8_wc_strpat}. Finds the first
+occurrence of @var{pattern} in @var{text}. Returns a pointer to the
+beginning of pattern in @var{text}. Returns @code{NULL} if no occurrence
+was found or if an error occurred. In the latter case, the global
+variable @code{errno} is set appropriately.
+@end deftypefn
+
@deftypefn Function int utf8_wc_to_mbstr (const unsigned *@var{wordbuf}, @
size_t @var{wordlen}, char *@var{s}, size_t @var{size})
@end deftypefn

Return to:

Send suggestions and report system problems to the System administrator.