From 7f83f4e3efe9faa6e1d91eb0a94d623af6c1def1 Mon Sep 17 00:00:00 2001 From: thor Date: Mon, 26 Jun 2006 12:11:40 +0000 Subject: [PATCH] These got some new-style debugging through the terminal control bug hunt. Also, I want to take the chance to hint at scripts/debugdef.pl that I added previously: It is a Perl script generating the debug.h header in a way to avoid variadic macros for fprintf. Result are debugN macros that mean "debug line with N arguments". Examples: debug1("Ok, there's one value: %i", var) debug3("now three of them: %i %f %i", var1, var2, var3) simplest case: debug("just a message"); git-svn-id: svn://scm.orgis.org/mpg123/trunk@176 35dc7657-300d-0410-a2e5-dc2837fedb53 --- src/getlopt.c | 34 +++++++++------------------------- src/term.c | 3 ++- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/src/getlopt.c b/src/getlopt.c index 40f02f24..0a37c483 100644 --- a/src/getlopt.c +++ b/src/getlopt.c @@ -9,14 +9,10 @@ * Fri Dec 23, 2005 */ +#include "config.h" +#include "debug.h" #include "getlopt.h" -/* #define GLO_DEBUG */ - -#ifdef GLO_DEBUG -#include -#endif - int loptind = 1; /* index in argv[] */ int loptchr = 0; /* index in argv[loptind] */ char *loptarg; /* points to argument if present, else to option */ @@ -57,30 +53,22 @@ int performoption (int argc, char *argv[], topt *opt) if (opt->var) { if (opt->flags & GLO_CHAR) /* var is *char */ { - #ifdef GLO_DEBUG - fprintf(stderr, "[char at %ld]\n", opt->var); - #endif + debug1("char at %p", opt->var); *((char *) opt->var) = (char) opt->value;\ } else if(opt->flags & GLO_LONG) { - #ifdef GLO_DEBUG - fprintf(stderr, "[long at %ld]\n", opt->var); - #endif + debug1("long at %p", opt->var); *( (long *) opt->var ) = opt->value; } else if(opt->flags & GLO_INT) { - #ifdef GLO_DEBUG - fprintf(stderr, "[int at %ld]\n", opt->var); - #endif + debug1("int at %p", opt->var); *( (int *) opt->var ) = (int) opt->value; } - #ifdef GLO_DEBUG - else fprintf(stderr, "[Option without type flag! This is a programming error!]\n"); + else debug("Option without type flag! This is a programming error!"); - fprintf(stderr,"[dubious assignment done]\n"); - #endif + debug("casting assignment done"); } else result = opt->value ? opt->value : opt->sname; @@ -97,9 +85,7 @@ int performoption (int argc, char *argv[], topt *opt) *((long *) opt->var) = atol(loptarg); else if(opt->flags & GLO_INT) *((int *) opt->var) = atoi(loptarg); - #ifdef GLO_DEBUG - else fprintf(stderr, "[Option without type flag! This is a programming error!]\n"); - #endif + else debug("Option without type flag! This is a programming error!"); } else result = opt->value ? opt->value : opt->sname; @@ -118,9 +104,7 @@ int getsingleopt (int argc, char *argv[], topt *opts) if (loptind >= argc) return (GLO_END); thisopt = argv[loptind]; - #ifdef GLO_DEBUG - fprintf(stderr,"[getsingleopt: %s]\n", thisopt); - #endif + debug1("getsingleopt: %s", thisopt); if (!loptchr) { /* start new option string */ if (thisopt[0] != '-' || !thisopt[1]) /* no more options */ return (GLO_END); diff --git a/src/term.c b/src/term.c index 22da13eb..21a6d6a5 100644 --- a/src/term.c +++ b/src/term.c @@ -1,6 +1,5 @@ #include "config.h" - #ifdef HAVE_TERMIOS #include @@ -9,6 +8,7 @@ #include #include +#include "debug.h" #include "mpg123.h" #include "buffer.h" #include "term.h" @@ -23,6 +23,7 @@ static struct termios old_tio; void term_init(void) { struct termios tio; + debug("term_init"); term_enable = 0;