1 Star 0 Fork 0

吉祥水/oofem-1

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
release_filter.pl 2.30 KB
一键复制 编辑 原始数据 按行查看 历史
Erik Svenning 提交于 2015-12-11 10:28 . Fixed merge conflict.
#!/usr/bin/perl
#
# set RESTRICTED on itself (this file will not be included in public release)
# <restricted_file>
#
# utility to exclude from oofem source the
# sections and files, which are not supposed
# to be in (public) release.
#
# WARNING:
#
# The original file is overridden !!!!
#
# each file is scanned for the following keywords:
#
# 1) <restricted_section> and </restricted_section>
# The section contained within these keywords will be removed
#
# 2) <restricted_file>
# The whole processed file will be excluded (removed)
#
#
# written by Borek Patzak (c) 2001
#
$proceed = 0;
$exclude = 1;
$skip_file = 0;
$parse_mode = $proceed;
if (@ARGV != 1)
{
printf ("Usage: release_filter.pl filename\n");
}
$fileName = $ARGV[0];
open (INPUT, $fileName)
or die "Can't open $fileName for reading: $!";
$tmpfilename = "tmpfile";
open (TMPFILE, ">$tmpfilename")
or die "Can't open $tmpfilename for writing: $!";
#parse the file and serach for keywords
while (($line = <INPUT>) && ($skip_file == 0))
{
# chop $line;
&parseLine ($line);
}
close (TMPFILE);
if ($skip_file == 0)
{
if ($parse_mode == $exclude) {
die ("error: exclude_section missing end\n");
}
rename ($tmpfilename, $fileName)
or die "Can't rename $tmpfilename to $fileName: $!";
} else {
print "exclude_file detected: removing $fileName\n";
unlink $fileName;
}
sub parseLine {
local ($line) = @_;
local ($strBefore, $strAfter);
# print "GET: $line";
if ($skip_file)
{
return;
}
if ($line =~ /(.*)<(restricted_section|RESTRICTED_SECTION)>(.*)/) {
$strBefore = $1;
$strAfter = $3;
&parseLine ($strBefore);
if ($parse_mode == $exclude) {
die "error: nested exclude_sections detected: $fileName\n";
}
$parse_mode = $exclude;
&parseLine ($strAfter);
} elsif ($line =~ /(.*)<\/(restricted_section|RESTRICTED_SECTION)>(.*)/) {
if ($parse_mode == $proceed) {
die "error: end of non-opened exclude_sections detected\n";
}
$strBefore = $1;
$strAfter = $3;
$parse_mode = $proceed;
&parseLine ($strAfter);
print TMPFILE "\n";
} elsif ($line =~ /(.*)<(restricted_file|RESTRICTED_FILE)>(.*)/) {
# print "exclude_file detected\n";
$skip_file = 1;
return;
} else {
if ($parse_mode == $proceed)
{
print TMPFILE $line;
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/jixiangshui/oofem-1.git
git@gitee.com:jixiangshui/oofem-1.git
jixiangshui
oofem-1
oofem-1
master

搜索帮助