Remove re expressions used for queries in skysh

These are no longer relevant because of the last commit

Signed-off-by: Sayan Nandan <nandansayan@outlook.com>
next
Sayan Nandan 3 years ago
parent 4d4ce95f13
commit 49d7eecbab
No known key found for this signature in database
GPG Key ID: 5EDED89A1ADA6273

3
Cargo.lock generated

@ -471,9 +471,6 @@ checksum = "dd8f7255a17a627354f321ef0055d63b898c6fb27eff628af4d1b66b7331edf6"
name = "libsky"
version = "0.7.1"
dependencies = [
"lazy_static",
"regex",
"skytable 0.6.0 (git+https://github.com/skytable/client-rust?branch=next)",
"termcolor",
]

@ -1,17 +1,11 @@
[package]
name = "libsky"
version = "0.7.1"
authors = ["Sayan Nandan <ohsayan@outlook.com>"]
edition = "2018"
name = "libsky"
version = "0.7.1"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
# internal deps
skytable = { git = "https://github.com/skytable/client-rust", branch = "next", features = [
"dbg",
], default-features = false }
# external deps
lazy_static = "1.4.0"
termcolor = "1.1.2"
regex = "1.5.4"

@ -32,7 +32,6 @@
//! This contains modules which are shared by both the `cli` and the `server` modules
pub mod util;
use skytable::Query;
use std::error::Error;
/// A generic result
pub type TResult<T> = Result<T, Box<dyn Error>>;
@ -43,12 +42,6 @@ pub static VERSION: &str = env!("CARGO_PKG_VERSION");
/// The URL
pub static URL: &str = "https://github.com/skytable/skytable";
use std::str::FromStr;
lazy_static::lazy_static! {
static ref RE: regex::Regex = regex::Regex::from_str(r#"("[^"]*"|'[^']*'|[\S]+)+"#).unwrap();
}
#[macro_export]
/// Don't use unwrap_or but use this macro as the optimizer fails to optimize away usages
/// of unwrap_or and creates a lot of LLVM IR bloat. use
@ -61,40 +54,3 @@ macro_rules! option_unwrap_or {
}
};
}
pub fn split_into_args(q: &str) -> Vec<String> {
let args: Vec<String> = RE
.find_iter(q)
.map(|val| {
let mut v = val.as_str();
let mut chars = v.chars();
let first = chars.next();
let last = chars.last();
if let Some('"') = first {
v = &v[1..];
if let Some('"') = last {
v = &v[..v.len()];
}
} else if let Some('\'') = first {
v = &v[1..];
if let Some('\'') = last {
v = &v[..v.len()];
}
}
v.to_owned()
})
.collect();
args
}
pub fn turn_into_query(q: &str) -> Query {
let mut query = Query::new();
split_into_args(q).into_iter().for_each(|arg| {
query.push(arg);
});
query
}
pub fn into_raw_query(q: &str) -> Vec<u8> {
turn_into_query(q).into_raw_query()
}

Loading…
Cancel
Save