From 944347e8283ed3ca8f48904eab684e23e6be4dbf Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Mon, 30 Sep 2019 19:59:35 -0500 Subject: [PATCH] Fix formatting. Run make format. --- src/core/capi.c | 12 ++++----- src/core/compile.c | 65 +++++++++++++++++++++++----------------------- 2 files changed, 38 insertions(+), 39 deletions(-) diff --git a/src/core/capi.c b/src/core/capi.c index c13f2721..f7fae4b1 100644 --- a/src/core/capi.c +++ b/src/core/capi.c @@ -227,16 +227,16 @@ JanetRange janet_getslice(int32_t argc, const Janet *argv) { range.end = length; } else if (argc == 2) { range.start = janet_checktype(argv[1], JANET_NIL) - ? 0 - : janet_gethalfrange(argv, 1, length, "start"); + ? 0 + : janet_gethalfrange(argv, 1, length, "start"); range.end = length; } else { range.start = janet_checktype(argv[1], JANET_NIL) - ? 0 - : janet_gethalfrange(argv, 1, length, "start"); + ? 0 + : janet_gethalfrange(argv, 1, length, "start"); range.end = janet_checktype(argv[2], JANET_NIL) - ? length - : janet_gethalfrange(argv, 2, length, "end"); + ? length + : janet_gethalfrange(argv, 2, length, "end"); if (range.end < range.start) range.end = range.start; } diff --git a/src/core/compile.c b/src/core/compile.c index fef980ec..251c84f0 100644 --- a/src/core/compile.c +++ b/src/core/compile.c @@ -320,7 +320,7 @@ JanetSlot *janetc_toslotskv(JanetCompiler *c, Janet ds) { return ret; } -/* Push slots loaded via janetc_toslots. Return the minimum number of slots pushed, +/* Push slots loaded via janetc_toslots. Return the minimum number of slots pushed, * or -1 - min_arity if there is a splice. (if there is no splice, min_arity is also * the maximum possible arity). */ int32_t janetc_pushslots(JanetCompiler *c, JanetSlot *slots) { @@ -422,56 +422,55 @@ static JanetSlot janetc_call(JanetFopts opts, JanetSlot *slots, JanetSlot fun) { /* Check for bad arity type if fun is a constant */ switch (janet_type(fun.constant)) { - case JANET_FUNCTION: - { - JanetFunction *f = janet_unwrap_function(fun.constant); - int32_t min = f->def->min_arity; - int32_t max = f->def->max_arity; - if (min_arity < 0) { - /* Call has splices */ - min_arity = -1 - min_arity; - if (min_arity > max && max >= 0) { - const uint8_t *es = janet_formatc( - "%v expects at most %d argument, got at least %d", - fun.constant, max, min_arity); - janetc_error(c, es); - } - } else { - /* Call has no splices */ - if (min_arity > max && max >= 0) { - const uint8_t *es = janet_formatc( - "%v expects at most %d argument, got %d", - fun.constant, max, min_arity); - janetc_error(c, es); - } - if (min_arity < min) { - const uint8_t *es = janet_formatc( - "%v expects at least %d argument, got %d", - fun.constant, min, min_arity); - janetc_error(c, es); - } + case JANET_FUNCTION: { + JanetFunction *f = janet_unwrap_function(fun.constant); + int32_t min = f->def->min_arity; + int32_t max = f->def->max_arity; + if (min_arity < 0) { + /* Call has splices */ + min_arity = -1 - min_arity; + if (min_arity > max && max >= 0) { + const uint8_t *es = janet_formatc( + "%v expects at most %d argument, got at least %d", + fun.constant, max, min_arity); + janetc_error(c, es); + } + } else { + /* Call has no splices */ + if (min_arity > max && max >= 0) { + const uint8_t *es = janet_formatc( + "%v expects at most %d argument, got %d", + fun.constant, max, min_arity); + janetc_error(c, es); + } + if (min_arity < min) { + const uint8_t *es = janet_formatc( + "%v expects at least %d argument, got %d", + fun.constant, min, min_arity); + janetc_error(c, es); } } - break; + } + break; case JANET_CFUNCTION: case JANET_ABSTRACT: break; case JANET_KEYWORD: if (min_arity == 0) { const uint8_t *es = janet_formatc("%v expects at least 1 argument, got 0", - fun.constant); + fun.constant); janetc_error(c, es); } break; default: if (min_arity > 1 || min_arity == 0) { const uint8_t *es = janet_formatc("%v expects 1 argument, got %d", - fun.constant, min_arity); + fun.constant, min_arity); janetc_error(c, es); } if (min_arity < -2) { const uint8_t *es = janet_formatc("%v expects 1 argument, got at least %d", - fun.constant, -1 - min_arity); + fun.constant, -1 - min_arity); janetc_error(c, es); } break;