diff --git a/ChangeLog b/ChangeLog index b3cad04f43..e326bb288e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Tue Jul 24 07:03:11 2012 Eric Hodel + + * string.c (rb_str_sub): Fixed wording of documentation to match the + replacement operation. Minor cleanup of markup. [Bug #6719] + * string.c (rb_str_sub_bang): Minor wording change for clarity, minor + cleanup of markup. + Mon Jul 23 23:58:40 2012 Nobuyoshi Nakada * enc/Makefile.in (TARGET_NAME, TARGET_ENTRY): needed for EXTDLDFLAGS diff --git a/string.c b/string.c index d038835c72..c3a0ae2038 100644 --- a/string.c +++ b/string.c @@ -3620,9 +3620,10 @@ get_pat(VALUE pat, int quote) * str.sub!(pattern, replacement) -> str or nil * str.sub!(pattern) {|match| block } -> str or nil * - * Performs the substitutions of String#sub in place, - * returning str, or nil if no substitutions were - * performed. + * Performs the same substitution as String#sub in-place. + * + * Returns +str+ if a substitution was performed or +nil+ if no substitution + * was performed. */ static VALUE @@ -3731,23 +3732,22 @@ rb_str_sub_bang(int argc, VALUE *argv, VALUE str) * str.sub(pattern, hash) -> new_str * str.sub(pattern) {|match| block } -> new_str * - * Returns a copy of str with the first occurrence of - * pattern substituted for the second argument. The pattern is - * typically a Regexp; if given as a String, any - * regular expression metacharacters it contains will be interpreted - * literally, e.g. '\\\d' will match a backlash followed by 'd', - * instead of a digit. + * Returns a copy of +str+ with the _first_ occurrence of +pattern+ + * replaced by the second argument. The +pattern+ is typically a Regexp; if + * given as a String, any regular expression metacharacters it contains will + * be interpreted literally, e.g. '\\\d' will match a backlash + * followed by 'd', instead of a digit. * - * If replacement is a String it will be substituted for - * the matched text. It may contain back-references to the pattern's capture - * groups of the form \\\d, where d is a group number, or - * \\\k, where n is a group name. If it is a + * If +replacement+ is a String it will be substituted for the matched text. + * It may contain back-references to the pattern's capture groups of the form + * "\\d", where d is a group number, or + * "\\k", where n is a group name. If it is a * double-quoted string, both back-references must be preceded by an - * additional backslash. However, within replacement the special match + * additional backslash. However, within +replacement+ the special match * variables, such as &$, will not refer to the current match. * - * If the second argument is a Hash, and the matched text is one - * of its keys, the corresponding value is the replacement string. + * If the second argument is a Hash, and the matched text is one of its keys, + * the corresponding value is the replacement string. * * In the block form, the current match string is passed in as a parameter, * and variables such as $1, $2, $`,