summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2021-02-18 15:35:55 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2021-09-10 20:00:06 +0900
commit091faca99ca92cb1146b3c4d8ebba67f4822561c (patch)
tree08b052fecf66fab8320b47eeef86ed1232b304a8 /string.c
parent1bdae3773f224dd711a601fbb0add5eea6b455fa (diff)
include/ruby/internal/intern/string.h: add doygen
Must not be a bad idea to improve documents. [ci skip]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4815
Diffstat (limited to 'string.c')
-rw-r--r--string.c25
1 files changed, 5 insertions, 20 deletions
diff --git a/string.c b/string.c
index 72de7d26e2..cbec890313 100644
--- a/string.c
+++ b/string.c
@@ -804,7 +804,11 @@ str_new0(VALUE klass, const char *ptr, long len, int termlen)
str = str_alloc(klass);
if (!STR_EMBEDDABLE_P(len, termlen)) {
RSTRING(str)->as.heap.aux.capa = len;
- RSTRING(str)->as.heap.ptr = ALLOC_N(char, (size_t)len + termlen);
+ /* :FIXME: @shyouhei guesses `len + termlen` is guaranteed to never
+ * integer overflow. If we can STATIC_ASSERT that, the following
+ * mul_add_mul can be reverted to a simple ALLOC_N. */
+ RSTRING(str)->as.heap.ptr =
+ rb_xmalloc_mul_add_mul(sizeof(char), len, sizeof(char), termlen);
STR_SET_NOEMBED(str);
}
else if (len == 0) {
@@ -10487,20 +10491,6 @@ rb_str_is_ascii_only_p(VALUE str)
return RBOOL(cr == ENC_CODERANGE_7BIT);
}
-/**
- * Shortens _str_ and adds three dots, an ellipsis, if it is longer
- * than _len_ characters.
- *
- * \param str the string to ellipsize.
- * \param len the maximum string length.
- * \return the ellipsized string.
- * \pre _len_ must not be negative.
- * \post the length of the returned string in characters is less than or equal to _len_.
- * \post If the length of _str_ is less than or equal _len_, returns _str_ itself.
- * \post the encoding of returned string is equal to the encoding of _str_.
- * \post the class of returned string is equal to the class of _str_.
- * \note the length is counted in characters.
- */
VALUE
rb_str_ellipsize(VALUE str, long len)
{
@@ -10559,11 +10549,6 @@ str_compat_and_valid(VALUE str, rb_encoding *enc)
static VALUE enc_str_scrub(rb_encoding *enc, VALUE str, VALUE repl, int cr);
-/**
- * @param str the string to be scrubbed
- * @param repl the replacement character
- * @return If given string is invalid, returns a new string. Otherwise, returns Qnil.
- */
VALUE
rb_str_scrub(VALUE str, VALUE repl)
{