From 95ef6961a2500d89bc065b2873ca3e77850539e3 Mon Sep 17 00:00:00 2001 From: comex Date: Mon, 22 Jun 2015 21:20:35 -0400 Subject: [PATCH] add # quotes, which I forgot about --- Cargo.toml | 2 +- src/lib.rs | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d9dbc87..0928ee2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "shlex" -version = "0.1.0" +version = "0.1.1" authors = ["comex "] license = "MIT/Apache-2.0" repository = "https://github.com/comex/rust-shlex" diff --git a/src/lib.rs b/src/lib.rs index 7c4888b..6ff8c97 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -130,11 +130,15 @@ impl<'a> Iterator for Shlex<'a> { // skip initial whitespace loop { match ch as char { - ' ' | '\t' | '\n' => { - if let Some(ch2) = self.next_char() { ch = ch2; } else { return None; } + ' ' | '\t' | '\n' => {}, + '#' => { + while let Some(ch2) = self.next_char() { + if ch2 as char == '\n' { break; } + } }, _ => { break; } } + if let Some(ch2) = self.next_char() { ch = ch2; } else { return None; } } self.parse_word(ch) } else { // no initial character @@ -193,6 +197,10 @@ static SPLIT_TEST_ITEMS: &'static [(&'static str, Option<&'static [&'static str] ("'\\", None), ("\"", None), ("'", None), + ("foo #bar\nbaz", Some(&["foo", "baz"])), + ("foo #bar", Some(&["foo"])), + ("foo#bar", Some(&["foo#bar"])), + ("foo\"#bar", None), ]; #[test]