[devhelp] SearchContext: "book:" and "page:" must be before other keywords



commit 93d40568d7caec4932aff8ae28d60f30d86d9ccc
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Thu Jan 18 19:24:14 2018 +0100

    SearchContext: "book:" and "page:" must be before other keywords

 src/dh-search-context.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/src/dh-search-context.c b/src/dh-search-context.c
index 674a320..53c14df 100644
--- a/src/dh-search-context.c
+++ b/src/dh-search-context.c
@@ -37,9 +37,11 @@ struct _DhSearchContext {
 };
 
 /* Process the input search string and extract:
- *  - If "book:" prefix given, a book_id;
- *  - If "page:" prefix given, a page_id;
- *  - All remaining keywords.
+ * - If "book:" prefix given, a book_id;
+ * - If "page:" prefix given, a page_id;
+ * - All remaining keywords.
+ *
+ * "book:" and "page:" must be before the other keywords.
  *
  * Returns TRUE if the extraction is successfull, FALSE if the @search_string is
  * invalid.
@@ -97,6 +99,12 @@ process_search_string (DhSearchContext *search,
                 /* Book prefix? */
                 prefix = "book:";
                 if (g_str_has_prefix (cur_token, prefix)) {
+                        /* Must be before normal keywords. */
+                        if (keyword_num > 0) {
+                                ret = FALSE;
+                                goto out;
+                        }
+
                         prefix_len = strlen (prefix);
 
                         /* If keyword given but no content, skip it. */
@@ -117,6 +125,12 @@ process_search_string (DhSearchContext *search,
                 /* Page prefix? */
                 prefix = "page:";
                 if (g_str_has_prefix (cur_token, prefix)) {
+                        /* Must be before normal keywords. */
+                        if (keyword_num > 0) {
+                                ret = FALSE;
+                                goto out;
+                        }
+
                         prefix_len = strlen (prefix);
 
                         /* If keyword given but no content, skip it. */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]