From 1ba42bb70dc5398614f15ce6d8bcb19650435cb5 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Mon, 25 Jul 2016 19:17:35 -0400 Subject: [PATCH] Skip whitespace more liberally when parsing PLTSTDERR and friends. Now accepts any whitespace, not just spaces, ignores both leading and trailing whitespace, and accepts multiple whitespace characters separating subterms. --- .../scribblings/reference/logging.scrbl | 25 ++++++++++++------- racket/src/racket/cmdline.inc | 10 ++++++-- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/pkgs/racket-doc/scribblings/reference/logging.scrbl b/pkgs/racket-doc/scribblings/reference/logging.scrbl index 1353136daa..dc87b1fc30 100644 --- a/pkgs/racket-doc/scribblings/reference/logging.scrbl +++ b/pkgs/racket-doc/scribblings/reference/logging.scrbl @@ -41,16 +41,17 @@ through environment variables: @litchar{none}, @litchar{fatal}, @litchar{error}, @litchar{warning}, @litchar{info}, or @litchar{debug}; all events the corresponding level of higher are printed. After an - initial @nonterm{level}, the value can contain space-separated - specifications of the form - @nonterm{level}@litchar["@"]@nonterm{topic}, which prints events - whose topics match @nonterm{topic} only at the given + initial @nonterm{level}, the value can contain + whitespace-separated specifications of the form + @nonterm{level}@litchar["@"]@nonterm{topic}, which prints + events whose topics match @nonterm{topic} only at the given @nonterm{level} or higher (where a @nonterm{topic} contains any - character other than a space or @litchar["@"]). For example, - the value @racket["error debug@GC"] prints all events at the - @racket['error] level and higher, but prints events for the topic - topic @racket['GC] at the @racket['debug] level and - higher (which includes all levels). + character other than whitespace or @litchar["@"]). Leading and + trailing whitespace is ignored. For example, the value + @racket["error debug@GC"] prints all events at the + @racket['error] level and higher, but prints events for the + topic @racket['GC] at the @racket['debug] level and higher + (which includes all levels). The default is @racket["error"].} @@ -73,6 +74,12 @@ logger to report events. For example, the bytecode compiler sometimes reports @racket['warning] events when it detects an expression that would produce a run-time error if evaluated. +@history[#:changed "6.6.0.2" @elem{Prior to version 6.6.0.2, parsing + of @envvar{PLTSTDERR} and @envvar{PLTSYSLOG} was very strict. + Leading and trailing whitespace was forbidden, and anything other + than exactly one space character separating two specifications was + rejected.}] + @; ---------------------------------------- @section{Creating Loggers} diff --git a/racket/src/racket/cmdline.inc b/racket/src/racket/cmdline.inc index a532da07f5..bf9a27e46e 100644 --- a/racket/src/racket/cmdline.inc +++ b/racket/src/racket/cmdline.inc @@ -746,6 +746,8 @@ static Scheme_Object *reverse_path_list(Scheme_Object *l, int rel_to_cwd) # define GC_CAN_IGNORE /**/ #endif +#include + static Scheme_Object *get_log_level(char *prog, char *real_switch, const char *envvar, const char *what, GC_CAN_IGNORE char *str) { int k, len, default_lvl = -1; @@ -755,6 +757,10 @@ static Scheme_Object *get_log_level(char *prog, char *real_switch, const char *e l = scheme_make_null(); while (1) { + while (*str && isspace(*str)) { + str++; + } + if (!*str) { if (default_lvl == -1) default_lvl = 0; if (last) @@ -792,13 +798,13 @@ static Scheme_Object *get_log_level(char *prog, char *real_switch, const char *e if (k != -1) { if (*str == '@') { str++; - for (s = str; *s && *s != ' '; s++) { + for (s = str; *s && !isspace(*s); s++) { } l = scheme_make_pair(scheme_make_sized_byte_string(str, s - str, 1), l); if (!last) last = l; l = scheme_make_pair(scheme_make_integer(k), l); str = s; - } else if ((*str == ' ') || !*str) { + } else if (isspace(*str) || !*str) { if (default_lvl == -1) default_lvl = k; else