Much progress! Half the unit tests pass.
This commit is contained in:
parent
75abfb4050
commit
e52ccce0eb
17 changed files with 296 additions and 253 deletions
19
src/debug.c
19
src/debug.c
|
|
@ -8,6 +8,7 @@
|
|||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
|
@ -35,11 +36,27 @@ int verbosity = 0;
|
|||
void debug_print( wchar_t *message, int level ) {
|
||||
#ifdef DEBUG
|
||||
if ( level & verbosity ) {
|
||||
fwide( stderr, 1 );
|
||||
fputws( message, stderr );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* `wprintf` adapted for the debug logging system. Print to stderr only
|
||||
* `verbosity` matches `level`. All other arguments as for `wprintf`.
|
||||
*/
|
||||
void debug_printf( int level, wchar_t * format, ...) {
|
||||
#ifdef DEBUG
|
||||
if ( level & verbosity ) {
|
||||
fwide( stderr, 1 );
|
||||
va_list(args);
|
||||
va_start(args, format);
|
||||
vfwprintf(stderr, format, args);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* print the object indicated by this `pointer` to stderr, if `verbosity`
|
||||
* matches `level`.`verbosity is a set of flags, see debug_print.h; so you can
|
||||
|
|
@ -48,6 +65,7 @@ void debug_print( wchar_t *message, int level ) {
|
|||
void debug_print_object( struct cons_pointer pointer, int level ) {
|
||||
#ifdef DEBUG
|
||||
if ( level & verbosity ) {
|
||||
fwide( stderr, 1 );
|
||||
print( stderr, pointer );
|
||||
}
|
||||
#endif
|
||||
|
|
@ -59,6 +77,7 @@ void debug_print_object( struct cons_pointer pointer, int level ) {
|
|||
void debug_dump_object( struct cons_pointer pointer, int level ) {
|
||||
#ifdef DEBUG
|
||||
if ( level & verbosity ) {
|
||||
fwide( stderr, 1 );
|
||||
dump_object( stderr, pointer );
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue