]> granicus.if.org Git - graphviz/commitdiff
debugging indexed scheme code
authorellson <devnull@localhost>
Thu, 2 Oct 2008 12:38:33 +0000 (12:38 +0000)
committerellson <devnull@localhost>
Thu, 2 Oct 2008 12:38:33 +0000 (12:38 +0000)
lib/inkpot/inkpot_scheme.c
lib/inkpot/inkpot_scheme.h
lib/inkpot/inkpot_value.c

index c943077b1f54645572a4d902d8cf3e08fab55704..244531416231a854c83d5b87c74e162756d825f3 100644 (file)
@@ -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");
index e95d62c7afe50cfc06829b26d2280e6a79d9605d..a9f0edc3dd032ecfcfe2200f8d9a589bed74dd8b 100644 (file)
@@ -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
index 106f80bb16b8c791d439e9c9f0ee928009d46f93..b7744894d5fec563d650cb919d8a043445a0965a 100644 (file)
@@ -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;