MCPcopy Create free account
hub / github.com/FastLED/FastLED / strip_string_literals

Function strip_string_literals

ci/lint_cpp_rs/src/lib.rs:1844–1875  ·  view source on GitHub ↗
(code: &str)

Source from the content-addressed store, hash-verified

1842}
1843
1844fn strip_string_literals(code: &str) -> String {
1845 let mut result = String::with_capacity(code.len());
1846 let mut quote: Option<char> = None;
1847 let mut escaped = false;
1848
1849 for ch in code.chars() {
1850 match quote {
1851 None => {
1852 if ch == '"' || ch == '\'' {
1853 quote = Some(ch);
1854 }
1855 result.push(ch);
1856 }
1857 Some(active_quote) => {
1858 if escaped {
1859 escaped = false;
1860 result.push(' ');
1861 } else if ch == '\\' {
1862 escaped = true;
1863 result.push(' ');
1864 } else if ch == active_quote {
1865 quote = None;
1866 result.push(ch);
1867 } else {
1868 result.push(' ');
1869 }
1870 }
1871 }
1872 }
1873
1874 result
1875}
1876
1877fn regex_has_include() -> &'static Regex {
1878 static VALUE: OnceLock<Regex> = OnceLock::new();

Callers 1

check_file_contentMethod · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected