Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port multibyte-string-p to rust #211

Merged
merged 3 commits into from Jun 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions rust_src/src/lib.rs
Expand Up @@ -80,6 +80,7 @@ pub use strings::Fstring_equal;
pub use strings::Fstring_as_multibyte;
pub use strings::Fstring_to_multibyte;
pub use strings::Fstring_to_unibyte;
pub use strings::Fmultibyte_string_p;
pub use vectors::Flength;
pub use vectors::Fsort;
pub use lists::merge;
Expand Down Expand Up @@ -168,6 +169,7 @@ pub extern "C" fn rust_init_syms() {
defsubr(&*strings::Sstringp);
defsubr(&*strings::Sbase64_encode_string);
defsubr(&*strings::Sbase64_decode_string);
defsubr(&*strings::Smultibyte_string_p);
defsubr(&*strings::Sstring_bytes);
defsubr(&*strings::Sstring_equal);
defsubr(&*strings::Sstring_as_multibyte);
Expand Down
7 changes: 7 additions & 0 deletions rust_src/src/strings.rs
Expand Up @@ -201,3 +201,10 @@ fn string_to_unibyte(string: LispObject) -> LispObject {
string
}
}

/// Return t if OBJECT is a multibyte string.
/// Return nil if OBJECT is either a unibyte string, or not a string.
#[lisp_fn]
fn multibyte_string_p(object: LispObject) -> LispObject {
LispObject::from_bool(object.as_string().map_or(false, |s| s.is_multibyte()))
}
12 changes: 0 additions & 12 deletions src/data.c
Expand Up @@ -286,17 +286,6 @@ DEFUN ("vectorp", Fvectorp, Svectorp, 1, 1, 0,
return Qnil;
}

DEFUN ("multibyte-string-p", Fmultibyte_string_p, Smultibyte_string_p,
1, 1, 0,
doc: /* Return t if OBJECT is a multibyte string.
Return nil if OBJECT is either a unibyte string, or not a string. */)
(Lisp_Object object)
{
if (STRINGP (object) && STRING_MULTIBYTE (object))
return Qt;
return Qnil;
}

DEFUN ("char-table-p", Fchar_table_p, Schar_table_p, 1, 1, 0,
doc: /* Return t if OBJECT is a char-table. */)
(Lisp_Object object)
Expand Down Expand Up @@ -3187,7 +3176,6 @@ syms_of_data (void)
defsubr (&Sinteractive_form);
defsubr (&Stype_of);
defsubr (&Skeywordp);
defsubr (&Smultibyte_string_p);
defsubr (&Svectorp);
defsubr (&Schar_table_p);
defsubr (&Svector_or_char_table_p);
Expand Down