1
Fork 0

Fix quote escaping inside check-cfg value

This commit is contained in:
Urgau 2024-05-20 11:44:09 +02:00
parent bc8e034c39
commit ccd3e99a1a
4 changed files with 49 additions and 17 deletions

View file

@ -48,10 +48,9 @@ enum EscapeQuotes {
fn to_check_cfg_arg(name: Symbol, value: Option<Symbol>, quotes: EscapeQuotes) -> String {
if let Some(value) = value {
let value = str::escape_debug(value.as_str()).to_string();
let values = match quotes {
EscapeQuotes::Yes => {
format!("\\\"{}\\\"", str::escape_debug(value.as_str()).to_string())
}
EscapeQuotes::Yes => format!("\\\"{}\\\"", value.replace("\"", "\\\\\\\\\"")),
EscapeQuotes::No => format!("\"{value}\""),
};
format!("cfg({name}, values({values}))")