From ebe1b0511444e82830e8de239c34c6817817fba8 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 24 Jun 2020 23:49:59 +0100 Subject: improve desktop text search header usage remove unecessary inclusion of desktop search header in content header which has knock on effect of not having ctype or string system headers dragged in unecessarily. Futher this highlighted use of ctype API where internal ascii processing ought to be used. --- content/content.c | 1 + content/content.h | 19 ------------------- content/handlers/css/css.c | 1 + content/handlers/html/box_special.c | 1 + content/handlers/html/box_textarea.c | 1 + content/handlers/html/dom_event.c | 2 ++ content/handlers/html/forms.c | 2 ++ content/handlers/html/interaction.c | 1 + content/handlers/image/png.c | 1 + content/handlers/text/textplain.c | 1 + content/textsearch.c | 8 +++++--- content/textsearch.h | 19 +++++++++++++++++++ 12 files changed, 35 insertions(+), 22 deletions(-) (limited to 'content') diff --git a/content/content.c b/content/content.c index f72f3d434..ae4718f54 100644 --- a/content/content.c +++ b/content/content.c @@ -23,6 +23,7 @@ #include #include +#include #include #include "netsurf/inttypes.h" diff --git a/content/content.h b/content/content.h index edf9ed2cc..1bae813b2 100644 --- a/content/content.h +++ b/content/content.h @@ -29,7 +29,6 @@ #include -#include "desktop/search.h" /* search flags enum */ #include "netsurf/content_type.h" #include "netsurf/mouse.h" /* mouse state enums */ #include "netsurf/console.h" /* console state and flags enums */ @@ -421,24 +420,6 @@ bool content_scroll_at_point(struct hlcache_handle *h, bool content_drop_file_at_point(struct hlcache_handle *h, int x, int y, char *file); -/** - * Free text search a content - * - * \param[in] h Handle to content to search. - * \param[in] context The context passed to gui table search handlers - * \param[in] flags The flags that control the search - * \param[in] The string being searched for. - * \retun NSERROR_OK on success else error code on faliure - */ -nserror content_textsearch(struct hlcache_handle *h, void *context, search_flags_t flags, const char *string); - -/** - * Clear a search - * - * \param[in] h Handle to content to clear search from. - */ -nserror content_textsearch_clear(struct hlcache_handle *h); - /** * Control debug con a content. diff --git a/content/handlers/css/css.c b/content/handlers/css/css.c index 6bdc124e2..be945fb97 100644 --- a/content/handlers/css/css.c +++ b/content/handlers/css/css.c @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +#include #include #include #include diff --git a/content/handlers/html/box_special.c b/content/handlers/html/box_special.c index c6be9e626..f761557e0 100644 --- a/content/handlers/html/box_special.c +++ b/content/handlers/html/box_special.c @@ -26,6 +26,7 @@ * Implementation of special element handling conversion. */ +#include #include #include diff --git a/content/handlers/html/box_textarea.c b/content/handlers/html/box_textarea.c index 1038be31a..b3e3c3610 100644 --- a/content/handlers/html/box_textarea.c +++ b/content/handlers/html/box_textarea.c @@ -21,6 +21,7 @@ * Box tree treeview box replacement (implementation). */ +#include #include #include "utils/config.h" diff --git a/content/handlers/html/dom_event.c b/content/handlers/html/dom_event.c index d490cad77..71ef13861 100644 --- a/content/handlers/html/dom_event.c +++ b/content/handlers/html/dom_event.c @@ -22,6 +22,8 @@ * Implementation of HTML content DOM event handling. */ +#include + #include "utils/config.h" #include "utils/corestrings.h" #include "utils/nsoption.h" diff --git a/content/handlers/html/forms.c b/content/handlers/html/forms.c index 08adf8d39..4669154e9 100644 --- a/content/handlers/html/forms.c +++ b/content/handlers/html/forms.c @@ -21,6 +21,8 @@ * HTML form handling implementation */ +#include + #include "utils/config.h" #include "utils/corestrings.h" #include "utils/log.h" diff --git a/content/handlers/html/interaction.c b/content/handlers/html/interaction.c index 421535c69..90e7b7626 100644 --- a/content/handlers/html/interaction.c +++ b/content/handlers/html/interaction.c @@ -26,6 +26,7 @@ #include #include +#include #include diff --git a/content/handlers/image/png.c b/content/handlers/image/png.c index 4926d9a27..06a38ca0f 100644 --- a/content/handlers/image/png.c +++ b/content/handlers/image/png.c @@ -19,6 +19,7 @@ */ #include +#include #include #include diff --git a/content/handlers/text/textplain.c b/content/handlers/text/textplain.c index b5ad0aec3..21876ec58 100644 --- a/content/handlers/text/textplain.c +++ b/content/handlers/text/textplain.c @@ -23,6 +23,7 @@ * plain text content handling implementation. */ +#include #include #include "utils/errors.h" diff --git a/content/textsearch.c b/content/textsearch.c index 802832089..3f97d42ee 100644 --- a/content/textsearch.c +++ b/content/textsearch.c @@ -25,9 +25,11 @@ #include #include #include +#include #include "utils/errors.h" #include "utils/utils.h" +#include "utils/ascii.h" #include "netsurf/types.h" #include "desktop/selection.h" @@ -507,11 +509,11 @@ content_textsearch_find_pattern(const char *string, if (ch != '#') { /* scan forwards until we find a match for this char */ - if (!case_sens) ch = toupper(ch); + if (!case_sens) ch = ascii_to_upper(ch); while (s < es) { if (case_sens) { if (*s == ch) break; - } else if (toupper(*s) == ch) + } else if (ascii_to_upper(*s) == ch) break; s++; } @@ -548,7 +550,7 @@ content_textsearch_find_pattern(const char *string, if (case_sens) matches = (*s == ch); else - matches = (toupper(*s) == toupper(ch)); + matches = (ascii_to_upper(*s) == ascii_to_upper(ch)); } if (matches && first) { ss = s; /* remember first non-'*' char */ diff --git a/content/textsearch.h b/content/textsearch.h index e30ebc452..c32b17cca 100644 --- a/content/textsearch.h +++ b/content/textsearch.h @@ -28,8 +28,27 @@ struct textsearch_context; struct content; +struct hlcache_handle; struct box; +/** + * Free text search a content + * + * \param[in] h Handle to content to search. + * \param[in] context The context passed to gui table search handlers + * \param[in] flags The flags that control the search + * \param[in] The string being searched for. + * \retun NSERROR_OK on success else error code on faliure + */ +nserror content_textsearch(struct hlcache_handle *h, void *context, search_flags_t flags, const char *string); + +/** + * Clear a search + * + * \param[in] h Handle to content to clear search from. + */ +nserror content_textsearch_clear(struct hlcache_handle *h); + /** * Ends the search process, invalidating all state freeing the list of * found boxes. -- cgit v1.2.3