aboutsummaryrefslogtreecommitdiff
path: root/pattern.h
diff options
context:
space:
mode:
Diffstat (limited to 'pattern.h')
-rw-r--r--pattern.h17
1 files changed, 14 insertions, 3 deletions
diff --git a/pattern.h b/pattern.h
index b903d5b..d12a25b 100644
--- a/pattern.h
+++ b/pattern.h
@@ -7,18 +7,29 @@
#include "files.h"
#include "types.h"
+typedef struct {
+ bool success;
+ union {
+ pat_t *pat;
+ struct {
+ const char *start, *end, *msg;
+ } error;
+ } value;
+} maybe_pat_t;
+
__attribute__((returns_nonnull, nonnull(1,2)))
pat_t *new_pat(file_t *f, const char *start, const char *end, size_t minlen, ssize_t maxlen, enum pattype_e type);
__attribute__((nonnull))
-pat_t *bp_stringpattern(file_t *f, const char *str);
+maybe_pat_t bp_stringpattern(file_t *f, const char *str);
__attribute__((nonnull(1,2)))
-pat_t *bp_replacement(file_t *f, pat_t *replacepat, const char *replacement);
+maybe_pat_t bp_replacement(file_t *f, pat_t *replacepat, const char *replacement);
__attribute__((nonnull(1)))
pat_t *chain_together(file_t *f, pat_t *first, pat_t *second);
__attribute__((nonnull(1)))
pat_t *either_pat(file_t *f, pat_t *first, pat_t *second);
__attribute__((nonnull))
-pat_t *bp_pattern(file_t *f, const char *str);
+maybe_pat_t bp_pattern(file_t *f, const char *str);
+
#endif
// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0