From 91791983aa5c596f6c944d43d2dd774289455751 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sat, 23 Jun 2012 02:20:59 -0700 Subject: [PATCH] fix indentation of some error messages `raise-syntax-error' and `raise-arguments-error' do not try to adjust indentation, anymore, because it's too confusing --- collects/racket/private/kw.rkt | 2 +- collects/scribblings/reference/exns.scrbl | 8 ++++---- src/racket/src/compile.c | 6 +++--- src/racket/src/error.c | 12 +----------- 4 files changed, 9 insertions(+), 19 deletions(-) diff --git a/collects/racket/private/kw.rkt b/collects/racket/private/kw.rkt index 468d762183..9ecdcd7a77 100644 --- a/collects/racket/private/kw.rkt +++ b/collects/racket/private/kw.rkt @@ -871,7 +871,7 @@ (null? (cdr l))) (raise-syntax-error #f - "missing procedure expression;\nprobably originally (), which is an illegal empty application" + "missing procedure expression;\n probably originally (), which is an illegal empty application" stx) (begin (when l diff --git a/collects/scribblings/reference/exns.scrbl b/collects/scribblings/reference/exns.scrbl index 4f18e27ce8..36862c2433 100644 --- a/collects/scribblings/reference/exns.scrbl +++ b/collects/scribblings/reference/exns.scrbl @@ -213,8 +213,8 @@ as a ``result'' instead of an ``argument.''} Creates an @racket[exn:fail:contract] value and @racket[raise]s it as an exception. The @racket[name] is used as the source procedure's name in the error message. The @racket[message] is the error -message; if @racket[message] contains newline characters, each new line is -suitably indented (by adding one extra space at the start). +message; if @racket[message] contains newline characters, each extra line should be +suitably indented (with one extra space at the start of each line), but it should not end with a newline character. Each @racket[field] must have a corresponding @racket[v], and the two are rendered on their own line in the error message, with each @racket[v] formatted @@ -313,8 +313,8 @@ exception. Macros use this procedure to report syntax errors. The @racket[name] argument is usually @racket[#f] when @racket[expr] is provided; it is described in more detail below. The @racket[message] is used as the main body of the error message; if -@racket[message] contains newline characters, each new line is -suitably indented (by adding one extra space at the start). +@racket[message] contains newline characters, each new line should be +suitably indented (with one space at the start), and it should not end with a newline character. The optional @racket[expr] argument is the erroneous source syntax object or S-expression (but the expression @racket[#f] cannot be diff --git a/src/racket/src/compile.c b/src/racket/src/compile.c index fa6c6f1209..346db309b4 100644 --- a/src/racket/src/compile.c +++ b/src/racket/src/compile.c @@ -361,7 +361,7 @@ static int check_form(Scheme_Object *form, Scheme_Object *base_form) static void bad_form(Scheme_Object *form, int l) { scheme_wrong_syntax(NULL, NULL, form, - "bad syntax;\nhas %d part%s after keyword", + "bad syntax;\n has %d part%s after keyword", l - 1, (l != 2) ? "s" : ""); } @@ -4814,13 +4814,13 @@ scheme_compile_expand_expr(Scheme_Object *form, Scheme_Comp_Env *env, scheme_wrong_syntax(scheme_compile_stx_string, orig_unbound_name, form, "unbound identifier%s;\n" - "also, no %S syntax transformer is bound", + " also, no %S syntax transformer is bound", phase, SCHEME_STX_VAL(stx)); } else { scheme_wrong_syntax(scheme_compile_stx_string, NULL, form, "%s is not allowed;\n" - "no %S syntax transformer is bound%s", + " no %S syntax transformer is bound%s", not_allowed, SCHEME_STX_VAL(stx), phase); diff --git a/src/racket/src/error.c b/src/racket/src/error.c index 04ba3fd1cc..f0c97f3713 100644 --- a/src/racket/src/error.c +++ b/src/racket/src/error.c @@ -1821,8 +1821,6 @@ void scheme_contract_error(const char *name, const char *msg, ...) nlen = strlen(name); seplen = strlen(sep); - msg = indent_lines(msg, &mlen, 0, 1); - len += mlen + nlen + seplen + 10; s = scheme_malloc_atomic(len); @@ -1857,7 +1855,7 @@ void scheme_wrong_chaperoned(const char *who, const char *what, Scheme_Object *o sprintf(buf, "non-chaperone result;\n" - "received a %s that is not a chaperone of the original %s", + " received a %s that is not a chaperone of the original %s", what, what); scheme_contract_error(who, @@ -2164,8 +2162,6 @@ static void do_wrong_syntax(const char *where, where = scheme_symbol_val(who); } - s = (char *)indent_lines(s, &slen, 0, 1); - if (v) { if (dv) blen = scheme_sprintf(buffer, blen, @@ -2742,11 +2738,6 @@ static Scheme_Object *do_raise_mismatch_error(const char *who, int mismatch, int s = scheme_char_string_to_byte_string(argv[i+offset]); st = SCHEME_BYTE_STR_VAL(s); slen = SCHEME_BYTE_STRLEN_VAL(s); - if (i == 1) { - intptr_t fl = slen; - st = (char *)indent_lines(st, &fl, 0, 1); - slen = fl; - } if (!mismatch) total += 5; } else { @@ -2781,7 +2772,6 @@ static Scheme_Object *do_raise_mismatch_error(const char *who, int mismatch, int } else { s2 = SCHEME_BYTE_STR_VAL(s); l2 = SCHEME_BYTE_STRLEN_VAL(s); - s2 = (char *)indent_lines(s2, &l2, 0, 1); } scheme_raise_exn(MZEXN_FAIL_CONTRACT,