summaryrefslogtreecommitdiff
path: root/src/dcgen
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2005-03-26 17:38:48 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2005-03-26 17:38:48 +0000
commit4e149db6d1732314abaecf3b45894e3bd81e3067 (patch)
treee8b3c74b34b518ec3a3d730b61438fecfc24a984 /src/dcgen
parent769902551213f2105d4a5cc88cd728035be782df (diff)
downloadcoreutils-4e149db6d1732314abaecf3b45894e3bd81e3067.tar.xz
Squeeze multiple blanks into one. Output a simple
array of adjacent strings rather than a more complicated data structure; this saves space in the dircolors executable.
Diffstat (limited to 'src/dcgen')
-rwxr-xr-xsrc/dcgen47
1 files changed, 9 insertions, 38 deletions
diff --git a/src/dcgen b/src/dcgen
index 3cb146221..6e90ed0d4 100755
--- a/src/dcgen
+++ b/src/dcgen
@@ -5,7 +5,7 @@ eval 'exec /p/bin/perl -S $0 ${1+"$@"}'
if 0;
# dcgen -- generate C declarations of arrays of lines and line lengths
-# Copyright (C) 1996, 1998, 2004 Free Software Foundation, Inc.
+# Copyright (C) 1996, 1998, 2004, 2005 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -39,54 +39,25 @@ while (<>)
{
chop;
s/[[:blank:]]*#.*//;
+ s/[[:blank:]]+/ /g;
if ($_)
{
push (@line, $_);
}
}
-local $n = @line;
-print "#define ${prefix}N_LINES $n\n\n";
-
local $indent = ' ';
-local $i;
-
-local $max_line_length = 0;
-for ($i = 0; $i < @line; $i++)
- {
- local $len = length ($line[$i]);
- $max_line_length = $len if $max_line_length < $len;
- }
-
-local $line_length_type = 'unsigned char';
-if ((1 << 8) <= $max_line_length)
- {
- $line_length_type = 'unsigned short int';
- if ((1 << 16) <= $max_line_length)
- {
- $line_length_type = 'unsigned int';
- }
- }
-print "static $line_length_type const ${prefix}line_length[${prefix}N_LINES] =\n{\n$indent";
-local $ind = $indent;
-for ($i = 0; $i < @line; $i++)
- {
- local $comma = ($i < @line - 1 ? ',' : '');
- $ind = '' if $i == @line - 1;
- local $sep = ($i && $i % 18 == 0 || $i == @line - 1 ? "\n$ind" : ' ');
- print length ($line[$i]), $comma, $sep;
- }
-print "};\n\n";
-
-print "static char const *const ${prefix}line[${prefix}N_LINES] =\n{\n";
+print "static char const ${prefix}line[] =\n";
while (1)
{
$_ = shift (@line);
- local $comma = (@line ? ',' : '');
- print "$indent\"$_\"$comma\n";
- last if !@line;
+ if (!@line)
+ {
+ print "$indent\"$_\";\n";
+ last;
+ }
+ print "$indent\"$_\\0\"\n";
}
-print "};\n";
exit (0);