mirror of
https://codeberg.org/scip/tablizer.git
synced 2025-12-17 12:31:06 +01:00
fixed pattern regex, fixed pattern AND operation
This commit is contained in:
@@ -340,7 +340,7 @@ func (conf *Config) ApplyDefaults() {
|
|||||||
|
|
||||||
func (conf *Config) PreparePattern(patterns []*Pattern) error {
|
func (conf *Config) PreparePattern(patterns []*Pattern) error {
|
||||||
// regex checks if a pattern looks like /$pattern/[i!]
|
// regex checks if a pattern looks like /$pattern/[i!]
|
||||||
flagre := regexp.MustCompile(`^/(.*)/([i!]+)$`)
|
flagre := regexp.MustCompile(`^/(.*)/([i!]*)$`)
|
||||||
|
|
||||||
for _, pattern := range patterns {
|
for _, pattern := range patterns {
|
||||||
matches := flagre.FindAllStringSubmatch(pattern.Pattern, -1)
|
matches := flagre.FindAllStringSubmatch(pattern.Pattern, -1)
|
||||||
|
|||||||
@@ -47,8 +47,9 @@ func matchPattern(conf cfg.Config, line string) bool {
|
|||||||
return fuzzy.MatchFold(conf.Patterns[0].Pattern, line)
|
return fuzzy.MatchFold(conf.Patterns[0].Pattern, line)
|
||||||
}
|
}
|
||||||
|
|
||||||
var match bool
|
var match int
|
||||||
|
|
||||||
|
//fmt.Printf("<%s>\n", line)
|
||||||
for _, re := range conf.Patterns {
|
for _, re := range conf.Patterns {
|
||||||
patmatch := re.PatternRe.MatchString(line)
|
patmatch := re.PatternRe.MatchString(line)
|
||||||
if re.Negate {
|
if re.Negate {
|
||||||
@@ -56,13 +57,16 @@ func matchPattern(conf cfg.Config, line string) bool {
|
|||||||
patmatch = !patmatch
|
patmatch = !patmatch
|
||||||
}
|
}
|
||||||
|
|
||||||
if match != patmatch {
|
if patmatch {
|
||||||
// toggles match if the last match and current match are different
|
match++
|
||||||
match = !match
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return match
|
//fmt.Printf("patmatch: %t, match: %d, pattern: %s, negate: %t\n", patmatch, match, re.Pattern, re.Negate)
|
||||||
|
}
|
||||||
|
|
||||||
|
// fmt.Printf("result: %t\n", match == len(conf.Patterns))
|
||||||
|
//fmt.Println()
|
||||||
|
return match == len(conf.Patterns)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -133,7 +133,7 @@
|
|||||||
.\" ========================================================================
|
.\" ========================================================================
|
||||||
.\"
|
.\"
|
||||||
.IX Title "TABLIZER 1"
|
.IX Title "TABLIZER 1"
|
||||||
.TH TABLIZER 1 "2025-01-21" "1" "User Commands"
|
.TH TABLIZER 1 "2025-01-22" "1" "User Commands"
|
||||||
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
||||||
.\" way too many mistakes in technical documents.
|
.\" way too many mistakes in technical documents.
|
||||||
.if n .ad l
|
.if n .ad l
|
||||||
|
|||||||
Reference in New Issue
Block a user