Hi all

A quick fix for  base> . I'm not sure I'm not breaking compatibility
with the old (broken according to the documentation) behaviour of
base>. But at least it's a start.
>From 459e6a5e3e87b4b704bb51af814f2461ff21a8de Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Philipp=20Br=C3=BCschweiler?= <[email protected]>
Date: Mon, 4 Jan 2010 17:59:14 +0100
Subject: [PATCH] math.parser: fix base> with radix > 16

---
 core/math/parser/parser-tests.factor |    3 +++
 core/math/parser/parser.factor       |    4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/core/math/parser/parser-tests.factor b/core/math/parser/parser-tests.factor
index 34bca8a..95a31f6 100644
--- a/core/math/parser/parser-tests.factor
+++ b/core/math/parser/parser-tests.factor
@@ -104,6 +104,9 @@ unit-test
 [ f ] [ "fdsf" bin> ] unit-test
 [ 3 ] [ "11" bin> ] unit-test
 
+[ 1952666161 ] [ "WAKEUP" 36 base> ] unit-test
+[ "sheeple" ] [ 62002031378 36 >base ] unit-test
+
 [ f ] [ "\0." string>number ] unit-test
 
 [ 1 1 >base ] must-fail
diff --git a/core/math/parser/parser.factor b/core/math/parser/parser.factor
index f04c010..bc6a898 100644
--- a/core/math/parser/parser.factor
+++ b/core/math/parser/parser.factor
@@ -10,7 +10,7 @@ IN: math.parser
         { [ dup CHAR: a <  ] [ CHAR: A 10 - - ] }
         [ CHAR: a 10 - - ]
     } cond
-    dup 0 < [ drop 255 ] [ dup 16 >= [ drop 255 ] when ] if ; inline
+    dup 0 < [ drop 255 ] [ dup 36 >= [ drop 255 ] when ] if ; inline
 
 : string>digits ( str -- digits )
     [ digit> ] B{ } map-as ; inline
@@ -93,7 +93,7 @@ SYMBOL: negative?
     } case ; inline
 
 : number-char? ( char -- ? )
-    "0123456789ABCDEFabcdef." member? ; inline
+    "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz." member? ; inline
 
 : last-unsafe ( seq -- elt )
     [ length 1 - ] [ nth-unsafe ] bi ; inline
-- 
1.6.6

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to