2003-06-19 01:28:22 +04:00
|
|
|
#!/usr/bin/perl
|
2009-10-02 01:21:28 +04:00
|
|
|
#=============================================================================
|
|
|
|
# KWSys - Kitware System Library
|
|
|
|
# Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2003-12-16 00:30:46 +03:00
|
|
|
#
|
2009-10-02 01:21:28 +04:00
|
|
|
# Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
# see accompanying file Copyright.txt for details.
|
2003-12-16 00:30:46 +03:00
|
|
|
#
|
2009-10-02 01:21:28 +04:00
|
|
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
# See the License for more information.
|
|
|
|
#=============================================================================
|
2003-06-19 01:28:22 +04:00
|
|
|
|
|
|
|
if ( $#ARGV+1 < 2 )
|
|
|
|
{
|
|
|
|
print "Usage: ./kwsysHeaderDump.pl <name> <header>\n";
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
$name = $ARGV[0];
|
|
|
|
$max = 0;
|
|
|
|
open(INFILE, $ARGV[1]);
|
|
|
|
while (chomp ($line = <INFILE>))
|
|
|
|
{
|
|
|
|
if (($line !~ /^\#/) &&
|
2004-05-10 21:15:45 +04:00
|
|
|
($line =~ s/.*kwsys${name}_([A-Za-z0-9_]*).*/\1/) &&
|
2003-06-19 01:28:22 +04:00
|
|
|
($i{$line}++ < 1))
|
|
|
|
{
|
|
|
|
push(@lines, "$line");
|
|
|
|
if (length($line) > $max)
|
|
|
|
{
|
|
|
|
$max = length($line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close(INFILE);
|
2004-05-10 21:15:45 +04:00
|
|
|
|
2003-06-19 01:28:22 +04:00
|
|
|
$width = $max + 13;
|
2004-05-10 21:15:45 +04:00
|
|
|
print sprintf("#define %-${width}s kwsys_ns(${name})\n", "kwsys${name}");
|
2003-06-19 01:28:22 +04:00
|
|
|
foreach $l (@lines)
|
|
|
|
{
|
2004-05-10 21:15:45 +04:00
|
|
|
print sprintf("#define %-${width}s kwsys_ns(${name}_$l)\n",
|
2003-06-19 01:28:22 +04:00
|
|
|
"kwsys${name}_$l");
|
|
|
|
}
|
|
|
|
print "\n";
|
|
|
|
print sprintf("# undef kwsys${name}\n");
|
|
|
|
foreach $l (@lines)
|
|
|
|
{
|
|
|
|
print sprintf("# undef kwsys${name}_$l\n");
|
|
|
|
}
|