[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2-demos] master 000d4ed 2/2: [ftview] Improve error tracking.
From: |
Werner Lemberg |
Subject: |
[freetype2-demos] master 000d4ed 2/2: [ftview] Improve error tracking. |
Date: |
Tue, 25 Oct 2022 00:20:45 -0400 (EDT) |
branch: master
commit 000d4ede52c09c1f2fb84801d82dba8df21ce2b1
Author: Alexei Podtelezhnikov <apodtele@gmail.com>
Commit: Alexei Podtelezhnikov <apodtele@gmail.com>
[ftview] Improve error tracking.
* src/ftcommon.c (FTDemo_Error_String): Spin off new function from...
(PanicZ): ... this function.
* src/ftcommon.h (FTDemo_Error_String): Declare it.
* src/ftview.c (Process_Error): Count and track persistent errors.
(Render_*): Use it.
(main): Report the persistent error code and description.
---
src/ftcommon.c | 31 +++++++++++++++++++------------
src/ftcommon.h | 4 ++++
src/ftview.c | 33 ++++++++++++++++++++++++++-------
3 files changed, 49 insertions(+), 19 deletions(-)
diff --git a/src/ftcommon.c b/src/ftcommon.c
index 2fb872e..622e20b 100644
--- a/src/ftcommon.c
+++ b/src/ftcommon.c
@@ -25,12 +25,6 @@
#include <freetype/ftmodapi.h>
- /* error messages */
-#undef FTERRORS_H_
-#define FT_ERROR_START_LIST {
-#define FT_ERRORDEF( e, v, s ) case v: str = s; break;
-#define FT_ERROR_END_LIST default: str = "unknown error"; }
-
#include "common.h"
#include "strbuf.h"
#include "ftcommon.h"
@@ -72,17 +66,30 @@
#endif /* NODEBUG */
- /* PanicZ */
- void
- PanicZ( const char* message )
+ /* error messages */
+#undef FTERRORS_H_
+#define FT_ERROR_START_LIST {
+#define FT_ERRORDEF( e, v, s ) case v: str = s; break;
+#define FT_ERROR_END_LIST default: str = "unknown error"; }
+
+ const FT_String*
+ FTDemo_Error_String( FT_Error err )
{
const FT_String *str;
-
- switch( error )
+ switch ( err )
#include <freetype/fterrors.h>
- fprintf( stderr, "%s\n error = 0x%04x, %s\n", message, error, str );
+ return str;
+ }
+
+
+ /* PanicZ */
+ void
+ PanicZ( const char* message )
+ {
+ fprintf( stderr, "%s\n error = 0x%04x, %s\n", message, error,
+ FTDemo_Error_String( error ) );
exit( 1 );
}
diff --git a/src/ftcommon.h b/src/ftcommon.h
index 6e3425a..5db1f49 100644
--- a/src/ftcommon.h
+++ b/src/ftcommon.h
@@ -47,6 +47,10 @@
#endif
+ const FT_String*
+ FTDemo_Error_String( FT_Error err );
+
+
/*************************************************************************/
/*************************************************************************/
/***** *****/
diff --git a/src/ftview.c b/src/ftview.c
index 6de31a3..2108889 100644
--- a/src/ftview.c
+++ b/src/ftview.c
@@ -106,6 +106,7 @@
int offset; /* as selected by the user */
int topleft; /* as displayed by ftview */
int num_fails;
+ int err_fails;
int preload;
int lcd_filter;
@@ -115,7 +116,7 @@
} status = { 1,
"", DIM, NULL, RENDER_MODE_ALL,
72, 48, 1, 0.04, 0.04, 0.02, 0.22,
- 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0,
FT_LCD_FILTER_DEFAULT, { 0x08, 0x4D, 0x56, 0x4D, 0x08 }, 2 };
@@ -156,6 +157,18 @@
}
+ static void
+ Process_Error()
+ {
+ status.num_fails++;
+
+ if ( status.err_fails == 0 )
+ status.err_fails = error;
+ if ( status.err_fails != error )
+ status.err_fails = -1;
+ }
+
+
static int
Render_Stroke( int num_indices,
int offset )
@@ -256,7 +269,7 @@
continue;
Next:
- status.num_fails++;
+ Process_Error();
}
return i - 1;
@@ -400,7 +413,7 @@
continue;
Next:
- status.num_fails++;
+ Process_Error();
}
return i - 1;
@@ -591,7 +604,7 @@
continue;
Next:
- status.num_fails++;
+ Process_Error();
}
return i - 1;
@@ -676,7 +689,7 @@
continue;
Next:
- status.num_fails++;
+ Process_Error();
}
return -1;
@@ -786,7 +799,7 @@
continue;
Next:
- status.num_fails++;
+ Process_Error();
}
}
@@ -1893,7 +1906,13 @@
} while ( Process_Event() == 0 );
printf( "Execution completed successfully.\n" );
- printf( "Fails = %d\n", status.num_fails );
+ if ( status.num_fails )
+ {
+ printf( "Fail count = %d, ", status.num_fails );
+ printf( status.err_fails == -1 ? "various errors\n"
+ : "Error code = 0x%02X (%s)\n",
+ status.err_fails, FTDemo_Error_String( status.err_fails ) );
+ }
FTDemo_Display_Done( display );
FTDemo_Done( handle );
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2-demos] master 000d4ed 2/2: [ftview] Improve error tracking.,
Werner Lemberg <=