~mdw
/
catacomb
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
base/asm-common.h: Add include guards.
[catacomb]
/
utils
/
split-pieces
diff --git
a/utils/split-pieces
b/utils/split-pieces
index
11ecd8a
..
0bffd50
100755
(executable)
--- a/
utils/split-pieces
+++ b/
utils/split-pieces
@@
-47,15
+47,15
@@
class BaseQfConvert (object):
print ";; piece widths = %r" % seq
return cls(p, seq)
def hack(me, n):
print ";; piece widths = %r" % seq
return cls(p, seq)
def hack(me, n):
- if
2*n >= me.p: n -=
p
+ if
me.SIGNEDP and 2*n >= me.p: n -= me.
p
nn = []
wds = cycle(me.wdseq)
while n:
wd = wds.next()
lim = 1 << wd; m = lim - 1
d = n&m; n >>= wd
nn = []
wds = cycle(me.wdseq)
while n:
wd = wds.next()
lim = 1 << wd; m = lim - 1
d = n&m; n >>= wd
- if d >= lim/2: d -= lim; n += 1
- nn.append(
str
(d))
+ if
me.SIGNEDP and
d >= lim/2: d -= lim; n += 1
+ nn.append(
me.fmt
(d))
return nn
def unhack(me, nn):
a = o = 0
return nn
def unhack(me, nn):
a = o = 0
@@
-65,13
+65,23
@@
class BaseQfConvert (object):
if a < 0: a += me.p
return a
if a < 0: a += me.p
return a
+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,
R_split = RX.compile(r',\s*|\s+')
def spliteval(arg): return map(eval, R_split.split(arg.strip()))
convmap = { 'scaf': ScafConvert,
'unscaf': ScafConvert,
- 'qf': BaseQfConvert,
- 'unqf': BaseQfConvert }
+ 'qf': SignedQfConvert,
+ 'unqf': SignedQfConvert,
+ 'uqf': UnsignedQfConvert,
+ 'unuqf': UnsignedQfConvert }
op = getarg()
cvt = convmap[op].parse()
if op.startswith('un'): prepare, conv, format = spliteval, cvt.unhack, str
op = getarg()
cvt = convmap[op].parse()
if op.startswith('un'): prepare, conv, format = spliteval, cvt.unhack, str