chiark / gitweb /
utils/split-pieces: Introduce unsigned quick fields.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 21 May 2018 16:41:57 +0000 (17:41 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 11 Jun 2018 15:37:16 +0000 (16:37 +0100)
There aren't any in Catacomb at the moment -- and I don't plan to add
any -- but other code uses them so it's useful to be able to work with
them.

utils/split-pieces

index a5b62945dc7e70b290966780a2b5e994e4413ac9..0bffd5009e19cde4ac8a9621a364606b097a0dcc 100755 (executable)
@@ -69,13 +69,19 @@ class SignedQfConvert (BaseQfConvert):
   SIGNEDP = True
   def fmt(me, n): return str(n)
 
+class UnsignedQfConvert (BaseQfConvert):
+  SIGNEDP = False
+  def fmt(me, n): return '0x%x' % n
+
 R_split = RX.compile(r',\s*|\s+')
 def spliteval(arg): return map(eval, R_split.split(arg.strip()))
 
 convmap = { 'scaf': ScafConvert,
             'unscaf': ScafConvert,
             'qf': SignedQfConvert,
-            'unqf': SignedQfConvert }
+            'unqf': SignedQfConvert,
+            'uqf': UnsignedQfConvert,
+            'unuqf': UnsignedQfConvert }
 op = getarg()
 cvt = convmap[op].parse()
 if op.startswith('un'): prepare, conv, format = spliteval, cvt.unhack, str