[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] master 049b9d8 1/2: [ttdebug]: Key 'I' toggles hexadec
From: |
Werner LEMBERG |
Subject: |
[freetype2-demos] master 049b9d8 1/2: [ttdebug]: Key 'I' toggles hexadecimal/decimal numbers display. |
Date: |
Sat, 30 Dec 2017 17:22:26 -0500 (EST) |
branch: master
commit 049b9d8e4c5d0932be6fc3945b811c00516b7b5b
Author: Werner Lemberg <address@hidden>
Commit: Werner Lemberg <address@hidden>
[ttdebug]: Key 'I' toggles hexadecimal/decimal numbers display.
* src/ttdebug.c (use_hex): New global variable.
(Cur_U_Line): Use it.
(RunIns): Use it.
Update help display.
Handle key `I'.
---
ChangeLog | 10 ++++++++
src/ttdebug.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++------------
2 files changed, 75 insertions(+), 16 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 46824e4..36643c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2017-12-30 Werner Lemberg <address@hidden>
+
+ [ttdebug]: Key 'I' toggles hexadecimal/decimal numbers display.
+
+ * src/ttdebug.c (use_hex): New global variable.
+ (Cur_U_Line): Use it.
+ (RunIns): Use it.
+ Update help display.
+ Handle key `I'.
+
2017-12-27 Werner Lemberg <address@hidden>
Fix compiler warnings.
diff --git a/src/ttdebug.c b/src/ttdebug.c
index 3108995..6374e57 100644
--- a/src/ttdebug.c
+++ b/src/ttdebug.c
@@ -80,7 +80,9 @@
static int num_tt_interpreter_versions;
static unsigned int dflt_tt_interpreter_version;
- static FT_Bool use_float = 0; /* number format */
+ /* number formats */
+ static FT_Bool use_float = 0; /* for points */
+ static FT_Bool use_hex = 1; /* for integers (except points) */
static FT_Error error;
@@ -835,7 +837,11 @@
for ( i = 0; i < n; i++ )
{
- sprintf( s, " $%02x", (unsigned)CUR.code[CUR.IP + i + 2] );
+ const FT_String* temp;
+
+
+ temp = use_hex ? " $%02x" : " %d";
+ sprintf( s, temp, (unsigned)CUR.code[CUR.IP + i + 2] );
strncat( tempStr, s, 8 );
}
}
@@ -851,9 +857,20 @@
for ( i = 0; i < n; i++ )
{
- sprintf( s, " $%02x%02x",
- (unsigned)CUR.code[CUR.IP + i * 2 + 2],
- (unsigned)CUR.code[CUR.IP + i * 2 + 3] );
+ if ( use_hex )
+ sprintf( s, " $%02x%02x",
+ (unsigned)CUR.code[CUR.IP + i * 2 + 2],
+ (unsigned)CUR.code[CUR.IP + i * 2 + 3] );
+ else
+ {
+ unsigned short temp;
+
+
+ temp = ( (unsigned)CUR.code[CUR.IP + i * 2 + 2] << 8 ) +
+ (unsigned)CUR.code[CUR.IP + i * 2 + 3];
+ sprintf( s, " %d",
+ (signed short)temp );
+ }
strncat( tempStr, s, 8 );
}
}
@@ -863,7 +880,11 @@
for ( i = 0; i <= n; i++ )
{
- sprintf( s, " $%02x", (unsigned)CUR.code[CUR.IP + i + 1] );
+ const FT_String* temp;
+
+
+ temp = use_hex ? " $%02x" : " %d";
+ sprintf( s, temp, (unsigned)CUR.code[CUR.IP + i + 1] );
strncat( tempStr, s, 8 );
}
}
@@ -873,9 +894,20 @@
for ( i = 0; i <= n; i++ )
{
- sprintf( s, " $%02x%02x",
- (unsigned)CUR.code[CUR.IP + i * 2 + 1],
- (unsigned)CUR.code[CUR.IP + i * 2 + 2] );
+ if ( use_hex )
+ sprintf( s, " $%02x%02x",
+ (unsigned)CUR.code[CUR.IP + i * 2 + 1],
+ (unsigned)CUR.code[CUR.IP + i * 2 + 2] );
+ else
+ {
+ unsigned short temp;
+
+
+ temp = ( (unsigned)CUR.code[CUR.IP + i * 2 + 1] << 8 ) +
+ (unsigned)CUR.code[CUR.IP + i * 2 + 2];
+ sprintf( s, " %d",
+ (signed short)temp );
+ }
strncat( tempStr, s, 8 );
}
}
@@ -1256,14 +1288,21 @@
if ( args < CUR.top && args >= 0 )
{
- /* we display signed hexadecimal numbers, which */
- /* is easier to read and needs less space */
long val = (signed long)CUR.stack[args];
- num_chars = sprintf( temp + col, "%s%04lx",
- val < 0 ? "-" : "",
- val < 0 ? -val : val );
+ if ( use_hex )
+ {
+ /* we display signed hexadecimal numbers, which */
+ /* is easier to read and needs less space */
+ num_chars = sprintf( temp + col, "%s%04lx",
+ val < 0 ? "-" : "",
+ val < 0 ? -val : val );
+ }
+ else
+ num_chars = sprintf( temp + col, "%ld",
+ val );
+
if ( col + num_chars >= 78 )
break;
}
@@ -1353,7 +1392,9 @@
"f finish current function C show CVT data\n"
"l show last bytecode instruction F toggle
floating/fixed\n"
"b toggle breakpoint at curr. pos. point format\n"
- "p toggle breakpoint at prev. pos. B show backtrace\n"
+ "p toggle breakpoint at prev. pos. I toggle hexadecimal/\n"
+ " decimal int. format\n"
+ " B show backtrace\n"
"\n"
"\n"
" Format of point changes:\n"
@@ -1376,11 +1417,19 @@
/* Toggle between floating and fixed point format */
case 'F':
use_float = !use_float;
- printf( "Use %s point format for displaying values.\n",
+ printf( "Use %s point format for displaying non-integer values.\n",
use_float ? "floating" : "fixed" );
printf( "\n" );
break;
+ /* Toggle between decimal and hexadimal integer format */
+ case 'I':
+ use_hex = !use_hex;
+ printf( "Use %s format for displaying integers.\n",
+ use_hex ? "hexadecimal" : "decimal" );
+ printf( "\n" );
+ break;
+
/* Show vectors */
case 'V':
if ( use_float )
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] master 049b9d8 1/2: [ttdebug]: Key 'I' toggles hexadecimal/decimal numbers display.,
Werner LEMBERG <=