@@ -84,7 +84,7 @@ int computeLineSize(void) { return computeCursorXPos(lineLength - 1, 0) + 1; }
8484int computeCursorXCurrentPos (void ) { return computeCursorXPos (cursor , hexOrAscii ); }
8585int computeCursorXPos (int cursor , int hexOrAscii )
8686{
87- int r = 11 ;
87+ int r = nAddrDigits + 3 ;
8888 int x = cursor % lineLength ;
8989 int h = (hexOrAscii ? x : lineLength - 1 );
9090
@@ -162,6 +162,13 @@ void exitCurses(void)
162162 endwin ();
163163}
164164
165+ static void printaddr (uint64_t addr )
166+ {
167+ char templ [7 ]; // maximum string is "%016lX", which is 6 chars + 1 null byte
168+ sprintf (templ ,"%%0%dlX" , nAddrDigits );
169+ PRINTW ((templ , addr ));
170+ }
171+
165172void display (void )
166173{
167174 long long fsize ;
@@ -176,7 +183,7 @@ void display(void)
176183 move (i / lineLength , 0 );
177184 for (j = 0 ; j < colsUsed ; j ++ ) printw (" " ); /* cleanup the line */
178185 move (i / lineLength , 0 );
179- PRINTW (( "%08lX" , ( int ) ( base + i )) );
186+ printaddr ( base + i );
180187 }
181188
182189 attrset (NORMAL );
@@ -201,7 +208,8 @@ void displayLine(int offset, int max)
201208#ifdef HAVE_COLORS
202209 mark_color = COLOR_PAIR (4 ) | A_BOLD ;
203210#endif
204- PRINTW (("%08lX " , (int ) (base + offset )));
211+ printaddr (base + offset );
212+ PRINTW ((" " ));
205213 for (i = offset ; i < offset + lineLength ; i ++ ) {
206214 if (i > offset ) MAXATTRPRINTW (bufferAttr [i ] & MARKED , (((i - offset ) % blocSize ) ? " " : " " ));
207215 if (i < max ) {
0 commit comments