--- /dev/null
+#!/usr/bin/ruby -w
+
+require 'optparse'
+require 'ostruct'
+require 'pp'
+
+##################### CLASSES #####################
+class MyOptionParse
+ def self.parse(args)
+ # default values
+ opts = OpenStruct.new
+ opts.width = 70
+
+ parser = OptionParser.new do |myparser|
+ myparser.banner = "Usage: #{$0} [opts]"
+ myparser.separator "Specific options:"
+ myparser.on("-w WIDTH", "--width",
+ "The maximum width of the enum identifier.") do |a|
+ opts.width = a.to_i
+ end
+ end
+
+ parser.parse!(args)
+ return opts
+ end
+end
+
+##################### FUNCTIONS #####################
+##################### CODE #####################
+$opts = MyOptionParse.parse(ARGV)
+#pp opts
+
+STDIN.each_line do |line|
+ line.chomp!
+ if line =~ /\#define[ \t]([^ \t]*)[ \t][ \t]*([^ \t]*)/ then
+ ident = $1
+ val = $2
+ ident2 = "#{ident} = "
+ printf(" %-#{$opts.width}s %s,\n", ident2, val)
+ else
+ puts line
+ end
+end