Index: runtime.c =================================================================== --- runtime.c +++ runtime.c @@ -7304,20 +7304,19 @@ if(C_immediatep(str) || C_header_bits(str) != C_STRING_TYPE) barf(C_BAD_ARGUMENT_TYPE_ERROR, "string->number", str); if((n = C_header_size(str)) == 0) { fail: - n = C_SCHEME_FALSE; - goto fini; + return C_SCHEME_FALSE; } if(n >= STRING_BUFFER_SIZE - 1) goto fail; - C_memcpy(sptr = buffer, C_c_string(str), n > (STRING_BUFFER_SIZE - 1) ? STRING_BUFFER_SIZE : n); + C_memcpy(sptr = buffer, C_c_string(str), n); buffer[ n ] = '\0'; - while(*sptr == '#') { + if(*sptr == '#') { switch(C_tolower((int)*(++sptr))) { case 'b': if(radixpf) goto fail; else { radix = 2; radixpf = 1; } break; case 'o': if(radixpf) goto fail; else { radix = 8; radixpf = 1; } break; case 'd': if(radixpf) goto fail; else { radix = 10; radixpf = 1; } break; case 'x': if(radixpf) goto fail; else { radix = 16; radixpf = 1; } break; @@ -7329,11 +7328,11 @@ ++sptr; } /* Scan for embedded special characters and do basic sanity checking: */ for(eptr = sptr, rptr = sptr; *eptr != '\0'; ++eptr) { - switch(C_tolower((int)*eptr)) { + switch(*eptr) { case '.': if(periodf || ratf || expf) goto fail; periodf = 1; break; @@ -7352,15 +7351,15 @@ sharpf = 0; /* Allow sharp signs in the denominator */ ratf = 1; rptr = eptr+1; break; - case 'e': - case 'd': - case 'f': - case 'l': - case 's': + case 'e': case 'E': + case 'd': case 'D': + case 'f': case 'F': + case 'l': case 'L': + case 's': case 'S': /* Don't set exp flag if we see the "f" in "inf.0" (preceded by 'n') */ /* Other failure modes are handled elsewhere. */ if(radix == 10 && eptr > sptr && C_tolower((int)*(eptr-1)) != 'n') { if (ratf) goto fail; @@ -7377,19 +7376,17 @@ if (eptr == rptr) goto fail; /* Disallow "empty" numbers like "#x" and "1/" */ /* check for rational representation: */ if(rptr != sptr) { if (*(rptr) == '-' || *(rptr) == '+') { - n = C_SCHEME_FALSE; - goto fini; + return C_SCHEME_FALSE; } *(rptr-1) = '\0'; switch(convert_string_to_number(sptr, radix, &n1, &fn1)) { case 0: - n = C_SCHEME_FALSE; - goto fini; + return C_SCHEME_FALSE; case 1: fn1 = (double)n1; break; @@ -7421,11 +7418,10 @@ if(exactpf && exactf) n = C_i_inexact_to_exact(n); break; } - fini: return n; } /* only left for backwards-compatibility */ @@ -7505,11 +7501,11 @@ return 0; } #endif } - if(C_strpbrk(str, "xX\0") != NULL) return 0; + if(C_strpbrk(str, "xX") != NULL) return 0; errno = 0; n = C_strtol(str, &eptr, radix); if(((n == LONG_MAX || n == LONG_MIN) && errno == ERANGE) || *eptr != '\0') { @@ -7519,19 +7515,19 @@ errno = 0; fn = C_strtod(str, &eptr2); if(fn == HUGE_VAL && errno == ERANGE) return 0; else if(eptr2 == str) return 0; - else if(*eptr2 == '\0' || (eptr != eptr2 && !C_strncmp(eptr2, ".0", C_strlen(eptr2)))) { + else if(*eptr2 == '\0' || (eptr != eptr2 && !C_strncmp(eptr2, ".0", len - (eptr2-str)))) { *flo = fn; return 2; } return 0; } else if((n & C_INT_SIGN_BIT) != ((n << 1) & C_INT_SIGN_BIT)) { /* doesn't fit into fixnum? */ - if(*eptr == '\0' || !C_strncmp(eptr, ".0", C_strlen(eptr))) { + if(*eptr == '\0' || !C_strncmp(eptr, ".0", len - (eptr-str))) { *flo = (double)n; return 2; } else return 0; }