# HG changeset patch # User Ryoma SHINYA # Date 1292294999 -32400 # Node ID 14faa199c3bf46f6313e4648d9bbec01b11d1cb2 # Parent f228eb7791621f214a73906aa41c69c94c8346dd add --regex option (jitgrep). it's useful when grep complex regexp. diff -r f228eb779162 -r 14faa199c3bf pyrect/jitgrep.py --- a/pyrect/jitgrep.py Tue Dec 14 11:07:30 2010 +0900 +++ b/pyrect/jitgrep.py Tue Dec 14 11:49:59 2010 +0900 @@ -11,7 +11,7 @@ def main(argv): myusage = """%prog [--buf-size=size] [--dump] [--CbC] [--time] [--debug] [--cc=compiler] [-c] - [-Olevel] regexp [file..] [--out=file] + [-Olevel] regexp [file..] [--out=file] [--regex=file] [--thread=thread_num] [--filter=algorithm] [--disable-booster] [--functional-transition]""" psr = OptionParser(usage=myusage) @@ -22,6 +22,8 @@ psr.add_option("--cc", action="store", type="string", dest="cc", default="gcc", metavar="FILE", help="Choose compiler (default is gcc).") + psr.add_option("--regex", action="store", type="string", dest="regex", default="", metavar="FILE", + help="Obtain patterns from file.") psr.add_option("-c", action="store_true", dest="compile", default=False , help="compile only.") psr.add_option("--buf-size=size", action="store", type="string", dest="bufsize", default="1M" , help="Set read-buffer size (e.x. 1024, 1024K, 2M)") psr.add_option("--cflags", action="store", type="string", dest="cflags", default="-O3", help="Print compile/matching time.") @@ -38,6 +40,14 @@ (opts, args) = psr.parse_args(argv) + if opts.regex: + fd = open(opts.regex, 'r') + regex = fd.read().rstrip() + fd.close() + if len(args) < 3: + args.append(args[1]) + args[1] = regex + if len(args) < 2: psr.print_usage() return