@@ -101,12 +101,11 @@ ID rb_intern(const char *name);
101101ID rb_intern2 (const char *name, long len);
102102
103103/* *
104- * Identical to rb_intern(), except it takes an instance of ::rb_cString .
104+ * Identical to rb_intern(), except it takes a `T_STRING` object .
105105 *
106106 * @param[in] str The name of the id.
107- * @pre `str` must either be an instance of ::rb_cSymbol, or an instance
108- * of ::rb_cString, or responds to `#to_str` method.
109- * @exception rb_eTypeError Can't convert `str` into ::rb_cString.
107+ * @pre `rb_type(str)` must be `T_STRING`.
108+ * @exception rb_eEncodingError `str` contains invalid character(s).
110109 * @exception rb_eRuntimeError Too many symbols.
111110 * @return A (possibly new) id whose value is the given str.
112111 * @note These days Ruby internally has two kinds of symbols
@@ -166,29 +165,34 @@ RBIMPL_ATTR_NONNULL(())
166165 * of ::rb_cSymbol, or an instance of ::rb_cString, or responds
167166 * to `#to_str` method.
168167 * @exception rb_eTypeError Can't convert `*namep` into ::rb_cString.
169- * @exception rb_eEncodingError Given string is non-ASCII .
168+ * @exception rb_eEncodingError Given string contains invalid character(s) .
170169 * @retval 0 No such id ever existed in the history.
171170 * @retval otherwise The id that represents the given name.
172171 * @post The object that `*namep` points to is a converted result
173172 * object, which is always an instance of either ::rb_cSymbol
174173 * or ::rb_cString.
174+ * @see rb_str_to_str
175175 * @see https://bugs.ruby-lang.org/issues/5072
176- *
177- * @internal
178- *
179- * @shyouhei doesn't know why this has to raise rb_eEncodingError.
180176 */
181177ID rb_check_id(volatile VALUE *namep);
182178
183179/* *
184- * @copydoc rb_intern_str()
180+ * Identical to rb_intern_str(), except it tries to convert the parameter object
181+ * to an instance of ::rb_cString or its subclasses.
185182 *
186- * @internal
187- *
188- * :FIXME: Can anyone tell us what is the difference between this one and
189- * rb_intern_str()? As far as @shyouhei reads the implementation it seems what
190- * rb_to_id() does is just waste some CPU time, then call rb_intern_str().
191- * He hopes he is wrong.
183+ * @param[in] str The name of the id.
184+ * @pre `str` must either be an instance of ::rb_cSymbol, or an instance
185+ * of ::rb_cString, or responds to `#to_str` method.
186+ * @exception rb_eTypeError Can't convert `str` into ::rb_cString.
187+ * @exception rb_eEncodingError Given string contains invalid character(s).
188+ * @exception rb_eRuntimeError Too many symbols.
189+ * @return A (possibly new) id whose value is the given str.
190+ * @note These days Ruby internally has two kinds of symbols
191+ * (static/dynamic). Symbols created using this function would
192+ * become static ones; i.e. would never be garbage collected. It
193+ * is up to you to avoid memory leaks. Think twice before using
194+ * it.
195+ * @see rb_str_to_str
192196 */
193197ID rb_to_id (VALUE str);
194198
@@ -245,17 +249,14 @@ RBIMPL_ATTR_NONNULL(())
245249 * of ::rb_cSymbol, or an instance of ::rb_cString, or responds
246250 * to `#to_str` method.
247251 * @exception rb_eTypeError Can't convert `*namep` into ::rb_cString.
248- * @exception rb_eEncodingError Given string is non-ASCII .
252+ * @exception rb_eEncodingError Given string contains invalid character(s) .
249253 * @retval RUBY_Qnil No such id ever existed in the history.
250254 * @retval otherwise The id that represents the given name.
251255 * @post The object that `*namep` points to is a converted result
252256 * object, which is always an instance of either ::rb_cSymbol
253257 * or ::rb_cString.
254258 * @see https://bugs.ruby-lang.org/issues/5072
255- *
256- * @internal
257- *
258- * @shyouhei doesn't know why this has to raise rb_eEncodingError.
259+ * @see rb_str_to_str
259260 */
260261VALUE rb_check_symbol(volatile VALUE *namep);
261262RBIMPL_SYMBOL_EXPORT_END ()
0 commit comments