From 5abb66e86d0f0632c85f40a49d244d795cf907ee Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Sun, 28 Aug 2011 18:18:30 +0900 Subject: [PATCH] fixing some error handling in brace syntax --- sexp.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sexp.c b/sexp.c index 3c362e41..a7b1e95b 100644 --- a/sexp.c +++ b/sexp.c @@ -79,7 +79,8 @@ sexp sexp_write_simple_object (sexp ctx sexp_api_params(self, n), sexp obj, sexp for (i=0; i", out); + if (nulls) + while (--nulls) sexp_write_string(ctx, " #", out); sexp_write_char(ctx, ' ', out); sexp_write(ctx, sexp_slot_ref(obj, i), out); } else { @@ -2074,7 +2075,7 @@ sexp sexp_read_raw (sexp ctx, sexp in) { break; } else if (tmp2 == SEXP_CLOSE_BRACE) { break; - } else if (c1 >= sexp_type_num_slots_of_object(ctx, tmp)) { + } else if (c1 >= sexp_type_field_len_base(tmp)) { res = sexp_read_error(ctx, "too many slots in object literal", res, in); break; } else { @@ -2299,7 +2300,11 @@ sexp sexp_read_op (sexp ctx sexp_api_params(self, n), sexp in) { res = sexp_read_raw(ctx, in); if (res == SEXP_CLOSE) res = sexp_read_error(ctx, "too many ')'s", SEXP_NULL, in); - if (res == SEXP_RAWDOT) +#if SEXP_USE_OBJECT_BRACE_LITERALS + else if (res == SEXP_CLOSE_BRACE) + res = sexp_read_error(ctx, "too many '}'s", SEXP_NULL, in); +#endif + else if (res == SEXP_RAWDOT) res = sexp_read_error(ctx, "unexpected '.'", SEXP_NULL, in); return res; }