dte test coverage


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 50.0% high: ≥ 85.0%
Coverage Exec / Excl / Total
Lines: 100.0% 10 / 0 / 10
Functions: 100.0% 3 / 0 / 3
Branches: -% 0 / 0 / 0

src/search.h
Line Branch Exec Source
1 #ifndef SEARCH_H
2 #define SEARCH_H
3
4 #include <regex.h>
5 #include <stdbool.h>
6 #include "command/error.h"
7 #include "util/macros.h"
8 #include "view.h"
9
10 typedef enum {
11 CSS_FALSE,
12 CSS_TRUE,
13 CSS_AUTO,
14 } SearchCaseSensitivity;
15
16 typedef struct {
17 regex_t regex;
18 char *pattern;
19 int re_flags; // If zero, regex hasn't been compiled
20 bool reverse;
21 } SearchState;
22
23 bool do_search_next(View *view, SearchState *search, ErrorBuffer *ebuf, SearchCaseSensitivity cs, bool skip) NONNULL_ARGS WARN_UNUSED_RESULT;
24
25 2 static inline void toggle_search_direction(SearchState *search)
26 {
27 2 search->reverse ^= 1;
28 2 }
29
30 NONNULL_ARGS WARN_UNUSED_RESULT
31 2 static inline bool search_next(View *view, SearchState *search, ErrorBuffer *ebuf, SearchCaseSensitivity cs)
32 {
33 2 return do_search_next(view, search, ebuf, cs, false);
34 }
35
36 NONNULL_ARGS WARN_UNUSED_RESULT
37 1 static inline bool search_prev(View *view, SearchState *search, ErrorBuffer *ebuf, SearchCaseSensitivity cs)
38 {
39 1 toggle_search_direction(search);
40 1 bool r = search_next(view, search, ebuf, cs);
41 1 toggle_search_direction(search);
42 1 return r;
43 }
44
45 bool search_tag(View *view, ErrorBuffer *ebuf, const char *pattern) NONNULL_ARGS WARN_UNUSED_RESULT;
46 void search_set_regexp(SearchState *search, const char *pattern) NONNULL_ARGS;
47 void search_free_regexp(SearchState *search) NONNULL_ARGS;
48
49 #endif
50