Example #1
0
static const char *
color_of(char *s, int arg)
{
    const char *result = "";
    char *t;
    int quoted = 0;
    int save;

    s = skip_blanks(s);
    t = skip_ident(s);
    if ((save = *t) != 0)
	*t = 0;

    if (is_class(s)) {
	if (FltOptions('c')) {
	    result = keyword_attr(s);
	    if (result == 0)
		result = class_attr(s);
	    if (result == 0)
		result = Ident2_attr;
	} else {
	    result = Ident2_attr;
	}
    } else if (arg && (*s != 0)) {
	char *base = s;

	if (!FltOptions('c'))
	    result = Action_attr;
	while (*s != 0) {
	    if (quoted) {
		if (*s == QUOTE)
		    quoted = 0;
	    } else if (*s == QUOTE) {
		quoted = 1;
		result = Literal_attr;
	    } else if ((s == base) && color_code(s, &result)) {
		break;
	    }
	    s++;
	}
    }
    if (save)
	*t = (char) save;
    return result;
}
Example #2
0
static const char *
actual_color(const char *param, int len, int arg)
{
    const char *result;
    char *s = strmalloc(param);

    if (len > 0) {		/* if not null-terminated, set it now */
	s[len] = '\0';
    }

    result = color_of(s, arg);
    if (*result == 0)
	result = keyword_attr(s);

    if (result != 0 && *result != 0 && !is_color(result)) {
	result = Literal_attr;
    }

    free(s);
    return result;
}
Example #3
0
/*
 * The "-i" option toggles between case-independent and case-dependent.
 */
const char *
get_keyword_attr(const char *text)
{
    return keyword_attr((FltOptions('i') & 1) ? lowercase_of(text) : text);
}
Example #4
0
const char *
ci_keyword_attr(const char *text)
{
    return keyword_attr(lowercase_of(text));
}