Author: mdiep
Date: Mon Jan  8 16:42:01 2007
New Revision: 16510

Modified:
   trunk/src/string.c

Log:
Remove an unreachable code path from string_to_num in src/string.c

Modified: trunk/src/string.c
==============================================================================
--- trunk/src/string.c  (original)
+++ trunk/src/string.c  Mon Jan  8 16:42:01 2007
@@ -1807,118 +1807,6 @@
             f = -0.0;
 #endif
         string_cstring_free(cstr);
-        return f;
-    }
-    /*
-     * results from that code below aren't really exact:
-     * float("1e100") != 10**100
-     */
-
-    if (s) {
-        UINTVAL idx = 0;
-        const UINTVAL length = s->strlen;
-        int sign = 1;
-        INTVAL seen_dot = 0;
-        INTVAL seen_e = 0;
-        int exp_sign = 0;
-        INTVAL in_exp = 0;
-        INTVAL in_number = 0;
-        INTVAL exponent = 0;
-        INTVAL fake_exponent = 0;
-        INTVAL digit_family = 0;
-        FLOATVAL exp_log=10.0, exp_val=1.0;
-
-        while (idx < length) {
-            const UINTVAL c = string_index(interp, s, idx);
-            const INTVAL df = Parrot_char_is_digit(interp, c);
-
-            if (df && !digit_family)
-                digit_family = df;
-
-            if (df && df == digit_family) {
-                if (in_exp) {
-                    exponent = exponent*10 +
-                        Parrot_char_digit_value(interp, c);
-                    if (!exp_sign) {
-                        exp_sign = 1;
-                    }
-                }
-                else {
-                    /* We're somewhere in the main string of numbers */
-                    in_number = 1;
-                    f = f * 10 + Parrot_char_digit_value(interp, c);
-                    if (seen_dot) {
-                        fake_exponent--;
-                    }
-                }
-            }
-            else if (!in_number) {
-                /* we've not yet seen any digits */
-                if (c == '-') { /* XXX: ascii */
-                    sign = -1;
-                }
-                else if (c == '.') {    /* XXX: ascii */
-                    seen_dot = 1;
-                }
-                else {
-                    seen_dot = 0;
-                    sign = 1;
-                }
-            }
-            else {
-                /* we've seen some digits, are we done yet? */
-                if (!seen_dot && c == '.' && !in_exp) { /* XXX: ascii */
-                    seen_dot = 1;
-                }
-                else if (!seen_e && (c == 'e' || c == 'E')) { /* XXX: ascii */
-                    seen_e = 1;
-                    in_exp = 1;
-                }
-                else if (seen_e && !exp_sign) {
-                    if (c == '+') {     /* XXX: ascii */
-                        exp_sign = 1;
-                    }
-                    else if (c == '-') {        /* XXX: ascii */
-                        exp_sign = -1;
-                    }
-                    else {
-                        break;  /* e-- is silly */
-                    }
-                }
-                else {
-                    break;      /* run out of number, all done */
-                }
-            }
-
-            ++idx;
-        }
-
-        exponent = fake_exponent + exponent * exp_sign;
-
-        if (exponent < 0) {
-            exponent = -exponent;
-            exp_sign=-1;
-        }
-
-        for (;;) {
-            if (exponent & 1) {
-                exp_val *= exp_log;
-                exponent--;
-            }
-            if (!exponent)
-                break;
-            exp_log *= exp_log;
-            exponent >>= 1;
-        }
-
-        if (exp_sign < 0)
-            f /= exp_val;
-        else
-            f *= exp_val;
-
-
-        if (sign < 0)
-            f = -f;
     }
 
     return f;

Reply via email to