4 eval 'exec /p/bin/perl -S $0 ${1+"$@"}'
7 # dcgen -- generate C declarations of arrays of lines and line lengths
8 # Copyright (C) 1996, 1998 Free Software Foundation, Inc.
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2, or (at your option)
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 # written by Jim Meyering
27 # If you uncomment the following lines, you should also do
28 # s/chop/chomp and s/local/my/.
32 # Convert an arbitrary file to dcl of two arrays.
33 # One of lines, the other of lengths.
45 print "#define ${prefix}N_LINES $n\n\n";
48 print "const size_t ${prefix}line_length[${prefix}N_LINES] =\n{\n$indent";
51 for ($i = 0; $i < @line; $i++)
53 local $comma = ($i < @line - 1 ?
',' : '');
54 $ind = '' if $i == @line - 1;
55 local $sep = ($i && $i % 18 == 0 || $i == @line - 1 ?
"\n$ind" : ' ');
56 print length ($line[$i]), $comma, $sep;
60 print "const char *const ${prefix}line[${prefix}N_LINES] =\n{\n";
64 local $comma = (@line ?
',' : '');
65 print "$indent\"$_\"$comma\n";