Remove declaration of statfs.
[coreutils.git] / src / dcgen
blob8f45b364b5df830f6c29d15ab9ccd9068a9b693b
1 #!/usr/bin/perl -w
2 # -*- perl -*-
4 eval 'exec /p/bin/perl -S $0 ${1+"$@"}'
5 if 0;
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)
13 # any later version.
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
23 # 02111-1307, USA.
25 # written by Jim Meyering
27 # If you uncomment the following lines, you should also do
28 # s/chop/chomp and s/local/my/.
29 #require 5.002;
30 #use strict;
32 # Convert an arbitrary file to dcl of two arrays.
33 # One of lines, the other of lengths.
35 local $prefix = 'G_';
37 local @line;
38 while (<>)
40 chop;
41 push (@line, $_);
44 local $n = @line;
45 print "#define ${prefix}N_LINES $n\n\n";
47 local $indent = ' ';
48 print "const size_t ${prefix}line_length[${prefix}N_LINES] =\n{\n$indent";
49 local $ind = $indent;
50 local $i;
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;
58 print "};\n\n";
60 print "const char *const ${prefix}line[${prefix}N_LINES] =\n{\n";
61 while (1)
63 $_ = shift (@line);
64 local $comma = (@line ? ',' : '');
65 print "$indent\"$_\"$comma\n";
66 last if !@line;
68 print "};\n";
70 exit (0);