File: config_extract.rb

package info (click to toggle)
libcdio 2.2.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 16,140 kB
  • sloc: ansic: 39,407; cpp: 2,556; sh: 1,263; makefile: 826; yacc: 324; ruby: 116; perl: 34
file content (31 lines) | stat: -rwxr-xr-x 882 bytes parent folder | download
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
#!/usr/bin/env ruby
comment_buffer = []
KEEP_LIST = %w(HAVE_CDDB HAVE_JOLIET HAVE_DARWIN_CDROM HAVE_BSDI_CDROM)

def handle_define_undefine(keyword, line, comment_buffer) 
  if KEEP_LIST.member?(keyword)
    puts 
    comment_buffer.each {|line| print line}
    print line
  end
  comment_buffer = []
end
  
in_comment = false
File.open("/tmp/config.h").readlines.each do |line|
  if match = line.match('^#define ([A-Z_]+)')
    handle_define_undefine(match[1], line, comment_buffer)
    in_comment = false
  elsif match = line.match('^/[*] #undef ([A-Z_]+)')
    handle_define_undefine(match[1], line, comment_buffer)
    in_comment = false
  elsif keyword = line.match('^/[*]')
    comment_buffer.push(line)
    in_comment = not(line.match('\*/$'))
  elsif in_comment
    comment_buffer.push(line)
    in_comment = not(line.match('\*/$'))
  else
    comment_buffer = []
  end
end