develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r34250 - trunk/languages/perl6/src/pmc

From:
pmichaud
Date:
December 22, 2008 11:49
Subject:
[svn:parrot] r34250 - trunk/languages/perl6/src/pmc
Message ID:
20081222194938.67450CBA12@x12.develooper.com
Author: pmichaud
Date: Mon Dec 22 11:49:37 2008
New Revision: 34250

Modified:
   trunk/languages/perl6/src/pmc/perl6str.pmc

Log:
[rakudo]:  Eliminate strcasecmp from inf/nan conversions (particle++)


Modified: trunk/languages/perl6/src/pmc/perl6str.pmc
==============================================================================
--- trunk/languages/perl6/src/pmc/perl6str.pmc	(original)
+++ trunk/languages/perl6/src/pmc/perl6str.pmc	Mon Dec 22 11:49:37 2008
@@ -157,15 +157,17 @@
                 sign = -1.0; s1++;
             }
 
-            if (tolower(*s1) == 'i') {
-                if (strncasecmp(s1, "inf", 3) == 0) s1 += 3;
+            if (tolower(s1[0]) == 'i' && tolower(s1[1]) == 'n' 
+                    && tolower(s1[2]) == 'f') {
+                s1 += 3;
                 while (s1 < end && isspace((unsigned char)*s1))
                     s1++;
                 return (s1 == end) ? sign * atof("inf") : 0.0;
             }
 
-            if (tolower(*s1) == 'n') {
-                if (strncasecmp(s1, "nan", 3) == 0) s1 += 3;
+            if (tolower(s1[0]) == 'n' && tolower(s1[1]) == 'a' 
+                    && tolower(s1[2]) == 'n') {
+                s1 += 3;
                 while (s1 < end && isspace((unsigned char)*s1))
                     s1++;
                 return (s1 == end) ? sign * atof("nan") : 0.0;



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About