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

revival of must_not_null() #5068

Merged
merged 1 commit into from
Nov 11, 2021
Merged
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
14 changes: 6 additions & 8 deletions include/ruby/internal/intern/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ RBIMPL_SYMBOL_EXPORT_BEGIN()
*/
VALUE rb_str_new(const char *ptr, long len);

RBIMPL_ATTR_NONNULL(())
/**
* Identical to rb_str_new(), except it assumes the passed pointer is a pointer
* to a C string.
*
* @param[in] ptr A C string.
* @exception rb_eNoMemError Failed to allocate memory.
* @exception rb_eArgError `ptr` is a null pointer.
* @return An instance of ::rb_cString, of "binary" encoding, whose
* contents are verbatim copy of `ptr`.
* @pre `ptr` must not be a null pointer.
Expand Down Expand Up @@ -122,14 +122,14 @@ VALUE rb_str_new_frozen(VALUE str);
*/
VALUE rb_str_new_with_class(VALUE obj, const char *ptr, long len);

RBIMPL_ATTR_NONNULL(())
/**
* @deprecated This function once was a thing in the old days, but makes no
* sense any longer today. Exists here for backwards
* compatibility only. You can safely forget about it.
*
* @param[in] ptr A C string.
* @exception rb_eNoMemError Failed to allocate memory.
* @exception rb_eArgError `ptr` is a null pointer.
* @return An instance of ::rb_cString, of "binary" encoding, whose
* contents are verbatim copy of `ptr`.
* @pre `ptr` must not be a null pointer.
Expand Down Expand Up @@ -333,7 +333,6 @@ VALUE rb_str_tmp_new(long len);
*/
VALUE rb_usascii_str_new(const char *ptr, long len);

RBIMPL_ATTR_NONNULL(())
/**
* Identical to rb_str_new_cstr(), except it generates a string of "US ASCII"
* encoding. It can also be seen as a routine Identical to
Expand All @@ -342,6 +341,7 @@ RBIMPL_ATTR_NONNULL(())
*
* @param[in] ptr A C string.
* @exception rb_eNoMemError Failed to allocate memory.
* @exception rb_eArgError `ptr` is a null pointer.
* @return An instance of ::rb_cString, of "US ASCII" encoding, whose
* contents are verbatim copy of `ptr`.
* @pre `ptr` must not be a null pointer.
Expand All @@ -361,7 +361,6 @@ VALUE rb_usascii_str_new_cstr(const char *ptr);
*/
VALUE rb_utf8_str_new(const char *ptr, long len);

RBIMPL_ATTR_NONNULL(())
/**
* Identical to rb_str_new_cstr(), except it generates a string of "UTF-8"
* encoding. It can also be seen as a routine Identical to
Expand All @@ -370,6 +369,7 @@ RBIMPL_ATTR_NONNULL(())
*
* @param[in] ptr A C string.
* @exception rb_eNoMemError Failed to allocate memory.
* @exception rb_eArgError `ptr` is a null pointer.
* @return An instance of ::rb_cString, of "UTF-8" encoding, whose contents
* are verbatim copy of `ptr`.
* @pre `ptr` must not be a null pointer.
Expand Down Expand Up @@ -553,7 +553,6 @@ VALUE rb_str_buf_append(VALUE dst, VALUE src);
/** @alias{rb_str_cat} */
VALUE rb_str_buf_cat(VALUE, const char*, long);

RBIMPL_ATTR_NONNULL(())
/** @alias{rb_str_cat_cstr} */
VALUE rb_str_buf_cat2(VALUE, const char*);

Expand Down Expand Up @@ -874,22 +873,21 @@ VALUE rb_str_resize(VALUE str, long len);
*/
VALUE rb_str_cat(VALUE dst, const char *src, long srclen);

RBIMPL_ATTR_NONNULL(())
/**
* Identical to rb_str_cat(), except it assumes the passed pointer is a pointer
* to a C string.
*
* @param[out] dst Destination object.
* @param[in] src Contents to append.
* @exception rb_eArgError Result string too big.
* @exception rb_eArgError `src` is a null pointer.
* @return The passed `dst`.
* @pre `dst` must not be any arbitrary objects except ::RString.
* @pre `src` must not be a null pointer.
* @post `dst` has the contents of `src` appended.
*/
VALUE rb_str_cat_cstr(VALUE dst, const char *src);

RBIMPL_ATTR_NONNULL(())
/** @alias{rb_str_cat_cstr} */
VALUE rb_str_cat2(VALUE, const char*);

Expand Down Expand Up @@ -1153,14 +1151,14 @@ VALUE rb_str_inspect(VALUE str);
*/
VALUE rb_str_dump(VALUE str);

RBIMPL_ATTR_NONNULL(())
/**
* Divides the given string based on the given delimiter. This is the
* 1-argument 0-block version of `String#split`.
*
* @param[in] str Object in question to split.
* @param[in] delim Delimiter, in C string.
* @exception rb_eTypeError `str` has no implicit conversion to String.
* @exception rb_eArgError `delim` is a null pointer.
* @return An array of strings, which are substrings of the passed `str`.
* If `delim` is an empty C string (i.e. `""`), `str` is split into
* each characters. If `delim` is a C string whose sole content is
Expand Down