Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/src/metta/runner/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,9 @@ fn include_path_from_cfg_atom(atom: &ExpressionAtom, env: &Environment) -> Resul
None => return Err(format!("Error in environment.metta. #includePath missing path value"))
};
let path = <&crate::SymbolAtom>::try_from(path_atom)?.name();
// At this stage stdlib is not loaded and thus path is parsed as a symbol not string.
// This is why we should manuall stip quotes from the symbol's name.
let path = crate::metta::runner::str::strip_quotes(path);

//TODO-FUTURE: In the future we may want to replace dyn-fmt with strfmt, and do something a
// little bit nicer than this
Expand Down
16 changes: 16 additions & 0 deletions lib/src/metta/runner/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,22 @@ impl std::fmt::Display for Str {
}
}

/// A utility function to return the part of a string in between starting and ending quotes
pub fn strip_quotes(src: &str) -> &str {
if let Some(first) = src.chars().next() {
if first == '"' {
if let Some(last) = src.chars().last() {
if last == '"' {
if src.len() > 1 {
return &src[1..src.len()-1]
}
}
}
}
}
src
}

#[derive(Default)]
struct StrSerializer {
value: Option<Str>,
Expand Down
Loading