[svn:parrot] r39372 - in branches/tt24_unicode_numifications: src/string t/op

bacek at svn.parrot.org bacek at svn.parrot.org
Wed Jun 3 22:51:48 UTC 2009


Author: bacek
Date: Wed Jun  3 22:51:47 2009
New Revision: 39372
URL: https://trac.parrot.org/parrot/changeset/39372

Log:
[core] Add support for Infinity in Str_to_num. Fix comments.

Modified:
   branches/tt24_unicode_numifications/src/string/api.c
   branches/tt24_unicode_numifications/t/op/string.t

Modified: branches/tt24_unicode_numifications/src/string/api.c
==============================================================================
--- branches/tt24_unicode_numifications/src/string/api.c	Wed Jun  3 22:37:23 2009	(r39371)
+++ branches/tt24_unicode_numifications/src/string/api.c	Wed Jun  3 22:51:47 2009	(r39372)
@@ -2182,7 +2182,7 @@
     INTVAL        d         = 0;    /* Integer descriminator */
     int           d_is_safe = 1;    /* We can use integer mantissa */
     int           d_length  = 0;
-    int           check_nan = 0;    /* Support for deprecated nan, inf */
+    int           check_nan = 0;    /* Check for NaN and Inf after main loop */
     String_iter iter;
     UINTVAL     offs;
     number_parse_state state = parse_start;
@@ -2190,13 +2190,6 @@
     if (!s)
         return 0.0;
 
-    if (Parrot_str_equal(interp, s, CONST_STRING(interp, "Inf")))
-        return PARROT_FLOATVAL_INF_POSITIVE;
-    else if (Parrot_str_equal(interp, s, CONST_STRING(interp, "-Inf")))
-        return PARROT_FLOATVAL_INF_NEGATIVE;
-    else if (Parrot_str_equal(interp, s, CONST_STRING(interp, "NaN")))
-        return PARROT_FLOATVAL_NAN_QUIET;
-
     ENCODING_ITER_INIT(interp, s, &iter);
 
     /* Handcrafter FSM to read float value */
@@ -2300,15 +2293,17 @@
         }
     }
 
-    /* DEPRECATED support for non-canonical NaN and Inf */
+    /* Support for non-canonical NaN and Inf */
     /* charpos <=2 because for "-i" iter will be advanced to next char already */
     if (check_nan && (iter.charpos <= 2)) {
         STRING *t = Parrot_str_upcase(interp, s);
         if (Parrot_str_equal(interp, t, CONST_STRING(interp, "NAN")))
             return PARROT_FLOATVAL_NAN_QUIET;
-        else if (Parrot_str_equal(interp, t, CONST_STRING(interp, "INF")))
+        else if (Parrot_str_equal(interp, t, CONST_STRING(interp, "INF"))
+                || Parrot_str_equal(interp, t, CONST_STRING(interp, "INFINITY")))
             return PARROT_FLOATVAL_INF_POSITIVE;
-        else if (Parrot_str_equal(interp, t, CONST_STRING(interp, "-INF")))
+        else if (Parrot_str_equal(interp, t, CONST_STRING(interp, "-INF"))
+                || Parrot_str_equal(interp, t, CONST_STRING(interp, "-INFINITY")))
             return PARROT_FLOATVAL_INF_NEGATIVE;
         else
             return 0.0;

Modified: branches/tt24_unicode_numifications/t/op/string.t
==============================================================================
--- branches/tt24_unicode_numifications/t/op/string.t	Wed Jun  3 22:37:23 2009	(r39371)
+++ branches/tt24_unicode_numifications/t/op/string.t	Wed Jun  3 22:51:47 2009	(r39372)
@@ -2941,12 +2941,18 @@
     say $N0
     $N0 = 'iNf'
     say $N0
+    $N0 = 'INFINITY'
+    say $N0
     $N0 = '-INF'
     say $N0
+    $N0 = '-Infinity'
+    say $N0
 .end
 CODE
 NaN
 Inf
+Inf
+-Inf
 -Inf
 OUT
 


More information about the parrot-commits mailing list