diff options
author | Owen Taylor <otaylor@redhat.com> | 2005-03-05 00:50:48 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2005-03-05 00:50:48 +0000 |
commit | 19eb8c57fe45fabcda2a3d62672496ce0e86b1c5 (patch) | |
tree | c841cf6093ff18c8fdb85a0de8183842e52b83b5 /tools | |
parent | c4086835761f0021c372cf2d44998aac89b4778d (diff) | |
download | pango-19eb8c57fe45fabcda2a3d62672496ce0e86b1c5.tar.gz |
Reduce non-shared data (#168899, inspired by patches from Tommi Komulainen
2005-03-04 Owen Taylor <otaylor@redhat.com>
Reduce non-shared data (#168899, inspired by patches
from Tommi Komulainen and Ross Burton)
* pango/pango-color.c pango/pango-color-table.h
tools/gen-color-table.pl: Redo storage of colors to
use offsets into a static string rather than embedded
strings. (Inspired by a patch from Tommi Komulainen,
#168899)
* pango/break.c pango/fonts.c pango/pango-color.c
pango/pango-layout.c pango/pango-markup.c
pango/pango-script-lang-table.h
pango/mini-fribidi/fribidi_types.c
tools/gen-script-for-lang.c: Add const in various places
* modules/arabic/arabic-fc.c modules/hebrew/hebrew-fc.c:
modules/indic/{indic-fc.c,indic-ot-class-tables.c,
indic-ot.h} modules/syriac/syriac-ot.c (syriac): Further
addition of const.
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/gen-color-table.pl | 74 | ||||
-rw-r--r-- | tools/gen-script-for-lang.c | 2 |
2 files changed, 75 insertions, 1 deletions
diff --git a/tools/gen-color-table.pl b/tools/gen-color-table.pl new file mode 100755 index 00000000..e62994e1 --- /dev/null +++ b/tools/gen-color-table.pl @@ -0,0 +1,74 @@ +#!/usr/bin/perl -w + +if (@ARGV != 1) { + die "Usage: gen-colors.pl rgb.txt > pango-color-table.h\n"; +} + +open IN, $ARGV[0] || die "Cannot open $ARGV[0]: $!\n"; + +@colors = (); +while (defined($_ = <IN>)) { + next if /^!/; + if (!/^\s*([0-9]+)\s+([0-9]+)\s+([0-9]+)\s+(.*\S)\s+$/) { + die "Cannot parse line $_"; + } + + push @colors, [$1, $2, $3, $4]; +} + +@colors = sort { lc($a->[3]) cmp lc($b->[3]) } @colors; + +$offset = 0; + +$date = gmtime; + +print <<EOT; +/* pango-color-table.h: Generated by gen-color-table.pl from rgb.txt + * + * Date: $date + * + * Do not edit. + */ +static const char color_names[] = +EOT + +for $color (@colors) { + $name = $color->[3]; + + if ($offset != 0) { + print qq(\n); + } + print qq( "$name\\0"); + + $color->[4] = $offset; + $offset += length($name) + 1; +} + +print ";\n\n"; + +print <<EOT; +typedef struct { + guint16 name_offset; + guchar red; + guchar green; + guchar blue; +} ColorEntry; + +static const ColorEntry color_entries[] = { +EOT + +$i = 0; +for $color (@colors) { + $red = $color->[0]; + $green = $color->[1]; + $blue = $color->[2]; + $offset = $color->[4]; + + if ($i != 0) { + print ",\n"; + } + print " { $offset, $red, $green, $blue }"; + $i++; +} + +print "\n};\n"; diff --git a/tools/gen-script-for-lang.c b/tools/gen-script-for-lang.c index 0eb8e7ad..9b243e31 100644 --- a/tools/gen-script-for-lang.c +++ b/tools/gen-script-for-lang.c @@ -269,7 +269,7 @@ int main (int argc, char **argv) " PangoScript scripts[%d];\n" "} PangoScriptForLang;\n" "\n" - "PangoScriptForLang pango_script_for_lang[] = {\n", + "static const PangoScriptForLang pango_script_for_lang[] = {\n", max_lang_len, MAX_SCRIPTS); |