caddyfile: Track import name instead of modifying filename (#5540)

* Merge branch 'master' into import_file_stack

* remove space in log key
This commit is contained in:
WeidiDeng 2023-05-26 03:05:00 +08:00 committed by GitHub
parent 942fbb37ec
commit 9cde715525
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 31 deletions

View file

@ -39,7 +39,7 @@ type (
// Token represents a single parsable unit.
Token struct {
File string
origFile string
imports []string
Line int
Text string
wasQuoted rune // enclosing quote character, if any
@ -321,23 +321,6 @@ func (l *lexer) finalizeHeredoc(val []rune, marker string) ([]rune, error) {
return []rune(out), nil
}
// originalFile gets original filename before import modification.
func (t Token) originalFile() string {
if t.origFile != "" {
return t.origFile
}
return t.File
}
// updateFile updates the token's source filename for error display
// and remembers the original filename. Used during "import" processing.
func (t *Token) updateFile(file string) {
if t.origFile == "" {
t.origFile = t.File
}
t.File = file
}
func (t Token) Quoted() bool {
return t.wasQuoted > 0
}