aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorMatthew Hall <hallmatthew314@gmail.com>2024-04-04 01:01:03 +1300
committerMatthew Hall <hallmatthew314@gmail.com>2024-04-04 01:03:22 +1300
commit856581e43af0261fd396f6268b9cf11cd7fe2b30 (patch)
treea3792fc7cfbc995f723264e8f03a9ba2d264a472 /src/main.rs
parent82b522fcebfbcb6e464d7b87cb017b110368b70c (diff)
Re-work literals to only begin with a double-quote and not end with one
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs
index 74cb73d..14ff4eb 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -25,6 +25,7 @@ enum Error {
DuplicateCategory(OsString),
BadPath(PathBuf),
EmptyOption,
+ InvalidLiteral(String),
}
impl fmt::Display for Error {
@@ -54,6 +55,8 @@ impl fmt::Display for Error {
write!(f, "failed to parse path: {:?}", p),
Error::EmptyOption =>
write!(f, "multi-option variable had an empty option"),
+ Error::InvalidLiteral(s) =>
+ write!(f, "literal option contains an inner quote-mark: {}", s),
}
}
}
@@ -100,13 +103,11 @@ impl DropIn {
return Ok(DropIn::OneOf(options))
}
- // TODO: investigate viability of supporting escape sequences
- if let Some(inner) = text.strip_prefix('"')
- .and_then(|s| s.strip_suffix('"'))
- {
- // REVIEW: investigate interactions of filenames that contain '"'
- if !inner.contains('"') {
- return Ok(DropIn::Literal(inner.to_string()));
+ if let Some(lit) = text.strip_prefix('"') {
+ if lit.contains('"') {
+ return Err(Error::InvalidLiteral(text.to_string()));
+ } else {
+ return Ok(DropIn::Literal(lit.to_string()));
}
}