Skip to content

Commit

Permalink
compatibility: To display a percent sign, you need to use a double pe…
Browse files Browse the repository at this point in the history
…rcent sign (%%) in the format string.
  • Loading branch information
Nelson-numerical-software committed Nov 27, 2023
1 parent d00167f commit f9ac700
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- visibility title and labels.
- object constructor must be in '@' directory and no more in parent directory (compatibility).
- `subsref`, `subsasgn` compatibility with `substruct`.
- To display a percent sign, you need to use a double percent sign (%%) in the format string (compatibility).
- French translation updated (100%, Thanks to weblate contributors)
- [#997](http://github.com/Nelson-numerical-software/nelson/issues/997) Macos BigSur Github CI support removed.
- Qt 6.6.1 on win64 CI build.
Expand Down
2 changes: 1 addition & 1 deletion modules/graphics/functions/pie.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function validateExplode(haveExplode)
end

for i = 1:length(X)
labels{i} = sprintf('%d%', XL(i));
labels{i} = sprintf('%d%%', XL(i));
end
end
%=============================================================================
Expand Down
3 changes: 2 additions & 1 deletion modules/graphics/help/en_US/xml/pie.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@

<param_input_item>
<param_name>labels</param_name>
<param_description>'%.0f%' (default) or array of text labels</param_description>
<param_description
>'%.0f%%' (default) or array of text labels</param_description>
</param_input_item>

<param_input_item>
Expand Down
9 changes: 9 additions & 0 deletions modules/stream_manager/help/en_US/xml/fprintf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@
</tr>
</table>

<p
>To display a percent sign, you need to use a double percent sign (%%) in the format string.</p>
</description>

<used_function />
Expand Down Expand Up @@ -183,6 +185,13 @@ end

</example_item>

<example_item>
<example_item_type>nelson</example_item_type>
<example_item_description>Display a percent sign</example_item_description>
<example_item_data><![CDATA[fprintf(1, '%d%%.', 95)]]>
</example_item_data>
</example_item>


</examples>

Expand Down
1 change: 1 addition & 0 deletions modules/stream_manager/src/cpp/PrintfFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ printfFunction(const ArrayOfVector& args, std::wstring& errorMessage, std::wstri
if (*(dp + 1) == L'\0') {
return true;
}
dp += 2;
}
if (*dp == L'%' && *(dp + 1)) {
np = PrintfHelper::validateFormatSpec(dp + 1);
Expand Down
4 changes: 4 additions & 0 deletions modules/stream_manager/tests/test_fprintf.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,7 @@
assert_istrue(iscellstr(ce));
assert_istrue(any(contains(ce, 'windows-1251')));
%=============================================================================
R = evalc('fprintf(1,''%d%%.'',50)')
REF = '50%.';
assert_isequal(R, REF);
%=============================================================================
11 changes: 8 additions & 3 deletions modules/string/help/en_US/xml/sprintf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@
<td>Character vector.</td>
</tr>
</table>

<p
>To display a percent sign, you need to use a double percent sign (%%) in the format string.</p>
</description>

<used_function />
Expand Down Expand Up @@ -146,10 +147,14 @@
<example_item_description />
<example_item_data><![CDATA[sprintf('an value %g.', pi)]]>
</example_item_data>

</example_item>


<example_item>
<example_item_type>nelson</example_item_type>
<example_item_description>Display a percent sign</example_item_description>
<example_item_data><![CDATA[sprintf('%d%%.', 95)]]>
</example_item_data>
</example_item>
</examples>

<see_also>
Expand Down
4 changes: 4 additions & 0 deletions modules/string/tests/test_sprintf.m
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,7 @@
REF = '20 %.';
assert_isequal(R, REF);
%=============================================================================
R = sprintf('%d%%.',50);
REF = '50%.';
assert_isequal(R, REF);
%=============================================================================

0 comments on commit f9ac700

Please sign in to comment.