Fix broken atof (bug #835452)
This commit is contained in:
parent
5809b8b071
commit
ee9004b7a8
94
perl-5.16.0-fix-broken-atof.patch
Normal file
94
perl-5.16.0-fix-broken-atof.patch
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
From 78787052b6a68c0f54cfa983a69c44276de9daa4 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jesse Luehrs <doy@tozt.net>
|
||||||
|
Date: Tue, 26 Jun 2012 00:13:54 -0500
|
||||||
|
Subject: [PATCH] use a less broken test for locale radix in atof [perl #109318]
|
||||||
|
|
||||||
|
---
|
||||||
|
lib/locale.t | 33 +++++++++++++++++++++++++++++++++
|
||||||
|
numeric.c | 25 +++++++++++++++----------
|
||||||
|
2 files changed, 48 insertions(+), 10 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lib/locale.t b/lib/locale.t
|
||||||
|
index dfc6d2b..26a7bd4 100644
|
||||||
|
--- a/lib/locale.t
|
||||||
|
+++ b/lib/locale.t
|
||||||
|
@@ -1247,6 +1247,39 @@ foreach $Locale (@Locale) {
|
||||||
|
print "# failed $locales_test_number locale '$Locale' characters @f\n"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ # [perl #109318]
|
||||||
|
+ {
|
||||||
|
+ my @f = ();
|
||||||
|
+ ++$locales_test_number;
|
||||||
|
+ $test_names{$locales_test_number} = 'Verify atof with locale radix and negative exponent';
|
||||||
|
+
|
||||||
|
+ my $radix = POSIX::localeconv()->{decimal_point};
|
||||||
|
+ my @nums = (
|
||||||
|
+ "3.14e+9", "3${radix}14e+9", "3.14e-9", "3${radix}14e-9",
|
||||||
|
+ "-3.14e+9", "-3${radix}14e+9", "-3.14e-9", "-3${radix}14e-9",
|
||||||
|
+ );
|
||||||
|
+
|
||||||
|
+ if (! $is_utf8_locale) {
|
||||||
|
+ use locale;
|
||||||
|
+ for my $num (@nums) {
|
||||||
|
+ push @f, $num
|
||||||
|
+ unless sprintf("%g", $num) =~ /3.+14/;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ else {
|
||||||
|
+ use locale ':not_characters';
|
||||||
|
+ for my $num (@nums) {
|
||||||
|
+ push @f, $num
|
||||||
|
+ unless sprintf("%g", $num) =~ /3.+14/;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ tryneoalpha($Locale, $locales_test_number, @f == 0);
|
||||||
|
+ if (@f) {
|
||||||
|
+ print "# failed $locales_test_number locale '$Locale' numbers @f\n"
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
my $final_locales_test_number = $locales_test_number;
|
||||||
|
diff --git a/numeric.c b/numeric.c
|
||||||
|
index be86f3a..3eb8a0e 100644
|
||||||
|
--- a/numeric.c
|
||||||
|
+++ b/numeric.c
|
||||||
|
@@ -847,17 +847,22 @@ Perl_my_atof(pTHX_ const char* s)
|
||||||
|
|
||||||
|
PERL_ARGS_ASSERT_MY_ATOF;
|
||||||
|
|
||||||
|
- if (PL_numeric_local && IN_SOME_LOCALE_FORM) {
|
||||||
|
- NV y;
|
||||||
|
+ if (PL_numeric_local && PL_numeric_radix_sv && IN_SOME_LOCALE_FORM) {
|
||||||
|
+ char *standard = NULL, *local = NULL;
|
||||||
|
+ bool use_standard_radix;
|
||||||
|
|
||||||
|
- /* Scan the number twice; once using locale and once without;
|
||||||
|
- * choose the larger result (in absolute value). */
|
||||||
|
- Perl_atof2(s, x);
|
||||||
|
- SET_NUMERIC_STANDARD();
|
||||||
|
- Perl_atof2(s, y);
|
||||||
|
- SET_NUMERIC_LOCAL();
|
||||||
|
- if ((y < 0.0 && y < x) || (y > 0.0 && y > x))
|
||||||
|
- return y;
|
||||||
|
+ standard = strchr(s, '.');
|
||||||
|
+ local = strstr(s, SvPV_nolen(PL_numeric_radix_sv));
|
||||||
|
+
|
||||||
|
+ use_standard_radix = standard && (!local || standard < local);
|
||||||
|
+
|
||||||
|
+ if (use_standard_radix)
|
||||||
|
+ SET_NUMERIC_STANDARD();
|
||||||
|
+
|
||||||
|
+ Perl_atof2(s, x);
|
||||||
|
+
|
||||||
|
+ if (use_standard_radix)
|
||||||
|
+ SET_NUMERIC_LOCAL();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Perl_atof2(s, x);
|
||||||
|
--
|
||||||
|
1.7.4.1
|
||||||
|
|
14
perl.spec
14
perl.spec
@ -26,7 +26,7 @@
|
|||||||
Name: perl
|
Name: perl
|
||||||
Version: %{perl_version}
|
Version: %{perl_version}
|
||||||
# release number must be even higher, because dual-lived modules will be broken otherwise
|
# release number must be even higher, because dual-lived modules will be broken otherwise
|
||||||
Release: 224%{?dist}
|
Release: 225%{?dist}
|
||||||
Epoch: %{perl_epoch}
|
Epoch: %{perl_epoch}
|
||||||
Summary: Practical Extraction and Report Language
|
Summary: Practical Extraction and Report Language
|
||||||
Group: Development/Languages
|
Group: Development/Languages
|
||||||
@ -74,12 +74,18 @@ Patch7: perl-5.10.0-x86_64-io-test-failure.patch
|
|||||||
Patch8: perl-5.14.1-offtest.patch
|
Patch8: perl-5.14.1-offtest.patch
|
||||||
|
|
||||||
# Fix find2perl to translate ? glob properly, rhbz#825701, RT#113054
|
# Fix find2perl to translate ? glob properly, rhbz#825701, RT#113054
|
||||||
Patch9: perl-5.14.2-find2perl-transtate-question-mark-properly.patch
|
Patch9: perl-5.14.2-find2perl-transtate-question-mark-properly.patch
|
||||||
|
|
||||||
|
# Fix broken atof, rhbz#835452, RT#109318
|
||||||
|
Patch10: perl-5.16.0-fix-broken-atof.patch
|
||||||
|
|
||||||
# Fix searching for Unicode::Collate::Locale data, rhbz#756118, CPANRT#72666,
|
# Fix searching for Unicode::Collate::Locale data, rhbz#756118, CPANRT#72666,
|
||||||
# fixed in Unicode-Collate-0.87.
|
# fixed in Unicode-Collate-0.87.
|
||||||
# TODO Looks like it was fixed differently?
|
# TODO Looks like it was fixed differently?
|
||||||
#Patch13: perl-5.14.2-locale-search-inc.patch
|
#Patch13: perl-5.14.2-locale-search-inc.patch
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Update some of the bundled modules
|
# Update some of the bundled modules
|
||||||
# see http://fedoraproject.org/wiki/Perl/perl.spec for instructions
|
# see http://fedoraproject.org/wiki/Perl/perl.spec for instructions
|
||||||
|
|
||||||
@ -1295,6 +1301,7 @@ tarball from perl.org.
|
|||||||
%patch7 -p1
|
%patch7 -p1
|
||||||
%patch8 -p1
|
%patch8 -p1
|
||||||
%patch9 -p1
|
%patch9 -p1
|
||||||
|
%patch10 -p1
|
||||||
|
|
||||||
#copy the example script
|
#copy the example script
|
||||||
cp -a %{SOURCE5} .
|
cp -a %{SOURCE5} .
|
||||||
@ -2525,6 +2532,9 @@ sed \
|
|||||||
|
|
||||||
# Old changelog entries are preserved in CVS.
|
# Old changelog entries are preserved in CVS.
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Jul 02 2012 Jitka Plesnikova <jplesnik@redhat.com> 4:5.16.0-225
|
||||||
|
- Fix broken atof (bug #835452)
|
||||||
|
|
||||||
* Wed Jun 27 2012 Petr Pisar <ppisar@redhat.com> - 4:5.16.0-224
|
* Wed Jun 27 2012 Petr Pisar <ppisar@redhat.com> - 4:5.16.0-224
|
||||||
- perl-Pod-Perldoc must require groff-base because Pod::Perldoc::ToMan executes
|
- perl-Pod-Perldoc must require groff-base because Pod::Perldoc::ToMan executes
|
||||||
roff
|
roff
|
||||||
|
Loading…
Reference in New Issue
Block a user