resolv-conf/.patchy/0001-Use-1-indexed-line-numbers-when-displaying-parse-err.patch

52 lines
2.3 KiB
Diff

From 18a0e66ba75052f41aa73a93c915fcf00f21700a Mon Sep 17 00:00:00 2001
From: Jade Ellis <jade@ellis.link>
Date: Fri, 20 Jun 2025 22:56:05 +0100
Subject: [PATCH] Use 1-indexed line numbers when displaying parse error
messages
---
src/grammar.rs | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/grammar.rs b/src/grammar.rs
index 08fd361..65386d8 100644
--- a/src/grammar.rs
+++ b/src/grammar.rs
@@ -27,25 +27,27 @@ pub enum ParseError {
impl std::fmt::Display for ParseError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
- ParseError::InvalidUtf8(line, err) => write!(f, "bad unicode at line {line}: {err}"),
+ ParseError::InvalidUtf8(line, err) => write!(f, "bad unicode at line {}: {err}", line + 1),
ParseError::InvalidValue(line) => write!(
f,
- "directive at line {line} is improperly formatted or contains invalid value",
+ "directive at line {} is improperly formatted or contains invalid value",
+ line + 1
),
ParseError::InvalidOptionValue(line) => write!(
f,
- "directive options at line {line} contains invalid value of some option",
+ "directive options at line {} contains invalid value of some option",
+ line + 1
),
ParseError::InvalidOption(line) => {
- write!(f, "option at line {line} is not recognized")
+ write!(f, "option at line {} is not recognized", line + 1)
}
ParseError::InvalidDirective(line) => {
- write!(f, "directive at line {line} is not recognized")
+ write!(f, "directive at line {} is not recognized", line + 1)
}
ParseError::InvalidIp(line, err) => {
- write!(f, "directive at line {line} contains invalid IP: {err}")
+ write!(f, "directive at line {} contains invalid IP: {err}", line + 1)
}
- ParseError::ExtraData(line) => write!(f, "extra data at the end of line {line}"),
+ ParseError::ExtraData(line) => write!(f, "extra data at the end of line {}", line + 1),
}
}
}
--
2.39.5 (Apple Git-154)