aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2019-08-22 13:06:15 -0400
committerKevin O'Connor <kevin@koconnor.net>2019-08-22 13:06:44 -0400
commitff7be3e0261e844c81ae1d4c3f016c0b9dd75b77 (patch)
tree180ff9c6f78854223e498b50d5d7074542ff5271 /src
parent7d014933cea167043b0347e8d49f0fa36762c45a (diff)
downloadkutter-ff7be3e0261e844c81ae1d4c3f016c0b9dd75b77.tar.gz
kutter-ff7be3e0261e844c81ae1d4c3f016c0b9dd75b77.tar.xz
kutter-ff7be3e0261e844c81ae1d4c3f016c0b9dd75b77.zip
ctr: Encode negative integers in normal hex notation
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src')
-rw-r--r--src/ctr.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/ctr.h b/src/ctr.h
index b5b56ee2..4032e268 100644
--- a/src/ctr.h
+++ b/src/ctr.h
@@ -16,7 +16,8 @@
// Macro to encode an integer for use with DECL_CTR_INT()
#define _CTR_HEX(H) ((H) > 9 ? (H) - 10 + 'A' : (H) + '0')
-#define _CTR_INT(V, S) _CTR_HEX(((uint32_t)(V) >> (S)) & 0x0f)
+#define _CTR_SHIFT(V, S) _CTR_HEX(((uint32_t)(V) >> (S)) & 0x0f)
+#define _CTR_INT(V, S) ((V) < 0 ? _CTR_SHIFT(-(V), (S)) : _CTR_SHIFT((V), (S)))
#define CTR_INT(VALUE) { \
' ', (VALUE) < 0 ? '-' : '+', '0', 'x', \
_CTR_INT((VALUE),28), _CTR_INT((VALUE),24), \