mirror of
https://github.com/zyedidia/micro.git
synced 2026-02-04 22:20:20 +09:00
@@ -6,7 +6,7 @@ import "regexp"
|
||||
// to determine the filetype of the file
|
||||
// It will return the corresponding syntax definition for the filetype
|
||||
func MatchFiletype(ftdetect [2]*regexp.Regexp, filename string, firstLine []byte) bool {
|
||||
if ftdetect[0].MatchString(filename) {
|
||||
if ftdetect[0] != nil && ftdetect[0].MatchString(filename) {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -106,10 +106,6 @@ func MakeHeader(data []byte) (*Header, error) {
|
||||
fnameRgx := string(lines[1])
|
||||
headerRgx := string(lines[2])
|
||||
|
||||
if fnameRgx == "" && headerRgx == "" {
|
||||
return nil, errors.New("Syntax file must include at least one detection regex")
|
||||
}
|
||||
|
||||
if fnameRgx != "" {
|
||||
header.FtDetect[0], err = regexp.Compile(fnameRgx)
|
||||
}
|
||||
@@ -136,10 +132,6 @@ func MakeHeaderYaml(data []byte) (*Header, error) {
|
||||
header := new(Header)
|
||||
header.FileType = hdrYaml.FileType
|
||||
|
||||
if hdrYaml.Detect.FNameRgx == "" && hdrYaml.Detect.HeaderRgx == "" {
|
||||
return nil, errors.New("Syntax file must include at least one detection regex")
|
||||
}
|
||||
|
||||
if hdrYaml.Detect.FNameRgx != "" {
|
||||
header.FtDetect[0], err = regexp.Compile(hdrYaml.Detect.FNameRgx)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user