From: ellson Date: Thu, 2 Oct 2008 12:38:33 +0000 (+0000) Subject: debugging indexed scheme code X-Git-Tag: LAST_LIBGRAPH~32^2~3253 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cbe69c539f77384205b08b15ae70834a069faa31;p=graphviz debugging indexed scheme code --- diff --git a/lib/inkpot/inkpot_scheme.c b/lib/inkpot/inkpot_scheme.c index c943077b1..244531416 100644 --- a/lib/inkpot/inkpot_scheme.c +++ b/lib/inkpot/inkpot_scheme.c @@ -97,21 +97,43 @@ static inkpot_scheme_name_t *inkpot_find_scheme_name ( const char *scheme ) static int inkpot_scheme_index_cmpf ( const void *key, const void *base) { const char *k = (const char*)key; - const char *b = &TAB_SCHEME_STRINGS[((inkpot_scheme_index_t *)base)->string_idx]; + const char *b = &TAB_SCHEME_STRINGS[((inkpot_scheme_index_t *)base)->scheme_string_idx]; return string_cmpf(k, b); } -static inkpot_scheme_index_t *inkpot_find_scheme_index ( const char *scheme ) +static int inkpot_subscheme_index_cmpf ( const void *key, const void *base) +{ + const char *k = (const char*)key; + const char *b = &TAB_SUBSCHEME_STRINGS[((inkpot_scheme_index_t *)base)->subscheme_string_idx]; + + return string_cmpf(k, b); +} + +static inkpot_scheme_index_t *inkpot_find_scheme_index ( const char *scheme) { if (scheme == NULL) return NULL; + return (inkpot_scheme_index_t *) bsearch( (void*)scheme, (void*)TAB_SCHEMES_INDEX, SZT_SCHEMES_INDEX, sizeof(inkpot_scheme_index_t), inkpot_scheme_index_cmpf); } +#if 0 +static inkpot_subscheme_index_t *inkpot_find_subscheme_index ( const char *subscheme ) +{ + if (subscheme == NULL) + return NULL; + + return (inkpot_subscheme_index_t *) bsearch( + (void*)subscheme, (void*)TAB_SUBSCHEMES_INDEX, + SZT_SUBSCHEMES_INDEX, sizeof(inkpot_subscheme_index_t), + inkpot_subscheme_index_cmpf); +} +#endif + static inkpot_status_t inkpot_scheme ( inkpot_t *inkpot, const char *scheme ) { inkpot_scheme_name_t *inkpot_scheme_name; @@ -481,9 +503,10 @@ inkpot_status_t inkpot_put ( inkpot_t *inkpot, const char *color ) *++q = '\0'; for (i=0; i < inkpot->active_schemes; i++) { j = inkpot->scheme_list[i]; - p = &TAB_SCHEME_STRINGS[TAB_SCHEMES_INDEX[j].string_idx]; + p = &TAB_SCHEME_STRINGS[TAB_SCHEMES_INDEX[j].scheme_string_idx]; if (*p != *s || strcmp(p, s) != 0) continue; + /* FIXME - deal with subschemes */ first = TAB_SCHEMES_INDEX[j].first_value_idx; if (++j >= SZT_SCHEMES_INDEX) last = SZT_IXVALUES; @@ -765,12 +788,12 @@ inkpot_status_t inkpot_debug_schemes( inkpot_t *inkpot ) } for (j = 0; j < inkpot->active_schemes; j++) { inkpot_puts(inkpot, " "); - inkpot_puts(inkpot, &TAB_SCHEME_STRINGS[TAB_SCHEMES_INDEX[inkpot->scheme_list[j]].string_idx]); + inkpot_puts(inkpot, &TAB_SCHEME_STRINGS[TAB_SCHEMES_INDEX[inkpot->scheme_list[j]].scheme_string_idx]); inkpot_puts(inkpot, "#(in)"); } for (j = 0; j < inkpot->active_out_schemes; j++) { inkpot_puts(inkpot, " "); - inkpot_puts(inkpot, &TAB_SCHEME_STRINGS[TAB_SCHEMES_INDEX[inkpot->out_scheme_list[j]].string_idx]); + inkpot_puts(inkpot, &TAB_SCHEME_STRINGS[TAB_SCHEMES_INDEX[inkpot->out_scheme_list[j]].scheme_string_idx]); inkpot_puts(inkpot, "#(out)"); } inkpot_puts(inkpot, "\n"); diff --git a/lib/inkpot/inkpot_scheme.h b/lib/inkpot/inkpot_scheme.h index e95d62c7a..a9f0edc3d 100644 --- a/lib/inkpot/inkpot_scheme.h +++ b/lib/inkpot/inkpot_scheme.h @@ -22,13 +22,16 @@ typedef unsigned char IDX_MRU_CACHE; typedef struct inkpot_scheme_name_s { IDX_SCHEME_STRINGS - string_idx; /* The scheme name in TAB_STRINGS. (e.g. "x11") */ + string_idx; /* The scheme name in TAB_COLOR_STRINGS. (e.g. "x11") */ } inkpot_scheme_name_t; typedef struct inkpot_scheme_index_s { IDX_SCHEME_STRINGS - string_idx; /* The indexed scheme name in TAB_STRINGS. - * e.g "blues7" from Brewer */ + scheme_string_idx; /* The indexed scheme name in TAB_SCHEME_STRINGS. e.g "brewer" */ + + IDX_SUBSCHEME_STRINGS + subscheme_string_idx; /* The subscheme name in TAB_SUBSCHEME_STRINGS. e.g "blues7" */ + IDX_IXVALUES first_value_idx; /* The first index to the color values in * TAB_IXVALUES. Terminated by the diff --git a/lib/inkpot/inkpot_value.c b/lib/inkpot/inkpot_value.c index 106f80bb1..b7744894d 100644 --- a/lib/inkpot/inkpot_value.c +++ b/lib/inkpot/inkpot_value.c @@ -49,7 +49,7 @@ inkpot_status_t inkpot_value_get ( inkpot_values_t *values, inkpot_value_t *valu value->vtype = VTYPE_rgba; /* FIXME */ } else if (value->index - SZT_VALUES < SZT_NONAME_VALUES) { - i = 3 * value->index; + i = 3 * value->index - SZT_VALUES; v = TAB_NONAME_VALUES_24[i++]; value->value[0] = v | v << 8; v = TAB_NONAME_VALUES_24[i++]; value->value[1] = v | v << 8;