/** @brief sets the format strings (what should be before, and what after the original message) */ void format(const string_type & format_before_str, const string_type & format_after_str) { m_format_before_str = format_before_str; m_format_after_str = format_after_str; set_and_configure( m_format_before, format_before_str, parse_formatter() ); set_and_configure( m_format_after, format_after_str, parse_formatter() ); };
inline basic_formatter< CharT > parse_formatter(const CharT* str) { return parse_formatter(str, str + std::char_traits< CharT >::length(str)); }
inline basic_formatter< CharT > parse_formatter(std::basic_string< CharT, TraitsT, AllocatorT > const& str) { const CharT* p = str.c_str(); return parse_formatter(p, p + str.size()); }
/* Parse the rcfile, once it has been opened successfully at rcstream, * and close it afterwards. If syntax_only is TRUE, only allow the file * to contain color syntax commands: syntax, color, and icolor. */ void parse_rcfile(FILE *rcstream #ifndef DISABLE_COLOR , bool syntax_only #endif ) { char *buf = NULL; ssize_t len; size_t n = 0; #ifndef DISABLE_COLOR syntaxtype *end_syn_save = NULL; #endif while ((len = getline(&buf, &n, rcstream)) > 0) { char *ptr, *keyword, *option; int set = 0; size_t i; /* Ignore the newline. */ if (buf[len - 1] == '\n') buf[len - 1] = '\0'; lineno++; ptr = buf; while (isblank(*ptr)) ptr++; /* If we have a blank line or a comment, skip to the next * line. */ if (*ptr == '\0' || *ptr == '#') continue; /* Otherwise, skip to the next space. */ keyword = ptr; ptr = parse_next_word(ptr); #ifndef DISABLE_COLOR /* Handle extending first... */ if (strcasecmp(keyword, "extendsyntax") == 0) { char *syntaxname = ptr; syntaxtype *ts = NULL; ptr = parse_next_word(ptr); for (ts = syntaxes; ts != NULL; ts = ts->next) if (!strcmp(ts->desc, syntaxname)) break; if (ts == NULL) { rcfile_error(N_("Could not find syntax \"%s\" to extend"), syntaxname); continue; } else { end_syn_save = endsyntax; endsyntax = ts; keyword = ptr; ptr = parse_next_word(ptr); } } #endif /* Try to parse the keyword. */ if (strcasecmp(keyword, "set") == 0) { #ifndef DISABLE_COLOR if (syntax_only) rcfile_error( N_("Command \"%s\" not allowed in included file"), keyword); else #endif set = 1; } else if (strcasecmp(keyword, "unset") == 0) { #ifndef DISABLE_COLOR if (syntax_only) rcfile_error( N_("Command \"%s\" not allowed in included file"), keyword); else #endif set = -1; } #ifndef DISABLE_COLOR else if (strcasecmp(keyword, "include") == 0) { if (syntax_only) rcfile_error( N_("Command \"%s\" not allowed in included file"), keyword); else parse_include(ptr); } else if (strcasecmp(keyword, "syntax") == 0) { if (endsyntax != NULL && endcolor == NULL) rcfile_error(N_("Syntax \"%s\" has no color commands"), endsyntax->desc); parse_syntax(ptr); } else if (strcasecmp(keyword, "magic") == 0) #ifdef HAVE_LIBMAGIC parse_magic_exp(ptr); #else ; #endif else if (strcasecmp(keyword, "header") == 0) parse_header_exp(ptr); else if (strcasecmp(keyword, "color") == 0) parse_colors(ptr, FALSE); else if (strcasecmp(keyword, "icolor") == 0) parse_colors(ptr, TRUE); else if (strcasecmp(keyword, "linter") == 0) parse_linter(ptr); else if (strcasecmp(keyword, "formatter") == 0) #ifndef DISABLE_SPELLER parse_formatter(ptr); #else ; #endif #endif /* !DISABLE_COLOR */ else if (strcasecmp(keyword, "bind") == 0)