parse: ignore leading whitespace for comments
Comments were only ignored if the string parsed started with "#". This commit trims leading whitespace and tab characters to make sure all lines with "#" being the first non-whitespace character are ignored. Signed-off-by: Stephen Chung <schung@redhat.com>
This commit is contained in:
parent
a29236e678
commit
f3fc3d06d6
2 changed files with 72 additions and 3 deletions
7
parse.go
7
parse.go
|
@ -16,11 +16,14 @@ func ParseSpec(r io.Reader) (*DirectoryHierarchy, error) {
|
|||
}
|
||||
for s.Scan() {
|
||||
str := s.Text()
|
||||
trimmedStr := strings.TrimLeftFunc(str, func(c rune) bool {
|
||||
return c == ' ' || c == '\t'
|
||||
})
|
||||
e := Entry{Pos: i}
|
||||
switch {
|
||||
case strings.HasPrefix(str, "#"):
|
||||
case strings.HasPrefix(trimmedStr, "#"):
|
||||
e.Raw = str
|
||||
if strings.HasPrefix(str, "#mtree") {
|
||||
if strings.HasPrefix(trimmedStr, "#mtree") {
|
||||
e.Type = SignatureType
|
||||
} else {
|
||||
e.Type = CommentType
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue