X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=util.c;h=5e6e4f3a57ac913d67ab4fa7b649c125ea50a1eb;hb=1087eb7b2d8447adf9a7deb549d4004a87b46b10;hp=8551aca7f6c43eb03b6206431447f84723818541;hpb=e15efca6667b2673b4c1a5879a6917eab6800e58;p=polyglot.git diff --git a/util.c b/util.c index 8551aca..5e6e4f3 100644 --- a/util.c +++ b/util.c @@ -29,7 +29,6 @@ static bool Error; FILE * LogFile=NULL; - // functions // util_init() @@ -158,45 +157,47 @@ void my_log_close() { // my_log() void my_log(const char format[], ...) { + + char string[FormatBufferSize]; + + ASSERT(format!=NULL); - va_list ap; - - ASSERT(format!=NULL); +// format - if (LogFile != NULL) { - fprintf(LogFile,"%.3f ",now_real()); - va_start(ap,format); + CONSTRUCT_ARG_STRING(format,string); + - vfprintf(LogFile,format,ap); - va_end(ap); + if (LogFile != NULL) { + fprintf(LogFile,"%.3f %s",now_real(),string); #ifdef _WIN32 - fflush(LogFile); + fflush(LogFile); #endif - } + } } // my_fatal() void my_fatal(const char format[], ...) { - va_list ap; + char string[FormatBufferSize]; - ASSERT(format!=NULL); + ASSERT(format!=NULL); - va_start(ap,format); +// format - vfprintf(stderr,format,ap); - if (LogFile != NULL) vfprintf(LogFile,format,ap); + CONSTRUCT_ARG_STRING(format,string); + + fprintf(stderr,"%s",string); + if (LogFile != NULL) fprintf(LogFile,"%s",string); - va_end(ap); - if (Error) { // recursive error - my_log("POLYGLOT *** RECURSIVE ERROR ***\n"); - exit(EXIT_FAILURE); - // abort(); - } else { - Error = TRUE; - quit(); - } + if (Error) { // recursive error + my_log("POLYGLOT *** RECURSIVE ERROR ***\n"); + exit(EXIT_FAILURE); + // abort(); + } else { + Error = TRUE; + quit(); + } } // my_file_read_line() @@ -394,19 +395,4 @@ double my_timer_elapsed_real(const my_timer_t * timer) { } -char * my_getcwd(char *buf, size_t size){ -#ifdef _WIN32 - return _getcwd(buf,size); -#else - return getcwd(buf,size); -#endif -} -int my_chdir (const char *path){ - ASSERT(path!=NULL); -#ifdef _WIN32 - return _chdir(path); -#else - return chdir(path); -#endif -}