perl-vutil-revert.patch 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. --- perl-5.20.0/vutil.c 2014-05-26 09:34:21.000000000 -0400
  2. +++ perl-5.20.0-patched/vutil.c 2014-06-19 09:25:19.024409700 -0400
  3. @@ -585,11 +585,29 @@
  4. {
  5. STRLEN len;
  6. +#ifdef USE_LOCALE_NUMERIC
  7. + char *loc = setlocale(LC_NUMERIC, NULL);
  8. + if (loc) {
  9. + /* setlocale returns NULL on error */
  10. + if (loc[0] == 'C' && loc[1] == '\0') {
  11. + /* LC_NUMERIC is already C, nothing to do */
  12. + loc = NULL;
  13. + }
  14. + else {
  15. + loc = savepv(loc);
  16. + if (!setlocale(LC_NUMERIC, "C")) {
  17. + /* error! do not restore locale later */
  18. + Safefree(loc);
  19. + loc = NULL;
  20. + }
  21. + }
  22. + }
  23. +#endif
  24. +
  25. /* may get too much accuracy */
  26. char tbuf[64];
  27. SV *sv = SvNVX(ver) > 10e50 ? newSV(64) : 0;
  28. char *buf;
  29. - STORE_NUMERIC_LOCAL_SET_STANDARD();
  30. if (sv) {
  31. Perl_sv_catpvf(aTHX_ sv, "%.9"NVff, SvNVX(ver));
  32. len = SvCUR(sv);
  33. @@ -599,7 +617,15 @@
  34. len = my_snprintf(tbuf, sizeof(tbuf), "%.9"NVff, SvNVX(ver));
  35. buf = tbuf;
  36. }
  37. - RESTORE_NUMERIC_LOCAL();
  38. +
  39. +#ifdef USE_LOCALE_NUMERIC
  40. + if (loc) {
  41. + /* restore locale */
  42. + setlocale(LC_NUMERIC, loc);
  43. + Safefree(loc);
  44. + }
  45. +#endif
  46. +
  47. while (buf[len-1] == '0' && len > 0) len--;
  48. if ( buf[len-1] == '.' ) len--; /* eat the trailing decimal */
  49. version = savepvn(buf, len);