Skip to content

Commit e816742

Browse files
committed
Fix GH-3336: String arguments that are converted have misleading explanation
1 parent 8cb32bd commit e816742

File tree

3 files changed

+71
-64
lines changed

3 files changed

+71
-64
lines changed

language-snippets.ent

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2116,7 +2116,12 @@ or an explicit call to <function>chr</function> should be made.</para></warning>
21162116

21172117
<!-- GMP Notes -->
21182118
<!ENTITY gmp.return 'A <classname xmlns="http://docbook.org/ns/docbook">GMP</classname> object.'>
2119-
<!ENTITY gmp.parameter '<para xmlns="http://docbook.org/ns/docbook">A <classname>GMP</classname> object, an &integer; or a numeric &string;.</para>'>
2119+
<!ENTITY gmp.parameter '<para xmlns="http://docbook.org/ns/docbook">
2120+
A <classname>GMP</classname> object, an &integer;,
2121+
or a &string; that can be interpreted as a number following the same logic
2122+
as if the string was used in <function>gmp_init</function> with a
2123+
<parameter>base</parameter> equal to 0.
2124+
</para>'>
21202125

21212126
<!-- MySQLi Notes -->
21222127
<!ENTITY mysqli.result.description '<varlistentry xmlns="http://docbook.org/ns/docbook"><term>

reference/gmp/functions/gmp-init.xml

Lines changed: 61 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,37 +20,42 @@
2020

2121
<refsect1 role="parameters">
2222
&reftitle.parameters;
23-
<para>
24-
<variablelist>
25-
<varlistentry>
26-
<term><parameter>num</parameter></term>
27-
<listitem>
28-
<para>
29-
An integer or a string. The string representation can be decimal,
30-
hexadecimal or octal.
31-
</para>
32-
</listitem>
33-
</varlistentry>
34-
<varlistentry>
35-
<term><parameter>base</parameter></term>
36-
<listitem>
37-
<para>
38-
The base.
39-
</para>
40-
<para>
41-
The base may vary from 2 to 62. If base is 0 (default value), the
42-
actual base is determined from the leading characters: if the first
43-
two characters are <literal>0x</literal> or <literal>0X</literal>,
44-
hexadecimal is assumed, if the first two characters are <literal>0b</literal> or <literal>0B</literal>,
45-
binary is assumed, otherwise if the first character is <literal>0</literal>,
46-
octal is assumed, otherwise decimal is assumed.
47-
For bases up to 36, case is ignored; upper-case and lower-case letters have the same value.
48-
For bases 37 to 62, upper-case letter represent the usual 10 to 35 while lower-case letter represent 36 to 61.
49-
</para>
50-
</listitem>
51-
</varlistentry>
52-
</variablelist>
53-
</para>
23+
<variablelist>
24+
<varlistentry>
25+
<term><parameter>num</parameter></term>
26+
<listitem>
27+
<simpara>
28+
An integer or a string.
29+
</simpara>
30+
</listitem>
31+
</varlistentry>
32+
<varlistentry>
33+
<term><parameter>base</parameter></term>
34+
<listitem>
35+
<simpara>
36+
The base to use for converting a <type>string</type> representation.
37+
</simpara>
38+
<simpara>
39+
An explicit base can be between 2 and 62.
40+
For bases up to 36, case is ignored; upper-case and lower-case letters have the same value.
41+
For bases 37 to 62, upper-case letter represent the usual 10 to 35 while lower-case letter represent 36 to 61.
42+
</simpara>
43+
<simpara>
44+
If <parameter>base</parameter> is <literal>0</literal> then the actual
45+
base is determined from the leading characters of <parameter>num</parameter>.
46+
If the first two characters are <literal>0x</literal> or <literal>0X</literal>,
47+
the string is interpreted as a hexadecimal integer.
48+
If the first two characters are <literal>0b</literal> or <literal>0B</literal>,
49+
the string is interpreted as a binary integer.
50+
If the first two characters are <literal>0o</literal> or <literal>0o</literal>,
51+
the string is interpreted as an octal integer.
52+
Moreover, if the first character is <literal>0</literal> the string
53+
is also interpreted as an octal integer.
54+
In all other cases, the string is interpreted as a decimal integer.
55+
</simpara>
56+
</listitem>
57+
</varlistentry>
58+
</variablelist>
5459
</refsect1>
5560

5661
<refsect1 role="returnvalues">
@@ -60,6 +65,31 @@
6065
</para>
6166
</refsect1>
6267

68+
<refsect1 role="changelog"><!-- {{{ -->
69+
&reftitle.changelog;
70+
<informaltable>
71+
<tgroup cols="2">
72+
<thead>
73+
<row>
74+
<entry>&Version;</entry>
75+
<entry>&Description;</entry>
76+
</row>
77+
</thead>
78+
<tbody>
79+
<row>
80+
<entry>8.1.0</entry>
81+
<entry>
82+
Support for explicit octal prefixes <literal>0o</literal> and
83+
<literal>0o</literal> has been added for <parameter>num</parameter> strings.
84+
Interpretation of such prefixes when <parameter>base</parameter> is 0
85+
has also been added.
86+
</entry>
87+
</row>
88+
</tbody>
89+
</tgroup>
90+
</informaltable>
91+
</refsect1>
92+
6393
<refsect1 role="examples">
6494
&reftitle.examples;
6595
<para>

reference/gmp/gmp/construct.xml

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<refentry xml:id="gmp.construct" xmlns="http://docbook.org/ns/docbook">
2+
<refentry xml:id="gmp.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xi="http://www.w3.org/2001/XInclude">
33
<refnamediv>
44
<refname>GMP::__construct</refname>
55
<refpurpose>Create GMP number</refpurpose>
@@ -19,37 +19,9 @@
1919

2020
<refsect1 role="parameters">
2121
&reftitle.parameters;
22-
<para>
23-
<variablelist>
24-
<varlistentry>
25-
<term><parameter>num</parameter></term>
26-
<listitem>
27-
<para>
28-
An integer or a string. The string representation can be decimal,
29-
hexadecimal or octal.
30-
</para>
31-
</listitem>
32-
</varlistentry>
33-
<varlistentry>
34-
<term><parameter>base</parameter></term>
35-
<listitem>
36-
<para>
37-
The base.
38-
</para>
39-
<para>
40-
The base may vary from 2 to 62. If base is 0 (default value), the
41-
actual base is determined from the leading characters: if the first
42-
two characters are <literal>0x</literal> or <literal>0X</literal>,
43-
hexadecimal is assumed, if the first two characters are <literal>0b</literal> or <literal>0B</literal>,
44-
binary is assumed, otherwise if the first character is <literal>0</literal>,
45-
octal is assumed, otherwise decimal is assumed.
46-
For bases up to 36, case is ignored; upper-case and lower-case letters have the same value.
47-
For bases 37 to 62, upper-case letter represent the usual 10 to 35 while lower-case letter represent 36 to 61.
48-
</para>
49-
</listitem>
50-
</varlistentry>
51-
</variablelist>
52-
</para>
22+
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('function.gmp-init')/db:refsect1[@role='parameters']/db:variablelist)">
23+
<xi:fallback/>
24+
</xi:include>
5325
</refsect1>
5426

5527
<!--

0 commit comments

Comments
 (0)