mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-03 19:26:34 +02:00
Bug fixes
This commit is contained in:
parent
fb18bf46ce
commit
e01815ae21
3 changed files with 22 additions and 10 deletions
|
@ -10,6 +10,7 @@ Features
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
|
|
||||||
- Prevent `remainder` from crashing the runtime due to divide by zero.
|
- Prevent `remainder` from crashing the runtime due to divide by zero.
|
||||||
|
- Avoid printing an unnecessary colon after certain error messages.
|
||||||
|
|
||||||
## 0.5.4 - August 3, 2017
|
## 0.5.4 - August 3, 2017
|
||||||
|
|
||||||
|
|
12
runtime.c
12
runtime.c
|
@ -5745,7 +5745,7 @@ void _read_line_comment(port_type *p)
|
||||||
}
|
}
|
||||||
if (p->mem_buf[p->buf_idx++] == '\n') {
|
if (p->mem_buf[p->buf_idx++] == '\n') {
|
||||||
p->line_num++; // Ignore col_num since we are just skipping over chars
|
p->line_num++; // Ignore col_num since we are just skipping over chars
|
||||||
p->col_num = 0;
|
p->col_num = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5780,7 +5780,7 @@ void _read_multiline_comment(port_type *p)
|
||||||
|
|
||||||
if (p->mem_buf[p->buf_idx] == '\n') {
|
if (p->mem_buf[p->buf_idx] == '\n') {
|
||||||
p->line_num++;
|
p->line_num++;
|
||||||
p->col_num = 0;
|
p->col_num = 1;
|
||||||
} else {
|
} else {
|
||||||
p->col_num++;
|
p->col_num++;
|
||||||
}
|
}
|
||||||
|
@ -5804,7 +5804,7 @@ void _read_whitespace(port_type *p)
|
||||||
if (p->mem_buf[p->buf_idx] == '\n') {
|
if (p->mem_buf[p->buf_idx] == '\n') {
|
||||||
p->buf_idx++;
|
p->buf_idx++;
|
||||||
p->line_num++; // Ignore col_num since we are just skipping over chars
|
p->line_num++; // Ignore col_num since we are just skipping over chars
|
||||||
p->col_num = 0;
|
p->col_num = 1;
|
||||||
break;
|
break;
|
||||||
} else if (isspace(p->mem_buf[p->buf_idx])) {
|
} else if (isspace(p->mem_buf[p->buf_idx])) {
|
||||||
p->buf_idx++;
|
p->buf_idx++;
|
||||||
|
@ -5921,7 +5921,7 @@ void _read_string(void *data, object cont, port_type *p)
|
||||||
escaped = 1;
|
escaped = 1;
|
||||||
} else if (c == '\n') {
|
} else if (c == '\n') {
|
||||||
p->line_num++;
|
p->line_num++;
|
||||||
p->col_num = 0;
|
p->col_num = 1;
|
||||||
_read_add_to_tok_buf(p, c);
|
_read_add_to_tok_buf(p, c);
|
||||||
} else {
|
} else {
|
||||||
_read_add_to_tok_buf(p, c);
|
_read_add_to_tok_buf(p, c);
|
||||||
|
@ -5956,7 +5956,7 @@ void _read_literal_identifier(void *data, port_type *p)
|
||||||
}
|
}
|
||||||
} else if (c == '\n') {
|
} else if (c == '\n') {
|
||||||
p->line_num++;
|
p->line_num++;
|
||||||
p->col_num = 0;
|
p->col_num = 1;
|
||||||
_read_add_to_tok_buf(p, c);
|
_read_add_to_tok_buf(p, c);
|
||||||
} else {
|
} else {
|
||||||
_read_add_to_tok_buf(p, c);
|
_read_add_to_tok_buf(p, c);
|
||||||
|
@ -6194,7 +6194,7 @@ void Cyc_io_read_token(void *data, object cont, object port)
|
||||||
} else if (c == '\n') {
|
} else if (c == '\n') {
|
||||||
if (p->tok_end) _read_return_atom(data, cont, p);
|
if (p->tok_end) _read_return_atom(data, cont, p);
|
||||||
p->line_num++;
|
p->line_num++;
|
||||||
p->col_num = 0;
|
p->col_num = 1;
|
||||||
} else if (isspace(c)) {
|
} else if (isspace(c)) {
|
||||||
if (p->tok_end) _read_return_atom(data, cont, p);
|
if (p->tok_end) _read_return_atom(data, cont, p);
|
||||||
_read_whitespace(p);
|
_read_whitespace(p);
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
(car args))))
|
(car args))))
|
||||||
(let ((result (parse fp)))
|
(let ((result (parse fp)))
|
||||||
(if (Cyc-opaque? result)
|
(if (Cyc-opaque? result)
|
||||||
(error "unexpected closing parenthesis")
|
(read-error fp "unexpected closing parenthesis")
|
||||||
result)))))
|
result)))))
|
||||||
|
|
||||||
;; read-all -> port -> [objects]
|
;; read-all -> port -> [objects]
|
||||||
|
@ -82,6 +82,17 @@
|
||||||
"(void *data, int argc, closure _, object k, object port)"
|
"(void *data, int argc, closure _, object k, object port)"
|
||||||
" Cyc_io_read_token(data, k, port);")
|
" Cyc_io_read_token(data, k, port);")
|
||||||
|
|
||||||
|
(define-c read-error
|
||||||
|
"(void *data, int argc, closure _, object k, object port, object msg)"
|
||||||
|
" char buf[1024];
|
||||||
|
port_type *p;
|
||||||
|
Cyc_check_port(data, port);
|
||||||
|
Cyc_check_str(data, msg);
|
||||||
|
p = ((port_type *)port);
|
||||||
|
snprintf(buf, 1023, \"(line %d, column %d): %s\",
|
||||||
|
p->line_num, p->col_num, string_str(msg));
|
||||||
|
Cyc_rt_raise_msg(data, buf);")
|
||||||
|
|
||||||
(define-c Cyc-opaque-eq?
|
(define-c Cyc-opaque-eq?
|
||||||
"(void *data, int argc, closure _, object k, object opq, object obj)"
|
"(void *data, int argc, closure _, object k, object opq, object obj)"
|
||||||
" if (Cyc_is_opaque(opq) == boolean_f)
|
" if (Cyc_is_opaque(opq) == boolean_f)
|
||||||
|
@ -104,7 +115,7 @@
|
||||||
(t (parse fp)))
|
(t (parse fp)))
|
||||||
(cond
|
(cond
|
||||||
((eof-object? t)
|
((eof-object? t)
|
||||||
(error "missing closing parenthesis"))
|
(read-error fp "missing closing parenthesis"))
|
||||||
((Cyc-opaque-eq? t #\))
|
((Cyc-opaque-eq? t #\))
|
||||||
(if (and (> (length lis) 2)
|
(if (and (> (length lis) 2)
|
||||||
(equal? (cadr lis) (string->symbol ".")))
|
(equal? (cadr lis) (string->symbol ".")))
|
||||||
|
@ -135,7 +146,7 @@
|
||||||
(t (parse fp)))
|
(t (parse fp)))
|
||||||
(cond
|
(cond
|
||||||
((eof-object? t)
|
((eof-object? t)
|
||||||
(error "missing closing parenthesis"))
|
(read-error fp "missing closing parenthesis"))
|
||||||
((Cyc-opaque-eq? t #\))
|
((Cyc-opaque-eq? t #\))
|
||||||
(list->vector (reverse lis)))
|
(list->vector (reverse lis)))
|
||||||
(else
|
(else
|
||||||
|
@ -145,7 +156,7 @@
|
||||||
(t (parse fp)))
|
(t (parse fp)))
|
||||||
(cond
|
(cond
|
||||||
((eof-object? t)
|
((eof-object? t)
|
||||||
(error "missing closing parenthesis"))
|
(read-error fp "missing closing parenthesis"))
|
||||||
((Cyc-opaque-eq? t #\))
|
((Cyc-opaque-eq? t #\))
|
||||||
(apply bytevector (reverse lis)))
|
(apply bytevector (reverse lis)))
|
||||||
(else
|
(else
|
||||||
|
|
Loading…
Add table
Reference in a new issue