From ee1b8041597e73b426611e3cf9786d35b45c5c24 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Mon, 25 Mar 2024 11:59:12 -0500 Subject: [PATCH] core: remove ?string>number in favor of ?if --- basis/http/download/download.factor | 19 ++++++++++++------- basis/http/server/requests/requests.factor | 5 +++-- core/math/parser/parser.factor | 3 --- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/basis/http/download/download.factor b/basis/http/download/download.factor index df9fca6e59..1d087a07bd 100644 --- a/basis/http/download/download.factor +++ b/basis/http/download/download.factor @@ -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 ; diff --git a/basis/http/server/requests/requests.factor b/basis/http/server/requests/requests.factor index fce1477f2a..eeb7a56c67 100644 --- a/basis/http/server/requests/requests.factor +++ b/basis/http/server/requests/requests.factor @@ -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 ) diff --git a/core/math/parser/parser.factor b/core/math/parser/parser.factor index c537bf9a4b..c5e7c2e115 100644 --- a/core/math/parser/parser.factor +++ b/core/math/parser/parser.factor @@ -383,9 +383,6 @@ PRIVATE> : string>number ( str -- n/f ) 10 [ @first-char ] require-next-digit ; -: ?string>number ( str -- n/str ? ) - dup string>number [ nip t ] [ f ] if* ; - : base> ( str radix -- n/f ) [ @first-char-no-radix ] require-next-digit ; -- 2.34.1