changed buf_init to buf_init_const
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
diff --git a/libkc3/array.c b/libkc3/array.c
index fa40239..a604a56 100644
--- a/libkc3/array.c
+++ b/libkc3/array.c
@@ -221,7 +221,7 @@ s_array * array_init_1 (s_array *array, const char *p)
assert(array);
assert(p);
len = strlen(p);
- buf_init(&buf, false, len, (char *) p);
+ buf_init_const(&buf, len, p);
buf.wpos = len;
r = buf_parse_array(&buf, &tmp);
if (r < 0 || (uw) r != len) {
diff --git a/libkc3/block.c b/libkc3/block.c
index c9307c0..63be828 100644
--- a/libkc3/block.c
+++ b/libkc3/block.c
@@ -59,7 +59,7 @@ s_block * block_init_1 (s_block *block, const char *p)
assert(block);
assert(p);
len = strlen(p);
- buf_init(&buf, false, len, (char *) p);
+ buf_init_const(&buf, len, p);
buf.wpos = len;
r = buf_parse_block(&buf, block);
if (r < 0 || (uw) r != len) {
diff --git a/libkc3/buf_fd.c b/libkc3/buf_fd.c
index b05abef..e1369a3 100644
--- a/libkc3/buf_fd.c
+++ b/libkc3/buf_fd.c
@@ -84,11 +84,6 @@ sw buf_fd_open_r_refill (s_buf *buf)
if ((uw) avail > size)
avail = size;
r = read(fd, buf->ptr.pchar + buf->wpos, avail);
- if (r < 0) {
- err_puts("buf_fd_open_r_refill: read");
- assert(! "buf_fd_open_r_refill: read");
- return r;
- }
if (buf->wpos + r > buf->size) {
err_puts("buf_fd_open_r_refill: buffer overflow");
assert(! "buf_fd_open_r_refill: buffer overflow");
diff --git a/libkc3/buf_parse.c b/libkc3/buf_parse.c
index 9264482..324115d 100644
--- a/libkc3/buf_parse.c
+++ b/libkc3/buf_parse.c
@@ -2949,7 +2949,7 @@ sw buf_parse_paren_sym (s_buf *buf, const s_sym **dest)
s_buf_save save;
const s_sym *tmp;
s_buf tmp_buf;
- s8 tmp_buf_data[64] = {0};
+ char tmp_buf_data[64] = {0};
buf_save_init(buf, &save);
if ((r = buf_read_1(buf, "(")) <= 0)
goto clean;
@@ -2973,7 +2973,7 @@ sw buf_parse_paren_sym (s_buf *buf, const s_sym **dest)
break;
result += r;
buf_init(&tmp_buf, false, sizeof(tmp_buf_data),
- (char *) tmp_buf_data);
+ tmp_buf_data);
buf_inspect_sym(&tmp_buf, &tmp);
buf_write_1(&tmp_buf, "[");
if ((r = buf_parse_uw(buf, &b)) <= 0)
diff --git a/libkc3/call.c b/libkc3/call.c
index 7be110a..e4a14f1 100644
--- a/libkc3/call.c
+++ b/libkc3/call.c
@@ -54,7 +54,7 @@ s_call * call_init_1 (s_call *call, const char *p)
uw len;
sw r;
len = strlen(p);
- buf_init(&buf, false, len, (char *) p);
+ buf_init_const(&buf, len, p);
buf.wpos = len;
r = buf_parse_call(&buf, call);
if (r < 0 || (uw) r != len) {
diff --git a/libkc3/cow.c b/libkc3/cow.c
index 7327388..ee7f0a5 100644
--- a/libkc3/cow.c
+++ b/libkc3/cow.c
@@ -77,7 +77,7 @@ s_cow * cow_init_1 (s_cow *cow, const char *utf8)
uw len;
sw r;
len = strlen(utf8);
- buf_init(&buf, false, len, (char *) utf8); // buf is read-only
+ buf_init_const(&buf, len, utf8); // buf is read-only
buf.wpos = len;
r = buf_parse_cow(&buf, cow);
if (r < 0 || (uw) r != len) {
diff --git a/libkc3/fn.c b/libkc3/fn.c
index 5275062..0f24da9 100644
--- a/libkc3/fn.c
+++ b/libkc3/fn.c
@@ -58,7 +58,7 @@ s_fn * fn_init (s_fn *fn, const s_sym *module)
return fn;
}
-s_fn * fn_init_1 (s_fn *fn, char *p)
+s_fn * fn_init_1 (s_fn *fn, const char *p)
{
s_buf buf;
uw len;
@@ -66,7 +66,7 @@ s_fn * fn_init_1 (s_fn *fn, char *p)
assert(fn);
assert(p);
len = strlen(p);
- buf_init(&buf, false, len, (char *) p);
+ buf_init_const(&buf, len, p);
buf.wpos = len;
r = buf_parse_fn(&buf, fn);
if (r < 0 || (uw) r != len) {
diff --git a/libkc3/fn.h b/libkc3/fn.h
index 5a1aeb7..568e325 100644
--- a/libkc3/fn.h
+++ b/libkc3/fn.h
@@ -24,7 +24,7 @@
/* Stack-allocation compatible functions, call fn_clean after use. */
void fn_clean (s_fn *fn);
s_fn * fn_init (s_fn *fn, const s_sym *module);
-s_fn * fn_init_1 (s_fn *fn, char *p);
+s_fn * fn_init_1 (s_fn *fn, const char *p);
s_fn * fn_init_cast (s_fn *fn, const s_sym * const *type,
const s_tag *tag);
s_fn * fn_init_copy (s_fn *fn, const s_fn *src);
diff --git a/libkc3/integer.c b/libkc3/integer.c
index f9072ab..0021305 100644
--- a/libkc3/integer.c
+++ b/libkc3/integer.c
@@ -250,7 +250,7 @@ s_integer * integer_init_1 (s_integer *i, const char *p)
assert(i);
assert(p);
// FIXME
- buf_init_1(&buf, false, (char *) p);
+ buf_init_1_const(&buf, p);
buf_parse_integer(&buf, i);
return i;
}
diff --git a/libkc3/map.c b/libkc3/map.c
index 84331ad..68c8022 100644
--- a/libkc3/map.c
+++ b/libkc3/map.c
@@ -117,7 +117,7 @@ s_map * map_init_1 (s_map *map, const char *p)
assert(map);
assert(p);
len = strlen(p);
- buf_init(&buf, false, len, (char *) p);
+ buf_init_const(&buf, len, p);
buf.wpos = len;
r = buf_parse_map(&buf, map);
if (r < 0 || (uw) r != len) {
diff --git a/libkc3/ratio.c b/libkc3/ratio.c
index f96b997..259a38f 100644
--- a/libkc3/ratio.c
+++ b/libkc3/ratio.c
@@ -124,7 +124,7 @@ s_ratio * ratio_init_1 (s_ratio *q, const char *p)
if (! p)
return NULL;
len = strlen(p);
- buf_init(&buf, false, len, (char *) p); // buf is read-only
+ buf_init_const(&buf, len, p); // buf is read-only
buf.wpos = len;
r = buf_parse_ratio(&buf, &tmp);
if (r < 0 || (uw) r != len) {
diff --git a/libkc3/s.c.in b/libkc3/s.c.in
index bd0a933..97c7f47 100644
--- a/libkc3/s.c.in
+++ b/libkc3/s.c.in
@@ -113,7 +113,7 @@ s_bits$ * s_bits$_init_str (s_bits$ *s, const s_str *str)
{
s_buf buf;
s_bits$ tmp = 0;
- buf_init(&buf, false, str->size, (char *) str->ptr.pchar);
+ buf_init_const(&buf, str->size, str->ptr.pchar);
buf.wpos = str->size;
if (buf_parse_s_bits$(&buf, &tmp) <= 0) {
err_puts("s_bits$_init_str: buf_parse_s_bits$");
diff --git a/libkc3/s16.c b/libkc3/s16.c
index 1b474c8..4a5711f 100644
--- a/libkc3/s16.c
+++ b/libkc3/s16.c
@@ -113,7 +113,7 @@ s16 * s16_init_str (s16 *s, const s_str *str)
{
s_buf buf;
s16 tmp = 0;
- buf_init(&buf, false, str->size, (char *) str->ptr.pchar);
+ buf_init_const(&buf, str->size, str->ptr.pchar);
buf.wpos = str->size;
if (buf_parse_s16(&buf, &tmp) <= 0) {
err_puts("s16_init_str: buf_parse_s16");
diff --git a/libkc3/s32.c b/libkc3/s32.c
index 685360d..2e6a5e4 100644
--- a/libkc3/s32.c
+++ b/libkc3/s32.c
@@ -113,7 +113,7 @@ s32 * s32_init_str (s32 *s, const s_str *str)
{
s_buf buf;
s32 tmp = 0;
- buf_init(&buf, false, str->size, (char *) str->ptr.pchar);
+ buf_init_const(&buf, str->size, str->ptr.pchar);
buf.wpos = str->size;
if (buf_parse_s32(&buf, &tmp) <= 0) {
err_puts("s32_init_str: buf_parse_s32");
diff --git a/libkc3/s64.c b/libkc3/s64.c
index 6c49e2f..eb04fab 100644
--- a/libkc3/s64.c
+++ b/libkc3/s64.c
@@ -113,7 +113,7 @@ s64 * s64_init_str (s64 *s, const s_str *str)
{
s_buf buf;
s64 tmp = 0;
- buf_init(&buf, false, str->size, (char *) str->ptr.pchar);
+ buf_init_const(&buf, str->size, str->ptr.pchar);
buf.wpos = str->size;
if (buf_parse_s64(&buf, &tmp) <= 0) {
err_puts("s64_init_str: buf_parse_s64");
diff --git a/libkc3/s8.c b/libkc3/s8.c
index e1f89dc..a7b899d 100644
--- a/libkc3/s8.c
+++ b/libkc3/s8.c
@@ -113,7 +113,7 @@ s8 * s8_init_str (s8 *s, const s_str *str)
{
s_buf buf;
s8 tmp = 0;
- buf_init(&buf, false, str->size, (char *) str->ptr.pchar);
+ buf_init_const(&buf, str->size, str->ptr.pchar);
buf.wpos = str->size;
if (buf_parse_s8(&buf, &tmp) <= 0) {
err_puts("s8_init_str: buf_parse_s8");
diff --git a/libkc3/str.c b/libkc3/str.c
index 0f7783e..2ab90a6 100644
--- a/libkc3/str.c
+++ b/libkc3/str.c
@@ -375,7 +375,7 @@ s_str * str_init_slice (s_str *str, const s_str *src, sw start, sw end)
s_str tmp = {0};
assert(str);
assert(src);
- buf_init(&buf, false, src->size, (char *) src->ptr.pchar);
+ buf_init_const(&buf, src->size, src->ptr.pchar);
if (! str_sw_pos_to_uw(start, src->size, &buf.rpos)) {
err_puts("str_init_slice: str_sw_pos_to_uw: start");
assert(! "str_init_slice: str_sw_pos_to_uw: start");
diff --git a/libkc3/sw.c b/libkc3/sw.c
index dc0cbc4..d9e7651 100644
--- a/libkc3/sw.c
+++ b/libkc3/sw.c
@@ -113,7 +113,7 @@ sw * sw_init_str (sw *s, const s_str *str)
{
s_buf buf;
sw tmp = 0;
- buf_init(&buf, false, str->size, (char *) str->ptr.pchar);
+ buf_init_const(&buf, str->size, str->ptr.pchar);
buf.wpos = str->size;
if (buf_parse_sw(&buf, &tmp) <= 0) {
err_puts("sw_init_str: buf_parse_sw");
diff --git a/libkc3/tuple.c b/libkc3/tuple.c
index 0d0ec66..fa96fc8 100644
--- a/libkc3/tuple.c
+++ b/libkc3/tuple.c
@@ -64,7 +64,7 @@ s_tuple * tuple_init_1 (s_tuple *tuple, const char *p)
assert(tuple);
assert(p);
len = strlen(p);
- buf_init(&buf, false, len, (char *) p);
+ buf_init_const(&buf, len, p);
buf.wpos = len;
r = buf_parse_tuple(&buf, tuple);
if (r < 0 || (uw) r != len) {