changeset 20076:dbf2418a46dd

Document expansion of escape sequences in single quotes (bug #44745). * io.txi: Note that all *printf functions expand escape sequences. * error.cc (Ferror, Fwarning): Note that escape sequences are expanded. * file-io.cc (Fprintf, Ffprintf, Fsprintf): Note that escape sequences are expanded. * regexp.cc (Fregexp, Fregexprep): Note that escape sequences are expanded.
author Rik <rik@octave.org>
date Tue, 07 Apr 2015 21:18:22 -0700
parents 055ad6fbc910
children dc1b0043c54f 302e48c2de5d
files doc/interpreter/io.txi libinterp/corefcn/error.cc libinterp/corefcn/file-io.cc libinterp/corefcn/regexp.cc
diffstat 4 files changed, 36 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/doc/interpreter/io.txi	Tue Apr 07 18:29:01 2015 -0700
+++ b/doc/interpreter/io.txi	Tue Apr 07 21:18:22 2015 -0700
@@ -392,6 +392,10 @@
 interpret the format template differently in order to improve the
 performance of printing vector and matrix values.
 
+Implementation Note: For compatability with @sc{matlab}, escape sequences in
+the template string (e.g., @qcode{"\n"} => newline) are expanded even
+when the template string is defined with single quotes.
+
 @DOCSTRING(printf)
 
 @DOCSTRING(fprintf)
--- a/libinterp/corefcn/error.cc	Tue Apr 07 18:29:01 2015 -0700
+++ b/libinterp/corefcn/error.cc	Tue Apr 07 21:18:22 2015 -0700
@@ -1093,11 +1093,11 @@
 which will only stop execution if an error has been found.\n\
 \n\
 Implementation Note: For compatibility with @sc{matlab}, escape\n\
-sequences (e.g., \"\\n\" => newline) are processed in @var{template}\n\
-regardless of whether @var{template} has been defined within single quotes\n\
-as long as there are two or more input arguments.\n\
-Use a second backslash to stop interpolation of the escape sequence (e.g.,\n\
-\"\\\\n\") or use the @code{regexptranslate} function.\n\
+sequences in @var{template} (e.g., \"\\n\" => newline) are processed\n\
+regardless of whether @var{template} has been defined with single quotes,\n\
+as long as there are two or more input arguments.  To disable escape sequence\n\
+expansion use a second backslash before the sequence (e.g., \"\\\\n\") or\n\
+use the @code{regexptranslate} function.\n\
 @seealso{warning, lasterror}\n\
 @end deftypefn")
 {
@@ -1392,11 +1392,11 @@
 workspace.\n\
 \n\
 Implementation Note: For compatibility with @sc{matlab}, escape\n\
-sequences (e.g., \"\\n\" => newline) are processed in @var{template}\n\
-regardless of whether @var{template} has been defined within single quotes\n\
-as long as there are two or more input arguments.\n\
-Use a second backslash to stop interpolation of the escape sequence (e.g.,\n\
-\"\\\\n\") or use the @code{regexptranslate} function.\n\
+sequences in @var{template} (e.g., \"\\n\" => newline) are processed\n\
+regardless of whether @var{template} has been defined with single quotes,\n\
+as long as there are two or more input arguments.  To disable escape sequence\n\
+expansion use a second backslash before the sequence (e.g., \"\\\\n\") or\n\
+use the @code{regexptranslate} function.\n\
 @seealso{warning_ids, lastwarn, error}\n\
 @end deftypefn")
 {
--- a/libinterp/corefcn/file-io.cc	Tue Apr 07 18:29:01 2015 -0700
+++ b/libinterp/corefcn/file-io.cc	Tue Apr 07 21:18:22 2015 -0700
@@ -888,6 +888,10 @@
 function exactly equivalent to @code{printf}.\n\
 \n\
 The optional output returns the number of bytes written to the file.\n\
+\n\
+Implementation Note: For compatability with @sc{matlab}, escape sequences in\n\
+the template string (e.g., @qcode{\"\\\\n\"} => newline) are expanded even\n\
+when the template string is defined with single quotes.\n\
 @seealso{fputs, fdisp, fwrite, fscanf, printf, sprintf, fopen}\n\
 @end deftypefn")
 {
@@ -954,6 +958,10 @@
 See the Formatted Output section of the GNU Octave manual for a\n\
 complete description of the syntax of the template string.\n\
 @end ifclear\n\
+\n\
+Implementation Note: For compatability with @sc{matlab}, escape sequences in\n\
+the template string (e.g., @qcode{\"\\\\n\"} => newline) are expanded even\n\
+when the template string is defined with single quotes.\n\
 @seealso{fprintf, sprintf, scanf}\n\
 @end deftypefn")
 {
@@ -1059,6 +1067,10 @@
 suitably sized string as an argument, Octave's @code{sprintf} function\n\
 returns the string, automatically sized to hold all of the items\n\
 converted.\n\
+\n\
+Implementation Note: For compatability with @sc{matlab}, escape sequences in\n\
+the template string (e.g., @qcode{\"\\\\n\"} => newline) are expanded even\n\
+when the template string is defined with single quotes.\n\
 @seealso{printf, fprintf, sscanf}\n\
 @end deftypefn")
 {
--- a/libinterp/corefcn/regexp.cc	Tue Apr 07 18:29:01 2015 -0700
+++ b/libinterp/corefcn/regexp.cc	Tue Apr 07 21:18:22 2015 -0700
@@ -677,11 +677,11 @@
 Match within a word\n\
 @end table\n\
 \n\
-Implementation Note: For compatibility with @sc{matlab}, ordinary escape\n\
-sequences (e.g., @qcode{\"\\n\"} => newline) are processed in @var{pat}\n\
-regardless of whether @var{pat} has been defined within single quotes.  Use\n\
-a second backslash to stop interpolation of the escape sequence (e.g.,\n\
-\"\\\\n\") or use the @code{regexptranslate} function.\n\
+Implementation Note: For compatibility with @sc{matlab}, escape sequences\n\
+in @var{pat} (e.g., @qcode{\"\\\\n\"} => newline) are expanded even when\n\
+@var{pat} has been defined with single quotes.  To disable expansion use\n\
+a second backslash before the escape sequence (e.g., \"\\\\n\") or use the\n\
+@code{regexptranslate} function.\n\
 \n\
 The outputs of @code{regexp} default to the order given below\n\
 \n\
@@ -1309,11 +1309,11 @@
 \n\
 @end table\n\
 \n\
-Implementation Note: For compatibility with @sc{matlab}, ordinary escape\n\
-sequences (e.g., @qcode{\"\\n\"} => newline) are processed in both @var{pat}\n\
-and @var{repstr} regardless of whether they were defined within single\n\
-quotes.  Use a second backslash to stop interpolation of the escape sequence\n\
-(e.g., \"\\\\n\") or use the @code{regexptranslate} function.\n\
+Implementation Note: For compatibility with @sc{matlab}, escape sequences\n\
+in @var{pat} (e.g., @qcode{\"\\\\n\"} => newline) are expanded even when\n\
+@var{pat} has been defined with single quotes.  To disable expansion use\n\
+a second backslash before the escape sequence (e.g., \"\\\\n\") or use the\n\
+@code{regexptranslate} function.\n\
 @seealso{regexp, regexpi, strrep}\n\
 @end deftypefn")
 {