diff options
Diffstat (limited to 'bytenumb.c')
-rwxr-xr-x[-rw-r--r--] | bytenumb.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/bytenumb.c b/bytenumb.c index 30ca469..b5821d3 100644..100755 --- a/bytenumb.c +++ b/bytenumb.c @@ -60,7 +60,8 @@ char * get_bytes(obj, minlen, s_name) obj, ARG1, s_name); { int byvlen = get_bytes_length(obj); - ASRTER(byvlen >= minlen, obj, s_wrong_length, s_name); + ASRTER((minlen < 0) ? byvlen >= -minlen : byvlen == minlen, + MAKINUM(byvlen), s_wrong_length, s_name); return (char*)scm_addr(cons(obj, list_of_0), s_name); } } @@ -74,7 +75,7 @@ SCM scm_bytes_to_integer(sbyts, sn) if (!(n)) return INUM0; { int cnt = abs(n); - char *byts = get_bytes(sbyts, cnt, s_bytes_to_integer); + char *byts = get_bytes(sbyts, -cnt, s_bytes_to_integer); int iu = 0, id = cnt - sizeof(BIGDIG); sizet ndigs = (cnt + sizeof(BIGDIG) - 1) / sizeof(BIGDIG); int negp = (0x80 & byts[0]) && (0 > n); @@ -83,7 +84,7 @@ SCM scm_bytes_to_integer(sbyts, sn) if (negp) for (; iu < ndigs; iu++) { int j = 0; - unsigned long dig = 0; + UBIGLONG dig = 0; for (; j < sizeof(BIGDIG); j++) { dig = (dig<<8) + (0xFF ^ ((id + j >= 0) ? (((unsigned char *)byts)[id + j]) : 255)); @@ -131,7 +132,7 @@ SCM scm_integer_to_bytes(sn, slen) } } else { - unsigned long res = n; + UBIGLONG res = n; while (!(0 > idx)) { byts[idx--] = res % 0x100; res = res>>8; @@ -143,7 +144,7 @@ SCM scm_integer_to_bytes(sn, slen) BIGDIG *digs = BDIGITS(sn), borrow = 1; sizet ndigs = NUMDIGS(sn); int iu = 0, id = abs(len) - 1; - unsigned long dig; + UBIGLONG dig; if ((0 > len) && (TYP16(sn)==tc16_bigneg)) for (; 0 <= id ; iu++) { sizet j = sizeof(BIGDIG); @@ -400,7 +401,7 @@ static char s_integer_byte_collate_M[] = "integer-byte-collate!"; SCM scm_integer_byte_collate_M(byte_vector) SCM byte_vector; { - char* bv = get_bytes(byte_vector, 1, s_integer_byte_collate_M); + char* bv = get_bytes(byte_vector, -1, s_integer_byte_collate_M); bv[0] = 0x80^(bv[0]); return byte_vector; } |