From 031963c91ed357c7ec1fdd6c9227e6098f167e9a Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 17 Nov 2014 19:02:55 -0500 Subject: [PATCH] embedding: cef_string_wide_cmp() --- ports/cef/string.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ports/cef/string.rs b/ports/cef/string.rs index 9f3baac8f10..650407f1d20 100644 --- a/ports/cef/string.rs +++ b/ports/cef/string.rs @@ -222,3 +222,18 @@ pub extern "C" fn cef_string_wide_set(src: *const wchar_t, src_len: size_t, outp } return 1; } + +#[no_mangle] +pub extern "C" fn cef_string_wide_cmp(a: *const cef_string_wide_t, b: *const cef_string_wide_t) -> c_int { + unsafe { + slice::raw::buf_as_slice((*a).str as *const wchar_t, (*a).length as uint, |astr:&[wchar_t]| { + slice::raw::buf_as_slice((*b).str as *const wchar_t, (*b).length as uint, |bstr:&[wchar_t]| { + match astr.cmp(bstr) { + Less => -1, + Equal => 0, + Greater => 1 + } + }) + }) + } +}