summaryrefslogtreecommitdiffstats
path: root/scilab/modules/output_stream
diff options
context:
space:
mode:
authorClément David <clement.david@esi-group.com>2021-07-15 15:50:48 +0200
committerClément David <clement.david@esi-group.com>2021-07-15 15:50:48 +0200
commit81a9cc049332de0c712cf56da585fcd25c8e59e3 (patch)
treef365c25a05c1782a16b2985bf7481116c106952d /scilab/modules/output_stream
parentb0937f19e4b8ddf416ca9a9a433bcbbd3f4ef2c0 (diff)
parent90b4ecb9b57ac6ad4e00d4a99b0d8bd1a6424403 (diff)
downloadscilab-master.zip
scilab-master.tar.gz
Merge remote-tracking branch 'origin/6.1'HEADmaster
Change-Id: I5d26fc380a28efe0bb6d0096fe9684b274b55bfe
Diffstat (limited to 'scilab/modules/output_stream')
-rw-r--r--scilab/modules/output_stream/Makefile.in2
-rw-r--r--scilab/modules/output_stream/help/en_US/mprintf.xml123
-rw-r--r--scilab/modules/output_stream/help/en_US/msprintf.xml134
-rw-r--r--scilab/modules/output_stream/help/en_US/printf_conversion.xml433
-rw-r--r--scilab/modules/output_stream/help/ja_JP/mprintf.xml112
-rw-r--r--scilab/modules/output_stream/help/ja_JP/msprintf.xml90
-rw-r--r--scilab/modules/output_stream/help/ja_JP/printf_conversion.xml400
-rw-r--r--scilab/modules/output_stream/help/pt_BR/printf_conversion.xml538
-rw-r--r--scilab/modules/output_stream/macros/%b_mfprintf.sci15
-rw-r--r--scilab/modules/output_stream/macros/%b_mprintf.sci15
-rw-r--r--scilab/modules/output_stream/macros/%b_msprintf.sci15
-rw-r--r--scilab/modules/output_stream/macros/%printf_boolean.sci34
-rw-r--r--scilab/modules/output_stream/tests/unit_tests/mprintf.dia.ref98
-rw-r--r--scilab/modules/output_stream/tests/unit_tests/mprintf.tst31
-rw-r--r--scilab/modules/output_stream/tests/unit_tests/msprintf.tst32
15 files changed, 1455 insertions, 617 deletions
diff --git a/scilab/modules/output_stream/Makefile.in b/scilab/modules/output_stream/Makefile.in
index fef6335..d68c09f 100644
--- a/scilab/modules/output_stream/Makefile.in
+++ b/scilab/modules/output_stream/Makefile.in
@@ -512,9 +512,11 @@ NMEDIT = @NMEDIT@
512OBJDUMP = @OBJDUMP@ 512OBJDUMP = @OBJDUMP@
513OBJEXT = @OBJEXT@ 513OBJEXT = @OBJEXT@
514OCAMLC = @OCAMLC@ 514OCAMLC = @OCAMLC@
515OCAMLCFLAGS = @OCAMLCFLAGS@
515OCAMLDEP = @OCAMLDEP@ 516OCAMLDEP = @OCAMLDEP@
516OCAMLLEX = @OCAMLLEX@ 517OCAMLLEX = @OCAMLLEX@
517OCAMLOPT = @OCAMLOPT@ 518OCAMLOPT = @OCAMLOPT@
519OCAMLOPTFLAGS = @OCAMLOPTFLAGS@
518OCAMLYACC = @OCAMLYACC@ 520OCAMLYACC = @OCAMLYACC@
519OPENMPI_CC = @OPENMPI_CC@ 521OPENMPI_CC = @OPENMPI_CC@
520OPENMPI_CFLAGS = @OPENMPI_CFLAGS@ 522OPENMPI_CFLAGS = @OPENMPI_CFLAGS@
diff --git a/scilab/modules/output_stream/help/en_US/mprintf.xml b/scilab/modules/output_stream/help/en_US/mprintf.xml
index 716bfff..f3ee5b2 100644
--- a/scilab/modules/output_stream/help/en_US/mprintf.xml
+++ b/scilab/modules/output_stream/help/en_US/mprintf.xml
@@ -3,8 +3,8 @@
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) 2008 - INRIA 4 * Copyright (C) 2008 - INRIA
5 * ... 5 * ...
6 *
7 * Copyright (C) 2012 - 2016 - Scilab Enterprises 6 * Copyright (C) 2012 - 2016 - Scilab Enterprises
7 * Copyright (C) 2021 - Samuel GOUGEON
8 * 8 *
9 * This file is hereby licensed under the terms of the GNU GPL v2.0, 9 * This file is hereby licensed under the terms of the GNU GPL v2.0,
10 * pursuant to article 5.3.4 of the CeCILL v.2.1. 10 * pursuant to article 5.3.4 of the CeCILL v.2.1.
@@ -38,19 +38,21 @@
38 <varlistentry> 38 <varlistentry>
39 <term>format</term> 39 <term>format</term>
40 <listitem> 40 <listitem>
41 <para>a Scilab string describing the format to use to write the 41 <para>a string providing the format to use to write all next arguments.
42 remaining operands. The format operand follows, as close as 42 The <varname>format</varname> follows -- as close as possible -- the C printf
43 possible, the C printf format operand syntax, as described 43 format operand syntax, as described in the
44 in the <link linkend="printf_conversion">printf_conversion</link> 44 <link linkend="printf_conversion">printf_conversion</link> page.
45 page. 45 UTF-8 extended characters and numbered placeholders "%n$.." are supported.
46 </para> 46 </para>
47 </listitem> 47 </listitem>
48 </varlistentry> 48 </varlistentry>
49 <varlistentry> 49 <varlistentry>
50 <term>a1,...,an</term> 50 <term>a1,...,an</term>
51 <listitem> 51 <listitem>
52 <para>Specifies the data to be converted and printed according to 52 <para>
53 the format parameter. 53 Data to be converted and printed according to the <varname>format</varname>
54 argument. Supported types: all numbers, booleans, strings. Only the real part
55 of complex numbers is considered (current Scilab limitation).
54 </para> 56 </para>
55 </listitem> 57 </listitem>
56 </varlistentry> 58 </varlistentry>
@@ -59,32 +61,117 @@
59 <refsection> 61 <refsection>
60 <title>Description</title> 62 <title>Description</title>
61 <para> 63 <para>
62 The <literal>mprintf</literal> function is a interface for C-coded version of 64 <literal>mprintf(format, a1, a2, ..)</literal> replaces placeholders provided inside the
63 <literal>printf</literal> function. 65 <varname>format</varname> string with values of <varname>a1</varname>, <varname>a2</varname>, ..
66 converted according to each respective placeholder directive, and writes the result to
67 the Scilab console.
68 </para>
69 <para>
70 If <varname>a1</varname>, <varname>a2</varname>, .. are arrays with multiple rows,
71 they feed the format row by row: the format is used iteratively for every row of the
72 (horizontally "concatenated") arrays, until the bottom
73 of the least tall array is reached. Remaining rows of taller arrays (if any) are ignored.
74 See examples.
75 </para>
76 <para>
77 If the total number of columns of <varname>a1</varname>, <varname>a2</varname>, ..
78 is bigger than the number of placeholders in the <varname>format</varname>,
79 then extra columns are ignored. If it is smaller, an error is yielded.
64 </para> 80 </para>
65 <para> 81 <para>
66 The <literal>mprintf</literal> function writes formatted operands to 82 The <literal>mprintf</literal> function is an extended interface for C-coded
67 the standard Scilab output (i.e the Scilab window). The argument operands 83 <literal>printf</literal>.
68 are formatted under control of the format operand.
69 </para> 84 </para>
70 </refsection> 85 </refsection>
71 <refsection> 86 <refsection>
72 <title>Examples</title> 87 <title>Examples</title>
73 <programlisting role="example"><![CDATA[ 88 <programlisting role="example"><![CDATA[
74mprintf('At iteration %i, Result is:\nalpha=%f',33,0.535) 89I = (1:4)';
75mprintf('%e ', [1; 2; 3]) 90A = [26.93 ; 63.25 ; 40.51 ; 91.84];
76mprintf('%d %d\n', [1, 2; 3, 4]) 91B = [ 3.62 ; 15.04 ; 25.3 ; 48.19];
77 ]]></programlisting> 92C = [ 4.37 28.06
93 48.18 %inf
94 41.48 %nan
95 26.39 77.83];
96Status = ["NOK" "NOK" "NOK" "OK"]';
97Format = "Iteration %d: Results: A= %f B= %2d%% Status= %3s C(1)= %g C(2)= %e\n";
98mprintf(Format, I, A, B, Status, C);
99 ]]></programlisting>
100 <screen><![CDATA[
101--> mprintf(Format, I, A, B, Status, C);
102Iteration 1: Results: A= 26.930000 B= 3% Status= NOK C(1)= 4.37 C(2)= 2.806000e+01
103Iteration 2: Results: A= 63.250000 B= 15% Status= NOK C(1)= 48.18 C(2)= Inf
104Iteration 3: Results: A= 40.510000 B= 25% Status= NOK C(1)= 41.48 C(2)= Nan
105Iteration 4: Results: A= 91.840000 B= 48% Status= OK C(1)= 26.39 C(2)= 7.783000e+01
106]]></screen>
107 <para/>
108 <para>
109 Supernumerary columns or rows are ignored:
110 </para>
111 <programlisting role="example"><![CDATA[
112A = [%T %F %T %T %F]';
113B = [ 4.37 28.06
114 48.18 %inf
115 41.48 %nan ];
116mprintf("OK? %s Value: %4.1f\n", A, B);
117 ]]></programlisting>
118 <screen><![CDATA[
119--> mprintf("OK? %s Value: %4.1f\n", A, B);
120OK? T Value: 4.4
121OK? F Value: 48.2
122OK? T Value: 41.5
123]]></screen>
124 <para/>
125 <para>
126 Numbered placeholders "%n$.." allow reordering printed data with the format:
127 </para>
128 <programlisting role="example"><![CDATA[
129names = ["Peter", "Martha" "John"]';
130ages = [32 25 8]';
131mprintf("%2$6s is %1$d-year old.\n", ages, names);
132 ]]></programlisting>
133 <screen><![CDATA[
134--> mprintf("%2$6s is %1$d-year old.\n", ages, names);
135 Peter is 32-year old.
136Martha is 25-year old.
137 John is 8-year old.
138]]></screen>
78 </refsection> 139 </refsection>
79 <refsection role="see also"> 140 <refsection role="see also">
80 <title>See also</title> 141 <title>See also</title>
81 <simplelist type="inline"> 142 <simplelist type="inline">
82 <member> 143 <member>
144 <link linkend="printf_conversion">printf_conversion</link>
145 </member>
146 <member>
83 <link linkend="disp">disp</link> 147 <link linkend="disp">disp</link>
84 </member> 148 </member>
85 <member> 149 <member>
86 <link linkend="printf_conversion">printf_conversion</link> 150 <link linkend="write">write</link>
151 </member>
152 <member>
153 <link linkend="percentio">percentio</link>
154 </member>
155 <member>
156 <link linkend="percentchars">percentchars</link>
87 </member> 157 </member>
88 </simplelist> 158 </simplelist>
89 </refsection> 159 </refsection>
160 <refsection role="history">
161 <title>History</title>
162 <revhistory>
163 <revision>
164 <revnumber>6.1.0</revnumber>
165 <revdescription>
166 Numbered placeholders "%n$.." are supported in the format.
167 </revdescription>
168 </revision>
169 <revision>
170 <revnumber>6.1.1</revnumber>
171 <revdescription>
172 Input data can be boolean.
173 </revdescription>
174 </revision>
175 </revhistory>
176 </refsection>
90</refentry> 177</refentry>
diff --git a/scilab/modules/output_stream/help/en_US/msprintf.xml b/scilab/modules/output_stream/help/en_US/msprintf.xml
index 1633f14..6f03a58 100644
--- a/scilab/modules/output_stream/help/en_US/msprintf.xml
+++ b/scilab/modules/output_stream/help/en_US/msprintf.xml
@@ -3,8 +3,8 @@
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) 2008 - INRIA 4 * Copyright (C) 2008 - INRIA
5 * ... 5 * ...
6 *
7 * Copyright (C) 2012 - 2016 - Scilab Enterprises 6 * Copyright (C) 2012 - 2016 - Scilab Enterprises
7 * Copyright (C) 2021 - Samuel GOUGEON
8 * 8 *
9 * This file is hereby licensed under the terms of the GNU GPL v2.0, 9 * This file is hereby licensed under the terms of the GNU GPL v2.0,
10 * pursuant to article 5.3.4 of the CeCILL v.2.1. 10 * pursuant to article 5.3.4 of the CeCILL v.2.1.
@@ -14,7 +14,10 @@
14 * along with this program. 14 * along with this program.
15 * 15 *
16 --> 16 -->
17<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="msprintf" xml:lang="en"> 17<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
18 xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml"
19 xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook"
20 xmlns:scilab="http://www.scilab.org" xml:id="msprintf" xml:lang="en">
18 <refnamediv> 21 <refnamediv>
19 <refname>msprintf</refname> 22 <refname>msprintf</refname>
20 <refpurpose>converts, formats, and writes data in a string</refpurpose> 23 <refpurpose>converts, formats, and writes data in a string</refpurpose>
@@ -25,7 +28,7 @@
25 </refnamediv> 28 </refnamediv>
26 <refsynopsisdiv> 29 <refsynopsisdiv>
27 <title>Syntax</title> 30 <title>Syntax</title>
28 <synopsis>str = msprintf(format,a1,...,an);</synopsis> 31 <synopsis>str = msprintf(format, a1,...,an)</synopsis>
29 </refsynopsisdiv> 32 </refsynopsisdiv>
30 <refsection> 33 <refsection>
31 <title>Arguments</title> 34 <title>Arguments</title>
@@ -33,23 +36,29 @@
33 <varlistentry> 36 <varlistentry>
34 <term>format</term> 37 <term>format</term>
35 <listitem> 38 <listitem>
36 <para>a Scilab string describing the format to use to write the 39 <para>
37 remaining operands. 40 a string providing the format to use to write all next arguments.
41 The <varname>format</varname> follows -- as close as possible -- the C printf
42 format operand syntax, as described in the
43 <link linkend="printf_conversion">printf_conversion</link> page.
44 UTF-8 extended characters and numbered placeholders "%n$.." are supported.
38 </para> 45 </para>
39 </listitem> 46 </listitem>
40 </varlistentry> 47 </varlistentry>
41 <varlistentry> 48 <varlistentry>
42 <term>str</term> 49 <term>a1,...,an</term>
43 <listitem> 50 <listitem>
44 <para>a character string.</para> 51 <para>
52 Data to be converted and written according to the <varname>format</varname>
53 argument. Supported types: all numbers, booleans, strings. Only the real part
54 of complex numbers is considered (current Scilab limitation).
55 </para>
45 </listitem> 56 </listitem>
46 </varlistentry> 57 </varlistentry>
47 <varlistentry> 58 <varlistentry>
48 <term>a1,...,an</term> 59 <term>str</term>
49 <listitem> 60 <listitem>
50 <para>Specifies the data to be converted and printed according to 61 <para>a string, or a column of strings.</para>
51 the format parameter.
52 </para>
53 </listitem> 62 </listitem>
54 </varlistentry> 63 </varlistentry>
55 </variablelist> 64 </variablelist>
@@ -57,14 +66,28 @@
57 <refsection> 66 <refsection>
58 <title>Description</title> 67 <title>Description</title>
59 <para> 68 <para>
60 The <literal>msprintf</literal> writes formatted operands in its 69 <literal>str=msprintf(format, a1, a2, ..)</literal> replaces placeholders provided
61 returned value (a Scilab string). The argument operands are formatted 70 inside the <varname>format</varname> string with values of <varname>a1</varname>,
62 under control of the format operand. 71 <varname>a2</varname>, .. converted according to each respective placeholder directive,
72 and set the result to the <varname>str</varname> string.
73 </para>
74 <para>
75 If <varname>a1</varname>, <varname>a2</varname>, .. are arrays with multiple rows,
76 they feed the format row by row: the format is used iteratively for every row of the
77 (horizontally "concatenated") arrays, until the bottom
78 of the least tall array is reached. Remaining rows of taller arrays (if any) are ignored.
79 See examples.
80 </para>
81 <para>
82 If the total number of columns of <varname>a1</varname>, <varname>a2</varname>, ..
83 is bigger than the number of placeholders in the <varname>format</varname>,
84 then extra columns are ignored. If it is smaller, an error is yielded.
63 </para> 85 </para>
64 <para> 86 <para>
65 <note> 87 <note>
66 Note that, in this case, the escape sequences (<literal>"\n"</literal>) (in format) 88 If either the <varname>format</varname> includes some Next_line "\n" sequence,
67 split string to a matrix of string (see example). 89 or if all arrays <varname>a1</varname>, <varname>a2</varname>.. have at least 2 rows,
90 the result <varname>str</varname> is a column of strings. See examples.
68 </note> 91 </note>
69 </para> 92 </para>
70 </refsection> 93 </refsection>
@@ -76,17 +99,92 @@ msprintf('%5.3f\n%5.3f',123,0.732)
76msprintf('--%s-\n-%d--',"hello",3) 99msprintf('--%s-\n-%d--',"hello",3)
77msprintf('%e ', [1;2;3]) 100msprintf('%e ', [1;2;3])
78msprintf('%d %d\n', [1, 2; 3, 4]) 101msprintf('%d %d\n', [1, 2; 3, 4])
79 ]]></programlisting> 102 ]]></programlisting>
103 <para/>
104 <programlisting role="example"><![CDATA[
105I = (1:4)';
106A = [26.93 ; 63.25 ; 40.51 ; 91.84];
107B = [ 3.62 ; 15.04 ; 25.3 ; 48.19];
108C = [ 4.37 28.06
109 48.18 %inf
110 41.48 %nan
111 26.39 77.83];
112Status = ["NOK" "NOK" "NOK" "OK"]';
113Format = "Iteration %d: Results: A= %f B= %2d%% Status= %3s C(1)= %g C(2)= %e\n";
114msprintf(Format, I, A, B, Status, C)
115 ]]></programlisting>
116 <screen><![CDATA[
117--> msprintf(Format, I, A, B, Status, C)
118 ans =
119 "Iteration 1: Results: A= 26.930000 B= 3% Status= NOK C(1)= 4.37 C(2)= 2.806000e+01"
120 "Iteration 2: Results: A= 63.250000 B= 15% Status= NOK C(1)= 48.18 C(2)= Inf"
121 "Iteration 3: Results: A= 40.510000 B= 25% Status= NOK C(1)= 41.48 C(2)= Nan"
122 "Iteration 4: Results: A= 91.840000 B= 48% Status= OK C(1)= 26.39 C(2)= 7.783000e+01"
123]]></screen>
124 <para/>
125 <para>
126 Supernumerary columns or rows are ignored:
127 </para>
128 <programlisting role="example"><![CDATA[
129A = [%T %F %T %T %F]';
130B = [ 4.37 28.06
131 48.18 %inf
132 41.48 %nan ];
133msprintf("OK? %s Value: %4.1f\n", A, B)
134 ]]></programlisting>
135 <screen><![CDATA[
136--> msprintf("OK? %s Value: %4.1f\n", A, B)
137 ans =
138 "OK? T Value: 4.4"
139 "OK? F Value: 48.2"
140 "OK? T Value: 41.5"
141]]></screen>
142 <para/>
143 <para>
144 Numbered placeholders "%n$.." allow reordering printed data with the format:
145 </para>
146 <programlisting role="example"><![CDATA[
147names = ["Peter", "Martha" "John"]';
148ages = [32 25 8]';
149msprintf("%2$6s is %1$d-year old.\n", ages, names)
150 ]]></programlisting>
151 <screen><![CDATA[
152--> msprintf("%2$6s is %1$d-year old.\n", ages, names)
153 ans =
154 " Peter is 32-year old."
155 "Martha is 25-year old."
156 " John is 8-year old."
157]]></screen>
80 </refsection> 158 </refsection>
81 <refsection role="see also"> 159 <refsection role="see also">
82 <title>See also</title> 160 <title>See also</title>
83 <simplelist type="inline"> 161 <simplelist type="inline">
84 <member> 162 <member>
163 <link linkend="printf_conversion">printf_conversion</link>
164 </member>
165 <member>
85 <link linkend="mprintf">mprintf</link> 166 <link linkend="mprintf">mprintf</link>
86 </member> 167 </member>
87 <member> 168 <member>
88 <link linkend="printf_conversion">printf_conversion</link> 169 <link linkend="percentchars">percentchars</link>
89 </member> 170 </member>
90 </simplelist> 171 </simplelist>
91 </refsection> 172 </refsection>
173 <refsection role="history">
174 <title>History</title>
175 <revhistory>
176 <revision>
177 <revnumber>6.1.0</revnumber>
178 <revdescription>
179 Numbered placeholders "%n$.." are supported in the format.
180 </revdescription>
181 </revision>
182 <revision>
183 <revnumber>6.1.1</revnumber>
184 <revdescription>
185 Input data can be boolean.
186 </revdescription>
187 </revision>
188 </revhistory>
189 </refsection>
92</refentry> 190</refentry>
diff --git a/scilab/modules/output_stream/help/en_US/printf_conversion.xml b/scilab/modules/output_stream/help/en_US/printf_conversion.xml
index f693e7f..b87ad2c 100644
--- a/scilab/modules/output_stream/help/en_US/printf_conversion.xml
+++ b/scilab/modules/output_stream/help/en_US/printf_conversion.xml
@@ -2,8 +2,8 @@
2<!-- 2<!--
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) XXXX-2008 - INRIA 4 * Copyright (C) XXXX-2008 - INRIA
5 *
6 * Copyright (C) 2012 - 2016 - Scilab Enterprises 5 * Copyright (C) 2012 - 2016 - Scilab Enterprises
6 * Copyright (C) 2021 - Samuel GOUGEON
7 * 7 *
8 * This file is hereby licensed under the terms of the GNU GPL v2.0, 8 * This file is hereby licensed under the terms of the GNU GPL v2.0,
9 * pursuant to article 5.3.4 of the CeCILL v.2.1. 9 * pursuant to article 5.3.4 of the CeCILL v.2.1.
@@ -13,11 +13,13 @@
13 * along with this program. 13 * along with this program.
14 * 14 *
15 --> 15 -->
16<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns4="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="printf_conversion" xml:lang="en"> 16<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
17 xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns4="http://www.w3.org/1999/xhtml"
18 xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook"
19 xmlns:scilab="http://www.scilab.org" xml:id="printf_conversion" xml:lang="en">
17 <refnamediv> 20 <refnamediv>
18 <refname>printf_conversion</refname> 21 <refname>printf_conversion</refname>
19 <refpurpose>mprintf, msprintf, mfprintf conversion 22 <refpurpose>mprintf, msprintf, mfprintf C-format specifications
20 specifications
21 </refpurpose> 23 </refpurpose>
22 </refnamediv> 24 </refnamediv>
23 <refsection> 25 <refsection>
@@ -25,7 +27,7 @@
25 <para> 27 <para>
26 Each conversion specification in the <literal>mprintf</literal> , 28 Each conversion specification in the <literal>mprintf</literal> ,
27 <literal>msprintf</literal> , <literal>mfprintf</literal> 29 <literal>msprintf</literal> , <literal>mfprintf</literal>
28 <literal>format</literal> parameter has the following syntax: 30 <literal>format</literal> string has the following syntax:
29 </para> 31 </para>
30 <itemizedlist> 32 <itemizedlist>
31 <listitem> 33 <listitem>
@@ -33,29 +35,43 @@
33 </listitem> 35 </listitem>
34 <listitem> 36 <listitem>
35 <para> 37 <para>
38 An optional integer n ≥ 1 followed by "$". n is the index of the input data
39 to substitute to the placeholder, in the msprintf, mprintf .. list of input data.
40 In a format string, placeholders are either all numbered or all non-numbered.
41 A given numbered placeholder can be used only once in its C-format string
42 (Scilab limitation).
43 </para>
44 </listitem>
45 <listitem>
46 <para>
36 Zero or more <literal>options</literal>, which modify the 47 Zero or more <literal>options</literal>, which modify the
37 meaning of the conversion specification. The following list contains 48 meaning of the conversion specification. The following list contains
38 the <literal>option</literal> characters and their meanings: 49 the <literal>option</literal> characters and their meanings:
39 </para> 50 </para>
40 <itemizedlist> 51 <table>
41 <listitem> 52 <tr>
42 <para>- : Left align, within the field, the result of the 53 <th>- :</th>
43 conversion. 54 <td>
44 </para> 55 Left align, within the field, the result of the conversion.
45 </listitem> 56 </td>
46 <listitem> 57 </tr>
47 <para>+ : Begin the result of a signed conversion with a sign (+ 58 <tr>
48 or -). 59 <th>+ :</th>
49 </para> 60 <td>
50 </listitem> 61 Begin the result of a signed conversion with a sign (+ or -).
51 <listitem> 62 </td>
52 <para>'space' : Prefix a space character to the result if the 63 </tr>
64 <tr>
65 <td style="white-space:nowrap"><emphasis role="bold">' ' :</emphasis></td>
66 <td>(space) Prefix a space character to the result if the
53 first character of a signed conversion is not a sign. If both the 67 first character of a signed conversion is not a sign. If both the
54 (space) and + options appear, the (space) option is ignored 68 (space) and + options appear, the (space) option is ignored.
55 </para> 69 </td>
56 </listitem> 70 </tr>
57 <listitem> 71 <tr>
58 <para># : Convert the value to an alternate form. For 72 <th># :</th>
73 <td>
74 Convert the value to an alternate form. For
59 <literal>c</literal>, <literal>d</literal>, <literal>i</literal>, 75 <literal>c</literal>, <literal>d</literal>, <literal>i</literal>,
60 <literal>s</literal>, and <literal>u</literal> conversions, the 76 <literal>s</literal>, and <literal>u</literal> conversions, the
61 <literal>#</literal> option has no effect. For 77 <literal>#</literal> option has no effect. For
@@ -68,10 +84,12 @@
68 no digits follow it. For <literal>g</literal> and 84 no digits follow it. For <literal>g</literal> and
69 <literal>G</literal> conversions, trailing zeros are not removed 85 <literal>G</literal> conversions, trailing zeros are not removed
70 from the result. 86 from the result.
71 </para> 87 </td>
72 </listitem> 88 </tr>
73 <listitem> 89 <tr>
74 <para>0 : Pad to the field width, using leading zeros (following 90 <th>0 :</th>
91 <td>
92 Pad to the field width, using leading zeros (following
75 any indication of sign or base) for <literal>d</literal>, 93 any indication of sign or base) for <literal>d</literal>,
76 <literal>i</literal>, <literal>o</literal>, <literal>u</literal>, 94 <literal>i</literal>, <literal>o</literal>, <literal>u</literal>,
77 <literal>x</literal>, <literal>X</literal>, <literal>e</literal>, 95 <literal>x</literal>, <literal>X</literal>, <literal>e</literal>,
@@ -83,12 +101,13 @@
83 <literal>o</literal> <literal>u</literal>, <literal>x</literal>, 101 <literal>o</literal> <literal>u</literal>, <literal>x</literal>,
84 and <literal>X</literal> conversions, if a precision is specified, 102 and <literal>X</literal> conversions, if a precision is specified,
85 the <literal>0</literal> flag is also ignored. 103 the <literal>0</literal> flag is also ignored.
86 </para> 104 </td>
87 </listitem> 105 </tr>
88 </itemizedlist> 106 </table>
89 </listitem> 107 </listitem>
90 <listitem> 108 <listitem>
91 <para>An optional decimal digit string that specifies the minimum field 109 <para>
110 An optional decimal digit string that specifies the minimum field
92 width. If the converted value has fewer characters than the field width, 111 width. If the converted value has fewer characters than the field width,
93 the field is padded on the left to the length specified by the field 112 the field is padded on the left to the length specified by the field
94 width. If the left-adjustment option is specified, the field is padded on 113 width. If the left-adjustment option is specified, the field is padded on
@@ -103,66 +122,99 @@
103 </para> 122 </para>
104 <itemizedlist> 123 <itemizedlist>
105 <listitem> 124 <listitem>
106 <para> 125 The minimum number of digits to appear for <literal>d</literal>,
107 The minimum number of digits to appear for <literal>d</literal>, 126 <literal>u</literal>, <literal>o</literal>, <literal>x</literal>, or
108 <literal>u</literal>, <literal>o</literal>, <literal>x</literal>, or 127 <literal>X</literal> conversions.
109 <literal>X</literal> conversions
110 </para>
111 </listitem> 128 </listitem>
112 <listitem> 129 <listitem>
113 <para>The number of digits to appear after the decimal point for 130 The number of digits to appear after the decimal point for
114 <literal>e</literal>, <literal>E</literal>, and <literal>f</literal> 131 <literal>e</literal>, <literal>E</literal>, and <literal>f</literal>
115 conversions 132 conversions.
116 </para>
117 </listitem> 133 </listitem>
118 <listitem> 134 <listitem>
119 <para>The maximum number of significant digits for 135 The maximum number of significant digits for
120 <literal>g</literal> and <literal>G</literal> conversions 136 <literal>g</literal> and <literal>G</literal> conversions.
121 </para>
122 </listitem> 137 </listitem>
123 <listitem> 138 <listitem>
124 <para>The maximum number of characters to be printed from a string in 139 The maximum number of characters to be printed from a string in
125 an <literal>s</literal> conversion 140 an <literal>s</literal> conversion.
126 </para>
127 </listitem> 141 </listitem>
128 </itemizedlist> 142 </itemizedlist>
129 </listitem> 143 </listitem>
130 <listitem> 144 <listitem>
131 <para>A character that indicates the type of conversion to be 145 <para>A character that indicates the type of conversion to be applied:
132 applied:
133 </para> 146 </para>
134 <itemizedlist> 147 <table>
135 <listitem> 148 <tr>
136 <para>% : Performs no conversion. Displays %.</para> 149 <th>% :</th>
137 </listitem> 150 <td>
138 <listitem> 151 Performs no conversion. Prints %.
139 <para> 152 <note>
140 d,i: Accepts an integer <literal>value</literal> and 153 This may be useful for instance to print percentages, or
141 converts it to signed decimal notation. The precision specifies 154 to process some LaTeX expression including LaTeX comments
155 starting with "%", etc.
156 </note>
157 </td>
158 </tr>
159 <tr>
160 <th>s :</th>
161 <td>
162 Accepts a string or boolean <literal>value</literal> and displays
163 characters from the string to the end or the number of characters
164 indicated by the precision is reached. If no precision is
165 specified, all characters up to the end are displayed.
166 UTF-8 extended characters are supported in input strings.
167 Booleans are converted into 'T' or 'F'.
168 </td>
169 </tr>
170 <tr>
171 <th>c :</th>
172 <td>
173 Not supported.
174 </td>
175 </tr>
176 <tr>
177 <td colspan="2">
178 All following conversions accept any decimal numerical or boolean
179 input <literal>value</literal>. Only the real part of any input
180 complex number is considered. Booleans are implicitly converted
181 into 0 and 1.
182 </td>
183 </tr>
184 <tr>
185 <th>d,i :</th>
186 <td>
187 Converts the input <literal>value</literal> to a signed integer int32
188 notation. Conversions for input |Numbers| ≥ 2^31 are not reliable.
189 The precision specifies
142 the minimum number of digits to appear. If the value being 190 the minimum number of digits to appear. If the value being
143 converted can be represented in fewer digits, it is expanded with 191 converted can be represented in fewer digits, it is expanded with
144 leading zeros. The default precision is 1. The result of 192 leading zeros. The default precision is 1. The result of
145 converting a zero value with a precision of zero is a null string. 193 converting a zero value with a precision of zero is a null string.
146 Specifying a field width with a zero as a leading character causes 194 Specifying a field width with a zero as a leading character causes
147 the field width value to be padded with leading zeros. 195 the field width value to be padded with leading zeros.
148 </para> 196 </td>
149 </listitem> 197 </tr>
150 <listitem> 198 <tr>
151 <para> 199 <th>u :</th>
152 u : Accepts an integer <literal>value</literal> and converts 200 <td>
153 it to unsigned decimal notation. The precision specifies the 201 Converts the input <literal>value</literal> to an unsigned integer
202 uint32 notation. Conversions for input |Numbers| ≥ 2^32 are not reliable.
203 The precision specifies the
154 minimum number of digits to appear. If the value being converted 204 minimum number of digits to appear. If the value being converted
155 can be represented in fewer digits, it is expanded with leading 205 can be represented in fewer digits, it is expanded with leading
156 zeros. The default precision is 1. The result of converting a zero 206 zeros. The default precision is 1. The result of converting a zero
157 value with a precision of zero is a null string. Specifying a 207 value with a precision of zero is a null string. Specifying a
158 field width with a zero as the leading character causes the field 208 field width with a zero as the leading character causes the field
159 width value to be padded with leading zeros. 209 width value to be padded with leading zeros.
160 </para> 210 </td>
161 </listitem> 211 </tr>
162 <listitem> 212 <tr>
163 <para> 213 <th>o :</th>
164 o : Accepts an integer <literal>value</literal> and converts 214 <td>
165 it to unsigned octal notation. The precision specifies the minimum 215 Converts the input <literal>value</literal> to an unsigned octal notation.
216 Conversions for input |Numbers| ≥ 2^32 are not reliable.
217 The precision specifies the minimum
166 number of digits to appear. If the value being converted can be 218 number of digits to appear. If the value being converted can be
167 represented in fewer digits, it is expanded with leading zeros. 219 represented in fewer digits, it is expanded with leading zeros.
168 The default precision is 1. The result of converting a zero value 220 The default precision is 1. The result of converting a zero value
@@ -170,14 +222,15 @@
170 width with a zero as the leading character causes the field width 222 width with a zero as the leading character causes the field width
171 value to be padded with leading zeros. An octal value for field 223 value to be padded with leading zeros. An octal value for field
172 width is not implied. 224 width is not implied.
173 </para> 225 </td>
174 </listitem> 226 </tr>
175 <listitem> 227 <tr>
176 <para> 228 <th>x, X :</th>
177 x, X : Accepts an integer <literal>value</literal> and 229 <td>
178 converts it to unsigned hexadecimal notation. The letters 230 Converts the input <literal>value</literal> to an unsigned hexadecimal
179 ``abcdef'' are used for the <literal>x</literal> conversion; the 231 notation. Conversions for input |Numbers| ≥ 2^32 are not reliable.
180 letters ``ABCDEF'' are used for the <literal>X</literal> 232 The letters ``abcdef'' are used for the <literal>x</literal> conversion;
233 the letters ``ABCDEF'' are used for the <literal>X</literal>
181 conversion. The precision specifies the minimum number of digits 234 conversion. The precision specifies the minimum number of digits
182 to appear. If the value being converted can be represented in 235 to appear. If the value being converted can be represented in
183 fewer digits, it is expanded with leading zeros. The default 236 fewer digits, it is expanded with leading zeros. The default
@@ -185,89 +238,71 @@
185 precision of zero is a null string. Specifying a field width with 238 precision of zero is a null string. Specifying a field width with
186 a zero as the leading character causes the field width value to be 239 a zero as the leading character causes the field width value to be
187 padded with leading zeros. 240 padded with leading zeros.
188 </para> 241 </td>
189 </listitem> 242 </tr>
190 <listitem> 243 <tr>
191 <para> 244 <th>f :</th>
192 f : Accepts a float or double <literal>value</literal> and 245 <td>
193 converts it to decimal notation in the format 246 Converts the input <literal>value</literal> to a decimal notation in
194 %[\-]<literal>ddd.ddd</literal>. The number of digits after the 247 the format %[\-]<literal>ddd.ddd</literal>.
195 decimal point is equal to the precision specification. 248 The number of digits after the decimal point is equal to the precision
196 </para> 249 specification.
197 <itemizedlist> 250 <itemizedlist>
198 <listitem> 251 <listitem>
199 <para>If no precision is specified, six digits are 252 If no precision is specified, six digits are output.
200 output. 253 </listitem>
201 </para> 254 <listitem>
202 </listitem> 255 If the precision is zero, no decimal point appears and
203 <listitem>
204 <para>If the precision is zero, no decimal point appears and
205 the system outputs a number rounded to the integer nearest to 256 the system outputs a number rounded to the integer nearest to
206 <literal>value</literal>. 257 <literal>value</literal>.
207 </para> 258 </listitem>
208 </listitem> 259 <listitem>
209 <listitem> 260 If a decimal point is output, at least one digit is output before it.
210 <para>If a decimal point is output, at least one digit is 261 </listitem>
211 output before it. 262 </itemizedlist>
212 </para> 263 </td>
213 </listitem> 264 </tr>
214 </itemizedlist> 265 <tr>
215 </listitem> 266 <th>e, E :</th>
216 <listitem> 267 <td>
217 <para>e, E : Accepts a real and converts it to the exponential 268 Converts the input <literal>value</literal> to the exponential
218 form %[\-]<literal>d.ddde</literal>+/\-<literal>dd</literal>. 269 form %[\-]<literal>d.ddde</literal>+/\-<literal>dd</literal>.
219 There is one digit before the decimal point, and the number of 270 There is one digit before the decimal point, and the number of
220 digits after the decimal point is equal to the precision 271 digits after the decimal point is equal to the precision
221 specification. 272 specification.
222 </para> 273 <itemizedlist>
223 <itemizedlist> 274 <listitem>
224 <listitem> 275 If no precision is specified, six digits are output.
225 <para>If no precision is specified, six digits are 276 </listitem>
226 output. 277 <listitem>
227 </para> 278 If the precision is zero, no decimal point appears.
228 </listitem> 279 </listitem>
229 <listitem> 280 <listitem>
230 <para>If the precision is zero, , no decimal point
231 appears.
232 </para>
233 </listitem>
234 <listitem>
235 <para>
236 The <literal>E</literal> conversion character produces a 281 The <literal>E</literal> conversion character produces a
237 number with E instead of e before the exponent. The exponent 282 number with E instead of e before the exponent. The exponent
238 always contains at least two digits. If the value is zero, the 283 always contains at least two digits. If the value is zero, the
239 exponent is zero. 284 exponent is zero.
240 </para> 285 </listitem>
241 </listitem> 286 </itemizedlist>
242 </itemizedlist> 287 </td>
243 </listitem> 288 </tr>
244 <listitem> 289 <tr>
245 <para>g, G : Accepts a real and converts it in the style of the 290 <td style="white-space:nowrap"><emphasis role="bold">g, G :</emphasis></td>
291 <td>
292 Converts the input <literal>value</literal> in the style of the
246 <literal>e</literal>, <literal>E</literal>, or 293 <literal>e</literal>, <literal>E</literal>, or
247 <literal>f</literal> conversion characters, with the precision 294 <literal>f</literal> conversion characters, with the precision
248 specifying the number of significant digits. Trailing zeros are 295 specifying the number of significant digits.
249 removed from the result. A decimal point appears only if it is 296 Trailing zeros are removed from the result.
250 followed by a digit. The style used depends on the value 297 A decimal point appears only if it is followed by a digit.
298 The style used depends on the value
251 converted. Style <literal>e</literal> (<literal>E</literal>, if 299 converted. Style <literal>e</literal> (<literal>E</literal>, if
252 <literal>G</literal> is the flag used) results only if the 300 <literal>G</literal> is the flag used) results only if the
253 exponent resulting from the conversion is less than -4, or if it 301 exponent resulting from the conversion is less than -4, or if it
254 is greater or equal to the precision. 302 is greater or equal to the precision.
255 </para> 303 </td>
256 </listitem> 304 </tr>
257 <listitem> 305 </table>
258 <para>c : Accepts and displays an integer value converted to a
259 character.
260 </para>
261 </listitem>
262 <listitem>
263 <para>
264 s : Accepts a string <literal>value</literal> and displays
265 characters from the string to the end or the number of characters
266 indicated by the precision is reached. If no precision is
267 specified, all characters up to the end are displayed.
268 </para>
269 </listitem>
270 </itemizedlist>
271 </listitem> 306 </listitem>
272 </itemizedlist> 307 </itemizedlist>
273 <para>A field width or precision can be indicated by an 308 <para>A field width or precision can be indicated by an
@@ -284,21 +319,46 @@
284 <para>The representation of the plus sign depends on whether the 319 <para>The representation of the plus sign depends on whether the
285 <literal>+</literal> or (space) formatting option is specified. 320 <literal>+</literal> or (space) formatting option is specified.
286 </para> 321 </para>
287 <para>display of exponential form %e is platform dependent with a different number of digits in exponent.</para> 322 <para>
288 <informaltable border="1"> 323 The display of exponential form %e is platform dependent with a different
289 <tr> 324 number of digits in exponent.
290 <td>Platform</td> 325 <informaltable border="1">
291 <td>Example: msprintf("%e",1.23e4)</td> 326 <tr>
292 </tr> 327 <td>Platform</td>
293 <tr> 328 <td>Example: msprintf("%e",1.23e4)</td>
294 <td>Windows</td> 329 </tr>
295 <td>1.23000e+004</td> 330 <tr>
296 </tr> 331 <td>Windows</td>
297 <tr> 332 <td>1.23000e+004</td>
298 <td>Linux/Mac OS</td> 333 </tr>
299 <td>1.23000e+04</td> 334 <tr>
300 </tr> 335 <td>Linux/Mac OS</td>
301 </informaltable> 336 <td>1.23000e+04</td>
337 </tr>
338 </informaltable>
339 </para>
340 <para>
341 <emphasis role="bold">Special escaped sequences</emphasis> are supported in Scilab
342 C-format strings:
343 <table>
344 <tr>
345 <th>\n :</th>
346 <td>Go to Next line (line feed)</td>
347 </tr>
348 <tr>
349 <th>\r :</th>
350 <td>Return: go to the head of current line (for overprinting)</td>
351 </tr>
352 <tr>
353 <th>\t :</th>
354 <td>horizontal Tab</td>
355 </tr>
356 <tr>
357 <th>\\ :</th>
358 <td>print a backslash \</td>
359 </tr>
360 </table>
361 </para>
302 </refsection> 362 </refsection>
303 <refsection> 363 <refsection>
304 <title>Examples</title> 364 <title>Examples</title>
@@ -320,7 +380,45 @@ mprintf('a float (exponential form): %3.2e\n', %pi);
320mprintf('a float (exponential form): %3.2g\n', %pi); 380mprintf('a float (exponential form): %3.2g\n', %pi);
321mprintf('a character: %c\n', 'a'); 381mprintf('a character: %c\n', 'a');
322mprintf('a character: %c\n', 'aaa'); 382mprintf('a character: %c\n', 'aaa');
323 ]]></programlisting> 383 ]]></programlisting>
384 <para/>
385 <para>
386 With input booleans:
387 </para>
388 <programlisting role="example"><![CDATA[
389mprintf("\n%%d: %d, %%u: %u, %%o: %o, %%f: %f, %%e: %e, %%s: %s\n" + ..
390 "%%d: %d, %%u: %u, %%o: %o, %%f: %f, %%e: %e, %%s: %s\n", ..
391 %T, %T, %T, %T, %T, %T, %F, %F, %F, %F, %F, %F);
392 ]]></programlisting>
393 <screen><![CDATA[
394%d: 1, %u: 1, %o: 1, %f: 1.000000, %e: 1.000000e+00, %s: T
395%d: 0, %u: 0, %o: 0, %f: 0.000000, %e: 0.000000e+00, %s: F
396]]></screen>
397 <para/>
398 <para>
399 With numbered placeholders:
400 </para>
401 <programlisting role="example"><![CDATA[
402mprintf("%2$s is %1$d-year old.\n", 32, "Peter");
403 ]]></programlisting>
404 <screen><![CDATA[
405Peter is 32-year old.
406]]></screen>
407 <para/>
408 <para>
409 With escaped sequences and UTF-8 extended characters:
410 </para>
411 <programlisting role="example"><![CDATA[
412mprintf("The path T:\\abc does not exist.\n");
413mprintf("abcdefghijk\tαβδ\tεϵ\tζηθικλ\rABCDE\n");
414 ]]></programlisting>
415 <screen><![CDATA[
416--> mprintf("The path T:\\abc does not exist.\n");
417The path T:\abc does not exist
418
419--> mprintf("abcdefghijk\tαβδ\tεϵ\tζηθικλ\rABCDE\n");
420ABCDEfghijk αβδ εϵ ζηθικλ
421]]></screen>
324 </refsection> 422 </refsection>
325 <refsection role="see also"> 423 <refsection role="see also">
326 <title>See also</title> 424 <title>See also</title>
@@ -336,4 +434,21 @@ mprintf('a character: %c\n', 'aaa');
336 </member> 434 </member>
337 </simplelist> 435 </simplelist>
338 </refsection> 436 </refsection>
437 <refsection role="history">
438 <title>History</title>
439 <revhistory>
440 <revision>
441 <revnumber>6.1.0</revnumber>
442 <revdescription>
443 Numbered placeholders "%n$.." are supported.
444 </revdescription>
445 </revision>
446 <revision>
447 <revnumber>6.1.1</revnumber>
448 <revdescription>
449 Input boolean data can be converted.
450 </revdescription>
451 </revision>
452 </revhistory>
453 </refsection>
339</refentry> 454</refentry>
diff --git a/scilab/modules/output_stream/help/ja_JP/mprintf.xml b/scilab/modules/output_stream/help/ja_JP/mprintf.xml
index 6dd7113..874572d5 100644
--- a/scilab/modules/output_stream/help/ja_JP/mprintf.xml
+++ b/scilab/modules/output_stream/help/ja_JP/mprintf.xml
@@ -3,8 +3,8 @@
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) 2008 - INRIA 4 * Copyright (C) 2008 - INRIA
5 * ... 5 * ...
6 *
7 * Copyright (C) 2012 - 2016 - Scilab Enterprises 6 * Copyright (C) 2012 - 2016 - Scilab Enterprises
7 * Copyright (C) 2021 - Samuel GOUGEON
8 * 8 *
9 * This file is hereby licensed under the terms of the GNU GPL v2.0, 9 * This file is hereby licensed under the terms of the GNU GPL v2.0,
10 * pursuant to article 5.3.4 of the CeCILL v.2.1. 10 * pursuant to article 5.3.4 of the CeCILL v.2.1.
@@ -47,13 +47,18 @@
47 formatオペランドは,C言語のprintfのformatオペランドと 47 formatオペランドは,C言語のprintfのformatオペランドと
48 構文にできるだけ近くなるよう作成されています, as described in the 48 構文にできるだけ近くなるよう作成されています, as described in the
49 <link linkend="printf_conversion">printf_conversion</link> page. 49 <link linkend="printf_conversion">printf_conversion</link> page.
50 UTF-8 extended characters and numbered placeholders "%n$.." are supported.
50 </para> 51 </para>
51 </listitem> 52 </listitem>
52 </varlistentry> 53 </varlistentry>
53 <varlistentry> 54 <varlistentry>
54 <term>a1,...,an</term> 55 <term>a1,...,an</term>
55 <listitem> 56 <listitem>
56 <para>formatパラメータに基づき変換,出力されるデータを定義します.</para> 57 <para>
58 formatパラメータに基づき変換,出力されるデータを定義します.
59 Supported types: all numbers, booleans, strings. Only the real part
60 of complex numbers is considered (current Scilab limitation).
61 </para>
57 </listitem> 62 </listitem>
58 </varlistentry> 63 </varlistentry>
59 </variablelist> 64 </variablelist>
@@ -61,30 +66,117 @@
61 <refsection> 66 <refsection>
62 <title>説明</title> 67 <title>説明</title>
63 <para> 68 <para>
64 <literal>mprintf</literal>関数はC言語の<literal>printf</literal>へ 69 <literal>mprintf(format, a1, a2, ..)</literal> replaces placeholders provided inside the
65 のインターフェイスです. 70 <varname>format</varname> string with values of <varname>a1</varname>, <varname>a2</varname>, ..
71 converted according to each respective placeholder directive, and writes the result to
72 the Scilab console.
66 </para> 73 </para>
67 <para> 74 <para>
68 <literal>mprintf</literal>関数は整形されたオペランドを 75 If <varname>a1</varname>, <varname>a2</varname>, .. are arrays with multiple rows,
69 Scilab標準出力(すなわち,Scilabウインドウ)に書き込みます. 76 they are processed row by row: the format is used iteratively for every row of the
70 argumentオペランドはformatオペランドの制御の下で整形されます. 77 arrays (horizontally "concatenated"), until the bottom
78 of the least tall array is reached. Remaining rows of taller arrays (if any) are ignored.
79 See examples.
80 </para>
81 <para>
82 If the total number of columns of <varname>a1</varname>, <varname>a2</varname>, ..
83 is bigger than the number of placeholders in the <varname>format</varname>,
84 then extra columns are ignored.
85 </para>
86 <para>
87 The <literal>mprintf</literal> function is an extended interface for C-coded
88 <literal>printf</literal>.
71 </para> 89 </para>
72 </refsection> 90 </refsection>
73 <refsection> 91 <refsection>
74 <title>例</title> 92 <title>例</title>
75 <programlisting role="example"><![CDATA[ 93 <programlisting role="example"><![CDATA[
76mprintf('At iteration %i, Result is:\nalpha=%f',33,0.535) 94I = (1:4)';
77 ]]></programlisting> 95A = [26.93 ; 63.25 ; 40.51 ; 91.84];
96B = [ 3.62 ; 15.04 ; 25.3 ; 48.19];
97C = [ 4.37 28.06
98 48.18 %inf
99 41.48 %nan
100 26.39 77.83];
101Status = ["NOK" "NOK" "NOK" "OK"]';
102Format = "Iteration %d: Results: A= %f B= %2d%% Status= %3s C(1)= %g C(2)= %e\n";
103mprintf(Format, I, A, B, Status, C);
104 ]]></programlisting>
105 <screen><![CDATA[
106--> mprintf(Format, I, A, B, Status, C);
107Iteration 1: Results: A= 26.930000 B= 3% Status= NOK C(1)= 4.37 C(2)= 2.806000e+01
108Iteration 2: Results: A= 63.250000 B= 15% Status= NOK C(1)= 48.18 C(2)= Inf
109Iteration 3: Results: A= 40.510000 B= 25% Status= NOK C(1)= 41.48 C(2)= Nan
110Iteration 4: Results: A= 91.840000 B= 48% Status= OK C(1)= 26.39 C(2)= 7.783000e+01
111]]></screen>
112 <para/>
113 <para>
114 Supernumerary columns or rows are ignored:
115 </para>
116 <programlisting role="example"><![CDATA[
117A = [%T %F %T %T %F]';
118B = [ 4.37 28.06
119 48.18 %inf
120 41.48 %nan ];
121mprintf("OK? %s Value: %4.1f\n", A, B);
122 ]]></programlisting>
123 <screen><![CDATA[
124--> mprintf("OK? %s Value: %4.1f\n", A, B);
125OK? T Value: 4.4
126OK? F Value: 48.2
127OK? T Value: 41.5
128]]></screen>
129 <para/>
130 <para>
131 Numbered placeholders "%n$.." allow reordering printed data with the format:
132 </para>
133 <programlisting role="example"><![CDATA[
134names = ["Peter", "Martha" "John"]';
135ages = [32 25 8]';
136mprintf("%2$6s is %1$d-year old.\n", ages, names);
137 ]]></programlisting>
138 <screen><![CDATA[
139--> mprintf("%2$6s is %1$d-year old.\n", ages, names);
140 Peter is 32-year old.
141Martha is 25-year old.
142 John is 8-year old.
143]]></screen>
78 </refsection> 144 </refsection>
79 <refsection role="see also"> 145 <refsection role="see also">
80 <title>参照</title> 146 <title>参照</title>
81 <simplelist type="inline"> 147 <simplelist type="inline">
82 <member> 148 <member>
149 <link linkend="printf_conversion">printf_conversion</link>
150 </member>
151 <member>
83 <link linkend="disp">disp</link> 152 <link linkend="disp">disp</link>
84 </member> 153 </member>
85 <member> 154 <member>
86 <link linkend="printf_conversion">printf_conversion</link> 155 <link linkend="write">write</link>
156 </member>
157 <member>
158 <link linkend="percentio">percentio</link>
159 </member>
160 <member>
161 <link linkend="percentchars">percentchars</link>
87 </member> 162 </member>
88 </simplelist> 163 </simplelist>
89 </refsection> 164 </refsection>
165 <refsection role="history">
166 <title>履歴</title>
167 <revhistory>
168 <revision>
169 <revnumber>6.1.0</revnumber>
170 <revdescription>
171 Numbered placeholders "%n$.." are supported in the format.
172 </revdescription>
173 </revision>
174 <revision>
175 <revnumber>6.1.1</revnumber>
176 <revdescription>
177 Input data can be boolean.
178 </revdescription>
179 </revision>
180 </revhistory>
181 </refsection>
90</refentry> 182</refentry>
diff --git a/scilab/modules/output_stream/help/ja_JP/msprintf.xml b/scilab/modules/output_stream/help/ja_JP/msprintf.xml
deleted file mode 100644
index 252b653..0000000
--- a/scilab/modules/output_stream/help/ja_JP/msprintf.xml
+++ /dev/null
@@ -1,90 +0,0 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) 2008 - INRIA
5 * ...
6 *
7 * Copyright (C) 2012 - 2016 - Scilab Enterprises
8 *
9 * This file is hereby licensed under the terms of the GNU GPL v2.0,
10 * pursuant to article 5.3.4 of the CeCILL v.2.1.
11 * This file was originally licensed under the terms of the CeCILL v2.1,
12 * and continues to be available under such terms.
13 * For more information, see the COPYING file which you should have received
14 * along with this program.
15 *
16 -->
17<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="msprintf" xml:lang="ja">
18 <refnamediv>
19 <refname>msprintf</refname>
20 <refpurpose>データを変換,整形し,文字列に書き込む</refpurpose>
21 </refnamediv>
22 <refnamediv xml:id="sprintf">
23 <refname>sprintf</refname>
24 <refpurpose>データを変換,整形し,文字列に書き込む (廃止)</refpurpose>
25 </refnamediv>
26 <refsynopsisdiv>
27 <title>呼び出し手順</title>
28 <synopsis>str = msprintf(format,a1,...,an);</synopsis>
29 </refsynopsisdiv>
30 <refsection>
31 <title>パラメータ</title>
32 <variablelist>
33 <varlistentry>
34 <term>format</term>
35 <listitem>
36 <para>
37 残りのオペランドを書き込む際に使用される
38 フォーマット定義するSclab文字列.
39 </para>
40 </listitem>
41 </varlistentry>
42 <varlistentry>
43 <term>str</term>
44 <listitem>
45 <para>文字列.</para>
46 </listitem>
47 </varlistentry>
48 <varlistentry>
49 <term>a1,...,an</term>
50 <listitem>
51 <para>S
52 formatパラメータに基づき変換,出力されるデータを定義します.
53 </para>
54 </listitem>
55 </varlistentry>
56 </variablelist>
57 </refsection>
58 <refsection>
59 <title>説明</title>
60 <para>
61 <literal>msprintf</literal>は,整形されたオペランドを
62 その戻り値(Scilab文字列)に書き込みます.
63 argumentオペランドはformatオペランドの制御の下で
64 整形されます.
65 </para>
66 <para>
67 この場合,エスケープシーケンス(<literal>"\n"</literal>) は
68 文字列を文字列の行列に分割することに注意してください (例を参照)
69 </para>
70 </refsection>
71 <refsection>
72 <title>例</title>
73 <programlisting role="example"><![CDATA[
74msprintf('%5.3f %5.3f',123,0.732)
75msprintf('%5.3f\n%5.3f',123,0.732)
76msprintf('--%s-\n-%d--',"hello",3)
77 ]]></programlisting>
78 </refsection>
79 <refsection role="see also">
80 <title>参照</title>
81 <simplelist type="inline">
82 <member>
83 <link linkend="mprintf">mprintf</link>
84 </member>
85 <member>
86 <link linkend="printf_conversion">printf_conversion</link>
87 </member>
88 </simplelist>
89 </refsection>
90</refentry>
diff --git a/scilab/modules/output_stream/help/ja_JP/printf_conversion.xml b/scilab/modules/output_stream/help/ja_JP/printf_conversion.xml
index f98ca0e..1d6bd317 100644
--- a/scilab/modules/output_stream/help/ja_JP/printf_conversion.xml
+++ b/scilab/modules/output_stream/help/ja_JP/printf_conversion.xml
@@ -2,8 +2,8 @@
2<!-- 2<!--
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) XXXX-2008 - INRIA 4 * Copyright (C) XXXX-2008 - INRIA
5 *
6 * Copyright (C) 2012 - 2016 - Scilab Enterprises 5 * Copyright (C) 2012 - 2016 - Scilab Enterprises
6 * Copyright (C) 2021 - Samuel GOUGEON
7 * 7 *
8 * This file is hereby licensed under the terms of the GNU GPL v2.0, 8 * This file is hereby licensed under the terms of the GNU GPL v2.0,
9 * pursuant to article 5.3.4 of the CeCILL v.2.1. 9 * pursuant to article 5.3.4 of the CeCILL v.2.1.
@@ -13,7 +13,10 @@
13 * along with this program. 13 * along with this program.
14 * 14 *
15 --> 15 -->
16<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns4="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="printf_conversion" xml:lang="ja"> 16<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
17 xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns4="http://www.w3.org/1999/xhtml"
18 xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook"
19 xmlns:scilab="http://www.scilab.org" xml:id="printf_conversion" xml:lang="ja">
17 <refnamediv> 20 <refnamediv>
18 <refname>printf_conversion</refname> 21 <refname>printf_conversion</refname>
19 <refpurpose>mprintf, msprintf, mfprintf 変換仕様</refpurpose> 22 <refpurpose>mprintf, msprintf, mfprintf 変換仕様</refpurpose>
@@ -31,27 +34,45 @@
31 </listitem> 34 </listitem>
32 <listitem> 35 <listitem>
33 <para> 36 <para>
37 An optional integer n ≥ 1 followed by "$". n is the index of the input data
38 to substitute to the placeholder, in the msprintf, mprintf .. list of input data.
39 In a format string, placeholders are either all numbered or all non-numbered.
40 A given numbered placeholder can be used only once in its C-format string
41 (Scilab limitation).
42 </para>
43 </listitem>
44 <listitem>
45 <para>
34 0個以上の <literal>options</literal>で, 46 0個以上の <literal>options</literal>で,
35 変換仕様の意味を修正します. 47 変換仕様の意味を修正します.
36 以下のリストに<literal>option</literal>文字とその意味を示します: 48 以下のリストに<literal>option</literal>文字とその意味を示します:
37 </para> 49 </para>
38 <itemizedlist> 50 <table>
39 <listitem> 51 <tr>
40 <para>- : 左揃え, フィールド内では, 変換の結果.</para> 52 <th>- :</th>
41 </listitem> 53 <td>
42 <listitem> 54 左揃え, フィールド内では, 変換の結果.
43 <para>+ : (+または -)を指定する符号変換の結果を開始.</para> 55 </td>
44 </listitem> 56 </tr>
45 <listitem> 57 <tr>
46 <para>'空白' : 58 <th>+ :</th>
47 符号変換後の最初の文字が符号ではない場合に結果の 59 <td>
60 (+または -)を指定する符号変換の結果を開始.
61 </td>
62 </tr>
63 <tr>
64 <td style="white-space:nowrap"><emphasis role="bold">' ' :</emphasis></td>
65 <td>
66 (空白) 符号変換後の最初の文字が符号ではない場合に結果の
48 前に空白文字を付加します. 67 前に空白文字を付加します.
49 (空白) および +オプションが共に指定された場合, 68 (空白) および +オプションが共に指定された場合,
50 (空白) オプションは無視されます. 69 (空白) オプションは無視されます.
51 </para> 70 </td>
52 </listitem> 71 </tr>
53 <listitem> 72 <tr>
54 <para># : 別の形式に値を変換. 73 <th># :</th>
74 <td>
75 別の形式に値を変換.
55 <literal>c</literal>, <literal>d</literal>, <literal>i</literal>, 76 <literal>c</literal>, <literal>d</literal>, <literal>i</literal>,
56 <literal>s</literal>, および <literal>u</literal> 変換の場合, 77 <literal>s</literal>, および <literal>u</literal> 変換の場合,
57 <literal>#</literal>オプションの効果はありません. 78 <literal>#</literal>オプションの効果はありません.
@@ -64,10 +85,11 @@
64 <literal>g</literal> および 85 <literal>g</literal> および
65 <literal>G</literal> 変換の場合, 86 <literal>G</literal> 変換の場合,
66 末尾の0は結果から除かれません. 87 末尾の0は結果から除かれません.
67 </para> 88 </td>
68 </listitem> 89 </tr>
69 <listitem> 90 <tr>
70 <para>0 : 91 <th>0 :</th>
92 <td>
71 <literal>d</literal>, 93 <literal>d</literal>,
72 <literal>i</literal>, <literal>o</literal>, <literal>u</literal>, 94 <literal>i</literal>, <literal>o</literal>, <literal>u</literal>,
73 <literal>x</literal>, <literal>X</literal>, <literal>e</literal>, 95 <literal>x</literal>, <literal>X</literal>, <literal>e</literal>,
@@ -82,9 +104,9 @@
82 <literal>o</literal> <literal>u</literal>, <literal>x</literal>, 104 <literal>o</literal> <literal>u</literal>, <literal>x</literal>,
83 および <literal>X</literal> 変換の場合, 精度が指定されると, 105 および <literal>X</literal> 変換の場合, 精度が指定されると,
84 <literal>0</literal> フラグも無視されます. 106 <literal>0</literal> フラグも無視されます.
85 </para> 107 </td>
86 </listitem> 108 </tr>
87 </itemizedlist> 109 </table>
88 </listitem> 110 </listitem>
89 </itemizedlist> 111 </itemizedlist>
90 <para> 112 <para>
@@ -102,42 +124,69 @@
102 このパラメータは 0 (ゼロ)と扱われます. 124 このパラメータは 0 (ゼロ)と扱われます.
103 精度指定子: 125 精度指定子:
104 </para> 126 </para>
127 <para>
105 <itemizedlist> 128 <itemizedlist>
106 <listitem> 129 <listitem>
107 <para> 130 <literal>d</literal>,
108 <literal>d</literal>, 131 <literal>u</literal>, <literal>o</literal>, <literal>x</literal>, または
109 <literal>u</literal>, <literal>o</literal>, <literal>x</literal>, または 132 <literal>X</literal>変換に関する最小表示桁数
110 <literal>X</literal>変換に関する最小表示桁数
111 </para>
112 </listitem> 133 </listitem>
113 <listitem> 134 <listitem>
114 <para> 135 <literal>e</literal>, <literal>E</literal>, および <literal>f</literal>
115 <literal>e</literal>, <literal>E</literal>, および <literal>f</literal> 136 における小数点の後に表示する桁数
116 における小数点の後に表示する桁数
117 </para>
118 </listitem> 137 </listitem>
119 <listitem> 138 <listitem>
120 <para> 139 <literal>g</literal> および<literal>G</literal>変換における
121 <literal>g</literal> および<literal>G</literal>変換における 140 有効桁の最大値
122 有効桁の最大値
123 </para>
124 </listitem> 141 </listitem>
125 <listitem> 142 <listitem>
126 <para> 143 <literal>s</literal>変換において文字列から出力される
127 <literal>s</literal>変換において文字列から出力される 144 最大文字数
128 最大文字数
129 </para>
130 </listitem> 145 </listitem>
131 <listitem> 146 <listitem>
132 <para>適用される変換の種類を示す文字:</para> 147 適用される変換の種類を示す文字:
133 <itemizedlist> 148 <table>
134 <listitem> 149 <tr>
135 <para>% : 変換しません. %を表示.</para> 150 <th>% :</th>
136 </listitem> 151 <td>
137 <listitem> 152 変換しません. %を表示.
138 <para> 153 <note>
139 d,i: 整数 <literal>value</literal> を受け取り, 154 This may be useful for instance to print percentages, or
140 符号付き10進数表記に変換します. 155 to process some LaTeX expression including LaTeX comments
156 starting with "%", etc.
157 </note>
158 </td>
159 </tr>
160 <tr>
161 <th>s :</th>
162 <td>
163 Accepts a string or boolean <literal>value</literal>,
164 文字列から末尾または精度に示された文字数に達するまで,
165 文字に変換します.精度が指定されない場合,末尾までの全ての文字が
166 表示されます.
167 Input strings including some UTF-8 extended characters are supported.
168 Booleans are converted into 'T' or 'F'.
169 </td>
170 </tr>
171 <tr>
172 <th>c :</th>
173 <td>
174 Not supported.
175 </td>
176 </tr>
177 <tr>
178 <td colspan="2">
179 All following conversions accept any decimal numerical or boolean
180 input <literal>value</literal>. Only the real part of any input
181 complex number is considered. Booleans are implicitly converted
182 into 0 and 1.
183 </td>
184 </tr>
185 <tr>
186 <th>d, i :</th>
187 <td>
188 Converts the input <literal>value</literal> to a signed integer int32
189 notation. Conversions for input |Numbers| ≥ 2^31 are not reliable.
141 精度は表示される最小の桁数を指定します. 190 精度は表示される最小の桁数を指定します.
142 変換される値がより少ない桁数で表せる場合, 191 変換される値がより少ない桁数で表せる場合,
143 前にゼロを付加して拡張されます. 192 前にゼロを付加して拡張されます.
@@ -146,12 +195,13 @@
146 前に付加する文字をゼロとしてフィールド幅を指定すると, 195 前に付加する文字をゼロとしてフィールド幅を指定すると,
147 フィールド幅までの値では前にゼロを付加するパディングが 196 フィールド幅までの値では前にゼロを付加するパディングが
148 行われます. 197 行われます.
149 </para> 198 </td>
150 </listitem> 199 </tr>
151 <listitem> 200 <tr>
152 <para> 201 <th>u :</th>
153 u : 整数 <literal>value</literal> を受け取り, 202 <td>
154 符号なし10進数表記に変換します. 203 Converts the input <literal>value</literal> to an unsigned integer
204 uint32 notation. Conversions for input |Numbers| ≥ 2^32 are not reliable.
155 精度は表示される最小の桁数を指定します. 205 精度は表示される最小の桁数を指定します.
156 変換される値がより少ない桁数で表せる場合, 206 変換される値がより少ない桁数で表せる場合,
157 前にゼロを付加して拡張されます. 207 前にゼロを付加して拡張されます.
@@ -160,12 +210,13 @@
160 前に付加する文字をゼロとしてフィールド幅を指定すると, 210 前に付加する文字をゼロとしてフィールド幅を指定すると,
161 フィールド幅までの値では前にゼロを付加するパディングが 211 フィールド幅までの値では前にゼロを付加するパディングが
162 行われます. 212 行われます.
163 </para> 213 </td>
164 </listitem> 214 </tr>
165 <listitem> 215 <tr>
166 <para> 216 <th>o :</th>
167 o : 整数 <literal>value</literal> を受け取り, 217 <td>
168 符号なし8進数表記に変換します. 218 Converts the input <literal>value</literal> to an unsigned octal notation.
219 Conversions for input |Numbers| ≥ 2^32 are not reliable.
169 精度は表示される最小の桁数を指定します. 220 精度は表示される最小の桁数を指定します.
170 変換される値がより少ない桁数で表せる場合, 221 変換される値がより少ない桁数で表せる場合,
171 前にゼロを付加して拡張されます. 222 前にゼロを付加して拡張されます.
@@ -174,12 +225,14 @@
174 前に付加する文字をゼロとしてフィールド幅を指定すると, 225 前に付加する文字をゼロとしてフィールド幅を指定すると,
175 フィールド幅までの値では前にゼロを付加するパディングが 226 フィールド幅までの値では前にゼロを付加するパディングが
176 行われます. フィールド幅に8進数を使用することはできません. 227 行われます. フィールド幅に8進数を使用することはできません.
177 </para> 228 </td>
178 </listitem> 229 </tr>
179 <listitem> 230 <tr>
180 <para> 231 <th>x, X :</th>
181 x, X : 整数 <literal>value</literal> を受け取り, 232 <td>
182 符号なし16進数表記に変換します.<literal>x</literal>変換では, 233 Converts the input <literal>value</literal> to an unsigned hexadecimal
234 notation. Conversions for input |Numbers| ≥ 2^32 are not reliable.
235 <literal>x</literal>変換では,
183 文字``abcdef''が使用されます;<literal>X</literal>変換では, 236 文字``abcdef''が使用されます;<literal>X</literal>変換では,
184 文字``ABCDEF''が使用されます. 237 文字``ABCDEF''が使用されます.
185 精度はは表示される最小の桁数を指定します. 238 精度はは表示される最小の桁数を指定します.
@@ -190,57 +243,59 @@
190 前に付加する文字をゼロとしてフィールド幅を指定すると, 243 前に付加する文字をゼロとしてフィールド幅を指定すると,
191 フィールド幅までの値では前にゼロを付加するパディングが 244 フィールド幅までの値では前にゼロを付加するパディングが
192 行われます. 245 行われます.
193 </para> 246 </td>
194 </listitem> 247 </tr>
195 <listitem> 248 <tr>
196 <para> 249 <th>f :</th>
197 f : float または double の<literal>value</literal> を受け取り, 250 <td>
198 %[\-]<literal>ddd.ddd</literal>形式の10進数表記に変換します. 251 Converts the input <literal>value</literal> to a decimal notation in
252 the format %[\-]<literal>ddd.ddd</literal>.
199 小数点以下の桁数は,精度指定子に等しくなります. 253 小数点以下の桁数は,精度指定子に等しくなります.
200 </para> 254 <itemizedlist>
201 <itemizedlist> 255 <listitem>
202 <listitem> 256 精度が指定されない場合, 6桁が出力されます.
203 <para>精度が指定されない場合, 6桁が出力されます.</para> 257 </listitem>
204 </listitem> 258 <listitem>
205 <listitem> 259 精度がゼロの場合, 小数点は表示されず,
206 <para>精度がゼロの場合, 小数点は表示されず,
207 システムは<literal>value</literal>に最も近い整数に丸めた数を 260 システムは<literal>value</literal>に最も近い整数に丸めた数を
208 出力します. 261 出力します.
209 </para> 262 </listitem>
210 </listitem> 263 <listitem>
211 <listitem> 264 小数点が出力される場合,最低でも1桁がその前に出力されます.
212 <para>小数点が出力される場合,最低でも1桁がその前に出力されます.</para> 265 </listitem>
213 </listitem> 266 </itemizedlist>
214 </itemizedlist> 267 </td>
215 </listitem> 268 </tr>
216 <listitem> 269 <tr>
217 <para> 270 <th>e, E :</th>
218 e, E : 実数を受け取り,指数形式%[\-]<literal>d.ddde</literal>+/\-<literal>dd</literal> 271 <td>
219 に変換します. 272 Converts the input <literal>value</literal> to the exponential
273 form %[\-]<literal>d.ddde</literal>+/\-<literal>dd</literal>.
220 小数点の前に1桁があり,小数点の後の桁数は精度指定子に等しくなります. 274 小数点の前に1桁があり,小数点の後の桁数は精度指定子に等しくなります.
221 </para> 275 <itemizedlist>
222 <itemizedlist> 276 <listitem>
223 <listitem> 277 精度が指定されない場合, 6桁が出力されます.
224 <para>精度が指定されない場合, 6桁が出力されます.</para> 278 </listitem>
225 </listitem> 279 <listitem>
226 <listitem> 280 精度がゼロの場合, 小数点は表示されません.
227 <para>精度がゼロの場合, 小数点は表示されません. 281 </listitem>
228 </para> 282 <listitem>
229 </listitem>
230 <listitem>
231 <para>
232 <literal>E</literal> 変換文字の場合, 283 <literal>E</literal> 変換文字の場合,
233 指数の前の e の代わりに E を付けた数値を出力します. 284 指数の前の e の代わりに E を付けた数値を出力します.
234 指数には常に2桁以上が含まれます. 285 指数には常に2桁以上が含まれます.
235 値が 0 の場合, 指数は 0 となります. 286 値が 0 の場合, 指数は 0 となります.
236 </para> 287 </listitem>
237 </listitem> 288 </itemizedlist>
238 </itemizedlist> 289 </td>
239 </listitem> 290 </tr>
240 <listitem> 291 <tr>
241 <para>g, G : 実数を受け取り,有効桁数を指定する精度を付けた 292 <td style="white-space:nowrap"><emphasis role="bold">g, G :</emphasis></td>
293 <td>
294 有効桁数を指定する精度を付けた
242 <literal>e</literal>, <literal>E</literal>, または 295 <literal>e</literal>, <literal>E</literal>, または
243 <literal>f</literal>変換文字の形式に変換します. 296 <literal>f</literal>変換文字の形式に変換します.
297 Booleans are converted into 0 and 1. Only the real part of complex
298 numbers is considered.
244 末尾のゼロは結果から削除されます. 299 末尾のゼロは結果から削除されます.
245 小数点は数字が続く場合にのみ表示されます. 300 小数点は数字が続く場合にのみ表示されます.
246 使用される形式は変換される値に依存します. 301 使用される形式は変換される値に依存します.
@@ -248,24 +303,14 @@
248 精度より大きいか等しい場合に, 303 精度より大きいか等しい場合に,
249 <literal>e</literal> (使用されるフラグが<literal>G</literal>の場合は 304 <literal>e</literal> (使用されるフラグが<literal>G</literal>の場合は
250 <literal>E</literal>)形式が使用されます. 305 <literal>E</literal>)形式が使用されます.
251 </para> 306 </td>
252 </listitem> 307 </tr>
253 <listitem> 308 </table>
254 <para>c : 整数値を受け取り,文字に変換します.</para>
255 </listitem>
256 <listitem>
257 <para>
258 s : 文字列 <literal>value</literal> を受け取り,
259 文字列から末尾または精度に示された文字数に達するまで,
260 文字に変換します.精度が指定されない場合,末尾までの全ての文字が
261 表示されます.
262 </para>
263 </listitem>
264 </itemizedlist>
265 </listitem> 309 </listitem>
266 </itemizedlist> 310 </itemizedlist>
267 <para>フィールド幅または精度は, 311 </para>
268 桁文字の代わりに<literal>*</literal> (アスタリスク)で 312 <para>
313 フィールド幅または精度は, 桁文字の代わりに<literal>*</literal> (アスタリスク)で
269 示すことができます. 314 示すことができます.
270 この場合,整数 <literal>value</literal>パラメータは 315 この場合,整数 <literal>value</literal>パラメータは
271 フィールド幅または精度を指定します. 316 フィールド幅または精度を指定します.
@@ -284,21 +329,43 @@
284 </para> 329 </para>
285 <para>指数形式 %e の表示はプレットフォームに依存し, 330 <para>指数形式 %e の表示はプレットフォームに依存し,
286 指数の桁数は異なります. 331 指数の桁数は異なります.
332 <informaltable border="1">
333 <tr>
334 <td>プラットフォーム</td>
335 <td>例: msprintf("%e",1.23e4)</td>
336 </tr>
337 <tr>
338 <td>Windows</td>
339 <td>1.23000e+004</td>
340 </tr>
341 <tr>
342 <td>Linux/Mac OS</td>
343 <td>1.23000e+04</td>
344 </tr>
345 </informaltable>
346 </para>
347 <para>
348 <emphasis role="bold">Special escaped sequenced</emphasis> are supported in C-format
349 strings:
350 <table>
351 <tr>
352 <th>\n :</th>
353 <td>Go to Next line (line feed)</td>
354 </tr>
355 <tr>
356 <th>\r :</th>
357 <td>Return: go to the head of current line (for overprinting)</td>
358 </tr>
359 <tr>
360 <th>\t :</th>
361 <td>horizontal Tab</td>
362 </tr>
363 <tr>
364 <th>\\ :</th>
365 <td>print a backslash \</td>
366 </tr>
367 </table>
287 </para> 368 </para>
288 <informaltable border="1">
289 <tr>
290 <td>プラットフォーム</td>
291 <td>例: msprintf("%e",1.23e4)</td>
292 </tr>
293 <tr>
294 <td>Windows</td>
295 <td>1.23000e+004</td>
296 </tr>
297 <tr>
298 <td>Linux/Mac OS</td>
299 <td>1.23000e+04</td>
300 </tr>
301 </informaltable>
302 </refsection> 369 </refsection>
303 <refsection> 370 <refsection>
304 <title>例</title> 371 <title>例</title>
@@ -320,7 +387,45 @@ mprintf('a float (exponential form): %3.2e\n', %pi);
320mprintf('a float (exponential form): %3.2g\n', %pi); 387mprintf('a float (exponential form): %3.2g\n', %pi);
321mprintf('a character: %c\n', 'a'); 388mprintf('a character: %c\n', 'a');
322mprintf('a character: %c\n', 'aaa'); 389mprintf('a character: %c\n', 'aaa');
323 ]]></programlisting> 390 ]]></programlisting>
391 <para/>
392 <para>
393 With input booleans:
394 </para>
395 <programlisting role="example"><![CDATA[
396mprintf("\n%%d: %d, %%u: %u, %%o: %o, %%f: %f, %%e: %e, %%s: %s\n" + ..
397 "%%d: %d, %%u: %u, %%o: %o, %%f: %f, %%e: %e, %%s: %s\n", ..
398 %T, %T, %T, %T, %T, %T, %F, %F, %F, %F, %F, %F);
399 ]]></programlisting>
400 <screen><![CDATA[
401%d: 1, %u: 1, %o: 1, %f: 1.000000, %e: 1.000000e+00, %s: T
402%d: 0, %u: 0, %o: 0, %f: 0.000000, %e: 0.000000e+00, %s: F
403]]></screen>
404 <para/>
405 <para>
406 With numbered placeholders:
407 </para>
408 <programlisting role="example"><![CDATA[
409mprintf("%2$s is %1$d-year old.\n", 32, "Peter");
410 ]]></programlisting>
411 <screen><![CDATA[
412Peter is 32-year old.
413]]></screen>
414 <para/>
415 <para>
416 With escaped sequences and UTF-8 extended characters:
417 </para>
418 <programlisting role="example"><![CDATA[
419mprintf("The path T:\\abc does not exist.\n");
420mprintf("abcdefghijk\tαβδ\tεϵ\tζηθικλ\rABCDE\n");
421 ]]></programlisting>
422 <screen><![CDATA[
423--> mprintf("The path T:\\abc does not exist.\n");
424The path T:\abc does not exist
425
426--> mprintf("abcdefghijk\tαβδ\tεϵ\tζηθικλ\rABCDE\n");
427ABCDEfghijk αβδ εϵ ζηθικλ
428]]></screen>
324 </refsection> 429 </refsection>
325 <refsection role="see also"> 430 <refsection role="see also">
326 <title>参照</title> 431 <title>参照</title>
@@ -336,4 +441,21 @@ mprintf('a character: %c\n', 'aaa');
336 </member> 441 </member>
337 </simplelist> 442 </simplelist>
338 </refsection> 443 </refsection>
444 <refsection role="history">
445 <title>履歴</title>
446 <revhistory>
447 <revision>
448 <revnumber>6.1.0</revnumber>
449 <revdescription>
450 Numbered placeholders "%n$.." are supported.
451 </revdescription>
452 </revision>
453 <revision>
454 <revnumber>6.1.1</revnumber>
455 <revdescription>
456 Input boolean data can be converted.
457 </revdescription>
458 </revision>
459 </revhistory>
460 </refsection>
339</refentry> 461</refentry>
diff --git a/scilab/modules/output_stream/help/pt_BR/printf_conversion.xml b/scilab/modules/output_stream/help/pt_BR/printf_conversion.xml
index ec8f2e1..4ec5be5 100644
--- a/scilab/modules/output_stream/help/pt_BR/printf_conversion.xml
+++ b/scilab/modules/output_stream/help/pt_BR/printf_conversion.xml
@@ -2,8 +2,8 @@
2<!-- 2<!--
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) XXXX-2008 - INRIA 4 * Copyright (C) XXXX-2008 - INRIA
5 *
6 * Copyright (C) 2012 - 2016 - Scilab Enterprises 5 * Copyright (C) 2012 - 2016 - Scilab Enterprises
6 * Copyright (C) 2021 - Samuel GOUGEON
7 * 7 *
8 * This file is hereby licensed under the terms of the GNU GPL v2.0, 8 * This file is hereby licensed under the terms of the GNU GPL v2.0,
9 * pursuant to article 5.3.4 of the CeCILL v.2.1. 9 * pursuant to article 5.3.4 of the CeCILL v.2.1.
@@ -13,7 +13,10 @@
13 * along with this program. 13 * along with this program.
14 * 14 *
15 --> 15 -->
16<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns4="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="printf_conversion" xml:lang="pt"> 16<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
17 xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns4="http://www.w3.org/1999/xhtml"
18 xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook"
19 xmlns:scilab="http://www.scilab.org" xml:id="printf_conversion" xml:lang="pt">
17 <refnamediv> 20 <refnamediv>
18 <refname>printf_conversion</refname> 21 <refname>printf_conversion</refname>
19 <refpurpose>Especificações de conversão de mprintf, msprintf, 22 <refpurpose>Especificações de conversão de mprintf, msprintf,
@@ -32,57 +35,76 @@
32 </listitem> 35 </listitem>
33 <listitem> 36 <listitem>
34 <para> 37 <para>
35 Zero ou mais <literal>options</literal> (opções), que modificam 38 An optional integer n ≥ 1 followed by "$". n is the index of the input data
36 o significado da especificação de conversão. A lista seguinte contem 39 to substitute to the placeholder, in the msprintf, mprintf .. list of input data.
37 os caracteres <literal>option</literal> e seus significados: 40 In a format string, placeholders are either all numbered or all non-numbered.
38 </para> 41 A given numbered placeholder can be used only once in its C-format string
39 </listitem> 42 (Scilab limitation).
40 <listitem>
41 <para>Alinhe à esquerda, dentro do campo, o resultado da
42 conversão.
43 </para>
44 </listitem>
45 <listitem>
46 <para>Comece o resultado de uma conversão com sinal com um sinal (+ ou
47 -).
48 </para> 43 </para>
49 </listitem> 44 </listitem>
50 <listitem> 45 <listitem>
51 <para>Prefixe um caractere de espaço ao resultado se o primeiro 46 <para>
52 caractere de uma conversão com sinal não for um sinal. Se ambas as 47 Zero ou mais <literal>options</literal> (opções), que modificam
53 opções (espaço) e + aparecerem, a opção (space) é ignorada. 48 o significado da especificação de conversão. A lista seguinte contem
54 </para> 49 os caracteres <literal>option</literal> e seus significados:
55 </listitem>
56 <listitem>
57 <para>Converta o valor para uma forma alternativa. Para as conversões
58 <literal>c</literal>, <literal>d</literal>, <literal>i</literal>,
59 <literal>s</literal>, e <literal>u</literal>, a opção
60 <literal>#</literal> não possui efeito. Para a conversão
61 <literal>o</literal>, <literal>#</literal> aumenta a precisão para
62 forçar o primeiro dígito do resultado a ser 0 (zero). Para as
63 conversões <literal>x</literal> e <literal>X</literal>, um valor
64 não-nulo possui 0x ou 0X prefixado a ele. Para as conversões
65 <literal>e, E, f, g,</literal> e <literal>G</literal>, o resultado
66 sempre contém ponto decimal, Mesmo que nenhum dígito o siga. Para as
67 conversões <literal>g</literal> e <literal>G</literal>, zeros por
68 último não são removidos.
69 </para>
70 </listitem>
71 <listitem>
72 <para>Aumente a largura do campo utilizando zeros à esquerda (seguindo
73 qualquer indicação de sinal ou base) para as conversões
74 <literal>d</literal>, <literal>i</literal>, <literal>o</literal>,
75 <literal>u</literal>, <literal>x</literal>, <literal>X</literal>,
76 <literal>e</literal>, <literal>E</literal>, <literal>f</literal>,
77 <literal>g</literal>, e <literal>G</literal>; nenhum aumento de espaço
78 é realizado. Se ambos os indicadores <literal>0</literal> e
79 <literal>\-</literal> (barra) aparecerem, o indicador
80 <literal>0</literal> é ignorado. Para as conversões
81 <literal>d</literal>, <literal>i</literal>, <literal>o</literal>
82 <literal>u</literal>, <literal>x</literal>, e <literal>X</literal>, se
83 uma precisão for especificada, o indicador <literal>0</literal> também
84 é ignorado.
85 </para> 50 </para>
51 <table>
52 <tr>
53 <th>- :</th>
54 <td>
55 Alinhe à esquerda, dentro do campo, o resultado da conversão.
56 </td>
57 </tr>
58 <tr>
59 <th>+ :</th>
60 <td>
61 Comece o resultado de uma conversão com sinal com um sinal (+ ou -).
62 </td>
63 </tr>
64 <tr>
65 <td style="white-space:nowrap"><emphasis role="bold">' ' :</emphasis></td>
66 <td>
67 (space) Prefixe um caractere de espaço ao resultado se o primeiro
68 caractere de uma conversão com sinal não for um sinal. Se ambas as
69 opções (espaço) e + aparecerem, a opção (space) é ignorada.
70 </td>
71 </tr>
72 <tr>
73 <th># :</th>
74 <td>
75 Converta o valor para uma forma alternativa. Para as conversões
76 <literal>c</literal>, <literal>d</literal>, <literal>i</literal>,
77 <literal>s</literal>, e <literal>u</literal>, a opção
78 <literal>#</literal> não possui efeito. Para a conversão
79 <literal>o</literal>, <literal>#</literal> aumenta a precisão para
80 forçar o primeiro dígito do resultado a ser 0 (zero). Para as
81 conversões <literal>x</literal> e <literal>X</literal>, um valor
82 não-nulo possui 0x ou 0X prefixado a ele. Para as conversões
83 <literal>e, E, f, g,</literal> e <literal>G</literal>, o resultado
84 sempre contém ponto decimal, Mesmo que nenhum dígito o siga. Para as
85 conversões <literal>g</literal> e <literal>G</literal>, zeros por
86 último não são removidos.
87 </td>
88 </tr>
89 <tr>
90 <th>0 :</th>
91 <td>
92 Aumente a largura do campo utilizando zeros à esquerda (seguindo
93 qualquer indicação de sinal ou base) para as conversões
94 <literal>d</literal>, <literal>i</literal>, <literal>o</literal>,
95 <literal>u</literal>, <literal>x</literal>, <literal>X</literal>,
96 <literal>e</literal>, <literal>E</literal>, <literal>f</literal>,
97 <literal>g</literal>, e <literal>G</literal>; nenhum aumento de espaço
98 é realizado. Se ambos os indicadores <literal>0</literal> e
99 <literal>\-</literal> (barra) aparecerem, o indicador
100 <literal>0</literal> é ignorado. Para as conversões
101 <literal>d</literal>, <literal>i</literal>, <literal>o</literal>
102 <literal>u</literal>, <literal>x</literal>, e <literal>X</literal>, se
103 uma precisão for especificada, o indicador <literal>0</literal> também
104 é ignorado.
105 </td>
106 </tr>
107 </table>
86 </listitem> 108 </listitem>
87 <listitem> 109 <listitem>
88 <para>Um string de dígitos decimais opcional que especifica a largura 110 <para>Um string de dígitos decimais opcional que especifica a largura
@@ -101,26 +123,22 @@
101 </para> 123 </para>
102 <itemizedlist> 124 <itemizedlist>
103 <listitem> 125 <listitem>
104 <para>O número mínimo de dígitos a aparecerem nas conversões 126 O número mínimo de dígitos a aparecerem nas conversões
105 <literal>d</literal>, <literal>u</literal>, <literal>o</literal>, 127 <literal>d</literal>, <literal>u</literal>, <literal>o</literal>,
106 <literal>x</literal>, ou <literal>X</literal> 128 <literal>x</literal>, ou <literal>X</literal>.
107 </para>
108 </listitem> 129 </listitem>
109 <listitem> 130 <listitem>
110 <para>O número de dígitos a aparecerem após o ponto decimal nas 131 O número de dígitos a aparecerem após o ponto decimal nas
111 conversões <literal>e</literal>, <literal>E</literal>, e 132 conversões <literal>e</literal>, <literal>E</literal>, e
112 <literal>f</literal> 133 <literal>f</literal>.
113 </para>
114 </listitem> 134 </listitem>
115 <listitem> 135 <listitem>
116 <para>O número máximo de dígitos significativos para as conversões 136 O número máximo de dígitos significativos para as conversões
117 <literal>g</literal> e <literal>G</literal> 137 <literal>g</literal> e <literal>G</literal>.
118 </para>
119 </listitem> 138 </listitem>
120 <listitem> 139 <listitem>
121 <para>O número máximo de caracteres a serem impressos a partir de um 140 O número máximo de caracteres a serem impressos a partir de um
122 string em uma convesão <literal>s</literal> 141 string em uma convesão <literal>s</literal>.
123 </para>
124 </listitem> 142 </listitem>
125 </itemizedlist> 143 </itemizedlist>
126 </listitem> 144 </listitem>
@@ -128,126 +146,163 @@
128 <para>O caractere que indica o tipo de conversão a ser 146 <para>O caractere que indica o tipo de conversão a ser
129 aplicada: 147 aplicada:
130 </para> 148 </para>
131 </listitem> 149 <table>
132 <listitem> 150 <tr>
133 <para>Não realiza conversão. Exibe %.</para> 151 <th>% :</th>
134 </listitem> 152 <td>
135 <listitem> 153 Não realiza conversão. Exibe %..
136 <para>Aceita um valor inteiro e o converte para notação decimal com 154 <note>
137 sinal. A precisão especifica o número mínimo de dígitos a aparecer. Se 155 This may be useful for instance to print percentages, or
138 o valor sendo convertido puder ser representado em menos dígitos, ele 156 to process some LaTeX expression including LaTeX comments
139 é expandido com zeros à esquerda. A precisão padrão é 1. O resultado 157 starting with "%", etc.
140 de se converter um valor zero com uma precisão de zero é um string 158 </note>
141 nulo. A especificação de uma largura de campo com zero como caractere 159 </td>
142 mais à esquerda faz com que o valor da largura do campo seja 160 </tr>
143 preenchido com zeros à esquerda. 161 <tr>
144 </para> 162 <th>s :</th>
145 </listitem> 163 <td>
146 <listitem> 164 Accepts a string or boolean <literal>value</literal> e exibe caracteres
147 <para>Aceita um valor inteiro e o converte para a notação decimal sem 165 do string até o fim ou até que o número de caracteres indicados pela
148 sinal. A precisão especifica o número mínimo de dígitos a aparecer. Se 166 precisão seja alcançado. Se nenhuma precisão for especificada, todos os
149 o valor sendo convertido puder ser representado em menos dígitos, ele 167 caracteres até o fim são exibidos.
150 é expandido com zeros à esquerda. A precisão padrão é 1. O resultado 168 UTF-8 extended characters are supported in input strings.
151 de se converter um valor zero com uma precisão de zero é um string 169 Booleans are converted into 'T' or 'F'.
152 nulo. A especificação de uma largura de campo com zero como caractere 170 </td>
153 mais à esquerda faz com que o valor da largura do campo seja 171 </tr>
154 preenchido com zeros à esquerda. 172 <tr>
155 </para> 173 <th>c :</th>
156 </listitem> 174 <td>Not supported.
157 <listitem> 175 </td>
158 <para>Aceita um valor inteiro e o converte para a sua notação octal 176 </tr>
159 sem sinal. A precisão especifica o número mínimo de dígitos a 177 <tr>
160 aparecer. Se o valor sendo convertido puder ser representado em menos 178 <td colspan="2">
161 dígitos, ele é expandido com zeros à esquerda. A precisão padrão é 1. 179 All following conversions accept any decimal numerical or boolean
162 O resultado de se converter um valor zero com uma precisão de zero é 180 input <literal>value</literal>. Only the real part of any input
163 um string nulo. A especificação de uma largura de campo com zero como 181 complex number is considered. Booleans are implicitly converted
164 caractere mais à esquerda faz com que o valor da largura do campo seja 182 into 0 and 1.
165 preenchido com zeros à esquerda. Não é implicado um valor octal para a 183 </td>
166 largura do campo. 184 </tr>
167 </para> 185 <tr>
168 </listitem> 186 <th>d,i :</th>
169 <listitem> 187 <td>
170 <para>Aceita um valor inteiro e o converte para a sua notação 188 Converts the input <literal>value</literal> to a signed integer int32
171 hexadecimal sem sinal. As letras ``abcdef'' são utilizadas para a 189 notation. Conversions for input |Numbers| ≥ 2^31 are not reliable.
172 conversão <literal>x</literal>; as letras ``ABCDEF'' são utilizadas 190 A precisão especifica o número mínimo de dígitos a aparecer. Se
173 para a conversão <literal>X</literal>. A precisão especifica o número 191 o valor sendo convertido puder ser representado em menos dígitos, ele
174 mínimo de dígitos a aparecer. Se o valor sendo convertido puder ser 192 é expandido com zeros à esquerda. A precisão padrão é 1. O resultado
175 representado em menos dígitos, ele é expandido com zeros à esquerda. A 193 de se converter um valor zero com uma precisão de zero é um string
176 precisão padrão é 1. O resultado de se converter um valor zero com uma 194 nulo. A especificação de uma largura de campo com zero como caractere
177 precisão de zero é um string nulo. A especificação de uma largura de 195 mais à esquerda faz com que o valor da largura do campo seja
178 campo com zero como caractere mais à esquerda faz com que o valor da 196 preenchido com zeros à esquerda.
179 largura do campo seja preenchido com zeros à esquerda. 197 </td>
180 </para> 198 </tr>
181 </listitem> 199 <tr>
182 <listitem> 200 <th>u :</th>
183 <para>Aceita um valor float ou double e o converte para a sua notação 201 <td>
184 decimal no formato %[\-]<literal>ddd.ddd</literal>. O número de 202 Converts the input <literal>value</literal> to an unsigned integer
185 dígitos após o ponto decimal é igual à especificação de 203 uint32 notation. Conversions for input |Numbers| ≥ 2^32 are not reliable.
186 precisão. 204 A precisão especifica o número mínimo de dígitos a aparecer. Se
187 </para> 205 o valor sendo convertido puder ser representado em menos dígitos, ele
188 </listitem> 206 é expandido com zeros à esquerda. A precisão padrão é 1. O resultado
189 <listitem> 207 de se converter um valor zero com uma precisão de zero é um string
190 <para>Se nenhuma precisão for especificada, a saída possui seis 208 nulo. A especificação de uma largura de campo com zero como caractere
191 dígitos 209 mais à esquerda faz com que o valor da largura do campo seja
192 </para> 210 preenchido com zeros à esquerda.
193 </listitem> 211 </td>
194 <listitem> 212 </tr>
195 <para>Se a precisão for zero, nenhum ponto decimal aparece e o sistema 213 <tr>
196 imprime na saída o valor inteiro mais próximo de 214 <th>o :</th>
197 <literal>value</literal>. 215 <td>
198 </para> 216 Converts the input <literal>value</literal> to an unsigned octal notation.
199 </listitem> 217 Conversions for input |Numbers| ≥ 2^32 are not reliable.
200 <listitem> 218 A precisão especifica o número mínimo de dígitos a
201 <para>Se a saída possui um ponto decimal, pelo menos um dígito é posto 219 aparecer. Se o valor sendo convertido puder ser representado em menos
202 antes dele. 220 dígitos, ele é expandido com zeros à esquerda. A precisão padrão é 1.
203 </para> 221 O resultado de se converter um valor zero com uma precisão de zero é
204 </listitem> 222 um string nulo. A especificação de uma largura de campo com zero como
205 <listitem> 223 caractere mais à esquerda faz com que o valor da largura do campo seja
206 <para>Aceita um real e o converte para a sua forma exponencial 224 preenchido com zeros à esquerda. Não é implicado um valor octal para a
207 %[\-]<literal>d.ddde</literal>+/\-<literal>dd</literal>. Há um dígito 225 largura do campo.
208 antes do ponto decimal, e o número de dígitos após o ponto decimal é 226 </td>
209 igual à especificação de precisão. 227 </tr>
210 </para> 228 <tr>
211 </listitem> 229 <th>x, X :</th>
212 <listitem> 230 <td>
213 <para>Se nenhuma precisão for especificada, a saída são seis 231 Converts the input <literal>value</literal> to an unsigned hexadecimal
214 dígitos 232 notation. Conversions for input |Numbers| ≥ 2^32 are not reliable.
215 </para> 233 As letras ``abcdef'' são utilizadas para a
216 </listitem> 234 conversão <literal>x</literal>; as letras ``ABCDEF'' são utilizadas
217 <listitem> 235 para a conversão <literal>X</literal>. A precisão especifica o número
218 <para>Se a precisão for zero, nenhum ponto decimal aparece.</para> 236 mínimo de dígitos a aparecer. Se o valor sendo convertido puder ser
219 </listitem> 237 representado em menos dígitos, ele é expandido com zeros à esquerda. A
220 <listitem> 238 precisão padrão é 1. O resultado de se converter um valor zero com uma
221 <para> 239 precisão de zero é um string nulo. A especificação de uma largura de
222 A caractere de conversão <literal>E</literal> produz um número 240 campo com zero como caractere mais à esquerda faz com que o valor da
223 com o caractere 'E', ao invés de 'e' antes do expoente. O expoente 241 largura do campo seja preenchido com zeros à esquerda.
224 sempre contém pelo menos dois dígitos. Se o valor for zero, o expoente 242 </td>
225 é zero. 243 </tr>
226 </para> 244 <tr>
227 </listitem> 245 <th>f :</th>
228 <listitem> 246 <td>
229 <para>Aceita um real e o converte no estilo dos caracteres de 247 Converte o <literal>value</literal> de entrada para a sua notação decimal
230 conversão <literal>e</literal>, <literal>E</literal>, ou 248 no formato% [\-]<literal>ddd.ddd</literal>.
231 <literal>f</literal>, com a precisão especificando o número de dígitos 249 O número de dígitos após o ponto decimal é igual à especificação de
232 significativos. Zeros por último são removidos. Um ponto decimal 250 precisão.
233 aparece apenas se for seguido de um dígito. O estilo depende do valor 251 <itemizedlist>
234 convertido. O resultado é o estilo <literal>e</literal> 252 <listitem>
235 (<literal>E</literal>, se <literal>G</literal> é o indicador 253 Se nenhuma precisão for especificada, a saída possui seis dígitos
236 utilizado) apenas se o expoente resultante da conversão for menor do 254 </listitem>
237 que -4, ou se for maior do que ou igual à precisão. 255 <listitem>
238 </para> 256 Se a precisão for zero, nenhum ponto decimal aparece e o sistema
239 </listitem> 257 imprime na saída o valor inteiro mais próximo de
240 <listitem> 258 <literal>value</literal>.
241 <para>Aceita e exibe um valor inteiro convertido em um 259 </listitem>
242 caractere. 260 <listitem>
243 </para> 261 Se a saída possui um ponto decimal, pelo menos um dígito é posto
244 </listitem> 262 antes dele.
245 <listitem> 263 </listitem>
246 <para>Aceita um valor string e exibe caracteres do string até o fim 264 </itemizedlist>
247 ou até que o número de caracteres indicados pela precisão seja 265 </td>
248 alcançado. Se nenhuma precisão for especificada, todos os caracteres 266 </tr>
249 até o fim são exibidos. 267 <tr>
250 </para> 268 <th>e, E :</th>
269 <td>
270 Converte o <literal>value</literal> de entrada para a sua forma exponencial
271 %[\-]<literal>d.ddde</literal>+/\-<literal>dd</literal>.
272 Há um dígito antes do ponto decimal, e o número de dígitos após o
273 ponto decimal é igual à especificação de precisão.
274 <itemizedlist>
275 <listitem>
276 Se nenhuma precisão for especificada, a saída são seis dígitos.
277 </listitem>
278 <listitem>
279 Se a precisão for zero, nenhum ponto decimal aparece.
280 </listitem>
281 <listitem>
282 A caractere de conversão <literal>E</literal> produz um
283 número com o caractere 'E', ao invés de 'e' antes do expoente.
284 O expoente sempre contém pelo menos dois dígitos. Se o valor
285 for zero, o expoente é zero.
286 </listitem>
287 </itemizedlist>
288 </td>
289 </tr>
290 <tr>
291 <td style="white-space:nowrap"><emphasis role="bold">g, G :</emphasis></td>
292 <td>
293 Converte o <literal>value</literal> de entrada no estilo dos caracteres
294 de conversão <literal>e</literal>, <literal>E</literal>, ou
295 <literal>f</literal>, com a precisão especificando o número de dígitos
296 significativos.
297 Zeros por último são removidos. Um ponto decimal
298 aparece apenas se for seguido de um dígito. O estilo depende do valor
299 convertido. O resultado é o estilo <literal>e</literal>
300 (<literal>E</literal>, se <literal>G</literal> é o indicador
301 utilizado) apenas se o expoente resultante da conversão for menor do
302 que -4, ou se for maior do que ou igual à precisão.
303 </td>
304 </tr>
305 </table>
251 </listitem> 306 </listitem>
252 </itemizedlist> 307 </itemizedlist>
253 <para>Uma largura de campo ou uma precisão podem ser indicadas por 308 <para>Uma largura de campo ou uma precisão podem ser indicadas por
@@ -264,6 +319,106 @@
264 <para>A representação do sinal de mais depende da opção de formatação 319 <para>A representação do sinal de mais depende da opção de formatação
265 especificada, se <literal>+</literal> ou (espaço). 320 especificada, se <literal>+</literal> ou (espaço).
266 </para> 321 </para>
322 <para>
323 Display of exponential form %e is platform dependent with a different number of digits
324 in exponent.
325 <informaltable border="1">
326 <tr>
327 <td>Platform</td>
328 <td>Example: msprintf("%e",1.23e4)</td>
329 </tr>
330 <tr>
331 <td>Windows</td>
332 <td>1.23000e+004</td>
333 </tr>
334 <tr>
335 <td>Linux/Mac OS</td>
336 <td>1.23000e+04</td>
337 </tr>
338 </informaltable>
339 </para>
340 <para>
341 <emphasis role="bold">Special escaped sequences</emphasis> are supported in Scilab
342 C-format strings:
343 <table>
344 <tr>
345 <th>\n :</th>
346 <td>Go to Next line (line feed)</td>
347 </tr>
348 <tr>
349 <th>\r :</th>
350 <td>Return: go to the head of current line (for overprinting)</td>
351 </tr>
352 <tr>
353 <th>\t :</th>
354 <td>horizontal Tab</td>
355 </tr>
356 <tr>
357 <th>\\ :</th>
358 <td>print a backslash \</td>
359 </tr>
360 </table>
361 </para>
362 </refsection>
363 <refsection>
364 <title>Exemplos</title>
365 <programlisting role="example"><![CDATA[
366mprintf('a string: %s\n', 'Scilab');
367mprintf('an integer: %d\n', 10);
368mprintf('an integer: %4d\n', 10);
369mprintf('a left justified integer: %-4d\n', 10);
370mprintf('an integer converted to float: %#fd\n',10);
371mprintf('an integer with a sign: %+4d\n', 10);
372mprintf('an integer with a sign: %+4d\n', -10);
373mprintf('an integer padded with zeros: %04d\n', 10);
374mprintf('an unsigned integer: %u\n', 10);
375mprintf('an unsigned integer: %4u\n', -10);
376mprintf('an integer converted to hexadecimal: %x\n', 10);
377mprintf('a float: %d\n', %pi);
378mprintf('a float: %3.2d\n', %pi);
379mprintf('a float (exponential form): %3.2e\n', %pi);
380mprintf('a float (exponential form): %3.2g\n', %pi);
381mprintf('a character: %c\n', 'a');
382mprintf('a character: %c\n', 'aaa');
383 ]]></programlisting>
384 <para/>
385 <para>
386 With input booleans:
387 </para>
388 <programlisting role="example"><![CDATA[
389mprintf("\n%%d: %d, %%u: %u, %%o: %o, %%f: %f, %%e: %e, %%s: %s\n" + ..
390 "%%d: %d, %%u: %u, %%o: %o, %%f: %f, %%e: %e, %%s: %s\n", ..
391 %T, %T, %T, %T, %T, %T, %F, %F, %F, %F, %F, %F);
392 ]]></programlisting>
393 <screen><![CDATA[
394%d: 1, %u: 1, %o: 1, %f: 1.000000, %e: 1.000000e+00, %s: T
395%d: 0, %u: 0, %o: 0, %f: 0.000000, %e: 0.000000e+00, %s: F
396]]></screen>
397 <para/>
398 <para>
399 With numbered placeholders:
400 </para>
401 <programlisting role="example"><![CDATA[
402mprintf("%2$s is %1$d-year old.\n", 32, "Peter");
403 ]]></programlisting>
404 <screen><![CDATA[
405Peter is 32-year old.
406]]></screen>
407 <para/>
408 <para>
409 With escaped sequences and UTF-8 extended characters:
410 </para>
411 <programlisting role="example"><![CDATA[
412mprintf("The path T:\\abc does not exist.\n");
413mprintf("abcdefghijk\tαβδ\tεϵ\tζηθικλ\rABCDE\n");
414 ]]></programlisting>
415 <screen><![CDATA[
416--> mprintf("The path T:\\abc does not exist.\n");
417The path T:\abc does not exist
418
419--> mprintf("abcdefghijk\tαβδ\tεϵ\tζηθικλ\rABCDE\n");
420ABCDEfghijk αβδ εϵ ζηθικλ
421]]></screen>
267 </refsection> 422 </refsection>
268 <refsection role="see also"> 423 <refsection role="see also">
269 <title>Ver Também</title> 424 <title>Ver Também</title>
@@ -279,4 +434,21 @@
279 </member> 434 </member>
280 </simplelist> 435 </simplelist>
281 </refsection> 436 </refsection>
437 <refsection role="history">
438 <title>Histórico</title>
439 <revhistory>
440 <revision>
441 <revnumber>6.1.0</revnumber>
442 <revdescription>
443 Numbered placeholders "%n$.." are supported.
444 </revdescription>
445 </revision>
446 <revision>
447 <revnumber>6.1.1</revnumber>
448 <revdescription>
449 Input boolean data can be converted.
450 </revdescription>
451 </revision>
452 </revhistory>
453 </refsection>
282</refentry> 454</refentry>
diff --git a/scilab/modules/output_stream/macros/%b_mfprintf.sci b/scilab/modules/output_stream/macros/%b_mfprintf.sci
new file mode 100644
index 0000000..dc38f49
--- /dev/null
+++ b/scilab/modules/output_stream/macros/%b_mfprintf.sci
@@ -0,0 +1,15 @@
1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) 2020 - Samuel GOUGEON - Le Mans Université
3//
4// This file is hereby licensed under the terms of the GNU GPL v2.0,
5// pursuant to article 5.3.4 of the CeCILL v.2.1.
6// This file was originally licensed under the terms of the CeCILL v2.1,
7// and continues to be available under such terms.
8// For more information, see the COPYING file which you should have received
9// along with this program.
10//
11
12function %b_mfprintf(fd, Format, varargin)
13 varargin = %printf_boolean(Format, varargin(:))
14 mfprintf(fd, Format, varargin(:))
15endfunction
diff --git a/scilab/modules/output_stream/macros/%b_mprintf.sci b/scilab/modules/output_stream/macros/%b_mprintf.sci
new file mode 100644
index 0000000..8882fca
--- /dev/null
+++ b/scilab/modules/output_stream/macros/%b_mprintf.sci
@@ -0,0 +1,15 @@
1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) 2020 - Samuel GOUGEON - Le Mans Université
3//
4// This file is hereby licensed under the terms of the GNU GPL v2.0,
5// pursuant to article 5.3.4 of the CeCILL v.2.1.
6// This file was originally licensed under the terms of the CeCILL v2.1,
7// and continues to be available under such terms.
8// For more information, see the COPYING file which you should have received
9// along with this program.
10//
11
12function %b_mprintf(Format, varargin)
13 varargin = %printf_boolean(Format, varargin(:))
14 mprintf(Format, varargin(:))
15endfunction
diff --git a/scilab/modules/output_stream/macros/%b_msprintf.sci b/scilab/modules/output_stream/macros/%b_msprintf.sci
new file mode 100644
index 0000000..1399464
--- /dev/null
+++ b/scilab/modules/output_stream/macros/%b_msprintf.sci
@@ -0,0 +1,15 @@
1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) 2020 - Samuel GOUGEON - Le Mans Université
3//
4// This file is hereby licensed under the terms of the GNU GPL v2.0,
5// pursuant to article 5.3.4 of the CeCILL v.2.1.
6// This file was originally licensed under the terms of the CeCILL v2.1,
7// and continues to be available under such terms.
8// For more information, see the COPYING file which you should have received
9// along with this program.
10//
11
12function r = %b_msprintf(Format, varargin)
13 varargin = %printf_boolean(Format, varargin(:))
14 r = msprintf(Format, varargin(:))
15endfunction
diff --git a/scilab/modules/output_stream/macros/%printf_boolean.sci b/scilab/modules/output_stream/macros/%printf_boolean.sci
new file mode 100644
index 0000000..86776a1
--- /dev/null
+++ b/scilab/modules/output_stream/macros/%printf_boolean.sci
@@ -0,0 +1,34 @@
1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) 2020 - Samuel GOUGEON - Le Mans Université
3//
4// This file is hereby licensed under the terms of the GNU GPL v2.0,
5// pursuant to article 5.3.4 of the CeCILL v.2.1.
6// This file was originally licensed under the terms of the CeCILL v2.1,
7// and continues to be available under such terms.
8// For more information, see the COPYING file which you should have received
9// along with this program.
10//
11
12function r = %printf_boolean(Format, varargin)
13 r = varargin
14 Format = strsubst(Format, "%%", "")
15 [s, e, Fields] = regexp(Format, "/%.*?[diuoxXfeEgGcs]/")
16 if grep(Fields, "$") <> [] then
17 // numbered formats: reordering fields in order to know
18 // the expected output format for each input argument.
19 for f = Fields'
20 [s,e,m,n] = regexp(f, "/%([0-9])\$/")
21 tmp(evstr(n)) = f
22 end
23 Fields = tmp
24 end
25 for i = 1:length(varargin)
26 if type(r(i)) == 4 // boolean
27 if or(part(Fields(i),$)==["s" "c"])
28 r(i) = string(r(i))
29 else
30 r(i) = bool2s(r(i))
31 end
32 end
33 end
34endfunction
diff --git a/scilab/modules/output_stream/tests/unit_tests/mprintf.dia.ref b/scilab/modules/output_stream/tests/unit_tests/mprintf.dia.ref
index a45bb94..4f885e4 100644
--- a/scilab/modules/output_stream/tests/unit_tests/mprintf.dia.ref
+++ b/scilab/modules/output_stream/tests/unit_tests/mprintf.dia.ref
@@ -1,6 +1,7 @@
1// ============================================================================= 1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2008 - INRIA 3// Copyright (C) 2008 - INRIA
4// Copyright (C) 2020 - Samuel GOUGEON - Le Mans Université
4// 5//
5// This file is distributed under the same license as the Scilab package. 6// This file is distributed under the same license as the Scilab package.
6// ============================================================================= 7// =============================================================================
@@ -211,3 +212,100 @@ mprintf("==>%10s : %08.4f %08.4f %08.4f<==\n\n",A,C,D);
211==> row 8 : 048.1851 069.7085 089.0622<== 212==> row 8 : 048.1851 069.7085 089.0622<==
212==> row 9 : 026.3956 084.1552 050.4221<== 213==> row 9 : 026.3956 084.1552 050.4221<==
213==> row 10 : 041.4810 040.6202 034.9362<== 214==> row 10 : 041.4810 040.6202 034.9362<==
215// Booleans
216// =============================================================================
217n = [%pi ; %e];
218b = [%T ; %F];
219for f = ["d" "i" "u" "o" "x" "X" "g" "G"]
220 mprintf("%"+f+"\n", b);
221 mprintf("%"+f+" %d\n", b, n);
222 if and(f <> ["u" "o" "x" "X"]) // http://bugzilla.scilab.org/16563
223 mprintf("%2$"+f+" %1$d\n", n, b);
224 end
225end
2261
2270
2281 3
2290 2
2301 3
2310 2
2321
2330
2341 3
2350 2
2361 3
2370 2
2381
2390
2401 3
2410 2
2421
2430
2441 3
2450 2
2461
2470
2481 3
2490 2
2501
2510
2521 3
2530 2
2541
2550
2561 3
2570 2
2581 3
2590 2
2601
2610
2621 3
2630 2
2641 3
2650 2
266// %f
267msprintf("%f\n", b);
268mprintf("%f %d\n", b, n);
2691.000000 3
2700.000000 2
271mprintf("%2$f %1$d\n", n, b);
2721.000000 3
2730.000000 2
274// %e
275mprintf("%e\n", b);
2761.000000e+00
2770.000000e+00
278mprintf("%e %d\n", b, n);
2791.000000e+00 3
2800.000000e+00 2
281mprintf("%2$e %1$d\n", n, b);
2821.000000e+00 3
2830.000000e+00 2
284// %E
285mprintf("%E\n", b);
2861.000000E+00
2870.000000E+00
288mprintf("%E %d\n", b, n);
2891.000000E+00 3
2900.000000E+00 2
291mprintf("%2$E %1$d\n", n, b);
2921.000000E+00 3
2930.000000E+00 2
294// %s, %c
295for f = ["s" "c"]
296 mprintf("%"+f+"\n", b);
297 mprintf("%"+f+" %d\n", b, n);
298 mprintf("%2$"+f+" %1$d\n", n, b);
299end
300T
301F
302T 3
303F 2
304T 3
305F 2
306T
307F
308T 3
309F 2
310T 3
311F 2
diff --git a/scilab/modules/output_stream/tests/unit_tests/mprintf.tst b/scilab/modules/output_stream/tests/unit_tests/mprintf.tst
index 9b5f8ba..d8a0712 100644
--- a/scilab/modules/output_stream/tests/unit_tests/mprintf.tst
+++ b/scilab/modules/output_stream/tests/unit_tests/mprintf.tst
@@ -1,6 +1,7 @@
1// ============================================================================= 1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2008 - INRIA 3// Copyright (C) 2008 - INRIA
4// Copyright (C) 2020 - Samuel GOUGEON - Le Mans Université
4// 5//
5// This file is distributed under the same license as the Scilab package. 6// This file is distributed under the same license as the Scilab package.
6// ============================================================================= 7// =============================================================================
@@ -155,3 +156,33 @@ D = [ ..
155 34.936154 ]; 156 34.936154 ];
156 157
157mprintf("==>%10s : %08.4f %08.4f %08.4f<==\n\n",A,C,D); 158mprintf("==>%10s : %08.4f %08.4f %08.4f<==\n\n",A,C,D);
159
160// Booleans
161// =============================================================================
162n = [%pi ; %e];
163b = [%T ; %F];
164for f = ["d" "i" "u" "o" "x" "X" "g" "G"]
165 mprintf("%"+f+"\n", b);
166 mprintf("%"+f+" %d\n", b, n);
167 if and(f <> ["u" "o" "x" "X"]) // http://bugzilla.scilab.org/16563
168 mprintf("%2$"+f+" %1$d\n", n, b);
169 end
170end
171// %f
172msprintf("%f\n", b);
173mprintf("%f %d\n", b, n);
174mprintf("%2$f %1$d\n", n, b);
175// %e
176mprintf("%e\n", b);
177mprintf("%e %d\n", b, n);
178mprintf("%2$e %1$d\n", n, b);
179// %E
180mprintf("%E\n", b);
181mprintf("%E %d\n", b, n);
182mprintf("%2$E %1$d\n", n, b);
183// %s, %c
184for f = ["s" "c"]
185 mprintf("%"+f+"\n", b);
186 mprintf("%"+f+" %d\n", b, n);
187 mprintf("%2$"+f+" %1$d\n", n, b);
188end
diff --git a/scilab/modules/output_stream/tests/unit_tests/msprintf.tst b/scilab/modules/output_stream/tests/unit_tests/msprintf.tst
index 9fddf26..a9b7a6a 100644
--- a/scilab/modules/output_stream/tests/unit_tests/msprintf.tst
+++ b/scilab/modules/output_stream/tests/unit_tests/msprintf.tst
@@ -2,6 +2,7 @@
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2008 - INRIA 3// Copyright (C) 2008 - INRIA
4// Copyright (C) 2013 - Scilab Enterprises - Adeline CARNIS 4// Copyright (C) 2013 - Scilab Enterprises - Adeline CARNIS
5// Copyright (C) 2020 - Samuel GOUGEON - Le Mans Université
5// 6//
6// This file is distributed under the same license as the Scilab package. 7// This file is distributed under the same license as the Scilab package.
7// ============================================================================= 8// =============================================================================
@@ -123,6 +124,7 @@ assert_checkequal(msprintf("%10s","text"), " text");
123assert_checkequal(msprintf("%10.3s","text"), " tex"); 124assert_checkequal(msprintf("%10.3s","text"), " tex");
124assert_checkequal(msprintf("%-10s","text"), "text "); 125assert_checkequal(msprintf("%-10s","text"), "text ");
125assert_checkequal(msprintf("%s","t"), "t"); 126assert_checkequal(msprintf("%s","t"), "t");
127assert_checkequal(msprintf("%s","éàöαβδ"), "éàöαβδ");
126 128
127// format '%x' 129// format '%x'
128// ============================================================================= 130// =============================================================================
@@ -210,3 +212,33 @@ refMsg = msprintf(_("%s: Wrong number of input arguments: data doesn''t fit with
210assert_checkerror("msprintf(""%2$d"", 1);", refMsg); 212assert_checkerror("msprintf(""%2$d"", 1);", refMsg);
211assert_checkerror("msprintf(""%d%1$d"", 1);", refMsg); 213assert_checkerror("msprintf(""%d%1$d"", 1);", refMsg);
212assert_checkerror("msprintf(""%1$d%d"", 1);", refMsg); 214assert_checkerror("msprintf(""%1$d%d"", 1);", refMsg);
215
216// Booleans
217// =============================================================================
218n = [%pi ; %e];
219b = [%T ; %F];
220for f = ["d" "i" "u" "o" "x" "X" "g" "G"]
221 assert_checkequal(msprintf("%"+f+"\n", b), ["1" ; "0"]);
222 assert_checkequal(msprintf("%"+f+" %d\n", b, n), ["1 3" ; "0 2"]);
223 if and(f <> ["u" "o" "x" "X"]) // http://bugzilla.scilab.org/16563
224 assert_checkequal(msprintf("%2$"+f+" %1$d\n", n, b), ["1 3" ; "0 2"]);
225 end
226end
227// %f
228assert_checkequal(msprintf("%f\n", b), ["1.000000" ; "0.000000"]);
229assert_checkequal(msprintf("%f %d\n", b, n), ["1.000000 3" ; "0.000000 2"]);
230assert_checkequal(msprintf("%2$f %1$d\n", n, b), ["1.000000 3" ; "0.000000 2"]);
231// %e
232assert_checkequal(msprintf("%e\n", b), ["1.000000e+00" ; "0.000000e+00"]);
233assert_checkequal(msprintf("%e %d\n", b, n), ["1.000000e+00 3" ; "0.000000e+00 2"]);
234assert_checkequal(msprintf("%2$e %1$d\n", n, b), ["1.000000e+00 3" ; "0.000000e+00 2"]);
235// %E
236assert_checkequal(msprintf("%E\n", b), ["1.000000E+00" ; "0.000000E+00"]);
237assert_checkequal(msprintf("%E %d\n", b, n), ["1.000000E+00 3" ; "0.000000E+00 2"]);
238assert_checkequal(msprintf("%2$E %1$d\n", n, b), ["1.000000E+00 3" ; "0.000000E+00 2"]);
239// %s, %c
240for f = ["s" "c"]
241 assert_checkequal(msprintf("%"+f+"\n", b), ["T" ; "F"]);
242 assert_checkequal(msprintf("%"+f+" %d\n", b, n), ["T 3" ; "F 2"]);
243 assert_checkequal(msprintf("%2$"+f+" %1$d\n", n, b), ["T 3" ; "F 2"]);
244end