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.
This commit is contained in:
Tony Garnock-Jones 2016-07-25 19:17:35 -04:00
parent 99dd403ef6
commit 1ba42bb70d
2 changed files with 24 additions and 11 deletions

View File

@ -41,16 +41,17 @@ through environment variables:
@litchar{none}, @litchar{fatal}, @litchar{error}, @litchar{none}, @litchar{fatal}, @litchar{error},
@litchar{warning}, @litchar{info}, or @litchar{debug}; all @litchar{warning}, @litchar{info}, or @litchar{debug}; all
events the corresponding level of higher are printed. After an events the corresponding level of higher are printed. After an
initial @nonterm{level}, the value can contain space-separated initial @nonterm{level}, the value can contain
specifications of the form whitespace-separated specifications of the form
@nonterm{level}@litchar["@"]@nonterm{topic}, which prints events @nonterm{level}@litchar["@"]@nonterm{topic}, which prints
whose topics match @nonterm{topic} only at the given events whose topics match @nonterm{topic} only at the given
@nonterm{level} or higher (where a @nonterm{topic} contains any @nonterm{level} or higher (where a @nonterm{topic} contains any
character other than a space or @litchar["@"]). For example, character other than whitespace or @litchar["@"]). Leading and
the value @racket["error debug@GC"] prints all events at the trailing whitespace is ignored. For example, the value
@racket['error] level and higher, but prints events for the topic @racket["error debug@GC"] prints all events at the
topic @racket['GC] at the @racket['debug] level and @racket['error] level and higher, but prints events for the
higher (which includes all levels). topic @racket['GC] at the @racket['debug] level and higher
(which includes all levels).
The default is @racket["error"].} 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 reports @racket['warning] events when it detects an expression that
would produce a run-time error if evaluated. 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} @section{Creating Loggers}

View File

@ -746,6 +746,8 @@ static Scheme_Object *reverse_path_list(Scheme_Object *l, int rel_to_cwd)
# define GC_CAN_IGNORE /**/ # define GC_CAN_IGNORE /**/
#endif #endif
#include <ctype.h>
static Scheme_Object *get_log_level(char *prog, char *real_switch, const char *envvar, const char *what, GC_CAN_IGNORE char *str) 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; 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(); l = scheme_make_null();
while (1) { while (1) {
while (*str && isspace(*str)) {
str++;
}
if (!*str) { if (!*str) {
if (default_lvl == -1) default_lvl = 0; if (default_lvl == -1) default_lvl = 0;
if (last) if (last)
@ -792,13 +798,13 @@ static Scheme_Object *get_log_level(char *prog, char *real_switch, const char *e
if (k != -1) { if (k != -1) {
if (*str == '@') { if (*str == '@') {
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); l = scheme_make_pair(scheme_make_sized_byte_string(str, s - str, 1), l);
if (!last) last = l; if (!last) last = l;
l = scheme_make_pair(scheme_make_integer(k), l); l = scheme_make_pair(scheme_make_integer(k), l);
str = s; str = s;
} else if ((*str == ' ') || !*str) { } else if (isspace(*str) || !*str) {
if (default_lvl == -1) if (default_lvl == -1)
default_lvl = k; default_lvl = k;
else else