Start changing all instances of 0x to #x

After this commit -0x123 is still supported, but 0x123 is not.
This commit is contained in:
Lassi Kortela 2019-08-10 15:51:43 +03:00
parent 003068f575
commit d5bb6b3116
5 changed files with 20 additions and 33 deletions

View File

@ -601,9 +601,9 @@ static void cvalue_printdata(struct ios *f, void *data, size_t len,
if (print_princ) if (print_princ)
outc(ch, f); outc(ch, f);
else if (weak) else if (weak)
HPOS += ios_printf(f, "0x%hhx", ch); HPOS += ios_printf(f, "#x%hhx", ch);
else else
HPOS += ios_printf(f, "#byte(0x%hhx)", ch); HPOS += ios_printf(f, "#byte(#x%hhx)", ch);
} else if (type == wcharsym) { } else if (type == wcharsym) {
uint32_t wc = *(uint32_t *)data; uint32_t wc = *(uint32_t *)data;
char seq[8]; 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); label = (value_t)ptrhash_get(&reverse_dlsym_lookup_table, cv);
if (label == (value_t)HT_NOTFOUND) { if (label == (value_t)HT_NOTFOUND) {
HPOS += HPOS +=
ios_printf(f, "#<builtin @0x%08zx>", (size_t)(builtin_t)fptr); ios_printf(f, "#<builtin @#x%08zx>", (size_t)(builtin_t)fptr);
} else { } else {
if (print_princ) { if (print_princ) {
outs(symbol_name(label), f); outs(symbol_name(label), f);

View File

@ -88,7 +88,6 @@ int isnumtok_base(char *tok, value_t *pval, int base)
int64_t i64; int64_t i64;
uint64_t ui64; uint64_t ui64;
double d; double d;
int ok;
if (*tok == '\0') if (*tok == '\0')
return 0; return 0;
@ -142,19 +141,7 @@ int isnumtok_base(char *tok, value_t *pval, int base)
if (tok[0] == '_') { if (tok[0] == '_') {
return 0; return 0;
} }
ok = 0; if (!read_digits(tok, &end, base, &ui64)) {
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) {
return 0; return 0;
} }
if (pval) if (pval)

View File

@ -22,4 +22,4 @@
(begin (begin
(princ (bin-draw (string.lpad (number->string n 2) 63 #\0))) (princ (bin-draw (string.lpad (number->string n 2) 63 #\0)))
(newline))) (newline)))
(nestlist rule30-step (uint64 0x0000000080000000) 32)) (nestlist rule30-step (uint64 #x0000000080000000) 32))

View File

@ -174,7 +174,7 @@
(lambda (n) (lambda (n)
(if (< n 2) n (+ (fib (- n 1)) (fib (- n 2)))))))) (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) ;(tt)
;(tt) ;(tt)

View File

@ -48,11 +48,11 @@
(test-square (every-sint -67)) (test-square (every-sint -67))
(test-square (every-int 3)) (test-square (every-int 3))
(test-square (every-int 0x80000000)) (test-square (every-int #x80000000))
(test-square (every-sint 0x80000000)) (test-square (every-sint #x80000000))
(test-square (every-sint -0x80000000)) (test-square (every-sint #x-80000000))
(assert (= (* 128 0x02000001) 0x100000080)) (assert (= (* 128 #x02000001) #x100000080))
(assert (= (/ 1) 1)) (assert (= (/ 1) 1))
(assert (= (/ -1) -1)) (assert (= (/ -1) -1))
@ -64,21 +64,21 @@
(assert (not (eqv? #\newline 10))) (assert (not (eqv? #\newline 10)))
; tricky cases involving INT_MIN ; tricky cases involving INT_MIN
(assert (< (- #uint32(0x80000000)) 0)) (assert (< (- #uint32(#x80000000)) 0))
(assert (> (- #int32(0x80000000)) 0)) (assert (> (- #int32(#x80000000)) 0))
(assert (< (- #uint64(0x8000000000000000)) 0)) (assert (< (- #uint64(#x8000000000000000)) 0))
(assert (> (- #int64(0x8000000000000000)) 0)) (assert (> (- #int64(#x8000000000000000)) 0))
; fixnum versions ; fixnum versions
(assert (= (- -536870912) 536870912)) (assert (= (- -536870912) 536870912))
(assert (= (- -2305843009213693952) 2305843009213693952)) (assert (= (- -2305843009213693952) 2305843009213693952))
(assert (not (equal? #int64(0x8000000000000000) #uint64(0x8000000000000000)))) (assert (not (equal? #int64(#x8000000000000000) #uint64(#x8000000000000000))))
(assert (equal? (+ #int64(0x4000000000000000) #int64(0x4000000000000000)) (assert (equal? (+ #int64(#x4000000000000000) #int64(#x4000000000000000))
#uint64(0x8000000000000000))) #uint64(#x8000000000000000)))
(assert (equal? (* 2 #int64(0x4000000000000000)) (assert (equal? (* 2 #int64(#x4000000000000000))
#uint64(0x8000000000000000))) #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 (equal? (string 'sym #byte(65) #wchar(945) "blah") "symA\u03B1blah"))
(assert (= (length (string #\x0)) 1)) (assert (= (length (string #\x0)) 1))