mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-01 03:32:02 +08:00
common: pass c_str in ffi escape string
This commit is contained in:
parent
5394ca1f96
commit
7bab4c4dda
|
@ -1,7 +1,7 @@
|
||||||
use crate::ffi;
|
use crate::ffi;
|
||||||
|
use crate::wchar_ffi::c_str;
|
||||||
use crate::wchar_ffi::{wstr, WCharFromFFI, WString};
|
use crate::wchar_ffi::{wstr, WCharFromFFI, WString};
|
||||||
use std::ffi::c_uint;
|
use std::{ffi::c_uint, mem};
|
||||||
use std::mem;
|
|
||||||
|
|
||||||
/// A scoped manager to save the current value of some variable, and optionally set it to a new
|
/// 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.
|
/// 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 {
|
pub enum EscapeStringStyle {
|
||||||
Script(EscapeFlags),
|
Script(EscapeFlags),
|
||||||
Url,
|
Url,
|
||||||
|
@ -89,5 +90,5 @@ pub fn escape_string(s: &wstr, style: EscapeStringStyle) -> WString {
|
||||||
EscapeStringStyle::Regex => ffi::escape_string_style_t::STRING_STYLE_REGEX,
|
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()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user