summaryrefslogtreecommitdiff
path: root/dhall_core/src/printer.rs
diff options
context:
space:
mode:
authorNadrieril2019-05-02 22:15:47 +0200
committerNadrieril2019-05-02 22:15:47 +0200
commit3268e1fb66e2c9eab22572da034a0ac9b3087867 (patch)
tree0f8dd6097f7e4e11ba69934dbedba4e6de320ce2 /dhall_core/src/printer.rs
parent69d310da1e4c4563ce41424f776879102b62d9a0 (diff)
Update dhall-lang submodule
Diffstat (limited to '')
-rw-r--r--dhall_core/src/printer.rs28
1 files changed, 24 insertions, 4 deletions
diff --git a/dhall_core/src/printer.rs b/dhall_core/src/printer.rs
index 8b37b0f..704000a 100644
--- a/dhall_core/src/printer.rs
+++ b/dhall_core/src/printer.rs
@@ -351,7 +351,7 @@ impl Display for ImportHashed {
use std::path::PathBuf;
use FilePrefix::*;
use ImportLocation::*;
- let quoted = |s: &str| -> String {
+ let quoted_path_component = |s: &str| -> String {
if s.chars().all(|c| c.is_ascii_alphanumeric()) {
s.to_owned()
} else {
@@ -361,7 +361,7 @@ impl Display for ImportHashed {
let fmt_path = |f: &mut fmt::Formatter, p: &PathBuf| {
let res: String = p
.iter()
- .map(|c| quoted(c.to_string_lossy().as_ref()))
+ .map(|c| quoted_path_component(c.to_string_lossy().as_ref()))
.join("/");
f.write_str(&res)
};
@@ -387,8 +387,28 @@ impl Display for ImportHashed {
write!(f, " using ({})", h)?
}
}
- Env(e) => {
- write!(f, "env:{}", quoted(e))?;
+ Env(s) => {
+ write!(f, "env:")?;
+ if s.chars().all(|c| c.is_ascii_alphanumeric()) {
+ write!(f, "{}", s)?;
+ } else {
+ write!(f, "\"")?;
+ for c in s.chars() {
+ match c {
+ '"' => f.write_str("\\\"")?,
+ '\\' => f.write_str("\\\\")?,
+ '\u{0007}' => f.write_str("\\a")?,
+ '\u{0008}' => f.write_str("\\b")?,
+ '\u{000C}' => f.write_str("\\f")?,
+ '\n' => f.write_str("\\n")?,
+ '\r' => f.write_str("\\r")?,
+ '\t' => f.write_str("\\t")?,
+ '\u{000B}' => f.write_str("\\v")?,
+ _ => write!(f, "{}", c)?,
+ }
+ }
+ write!(f, "\"")?;
+ }
}
Missing => {
write!(f, "missing")?;