File: ifdef.awk

package info (click to toggle)
xstow 1.0.0-2.1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,160 kB
  • ctags: 1,216
  • sloc: cpp: 7,218; sh: 1,194; makefile: 196; awk: 26
file content (31 lines) | stat: -rw-r--r-- 388 bytes parent folder | download | duplicates (3)
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
26
27
28
29
30
31
BEGIN{
  print_it = 1;
}

/^#ifdef/{
  if( match( defines, $2 ) )
  {
     print_it = 1;
  } else {
     printf( "%s:%d:#ifdef %s is undefined\n", FILENAME, FNR, $2 ) > "/dev/stderr";
     print_it = 0;
  }
}

{
   if( print_it && !match( $0, /^#/ ) )
      print $0;
   line++;   
}

/^#endif/{
  print_it = 1;
}

/^#else/{
  if( print_it )
    print_it = 0;
  else
    print_it = 1;
}