From c55a1bcd6b3275f21c94c05f7f98970e32668a2b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Marchal?= Date: Mon, 9 Jul 2012 09:30:24 +0200 Subject: [PATCH] Write getword errors on stderr Errors detected by any getword function is written using debuga (on stderr) instead of stdout. It makes the redirection easier. --- util.c | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/util.c b/util.c index 419c3e6..27c8546 100644 --- a/util.c +++ b/util.c @@ -83,11 +83,11 @@ int getword(char *word, int limit, struct getwordstruct *gwarea, char stop) for(x=0;((gwarea->current[x]) && (gwarea->current[x] != stop ));x++) { if(x>=limit) { - printf("SARG: getword loop detected after %d bytes.\n",x); - printf("SARG: Line=\"%s\"\n",gwarea->beginning); - printf("SARG: Record=\"%s\"\n",gwarea->current); - printf("SARG: searching for \'x%x\'\n",stop); - //printf("SARG: Maybe you have a broken record or garbage in your access.log file.\n"); + debuga(_("getword loop detected after %d bytes.\n"),x); + debuga(_("Line=\"%s\"\n"),gwarea->beginning); + debuga(_("Record=\"%s\"\n"),gwarea->current); + debuga(_("searching for \'x%x\'\n"),stop); + //debuga(_("Maybe you have a broken record or garbage in your access.log file.\n")); word[(limit>0) ? limit-1 : 0]='\0'; #if USE_GETWORD_BACKTRACE getword_backtrace(); @@ -124,11 +124,11 @@ int getword_multisep(char *word, int limit, struct getwordstruct *gwarea, char s for(x=0;((gwarea->current[x]) && (gwarea->current[x] != stop ));x++) { if(x>=limit) { - printf("SARG: getword_multisep loop detected.\n"); - printf("SARG: Line=\"%s\"\n",gwarea->beginning); - printf("SARG: Record=\"%s\"\n",gwarea->current); - printf("SARG: searching for \'x%x\'\n",stop); - //printf("SARG: Maybe you have a broken record or garbage in your access.log file.\n"); + debuga(_("getword_multisep loop detected.\n")); + debuga(_("Line=\"%s\"\n"),gwarea->beginning); + debuga(_("Record=\"%s\"\n"),gwarea->current); + debuga(_("searching for \'x%x\'\n"),stop); + //debuga(_("Maybe you have a broken record or garbage in your access.log file.\n")); if (limit>0) word[limit-1]='\0'; #if USE_GETWORD_BACKTRACE getword_backtrace(); @@ -151,11 +151,11 @@ int getword_skip(int limit, struct getwordstruct *gwarea, char stop) for(x=0;(gwarea->current[x] && (gwarea->current[x] != stop ));x++) { if(x>=limit) { - printf("SARG: getword_skip loop detected after %d bytes.\n",x); - printf("SARG: Line=\"%s\"\n",gwarea->beginning); - printf("SARG: Record=\"%s\"\n",gwarea->current); - printf("SARG: searching for \'x%x\'\n",stop); - //printf("SARG: Maybe you have a broken record or garbage in your access.log file.\n"); + debuga(_("getword_skip loop detected after %d bytes.\n"),x); + debuga(_("Line=\"%s\"\n"),gwarea->beginning); + debuga(_("Record=\"%s\"\n"),gwarea->current); + debuga(_("searching for \'x%x\'\n"),stop); + //debuga(_("Maybe you have a broken record or garbage in your access.log file.\n")); #if USE_GETWORD_BACKTRACE getword_backtrace(); #endif @@ -190,11 +190,11 @@ int getword_atoll(long long int *number, struct getwordstruct *gwarea, char stop *number=(*number * 10) + digit; } if(gwarea->current[x] && gwarea->current[x]!=stop) { - printf("SARG: getword_atoll loop detected after %d bytes.\n",x); - printf("SARG: Line=\"%s\"\n",gwarea->beginning); - printf("SARG: Record=\"%s\"\n",gwarea->current); - printf("SARG: searching for \'x%x\'\n",stop); - //printf("SARG: Maybe you have a broken record or garbage in your access.log file.\n"); + debuga(_("getword_atoll loop detected after %d bytes.\n"),x); + debuga(_("Line=\"%s\"\n"),gwarea->beginning); + debuga(_("Record=\"%s\"\n"),gwarea->current); + debuga(_("searching for \'x%x\'\n"),stop); + //debuga(_("Maybe you have a broken record or garbage in your access.log file.\n")); #if USE_GETWORD_BACKTRACE getword_backtrace(); #endif @@ -229,11 +229,11 @@ int getword_atoi(int *number, struct getwordstruct *gwarea, char stop) *number=(*number * 10) + digit; } if(gwarea->current[x] && gwarea->current[x]!=stop) { - printf("SARG: getword_atoi loop detected after %d bytes.\n",x); - printf("SARG: Line=\"%s\"\n",gwarea->beginning); - printf("SARG: Record=\"%s\"\n",gwarea->current); - printf("SARG: searching for \'x%x\'\n",stop); - //printf("SARG: Maybe you have a broken record or garbage in your access.log file.\n"); + debuga(_("getword_atoi loop detected after %d bytes.\n"),x); + debuga(_("Line=\"%s\"\n"),gwarea->beginning); + debuga(_("Record=\"%s\"\n"),gwarea->current); + debuga(_("searching for \'x%x\'\n"),stop); + //debuga(_("Maybe you have a broken record or garbage in your access.log file.\n")); #if USE_GETWORD_BACKTRACE getword_backtrace(); #endif @@ -438,11 +438,11 @@ void name_month(char *month,int month_len) for(x=0; x