common: pass c_str in ffi escape string

This commit is contained in:
Neeraj Jaiswal 2023-02-24 21:14:39 +05:30 committed by Johannes Altmanninger
parent 5394ca1f96
commit 7bab4c4dda

View File

@ -1,7 +1,7 @@
use crate::ffi;
use crate::wchar_ffi::c_str;
use crate::wchar_ffi::{wstr, WCharFromFFI, WString};
use std::ffi::c_uint;
use std::mem;
use std::{ffi::c_uint, mem};
/// A scoped manager to save the current value of some variable, and optionally set it to a new
/// value. When dropped, it restores the variable to its old value.
@ -35,6 +35,7 @@ impl<'a, T> Drop for ScopedPush<'a, T> {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum EscapeStringStyle {
Script(EscapeFlags),
Url,
@ -89,5 +90,5 @@ pub fn escape_string(s: &wstr, style: EscapeStringStyle) -> WString {
EscapeStringStyle::Regex => ffi::escape_string_style_t::STRING_STYLE_REGEX,
};
ffi::escape_string(s.as_ptr(), flags_int.into(), style).from_ffi()
ffi::escape_string(c_str!(s), flags_int.into(), style).from_ffi()
}