mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-25 13:05:05 +02:00
Removed unnecessary string->number2
This commit is contained in:
parent
76c84ad29e
commit
d2eba45376
2 changed files with 3 additions and 28 deletions
|
@ -9,7 +9,6 @@
|
||||||
(define-library (scheme base)
|
(define-library (scheme base)
|
||||||
;; In the future, may include this here: (include "../srfi/9.scm")
|
;; In the future, may include this here: (include "../srfi/9.scm")
|
||||||
(export
|
(export
|
||||||
string->number2 ;; TODO: should replace string->number primitive
|
|
||||||
cons-source
|
cons-source
|
||||||
syntax-rules
|
syntax-rules
|
||||||
letrec*
|
letrec*
|
||||||
|
@ -1052,30 +1051,6 @@
|
||||||
data,
|
data,
|
||||||
k,
|
k,
|
||||||
((p->mode == 0 && p->fp != NULL) ? boolean_t : boolean_f)); ")
|
((p->mode == 0 && p->fp != NULL) ? boolean_t : boolean_f)); ")
|
||||||
(define-c Cyc-string->number
|
|
||||||
"(void *data, int argc, closure _, object k, object str, object base)"
|
|
||||||
" make_int(result, 0);
|
|
||||||
Cyc_check_str(data, str);
|
|
||||||
Cyc_check_int(data, base);
|
|
||||||
|
|
||||||
if (integer_value(base) == 2) {
|
|
||||||
result.value = binstr2int(string_str(str));
|
|
||||||
}else if (integer_value(base) == 8) {
|
|
||||||
result.value = octstr2int(string_str(str));
|
|
||||||
}else {
|
|
||||||
result.value = hexstr2int(string_str(str));
|
|
||||||
}
|
|
||||||
return_closcall1(data, k, &result); ")
|
|
||||||
;; TODO: this should become the real string->number
|
|
||||||
(define (string->number2 str . base)
|
|
||||||
(if (or (null? base) (not (integer? (car base))))
|
|
||||||
(string->number str)
|
|
||||||
(let ((b (car base)))
|
|
||||||
(cond
|
|
||||||
((or (= b 2) (= b 8) (= b 16))
|
|
||||||
(Cyc-string->number str b))
|
|
||||||
(else
|
|
||||||
(string->number str))))))
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; syntax-rules
|
;; syntax-rules
|
||||||
|
|
|
@ -325,13 +325,13 @@
|
||||||
(parse-atom num)))))
|
(parse-atom num)))))
|
||||||
((eq? #\b next-c)
|
((eq? #\b next-c)
|
||||||
(parse-number fp toks all? parens ptbl
|
(parse-number fp toks all? parens ptbl
|
||||||
2 (lambda (num) (string->number2 (list->string num) 2))))
|
2 (lambda (num) (string->number (list->string num) 2))))
|
||||||
((eq? #\o next-c)
|
((eq? #\o next-c)
|
||||||
(parse-number fp toks all? parens ptbl
|
(parse-number fp toks all? parens ptbl
|
||||||
8 (lambda (num) (string->number2 (list->string num) 8))))
|
8 (lambda (num) (string->number (list->string num) 8))))
|
||||||
((eq? #\x next-c)
|
((eq? #\x next-c)
|
||||||
(parse-number fp toks all? parens ptbl
|
(parse-number fp toks all? parens ptbl
|
||||||
16 (lambda (num) (string->number2 (list->string num) 16))))
|
16 (lambda (num) (string->number (list->string num) 16))))
|
||||||
;; Vector
|
;; Vector
|
||||||
((eq? #\( next-c)
|
((eq? #\( next-c)
|
||||||
(let ((sub (parse fp '() '() #t #f (+ parens 1) ptbl))
|
(let ((sub (parse fp '() '() #t #f (+ parens 1) ptbl))
|
||||||
|
|
Loading…
Add table
Reference in a new issue