From d5bb6b3116ab1bef4ad5b0a5800c144e3899650a Mon Sep 17 00:00:00 2001 From: Lassi Kortela Date: Sat, 10 Aug 2019 15:51:43 +0300 Subject: [PATCH] Start changing all instances of 0x to #x After this commit -0x123 is still supported, but 0x123 is not. --- c/print.h | 6 +++--- c/read.h | 15 +-------------- scheme-examples/rule30.scm | 2 +- scheme-tests/test.scm | 2 +- scheme-tests/unittest.scm | 28 ++++++++++++++-------------- 5 files changed, 20 insertions(+), 33 deletions(-) diff --git a/c/print.h b/c/print.h index 7649e49..9297244 100644 --- a/c/print.h +++ b/c/print.h @@ -601,9 +601,9 @@ static void cvalue_printdata(struct ios *f, void *data, size_t len, if (print_princ) outc(ch, f); else if (weak) - HPOS += ios_printf(f, "0x%hhx", ch); + HPOS += ios_printf(f, "#x%hhx", ch); else - HPOS += ios_printf(f, "#byte(0x%hhx)", ch); + HPOS += ios_printf(f, "#byte(#x%hhx)", ch); } else if (type == wcharsym) { uint32_t wc = *(uint32_t *)data; char seq[8]; @@ -789,7 +789,7 @@ static void cvalue_print(struct ios *f, value_t v) label = (value_t)ptrhash_get(&reverse_dlsym_lookup_table, cv); if (label == (value_t)HT_NOTFOUND) { HPOS += - ios_printf(f, "#", (size_t)(builtin_t)fptr); + ios_printf(f, "#", (size_t)(builtin_t)fptr); } else { if (print_princ) { outs(symbol_name(label), f); diff --git a/c/read.h b/c/read.h index 7467dad..d583172 100644 --- a/c/read.h +++ b/c/read.h @@ -88,7 +88,6 @@ int isnumtok_base(char *tok, value_t *pval, int base) int64_t i64; uint64_t ui64; double d; - int ok; if (*tok == '\0') return 0; @@ -142,19 +141,7 @@ int isnumtok_base(char *tok, value_t *pval, int base) if (tok[0] == '_') { return 0; } - ok = 0; - if (tok[0] == '0') { - if (tok[1] == 'x') { - // TODO: We should get rid of 0x hex syntax: #x is enough. - if (!(ok = read_digits(tok + 2, &end, 16, &ui64))) { - return 0; - } - } - } - if (!ok) { - ok = read_digits(tok, &end, base, &ui64); - } - if (!ok) { + if (!read_digits(tok, &end, base, &ui64)) { return 0; } if (pval) diff --git a/scheme-examples/rule30.scm b/scheme-examples/rule30.scm index 083e78e..9741cb7 100644 --- a/scheme-examples/rule30.scm +++ b/scheme-examples/rule30.scm @@ -22,4 +22,4 @@ (begin (princ (bin-draw (string.lpad (number->string n 2) 63 #\0))) (newline))) - (nestlist rule30-step (uint64 0x0000000080000000) 32)) + (nestlist rule30-step (uint64 #x0000000080000000) 32)) diff --git a/scheme-tests/test.scm b/scheme-tests/test.scm index eb3a2ad..10d1bdb 100644 --- a/scheme-tests/test.scm +++ b/scheme-tests/test.scm @@ -174,7 +174,7 @@ (lambda (n) (if (< n 2) n (+ (fib (- n 1)) (fib (- n 2)))))))) -;(defun tt () (time (dotimes (i 500000) (* 0x1fffffff 1) ))) +;(defun tt () (time (dotimes (i 500000) (* #x1fffffff 1) ))) ;(tt) ;(tt) ;(tt) diff --git a/scheme-tests/unittest.scm b/scheme-tests/unittest.scm index 2891e20..514c216 100644 --- a/scheme-tests/unittest.scm +++ b/scheme-tests/unittest.scm @@ -48,11 +48,11 @@ (test-square (every-sint -67)) (test-square (every-int 3)) -(test-square (every-int 0x80000000)) -(test-square (every-sint 0x80000000)) -(test-square (every-sint -0x80000000)) +(test-square (every-int #x80000000)) +(test-square (every-sint #x80000000)) +(test-square (every-sint #x-80000000)) -(assert (= (* 128 0x02000001) 0x100000080)) +(assert (= (* 128 #x02000001) #x100000080)) (assert (= (/ 1) 1)) (assert (= (/ -1) -1)) @@ -64,21 +64,21 @@ (assert (not (eqv? #\newline 10))) ; tricky cases involving INT_MIN -(assert (< (- #uint32(0x80000000)) 0)) -(assert (> (- #int32(0x80000000)) 0)) -(assert (< (- #uint64(0x8000000000000000)) 0)) -(assert (> (- #int64(0x8000000000000000)) 0)) +(assert (< (- #uint32(#x80000000)) 0)) +(assert (> (- #int32(#x80000000)) 0)) +(assert (< (- #uint64(#x8000000000000000)) 0)) +(assert (> (- #int64(#x8000000000000000)) 0)) ; fixnum versions (assert (= (- -536870912) 536870912)) (assert (= (- -2305843009213693952) 2305843009213693952)) -(assert (not (equal? #int64(0x8000000000000000) #uint64(0x8000000000000000)))) -(assert (equal? (+ #int64(0x4000000000000000) #int64(0x4000000000000000)) - #uint64(0x8000000000000000))) -(assert (equal? (* 2 #int64(0x4000000000000000)) - #uint64(0x8000000000000000))) +(assert (not (equal? #int64(#x8000000000000000) #uint64(#x8000000000000000)))) +(assert (equal? (+ #int64(#x4000000000000000) #int64(#x4000000000000000)) + #uint64(#x8000000000000000))) +(assert (equal? (* 2 #int64(#x4000000000000000)) + #uint64(#x8000000000000000))) -(assert (equal? (uint64 (double -123)) #uint64(0xffffffffffffff85))) +(assert (equal? (uint64 (double -123)) #uint64(#xffffffffffffff85))) (assert (equal? (string 'sym #byte(65) #wchar(945) "blah") "symA\u03B1blah")) (assert (= (length (string #\x0)) 1))