forked from freebsd/freebsd-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b3517a
commit 2b7d40e
Showing
22 changed files
with
198 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/perl | ||
|
||
use warnings; | ||
use strict; | ||
|
||
if (@ARGV != 2) { | ||
die <<END; | ||
usage: ifdef-how <file> <line> | ||
Print the sequence of preprocessor conditionals which lead to the | ||
given line being retained after preprocessing. There is no output | ||
if the line is always retained. Conditionals that must be true are | ||
printed verbatim; conditionals that musy be false have their | ||
preprocessor keyword prefixed with NOT. | ||
Warning: this program does not parse comments or strings, so it will | ||
not handle tricky code correctly. | ||
END | ||
} | ||
|
||
my $file = shift; | ||
my $line = shift; | ||
|
||
open my $fh, '<', $file | ||
or die "ifdef-how: open $file: $!\n"; | ||
|
||
my @stack; | ||
while (<$fh>) { | ||
last if $. == $line; | ||
if (m{^\s*#\s*(if|ifdef|ifndef)\b}) { | ||
push @stack, $_; | ||
} | ||
if (m{^\s*#\s*(elif|else)\b}) { | ||
$stack[-1] =~ s{^(\s*#\s*)(?!NOT)\b}{${1}NOT}gm; | ||
$stack[-1] .= $_; | ||
} | ||
if (m{^\s*#\s*endif\b}) { | ||
pop @stack; | ||
} | ||
} | ||
|
||
print @stack; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
unifdef </dev/null >/dev/null 2>&1 || true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifdef FIRST | ||
wombats | ||
#endif /* com | ||
mmm | ||
mmmm | ||
ment */ |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifdef FIRST | ||
wombats | ||
#endif /* com | ||
mmm | ||
mmmm | ||
ment */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
unifdef dangle.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
umask 027 | ||
unifdef -DFOO=1 -DFOOB=42 -UBAR -ooutfile.c if1.c | ||
e=$? | ||
ls -l outfile.c | cut -d' ' -f1 1>&2 | ||
case ${BUILD_MINGW} in | ||
(yes) printf '%s\n' '-rw-r-----' 1>&2 ;; | ||
(*) ls -l outfile.c | cut -d' ' -f1 1>&2 ;; | ||
esac | ||
cat outfile.c | ||
rm outfile.c | ||
exit $e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
unifdef: whitespace.c: 3: Obfuscated preprocessor control line (#if line 1 depth 1) | ||
unifdef: whitespace.c: 4: Obfuscated preprocessor control line (#if line 1 depth 1) | ||
unifdef: Output may be truncated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.