From 8238b4405b52b91311a11f6e88a80e7928b8582c Mon Sep 17 00:00:00 2001 From: ellson Date: Sun, 5 Oct 2008 17:00:15 +0000 Subject: [PATCH] save work --- lib/inkpot/Makefile.am | 14 ++-- lib/inkpot/inkpot_lib.tcl | 141 ++++++++++++------------------------- lib/inkpot/inkpot_scheme.h | 14 ++-- 3 files changed, 60 insertions(+), 109 deletions(-) diff --git a/lib/inkpot/Makefile.am b/lib/inkpot/Makefile.am index 4b2438565..e8ad937a3 100644 --- a/lib/inkpot/Makefile.am +++ b/lib/inkpot/Makefile.am @@ -16,15 +16,15 @@ noinst_LTLIBRARIES = libinkpot_C.la man_MANS = inkpot.3 inkpot.1 pdf_DATA = inkpot.3.pdf inkpot.1.pdf -inkpot_SOURCES = inkpot.c -inkpot_LDADD = $(builddir)/libinkpot.la +#inkpot_SOURCES = inkpot.c +#inkpot_LDADD = $(builddir)/libinkpot.la -libinkpot_C_la_SOURCES = inkpot_scheme.c inkpot_value.c inkpot_xlate.c -libinkpot_C_la_LIBADD = $(top_builddir)/lib/rbtree/librbtree_C.la +#libinkpot_C_la_SOURCES = inkpot_scheme.c inkpot_value.c inkpot_xlate.c +#libinkpot_C_la_LIBADD = $(top_builddir)/lib/rbtree/librbtree_C.la -libinkpot_la_SOURCES = $(libinkpot_C_la_SOURCES) -libinkpot_la_LIBADD = $(libinkpot_C_la_LIBADD) -libinkpot_la_LDFLAGS = -version-info $(VERSION_INFO) -no-undefined +#libinkpot_la_SOURCES = $(libinkpot_C_la_SOURCES) +#libinkpot_la_LIBADD = $(libinkpot_C_la_LIBADD) +#libinkpot_la_LDFLAGS = -version-info $(VERSION_INFO) -no-undefined inkpot_value_table.h: $(builddir)/inkpot_define.h diff --git a/lib/inkpot/inkpot_lib.tcl b/lib/inkpot/inkpot_lib.tcl index e58e718bc..87eeb8cec 100755 --- a/lib/inkpot/inkpot_lib.tcl +++ b/lib/inkpot/inkpot_lib.tcl @@ -24,6 +24,7 @@ foreach {lib} $argv { foreach {color} [array names COLORS] { set value $COLORS($color) + # if a named color ends in a number, convert it to an indexed color if {[llength $color] == 1 && [regexp -- {([a-z]+)([0-9]+)} $color . icolor index] == 1} { unset COLORS($color) @@ -39,18 +40,12 @@ foreach {lib} $argv { 2 { foreach {icolor index} $color {break} lappend ALL_STRINGS($icolor) icolor - map ICV $icolor $value [list $scheme 0 $index] -#old -# map IV $index $value [list $scheme $icolor 0] -# lappend ALL_INDEX_SCHEMES([list $scheme $icolor 0]) $index $value + map ICRIV $icolor [list 0 $index $value] $scheme } 3 { foreach {icolor range index} $color {break} lappend ALL_STRINGS($icolor) icolor - map ICV $icolor $value [list $scheme $range $index] -#old -# map IV $index $value [list $scheme $icolor $range] -# lappend ALL_INDEX_SCHEMES([list $scheme $icolor $range]) $index $value + map ICRIV $icolor [list $range $index $value] $scheme } default { puts stderr "wrong number of keys in: \"$color\"" @@ -59,41 +54,6 @@ foreach {lib} $argv { } } -if {0} { -# crunch the data -foreach {v} [map2 IV] { - foreach {m1} [map2m1 IV $v] { - foreach {index scheme_icolor_range} $m1 { - foreach {scheme icolor range} $scheme_icolor_range {break} - map RIV [list $range $index] $v [list $scheme $icolor] - } - } -} - -foreach {v} [map2 RIV] { - foreach {m1} [map2m1 RIV $v] { - foreach {index scheme_icolor} $m1 { - foreach {scheme icolor} $scheme_icolor {break} - map SRIV [list $icolor $range $index] $v $scheme - } - } -} -} - -if {1} { -foreach {index_scheme} [lsort -ascii [array names ALL_INDEX_SCHEMES]] { - foreach {index value} $ALL_INDEX_SCHEMES($index_scheme) { - set indexes($index) $value - } - foreach {index} [lsort -dictionary [array names indexes]] { - lappend valueset $indexes($index) - } - lappend ALL_IDXSETS($valueset) $index_scheme - array unset indexes - unset valueset -} -} - #------------------------------------------------- write inkpot_value_table.h set f [open inkpot_value_table.h w] puts $f $preamble @@ -110,6 +70,7 @@ foreach {value} [map2 CV] { set ALL_VALUES_coded($value) $SZT_VALUES incr SZT_VALUES + # comment shows {{color {scheme...}}...} tab_end_block $f [map2m1 CV $value] } tab_end $f "};\n" @@ -118,8 +79,9 @@ tab_end $f "};\n" # generate NONAME_VALUES_24 set SZT_NONAME_VALUES 0 tab_begin $f "unsigned char TAB_NONAME_VALUES_24\[SZT_NONAME_VALUES_24\] = {" -foreach {value} [map2 IV] { - if {! [info exists ALL_VALUES($value)]} { +foreach {range_index_value} [lsort -dictionary [map2 ICRIV]] { + foreach {range index value} $range_index_value {break} + if {! [info exists ALL_VALUES_coded($value)]} { tab_begin_block $f $SZT_NONAME_VALUES foreach {r g b} $value {break} @@ -128,7 +90,8 @@ foreach {value} [map2 IV] { set ALL_VALUES_coded($value) [expr $SZT_NONAME_VALUES + $SZT_VALUES] incr SZT_NONAME_VALUES - tab_end_block $f [map2m1 RIV $value] + # comment shows {{icolor {scheme...}}...} + tab_end_block $f [map2m1 ICRIV $range_index_value] } } tab_end $f "};\n" @@ -179,79 +142,65 @@ tab_end $f "};\n" incr SZL_STRINGS -1 +foreach {m2} [lsort -dictionary [mapm2 ICRIV]] { + foreach {RIV schemes} $m2 {break} + foreach {range index value} $RIV {break} + foreach {m1} [map2m1 ICRIV $RIV] { + foreach {icolor schemes} $m1 {break} + lappend ALL_RANGES([list $schemes $icolor $range]) $m2 + } +} + # generate TAB_INDEXES set SZT_INDEXES 0 +set index -1 tab_begin $f "IDX_VALUES TAB_INDEXES\[SZT_INDEXES\] = {" -foreach {valueset} [lsort [array names ALL_IDXSETS]] { - set first_idx $SZT_INDEXES +foreach {schemes_icolor_range} [lsort -ascii [array names ALL_RANGES]] { tab_begin_block $f $SZT_INDEXES - foreach {value} $valueset { + set ALL_RANGES_coded($schemes_icolor_range) $SZT_INDEXES + foreach {m2} $ALL_RANGES($schemes_icolor_range) { + foreach {RIV schemes} $m2 {break} + foreach {range index value} $RIV {break} tab_elem $f $ALL_VALUES_coded($value), incr SZT_INDEXES } - set comment [list] - foreach {index_scheme} $ALL_IDXSETS($valueset) { - set ALL_INDEX_RANGES_coded($index_scheme) [list $first_idx [expr $SZT_INDEXES - $first_idx]] - foreach {scheme icolor range} $index_scheme {break} - if {$range} { - lappend comment $scheme/$icolor$range - } { - lappend comment $scheme/$icolor - } - } - tab_end_block $f $comment + tab_end_block $f [map2m1 ICRIV $RIV] } tab_end $f "};\n" -########################## -if {0} { -foreach {index_scheme} [lsort [array names ALL_INDEX_RANGES_coded]] { - foreach {scheme icolor range} $index_scheme {break} - foreach {first_idx size} $ALL_INDEX_RANGES_coded($index_scheme) {break} - lappend ALL_INDEX_ICOLOR_map([list $icolor $first_idx $size]) $scheme -} -foreach {icolor_first_idx_size} [array names ALL_INDEX_ICOLOR_map] { - foreach {icolor first_idx size} $icolor_first_idx_size {break} - foreach {scheme} $ALL_INDEX_ICOLOR_map($icolor_first_idx_size) {break} - lappend ALL_INDEX_ICOLORS_coded([list $scheme $icolor]) $first_idx $size -} - - -# generate TAB_ICOLORS -set SZT_ICOLORS 0 -tab_begin $f "inkpot_scheme_index_t TAB_ICOLORS\[SZT_ICOLORS\] = {" -foreach {scheme_icolor} [lsort [array names ALL_INDEX_ICOLORS_coded]] { - foreach {scheme icolor} $scheme_icolor {break} - - tab_begin_block $f $SZT_ICOLORS - - foreach {first_idx size} $ALL_INDEX_ICOLORS_coded($scheme_icolor) {break} - tab_elem $f "{$ALL_ICOLOR_STRINGS_coded($icolor),$first_idx,$size}," - - incr SZT_ICOLORS - - tab_end_block $f "$scheme/$icolor<1-$size>" +# generate TAB_RANGES +set SZT_RANGES 0 +tab_begin $f "inkpot_range_t TAB_RANGES\[SZT_RANGES\] = {" +foreach {schemes_icolor_range} [lsort -dictionary [array names ALL_INDEX_RANGES_coded]] { + tab_begin_block $f $SZT_RANGES + set first_idx $ALL_INDEX_RANGES_coded($schemes_icolor_range) + set size [llength $ALL_INDEX_RANGES($schemes_icolor_range)] + tab_elem $f "{$size,$first_idx}," + set ALL_RANGES_coded($schemes_icolor_range) $SZT_RANGES + incr SZT_RANGES + tab_end_block $f $m1 } tab_end $f "};\n" -} -########################### # generate TAB_ICOLORS set SZT_ICOLORS 0 tab_begin $f "inkpot_scheme_index_t TAB_ICOLORS\[SZT_ICOLORS\] = {" -foreach {icolor} [map1 ICV] { +foreach {m2} [lsort -dictionary [array names ALL_RANGES_coded]] { +if {0} { tab_begin_block $f $SZT_ICOLORS - #FIXME -# tab_elem $f "{$ALL_ICOLOR_STRINGS_coded($icolor),$ALL_ALTSETS_coded($color)}," - tab_elem $f "{$ALL_ICOLOR_STRINGS_coded($icolor),0}," + set icolor_set [mapm21 ICRIV $m2] + foreach {icolor} $icolor_set { + tab_elem $f "{$ALL_ICOLOR_STRINGS_coded($icolor),$ALL_RANGES_coded($m2)}," + } - tab_end_block $f $icolor + tab_end_block $f $icolor_set set ALL_ICOLORS_coded($color) $SZT_ICOLORS incr SZT_ICOLORS } +} tab_end $f "};\n" @@ -408,7 +357,7 @@ puts $f "\#define SZW_STRINGS $SZW_STRINGS" puts $f "" foreach {i} { STRINGS SCHEMES NAMES ALTS VALUES VALUE_TO TO_NAMES - SCHEMES_INDEX ICOLORS INDEXES NONAME_VALUES + SCHEMES_INDEX ICOLORS INDEXES RANGES NONAME_VALUES VALUES_24 NONAME_VALUES_24 } { if {[set SZT_$i] < 256} { diff --git a/lib/inkpot/inkpot_scheme.h b/lib/inkpot/inkpot_scheme.h index 24559bf8c..80eb96051 100644 --- a/lib/inkpot/inkpot_scheme.h +++ b/lib/inkpot/inkpot_scheme.h @@ -25,6 +25,12 @@ typedef struct inkpot_scheme_name_s { string_idx; /* The scheme name in TAB_STRINGS. (e.g. "x11") */ } inkpot_scheme_name_t; +typedef struct inkpot_range_s { + IDX_INDEXES + size, + first_value_idx; +} inkpot_range_t; + typedef struct inkpot_scheme_index_s { IDX_STRINGS scheme_string_idx; /* The indexed scheme name in TAB_STRINGS. e.g "brewer" */ @@ -32,12 +38,8 @@ typedef struct inkpot_scheme_index_s { IDX_STRINGS subscheme_string_idx; /* The subscheme name in TAB_STRINGS. e.g "blues7" */ - IDX_INDEXES - first_value_idx; /* The first index to the color values in - * TAB_INDEXES. Terminated by the - * first_value_idx of the next - * inkpot_scheme_index_t in TAB_SCHEMES_INDEX - * or by SZT_SCHEMES_INDEX */ + IDX_RANGES + range_idx; } inkpot_scheme_index_t; typedef struct inkpot_name_s { /* Color_name used by one or more -- 2.40.0