Cleanup previous PR

This commit is contained in:
Kovid Goyal 2023-09-03 18:59:37 +05:30
parent 07d9b95050
commit 4ffb22199b
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
3 changed files with 42 additions and 44 deletions

View file

@ -74,6 +74,8 @@ Detailed list of changes
- When multiple confirmable close requests are made focus the existing close confirmation window instead of opening a new one for each request (:iss:`6601`)
- Config file format: allow splitting lines by starting subsequent lines with a backslash (:pull:`6603`)
0.29.2 [2023-07-27]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View file

@ -264,44 +264,40 @@ def _parse(
base_path_for_includes = config_dir
it = iter(lines)
line: str
nextLine: str = ""
nextLineNum = 0
line = ''
next_line: str = ''
next_line_num = 0
while True:
try:
if nextLine != "":
line = nextLine
if next_line:
line = next_line
else:
line = next(it).lstrip()
nextLineNum += 1
lineNum = nextLineNum
next_line_num += 1
line_num = next_line_num
try:
nextLine = next(it).lstrip()
nextLineNum += 1
next_line = next(it).lstrip()
next_line_num += 1
while nextLine.startswith('\\'):
if line.endswith("\n"):
line = line[:-1]
line += nextLine[1:]
while next_line.startswith('\\'):
line = line.rstrip('\n') + next_line[1:]
try:
nextLine = next(it).lstrip()
nextLineNum += 1
next_line = next(it).lstrip()
next_line_num += 1
except StopIteration:
nextLine = ""
next_line = ''
break
except StopIteration:
nextLine = ""
pass
next_line = ''
try:
with currently_parsing.set_line(line, lineNum):
with currently_parsing.set_line(line, line_num):
parse_line(line, parse_conf_item, ans, base_path_for_includes, accumulate_bad_lines)
except Exception as e:
if accumulate_bad_lines is None:
raise
accumulate_bad_lines.append(BadLine(lineNum, line.rstrip(), e, currently_parsing.file))
accumulate_bad_lines.append(BadLine(line_num, line.rstrip(), e, currently_parsing.file))
except StopIteration:
break

View file

@ -74,41 +74,41 @@ func (self *ConfigParser) parse(scanner Scanner, name, base_path_for_includes st
}
lnum := 0
nextLineNum := 0
nextLine := ""
var line string
next_line_num := 0
next_line := ""
var line string
for {
if nextLine != "" {
line = nextLine
} else {
if next_line != "" {
line = next_line
} else {
if scanner.Scan() {
line = strings.TrimLeft(scanner.Text(), " \t")
next_line_num++
} else {
break
}
nextLineNum++
if line == "" {
continue
}
}
lnum = nextLineNum
if scanner.Scan() {
nextLine = strings.TrimLeft(scanner.Text(), " \t")
nextLineNum++
}
lnum = next_line_num
if scanner.Scan() {
next_line = strings.TrimLeft(scanner.Text(), " \t")
next_line_num++
for nextLine != "" && nextLine[0] == '\\' {
line += nextLine[1:]
if scanner.Scan() {
nextLine = strings.TrimLeft(scanner.Text(), " \t")
nextLineNum++
for strings.HasPrefix(next_line, `\`) {
line += next_line[1:]
if scanner.Scan() {
next_line = strings.TrimLeft(scanner.Text(), " \t")
next_line_num++
} else {
nextLine = ""
}
}
} else {
nextLine = ""
}
next_line = ""
}
}
} else {
next_line = ""
}
if line[0] == '#' {
if self.CommentsHandler != nil {