ruby-changes:46043
From: usa <ko1@a...>
Date: Sun, 26 Mar 2017 02:45:07 +0900 (JST)
Subject: [ruby-changes:46043] usa:r58114 (ruby_2_2): merge revision(s) 51871, 51872, 51874, 51875, 51876, 51877, 51878, 57517: [Backport #13190]
usa 2017-03-26 02:45:00 +0900 (Sun, 26 Mar 2017) New Revision: 58114 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58114 Log: merge revision(s) 51871,51872,51874,51875,51876,51877,51878,57517: [Backport #13190] * doc/syntax/literals.rdoc (Strings): mention about ?a literal. literals.rdoc: fix typos * doc/syntax/literals.rdoc (Strings): fix typos. * doc/syntax/literals.rdoc (Strings): [DOC] Document the full list of supported escape sequences in string literals. * doc/syntax/literals.rdoc (Strings): [DOC] Revise the character literal part. literals.rdoc: add DEL [ci skip] * doc/syntax/literals.rdoc (Strings): [DOC] add DEL. [DOC] `\0` is interpreted as NUL only if not followed by an octal digit. [DOC] Remove `\0` since it's aprt of octal notation A typo is fixed while at it. doc: Fix error for escape sequences in string literals Backslash goes first in escape sequences, so it must be "any other character following a backslash is interpreted as ...", while the doc says "...followed by...". Author: Marcus Stollsteimer <sto.mar@w...> [ruby-core:79418] [Bug #13190] Modified directories: branches/ruby_2_2/ Modified files: branches/ruby_2_2/ChangeLog branches/ruby_2_2/doc/syntax/literals.rdoc branches/ruby_2_2/version.h Index: ruby_2_2/doc/syntax/literals.rdoc =================================================================== --- ruby_2_2/doc/syntax/literals.rdoc (revision 58113) +++ ruby_2_2/doc/syntax/literals.rdoc (revision 58114) @@ -83,8 +83,33 @@ Any internal <tt>"</tt> must be escaped: https://github.com/ruby/ruby/blob/trunk/ruby_2_2/doc/syntax/literals.rdoc#L83 "This string has a quote: \". As you can see, it is escaped" -Double-quote strings allow escaped characters such as <tt>\n</tt> for newline, -<tt>\t</tt> for tab, etc. +Double-quote strings allow escaped characters such as <tt>\n</tt> for +newline, <tt>\t</tt> for tab, etc. The full list of supported escape +sequences are as follows: + + \a bell, ASCII 07h (BEL) + \b backspace, ASCII 08h (BS) + \t horizontal tab, ASCII 09h (TAB) + \n newline (line feed), ASCII 0Ah (LF) + \v vertical tab, ASCII 0Bh (VT) + \f form feed, ASCII 0Ch (FF) + \r carriage return, ASCII 0Dh (CR) + \e escape, ASCII 1Bh (ESC) + \s space, ASCII 20h (SPC) + \\ backslash, \ + \nnn octal bit pattern, where nnn is 1-3 octal digits ([0-7]) + \xnn hexadecimal bit pattern, where nn is 1-2 hexadecimal digits ([0-9a-fA-F]) + \unnnn Unicode character, where nnnn is exactly 4 hexadecimal digits ([0-9a-fA-F]) + \u{nnnn ...} Unicode character(s), where each nnnn is 1-6 hexadecimal digits ([0-9a-fA-F]) + \cx or \C-x control character, where x is an ASCII printable character + \M-x meta character, where x is an ASCII printable character + \M-\C-x meta control character, where x is an ASCII printable character + \M-\cx same as above + \c\M-x same as above + \c? or \C-? delete, ASCII 7Fh (DEL) + +Any other character following a backslash is interpreted as the +character itself. Double-quote strings allow interpolation of other values using <tt>#{...}</tt>: @@ -124,6 +149,23 @@ be concatenated as long as a percent-str https://github.com/ruby/ruby/blob/trunk/ruby_2_2/doc/syntax/literals.rdoc#L149 %q{a} 'b' "c" #=> "abc" "a" 'b' %q{c} #=> NameError: uninitialized constant q +One more way of writing strings is using <tt>?</tt>: + + ?a #=> "a" + +Basically only one character can be placed after <tt>?</tt>: + + ?abc #=> SyntaxError + +Exceptionally, <tt>\C-</tt>, <tt>\M-</tt> and their combination are allowed +before a character. They mean "control", "meta" and "control-meta" +respectively: + + ?\C-a #=> "\x01" + ?\M-a #=> "\xE1" + ?\M-\C-a #=> "\x81" + ?\C-\M-a #=> "\x81", same as above + === Here Documents If you are writing a large block of text you may use a "here document" or Index: ruby_2_2/version.h =================================================================== --- ruby_2_2/version.h (revision 58113) +++ ruby_2_2/version.h (revision 58114) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1 #define RUBY_VERSION "2.2.7" #define RUBY_RELEASE_DATE "2017-03-26" -#define RUBY_PATCHLEVEL 446 +#define RUBY_PATCHLEVEL 447 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 3 Index: ruby_2_2/ChangeLog =================================================================== --- ruby_2_2/ChangeLog (revision 58113) +++ ruby_2_2/ChangeLog (revision 58114) @@ -1,3 +1,17 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1 +Sun Mar 26 02:44:16 2017 Akinori MUSHA <knu@i...> + + * doc/syntax/literals.rdoc (Strings): [DOC] Revise the character + literal part. + +Sun Mar 26 02:44:16 2017 Akinori MUSHA <knu@i...> + + * doc/syntax/literals.rdoc (Strings): [DOC] Document the full list + of supported escape sequences in string literals. + +Sun Mar 26 02:44:16 2017 NAKAMURA Usaku <usa@r...> + + * doc/syntax/literals.rdoc (Strings): mention about ?a literal. + Sun Mar 26 02:35:17 2017 Nobuyoshi Nakada <nobu@r...> * ruby.c (process_options): convert -e script to the encoding Property changes on: ruby_2_2 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r51871-51872,51876-51878,57517 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/