From 7c9c599e4cc5555fd7cd1b554f8099128268d57e Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Wed, 4 Aug 2021 18:25:52 +0200 Subject: [PATCH] index_pointer now produces better sequences of chars --- hprint.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hprint.cpp b/hprint.cpp index fa552762..6cde00c3 100644 --- a/hprint.cpp +++ b/hprint.cpp @@ -48,10 +48,13 @@ EX map pointer_indices; EX string index_pointer(void *v) { if(v == nullptr) return "0"; - if(!pointer_indices.count(v)) pointer_indices[v] = isize(pointer_indices); + if(!pointer_indices.count(v)) { + int s = isize(pointer_indices); + pointer_indices[v] = s; + } + int i = pointer_indices[v]; string res; - int i = pointer_indices[v] + 1; - while(i) { res += ('A' + (i % 26)); i /= 26; } + while(true) { res += ('A' + (i % 26)); i /= 26; if(!i) break; i--; } return res; }