2010-05-12 13:27:55 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
# ========= |
|
2013-12-11 16:09:41 +00:00
|
|
|
# \\ / F ield | foam-extend: Open Source CFD
|
2018-05-29 07:35:20 +00:00
|
|
|
# \\ / O peration | Version: 4.1
|
2015-05-17 13:32:07 +00:00
|
|
|
# \\ / A nd | Web: http://www.foam-extend.org
|
|
|
|
# \\/ M anipulation | For copyright notice see file Copyright
|
2010-05-12 13:27:55 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# License
|
2013-12-11 16:09:41 +00:00
|
|
|
# This file is part of foam-extend.
|
2010-05-12 13:27:55 +00:00
|
|
|
#
|
2013-12-11 16:09:41 +00:00
|
|
|
# foam-extend is free software: you can redistribute it and/or modify it
|
2010-05-12 13:27:55 +00:00
|
|
|
# under the terms of the GNU General Public License as published by the
|
2013-12-11 16:09:41 +00:00
|
|
|
# Free Software Foundation, either version 3 of the License, or (at your
|
2010-05-12 13:27:55 +00:00
|
|
|
# option) any later version.
|
|
|
|
#
|
2013-12-11 16:09:41 +00:00
|
|
|
# foam-extend is distributed in the hope that it will be useful, but
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# General Public License for more details.
|
2010-05-12 13:27:55 +00:00
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2013-12-11 16:09:41 +00:00
|
|
|
# along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
2010-05-12 13:27:55 +00:00
|
|
|
#
|
|
|
|
# Script
|
|
|
|
# fix-Class
|
|
|
|
#
|
|
|
|
# Description
|
|
|
|
# Process the lists given on the command line.
|
|
|
|
# Column 1 = fileName, column 2 = Class or action
|
|
|
|
# See find-suspiciousTags for details.
|
|
|
|
#
|
|
|
|
# 1. fix ClassWithTrailingInformation by hand
|
|
|
|
# 2. InClass and InNamespace fixup
|
|
|
|
# 3. change
|
|
|
|
# |Class
|
|
|
|
# | anything
|
|
|
|
# ->
|
|
|
|
# |Class
|
|
|
|
# | className
|
|
|
|
#
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# stop if trailing junk has been detected
|
|
|
|
for fileList
|
|
|
|
do
|
|
|
|
[ -f $fileList -a -r $fileList ] || {
|
|
|
|
echo "cannot read file list: $fileList"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
grep ClassWithTrailingInformation $fileList
|
|
|
|
if [ $? = 0 ]
|
|
|
|
then
|
|
|
|
echo "#"
|
|
|
|
echo "# fix ClassWithTrailingInformation by hand"
|
|
|
|
echo "#"
|
|
|
|
exit 99
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
for fileList
|
|
|
|
do
|
|
|
|
# repair InClass, InNamespace
|
|
|
|
for tag in Class Namespace
|
|
|
|
do
|
|
|
|
backup=".repair-In$tag"
|
|
|
|
for file in $(sed -n -e "s/In$tag *$//p" $fileList)
|
|
|
|
do
|
|
|
|
echo "repair In$tag: $file"
|
|
|
|
perl -i$backup -pe "s/^$tag/In$tag/" $file
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
# repair the class names (with namespace)
|
|
|
|
backup=".repair-reclassify"
|
|
|
|
cat $fileList | while read fileName className
|
|
|
|
do
|
|
|
|
# use classes with '::' separator to avoid too
|
|
|
|
# many false positives
|
|
|
|
perl -i$backup -x $0 $fileName $className
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------- end-of-file
|
|
|
|
# embedded Perl program
|
|
|
|
#!/usr/bin/perl -w
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
# args: fileName className
|
|
|
|
# - className must contain '::'
|
|
|
|
my $className = pop;
|
|
|
|
@ARGV == 1 and ($className ||= '') =~ /::/ or exit 1;
|
|
|
|
|
|
|
|
warn "repair: @ARGV $className\n";
|
|
|
|
|
|
|
|
while (<>)
|
|
|
|
{
|
|
|
|
if (/^Class\s*$/) {
|
|
|
|
print;
|
|
|
|
$_ = <>; # get and discard the next line
|
|
|
|
$_ = " $className\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
print;
|
|
|
|
}
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------- end-of-file
|