File: cpp.pl

package info (click to toggle)
pdmenu 1.2.59
  • links: PTS
  • area: main
  • in suites: potato
  • size: 536 kB
  • ctags: 251
  • sloc: ansic: 1,999; sh: 297; perl: 75; makefile: 60
file content (25 lines) | stat: -rwxr-xr-x 489 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/perl -n
#
# This is a simplistic program that works the same as cpp. However, it
# only understands #define, #endif, and #ifdef. It cannot handle nested 
# #ifdef statements. And it doesn't mess with any lines not starting with "#".
#
# GNU copyright 1997, Joey Hess.

chomp;
if (/^#/) {
	if (!$skip && /^#define (.*)/) {
		$def{$1}=1;
	}
	elsif (/^#ifdef (.*)/) {
		if (!	$def{$1}) {
			$skip=1;
		}
	}
	elsif (/^#endif/) {
		undef $skip;
	}
}
elsif (!$skip) {
	print "$_\n"
}