aboutsummaryrefslogtreecommitdiff
path: root/lib/utf8.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2010-06-27 01:46:23 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2010-06-27 01:46:23 +0300
commitf753ae7494311ce7ea7007c7b8aa2eff99d8da73 (patch)
treed9bc4dfa27ec6248294518aebc926744a8e160cf /lib/utf8.c
parenta5a0bf378fde089faa63c84e079387e060ee4b56 (diff)
downloaddico-f753ae7494311ce7ea7007c7b8aa2eff99d8da73.tar.gz
dico-f753ae7494311ce7ea7007c7b8aa2eff99d8da73.tar.bz2
Implement `substr' strategy. Re-implement the `all' strategy as a module.
* configure.ac: Version 2.0.91 (AC_CONFIG_FILES): Add Makefiles in modules/stratall/ and modules/substr. * NEWS: Version 2.0.91 * dicod/dicod.c: Remove the built-in `all' strategy. * dicod/loader.c (dicod_load_module0): If DICO_CAPA_NODB capability is set, the module must have only the dico_init method. (dicod_init_database): Prohibit the use of DICO_CAPA_NODB modules. * include/dico/types.h (DICO_CAPA_NODB): New capability. * include/dico/utf8.h (utf8_wc_strchr, utf8_wc_strchr_ci) (utf8_wc_strstr, utf8_wc_strupper) (utf8_wc_strlower): New prototypes. * lib/utf8.c (utf8_wc_strchr, utf8_wc_strchr_ci) (utf8_wc_strstr, utf8_wc_strupper) (utf8_wc_strlower): New functions. * modules/Makefile.am (SUBDIRS): Add stratall and substr. * modules/stratall/Makefile.am: New file. * modules/stratall/stratall.c: New file. * modules/substr/Makefile.am: New file. * modules/substr/substr.c: New file. * tests/dicod.cfin: Use prepend-load-path.
Diffstat (limited to 'lib/utf8.c')
-rw-r--r--lib/utf8.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/lib/utf8.c b/lib/utf8.c
index 8d2f479..ae37447 100644
--- a/lib/utf8.c
+++ b/lib/utf8.c
@@ -1930,6 +1930,54 @@ utf8_wc_strcasecmp(const unsigned *a, const unsigned *b)
}
unsigned *
+utf8_wc_strchr(const unsigned *str, unsigned chr)
+{
+ for (; *str; str++)
+ if (*str == chr)
+ return str;
+ return NULL;
+}
+
+unsigned *
+utf8_wc_strchr_ci(const unsigned *str, unsigned chr)
+{
+ unsigned u = utf8_wc_toupper(chr);
+ for (; *str; str++)
+ if (utf8_wc_toupper(*str) == u)
+ return str;
+ return NULL;
+}
+
+int
+utf8_wc_strstr(const unsigned *haystack, const unsigned *needle)
+{
+ unsigned first = needle[0];
+
+ /* Is needle empty? */
+ if (first == 0)
+ return haystack;
+
+ /* Is needle nearly empty? */
+ if (needle[1] == 0)
+ return utf8_wc_strchr(haystack, first);
+ for (; *haystack; haystack++)
+ if (*haystack == first) {
+ /* Compare with needle's remaining units. */
+ const unsigned *hptr = haystack + 1;
+ const unsigned *nptr = needle + 1;
+ for (;;) {
+ if (*hptr != *nptr)
+ break;
+ hptr++;
+ nptr++;
+ if (*nptr == 0)
+ return haystack;
+ }
+ }
+ return NULL;
+}
+
+unsigned *
utf8_wc_quote(const unsigned *s)
{
size_t len = utf8_wc_strlen(s);
@@ -1988,6 +2036,20 @@ utf8_wc_to_mbstr(const unsigned *wordbuf, size_t wordlen, char **sptr)
return 0;
}
+void
+utf8_wc_strupper(unsigned *str)
+{
+ for (; *str; str++)
+ *str = utf8_wc_toupper(*str);
+}
+
+void
+utf8_wc_strlower(unsigned *str)
+{
+ for (; *str; str++)
+ *str = utf8_wc_tolower(*str);
+}
+
int
utf8_mbstr_to_wc(const char *str, unsigned **wptr, size_t * plen)
{

Return to:

Send suggestions and report system problems to the System administrator.