]> gitweb.factorcode.org Git - factor.git/commitdiff
core: remove ?string>number in favor of ?if
authorDoug Coleman <doug.coleman@gmail.com>
Mon, 25 Mar 2024 16:59:12 +0000 (11:59 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Mon, 25 Mar 2024 16:59:12 +0000 (11:59 -0500)
basis/http/download/download.factor
basis/http/server/requests/requests.factor
core/math/parser/parser.factor

index df9fca6e593a0b9059b20c90f1deb9974c0563ec..1d087a07bd471aa3d45b4afa82d318a7493adc64 100644 (file)
@@ -44,21 +44,26 @@ IN: http.download
     dup file-extension
     [ ?tail drop ]
     [
-        ?string>number
+        [ string>number ]
         [ 1 + number>string append ]
-        [ ".1" 3append ] if
+        [ ".1" 3append ] ?if
     ] bi ;
 
-: ?parenthesis-number ( str -- n/str ? )
-    dup { [ "(" head? ] [ ")" tail? ] } 1&&
-    [ rest but-last ?string>number ] [ f ] if ;
+: ?parenthesis-number ( str -- n/f )
+    [
+        {
+            [ "(" head? ]
+            [ ")" tail? ]
+            [ rest but-last string>number ]
+        } 1&&
+    ] [ drop f ] ?unless ;
 
 : increment-file-name ( path -- path' )
     [
         file-stem " " split1-last
-        ?parenthesis-number
+        [ ?parenthesis-number ]
         [ 1 + number>string "(" ")" surround " " glue ]
-        [ "(1)" append " " glue ] if
+        [ "(1)" append " " glue ] ?if
     ] [
         file-extension
     ] bi "." glue ;
index fce1477f2a3a4cb8177af016309d1fbf1d00c107..eeb7a56c67ec02f707ccf825fae0c15205cb92d9 100644 (file)
@@ -48,11 +48,12 @@ upload-limit [ 200,000,000 ] initialize
 
 : parse-content-length-safe ( request -- content-length )
     "content-length" header [
-        ?string>number [
+        [ string>number ]
+        [
             dup 0 upload-limit get between? [
                 invalid-content-length
             ] unless
-        ] [ invalid-content-length ] if
+        ] [ invalid-content-length ] ?if
     ] [ content-length-missing ] if* ;
 
 : parse-content ( request content-type -- post-data )
index c537bf9a4b0eec94cdad4dd2c5e1e8529562e8ab..c5e7c2e11571206835e21447d8c10e03c09ab7ae 100644 (file)
@@ -383,9 +383,6 @@ PRIVATE>
 : string>number ( str -- n/f )
     10 <number-parse> [ @first-char ] require-next-digit ;
 
-: ?string>number ( str -- n/str ? )
-    dup string>number [ nip t ] [ f ] if* ;
-
 : base> ( str radix -- n/f )
     <number-parse> [ @first-char-no-radix ] require-next-digit ;