From 7bab4c4ddabd1ce2c4dace55f7215e47e9665736 Mon Sep 17 00:00:00 2001 From: Neeraj Jaiswal Date: Fri, 24 Feb 2023 21:14:39 +0530 Subject: [PATCH] common: pass c_str in ffi escape string --- fish-rust/src/common.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fish-rust/src/common.rs b/fish-rust/src/common.rs index a2f7d0ad0..6c03f45dc 100644 --- a/fish-rust/src/common.rs +++ b/fish-rust/src/common.rs @@ -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 @@ fn drop(&mut self) { } } +#[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() }