Skip to content

Commit

Permalink
Fix number reader with padding and complex literal
Browse files Browse the repository at this point in the history
When padding appear in both parts (real & imag, or mag & angle),
it failed to parse.
  • Loading branch information
shirok committed Jan 4, 2025
1 parent 448cf6a commit 5736730
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/number.c
Original file line number Diff line number Diff line change
Expand Up @@ -4905,6 +4905,7 @@ static ScmObj read_number(struct numread_packet *ctx)
ScmObj realpart = read_real(&str, &len, ctx);
if (SCM_FALSEP(realpart) || len == 0) return realpart;

ctx->padread = FALSE;
switch (*str) {
case '@':
/* polar representation of complex*/
Expand Down
7 changes: 7 additions & 0 deletions test/number.scm
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,13 @@
(test* "complex reader (polar)" (make-polar 3.5 -3.0) 7/[email protected])
(test* "complex reader (polar)" #f (string->number "7/[email protected]"))

(test* "complex reader (padding)" '(100.0 234.5)
(decompose-complex (string->number "1##+234.5###i")))
(test* "complex reader (padding)" '100.0
(decompose-complex (string->number "1##@.0###")))
(test* "complex reader (padding)" '(0.0 1.2)
(decompose-complex (string->number "1.2##@.5###pi")))

;;------------------------------------------------------------------
(test-section "integer writer syntax")

Expand Down

0 comments on commit 5736730

Please sign in to comment.