AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Tool zum Entfernen von IFDEFs?

Ein Thema von Dani · begonnen am 22. Mai 2005 · letzter Beitrag vom 23. Mai 2005
 
Olli
(Gast)

n/a Beiträge
 
#3

Re: Tool zum Entfernen von IFDEFs?

  Alt 23. Mai 2005, 05:13
Also ich benutze dazu Perl
Code:
#!/usr/bin/perl
##############################################################################
##
## Simple perl script to filter only a single DEFINE symbol from the input
## file.
##
##############################################################################
my ($param1, $param2) = @ARGV;

if ((-z $param1) || ($param2 eq ''))
{
  print <DATA>;
  exit;
}
my $positive = 1;
# Open and read and close the file
open(FILE, $param1) or die;
$x = join('', <FILE>);
close(FILE);
# Check wether the symbol is negated or not
if ($param2 =~ /^!(.+)$/i)
{
  $param2 = $1;
  $positive = 0;
}
# According to the commandline evaluate the symbol
if ($positive != 0)
{
  # Replace all IFDEF ELSE ENDIF statements
  $x =~ s/\{\$IFDEF[\t\s]+$param2\}[\t\s\n]*(.+?)\{\$ELSE[\t\s]+[~]{0,1}$param2\}[\t\s\n]*(.+?)\{\$ENDIF[\t\s]+[~]{0,1}$param2\}[\t\s\n]*/$1/gism;
  $x =~ s/\{\$IFNDEF[\t\s]+$param2\}[\t\s\n]*(.+?)\{\$ELSE[\t\s]+[~]{0,1}$param2\}[\t\s\n]*(.+?)\{\$ENDIF[\t\s]+[~]{0,1}$param2\}[\t\s\n]*/$2/gism;
  # Replace all IFDEF ENDIF statements
  $x =~ s/\{\$IFDEF[\t\s]+$param2\}[\t\s\n]*(.+?)\{\$ENDIF[\t\s]+[~]{0,1}$param2\}[\t\s\n]*/$1/gism;
  $x =~ s/\{\$IFNDEF[\t\s]+$param2\}[\t\s\n]*(.+?)\{\$ENDIF[\t\s]+[~]{0,1}$param2\}[\t\s\n]*//gism;
}
else # If the symbol was negated at the commandline
{
  # Replace all IFDEF ELSE ENDIF statements
  $x =~ s/\{\$IFDEF[\t\s]+$param2\}[\t\s\n]*(.+?)\{\$ELSE[\t\s]+[~]{0,1}$param2\}[\t\s\n]*(.+?)\{\$ENDIF[\t\s]+[~]{0,1}$param2\}[\t\s\n]*/$2/gism;
  $x =~ s/\{\$IFNDEF[\t\s]+$param2\}[\t\s\n]*(.+?)\{\$ELSE[\t\s]+[~]{0,1}$param2\}[\t\s\n]*(.+?)\{\$ENDIF[\t\s]+[~]{0,1}$param2\}[\t\s\n]*/$1/gism;
  # Replace all IFDEF ENDIF statements
  $x =~ s/\{\$IFDEF[\t\s]+$param2\}[\t\s\n]*(.+?)\{\$ENDIF[\t\s]+[~]{0,1}$param2\}[\t\s\n]*//gism;
  $x =~ s/\{\$IFNDEF[\t\s]+$param2\}[\t\s\n]*(.+?)\{\$ENDIF[\t\s]+[~]{0,1}$param2\}[\t\s\n]*/$1/gism;
}
# Output to STDOUT
print "$x";
__END__
Syntax:

  simple_pp.pl <filename> [!]<symbol>

Output is printed to STDOUT. If you want to treat multiple symbols simply run
the script multiple times.

The exclamation mark in front of the symbol can be used to undefine the
respective symbol - otherwise it will be defined.

Any DEFINE or UNDEF directives concerning the given symbol inside the input
file will be ignored. Only commandline is taken.
Bedienungsanleitung ist enthalten

Ist von hier. Ich weiß nicht wie Robert das sieht, aber ich denke mal dadurch, daß ich es ins CVS eingecheckt hatte, ist es automatisch unter MPL.
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 07:59 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz