mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-17 14:27:12 +09:00
syntax parser: reintroduce header regex in .hdr files
Replacing header patterns with signature patterns was a mistake, since both have their own uses. So restore support for header regex, while keeping support for signature regex as well.
This commit is contained in:
@@ -18,6 +18,7 @@ type HeaderYaml struct {
|
||||
FileType string `yaml:"filetype"`
|
||||
Detect struct {
|
||||
FNameRgx string `yaml:"filename"`
|
||||
HeaderRgx string `yaml:"header"`
|
||||
SignatureRgx string `yaml:"signature"`
|
||||
} `yaml:"detect"`
|
||||
}
|
||||
@@ -25,6 +26,7 @@ type HeaderYaml struct {
|
||||
type Header struct {
|
||||
FileType string
|
||||
FNameRgx string
|
||||
HeaderRgx string
|
||||
SignatureRgx string
|
||||
}
|
||||
|
||||
@@ -59,6 +61,7 @@ func encode(name string, c HeaderYaml) {
|
||||
f, _ := os.Create(name + ".hdr")
|
||||
f.WriteString(c.FileType + "\n")
|
||||
f.WriteString(c.Detect.FNameRgx + "\n")
|
||||
f.WriteString(c.Detect.HeaderRgx + "\n")
|
||||
f.WriteString(c.Detect.SignatureRgx + "\n")
|
||||
f.Close()
|
||||
}
|
||||
@@ -70,7 +73,8 @@ func decode(name string) Header {
|
||||
var hdr Header
|
||||
hdr.FileType = string(strs[0])
|
||||
hdr.FNameRgx = string(strs[1])
|
||||
hdr.SignatureRgx = string(strs[2])
|
||||
hdr.HeaderRgx = string(strs[2])
|
||||
hdr.SignatureRgx = string(strs[3])
|
||||
fmt.Printf("took %v\n", time.Since(start))
|
||||
|
||||
return hdr
|
||||
|
||||
Reference in New Issue
Block a user