Get sanitize working with arbitrary keys

This commit is contained in:
Michael Sawyer 2000-09-29 21:31:02 +00:00
parent e65fe7af00
commit 229c6987e7
3 changed files with 38 additions and 18 deletions

View file

@ -13,7 +13,7 @@
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# $Id: Makefile.in,v 1.22 2000/09/27 18:00:40 mws Exp $
# $Id: Makefile.in,v 1.23 2000/09/29 21:31:00 mws Exp $
srcdir = @srcdir@
VPATH = @srcdir@
@ -78,5 +78,10 @@ confparser.y: confparser.y.dirty
depend: confparser.c
#ifndef NOMINUM_PUBLIC
distclean::
rm -f confparser.c confparser_p.h confparser.y
#else NOMINUM_PUBLIC
#+distclean::
#+ rm -f confparser.c confparser_p.h
#endif NOMINUM_PUBLIC

View file

@ -15,7 +15,7 @@
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# $Id: sanitize.pl,v 1.9 2000/09/28 17:35:19 gson Exp $
# $Id: sanitize.pl,v 1.10 2000/09/29 21:31:01 mws Exp $
# Don't try and sanitize this file: NOMINUM_IGNORE
@ -23,18 +23,18 @@
# sanitized.
#
# In normal mode, check file, removing code between
# #ifndef NOMINUM_key
# #ifndef key
# and the accompanying #else or #endif. Similarly, code in an #else
# clause after an #ifndef test will be removed. The #else or #endif's
# must appear as:
# #else /* NOMINUM_key */
# #endif /* NOMINUM_key */
# #else /* key */
# #endif /* key */
# Balance is tested.
# Non-.c/.h files are tested for the existance of NOMINUM_anything anywhere
# in the file, and a warning is generated, unless the string
# NOMINUM_IGNORE appears before NOMINUM_.
# If the string NOMINUM_key_DELETE is present, delete the file.
# If the string key_DELETE is present, delete the file.
# Usage:
# ./sanitize.pl -c - Check syntax only, don't change anything
@ -98,8 +98,9 @@ sub runfile($) {
break;
}
$masterstate = 0;
$intest = 0;
for ($i = 0 ; $i < $curkeys; $i++) {
if ((/NOMINUM_$key[$i]_DELETE/) &&
if ((/$key[$i]_DELETE/) &&
($showon[$i] == 1)) {
close(INFILE);
close(OUTFILE);
@ -107,7 +108,7 @@ sub runfile($) {
$deletefile = 1;
goto bailout;
}
elsif (/\#ifdef.+NOMINUM_$key[$i]/) {
elsif (/\#.*ifdef.+$key[$i]/) {
if ($state[$i] != 0) {
print(STDERR "*** ERROR in file ".
"$_[0] line $.: ".
@ -122,7 +123,7 @@ sub runfile($) {
$state[$i] = 1;
goto doneline;
}
elsif (/\#ifndef.+NOMINUM_$key[$i]/) {
elsif (/\#.*ifndef.+$key[$i]/) {
if ($state[$i] != 0) {
print(STDERR "*** ERROR in file ".
"$_[0] line $.: ".
@ -138,7 +139,7 @@ sub runfile($) {
goto doneline;
}
elsif (/\#else.+NOMINUM_$key[$i]/) {
elsif (/\#.*else.+$key[$i]/) {
if ($state[$i] == 0) {
print(STDERR "*** ERROR in file ".
"$_[0] line $.: ".
@ -157,7 +158,7 @@ sub runfile($) {
}
goto doneline;
}
elsif (/\#endif.+NOMINUM_$key[$i]/) {
elsif (/\#.*endif.+$key[$i]/) {
if ($state[$i] == 0) {
print(STDERR "*** ERROR in file ".
"$_[0] line $.: ".
@ -180,14 +181,25 @@ sub runfile($) {
}
doneline:
for ($i = 0 ; $i < $curkeys; $i++) {
if (($state[i] != 0) &&
($state[i] != $showon[$i])) {
if ($state[$i] != 0) {
$intest++;
}
if (($state[$i] != 0) &&
($state[$i] != $showon[$i])) {
$masterstate++;
break;
}
}
if (($masterstate == 0) && $makechange) {
print(OUTFILE);
if ($intest != 0) {
if (/^#\+(.*)/) {
print(OUTFILE "$1\n");
} else {
print(OUTFILE);
}
} else {
print(OUTFILE);
}
}
}
bailout:

View file

@ -15,19 +15,22 @@
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# $Id: sanitize_all.sh,v 1.6 2000/09/27 17:16:01 mws Exp $
# $Id: sanitize_all.sh,v 1.7 2000/09/29 21:31:02 mws Exp $
PERL=perl5
# Run this shell script from a CVS export'ed source tree, and it will
# sanitize all of the files in that tree.
find . -name '*.[ch]' | xargs $PERL util/sanitize.pl -kPUBLIC $*
find . -name '*.in' | xargs $PERL util/sanitize.pl -kPUBLIC $*
find . -name '*.[ch]' | xargs $PERL util/sanitize.pl -kNOMINUM_PUBLIC \
-kISC_PLATFORM_USETHREADS $*
find . -name '*.in' | xargs $PERL util/sanitize.pl -kNOMINUM_PUBLIC \
-kISC_PLATFORM_USETHREADS $*
for file in `find . -name '*.dirty'`
do
clean=`echo $file | sed 's/\.dirty$//'`
$PERL util/sanitize.pl -kPUBLIC - < $file > $clean
$PERL util/sanitize.pl -kNOMINUM_PUBLIC -kISC_PLATFORM_USETHREADS \
- < $file > $clean
rm $file
done