summaryrefslogtreecommitdiff
path: root/internal/cond/types.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/cond/types.go')
-rw-r--r--internal/cond/types.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/internal/cond/types.go b/internal/cond/types.go
index 9455f63..28a4fc9 100644
--- a/internal/cond/types.go
+++ b/internal/cond/types.go
@@ -24,6 +24,30 @@ type Cond struct {
opt Options // the case/fold settings conditions were compiled with; Task 8 needs them again at eval time
UsesContent bool // some content test exists
DupDirs [][]string // the raw directory arguments of each duplicate test, in order
+ Keywords []Keyword // every content keyword, as compiled, in order
+}
+
+// Keyword is one content keyword as a content test compares it: normalised
+// under the options it was compiled with.
+type Keyword struct {
+ Opt Options
+ Norm string
+}
+
+// Key is the keyword's identity across runs, for the keyword cache: its
+// options and its normalised text.
+func (k Keyword) Key() string { return KeywordKey(k.Opt, k.Norm) }
+
+// KeywordKey is Keyword.Key for opt and an already normalised keyword.
+func KeywordKey(opt Options, norm string) string {
+ b := []byte("sn:")
+ if opt.IgnoreCase {
+ b[0] = 'i'
+ }
+ if opt.Fold {
+ b[1] = 'f'
+ }
+ return string(b) + norm
}
// kind is what a compiled node tests, or how it combines its children.