mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
move definition of String#unicode_normalize! to C to make sure it is documented
* lib/unicode_normalize.rb: Remove definition of String#unicode_normalize! (including documentation) * string.c: Define String#unicode_normalize! in rb_str_unicode_normalize_bang in C, (including documentation) * lib/unicode_normalize/normalize.rb: Remove (re)definition of String#unicode_normalize! to avoid warnings (when $VERBOSE==true) and problems when String is frozen git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58553 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6faa8408e5
commit
90ab1ee023
3 changed files with 23 additions and 17 deletions
|
@ -7,18 +7,6 @@
|
||||||
# additions to class String for Unicode normalization
|
# additions to class String for Unicode normalization
|
||||||
#++
|
#++
|
||||||
class String
|
class String
|
||||||
|
|
||||||
# :call-seq:
|
|
||||||
# str.unicode_normalize!(form=:nfc)
|
|
||||||
#
|
|
||||||
# Destructive version of String#unicode_normalize, doing Unicode
|
|
||||||
# normalization in place.
|
|
||||||
#
|
|
||||||
def unicode_normalize!(form = :nfc)
|
|
||||||
require 'unicode_normalize/normalize.rb'
|
|
||||||
unicode_normalize! form
|
|
||||||
end
|
|
||||||
|
|
||||||
# :call-seq:
|
# :call-seq:
|
||||||
# str.unicode_normalized?(form=:nfc)
|
# str.unicode_normalized?(form=:nfc)
|
||||||
#
|
#
|
||||||
|
|
|
@ -160,10 +160,6 @@ module UnicodeNormalize # :nodoc:
|
||||||
end # module
|
end # module
|
||||||
|
|
||||||
class String # :nodoc:
|
class String # :nodoc:
|
||||||
def unicode_normalize!(form = :nfc)
|
|
||||||
replace(UnicodeNormalize.normalize(self, form))
|
|
||||||
end
|
|
||||||
|
|
||||||
def unicode_normalized?(form = :nfc)
|
def unicode_normalized?(form = :nfc)
|
||||||
UnicodeNormalize.normalized?(self, form)
|
UnicodeNormalize.normalized?(self, form)
|
||||||
end
|
end
|
||||||
|
|
24
string.c
24
string.c
|
@ -9615,7 +9615,6 @@ rb_str_unicode_normalize(int argc, VALUE *argv, VALUE str)
|
||||||
rb_require("unicode_normalize/normalize.rb");
|
rb_require("unicode_normalize/normalize.rb");
|
||||||
UnicodeNormalizeRequired = 1;
|
UnicodeNormalizeRequired = 1;
|
||||||
}
|
}
|
||||||
/* return rb_funcall2(str, id_unicode_normalize, argc, argv); */
|
|
||||||
if (argc==0)
|
if (argc==0)
|
||||||
return rb_funcall(mUnicodeNormalize, id_normalize, 1, str);
|
return rb_funcall(mUnicodeNormalize, id_normalize, 1, str);
|
||||||
else if (argc==1)
|
else if (argc==1)
|
||||||
|
@ -9624,6 +9623,28 @@ rb_str_unicode_normalize(int argc, VALUE *argv, VALUE str)
|
||||||
rb_raise(rb_eArgError, "too many arguments to unicode_normalize");
|
rb_raise(rb_eArgError, "too many arguments to unicode_normalize");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* call-seq:
|
||||||
|
* str.unicode_normalize!(form=:nfc)
|
||||||
|
*
|
||||||
|
* Destructive version of String#unicode_normalize, doing Unicode
|
||||||
|
* normalization in place.
|
||||||
|
*/
|
||||||
|
static VALUE
|
||||||
|
rb_str_unicode_normalize_bang(int argc, VALUE *argv, VALUE str)
|
||||||
|
{
|
||||||
|
if (!UnicodeNormalizeRequired) {
|
||||||
|
rb_require("unicode_normalize/normalize.rb");
|
||||||
|
UnicodeNormalizeRequired = 1;
|
||||||
|
}
|
||||||
|
if (argc==0)
|
||||||
|
return rb_str_replace(str, rb_funcall(mUnicodeNormalize, id_normalize, 1, str));
|
||||||
|
else if (argc==1)
|
||||||
|
return rb_str_replace(str, rb_funcall(mUnicodeNormalize, id_normalize, 2, str, argv[0]));
|
||||||
|
else
|
||||||
|
rb_raise(rb_eArgError, "too many arguments to unicode_normalize!");
|
||||||
|
}
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* Document-class: Symbol
|
* Document-class: Symbol
|
||||||
*
|
*
|
||||||
|
@ -10277,6 +10298,7 @@ Init_String(void)
|
||||||
id_normalize = rb_intern("normalize");
|
id_normalize = rb_intern("normalize");
|
||||||
|
|
||||||
rb_define_method(rb_cString, "unicode_normalize", rb_str_unicode_normalize, -1);
|
rb_define_method(rb_cString, "unicode_normalize", rb_str_unicode_normalize, -1);
|
||||||
|
rb_define_method(rb_cString, "unicode_normalize!", rb_str_unicode_normalize_bang, -1);
|
||||||
|
|
||||||
rb_fs = Qnil;
|
rb_fs = Qnil;
|
||||||
rb_define_hooked_variable("$;", &rb_fs, 0, rb_fs_setter);
|
rb_define_hooked_variable("$;", &rb_fs, 0, rb_fs_setter);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue