Allow progressive parsing of stdin (rather than waiting for EOF)
[bitfield] / bitfield
index 3651677f86c29ab8a90d9a67df14fa086ffa4503..1a03ddb96419c9f2f77ea08830a21c6d25665d14 100644 (file)
--- a/bitfield
+++ b/bitfield
@@ -275,19 +275,19 @@ def main():
                print "No such register '%s'" % reg_id
                return 1
 
-       r = regs[reg_id]
-       print "decoding as %s" % r.name
+       reg = regs[reg_id]
+       print "decoding as %s" % reg.name
 
        if args:
-               values = args
+               value_iter = args.__iter__()
        else:
-               try:
-                       values = sys.stdin.readlines()
-               except KeyboardInterrupt, e:
-                       return
-
-       for value in values:
-               decode_value(r, value.strip(), options)
+               value_iter = iter(sys.stdin.readline, '')
+               
+       try:
+               for value in value_iter:
+                       decode_value(reg, value.strip(), options)
+       except KeyboardInterrupt, e:
+               pass
 
        return 0