X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=util.c;h=3016e23d9add324b2e91229601db9af35785210f;hb=ac968003c13bde5c86ffa19f8819e436b5bc03e6;hp=8551aca7f6c43eb03b6206431447f84723818541;hpb=e15efca6667b2673b4c1a5879a6917eab6800e58;p=polyglot.git diff --git a/util.c b/util.c index 8551aca..3016e23 100644 --- a/util.c +++ b/util.c @@ -18,7 +18,9 @@ #include #include #include +#ifndef _MSC_VER #include +#endif #include "main.h" #include "util.h" @@ -29,7 +31,6 @@ static bool Error; FILE * LogFile=NULL; - // functions // util_init() @@ -158,45 +159,47 @@ void my_log_close() { // my_log() void my_log(const char format[], ...) { + + char string[FormatBufferSize]; + + ASSERT(format!=NULL); - va_list ap; +// format - ASSERT(format!=NULL); + CONSTRUCT_ARG_STRING(format,string); + - if (LogFile != NULL) { - fprintf(LogFile,"%.3f ",now_real()); - va_start(ap,format); - - 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); + my_log("POLYGLOT %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() @@ -336,7 +339,10 @@ double now_real() { return tv->tv_sec + tv->tv_usec * 1E-6; #else - return (double) GetTickCount() / 1000.0; // we can do better here:-) + struct _timeb timeptr; + _ftime(&timeptr); + return(timeptr.time+((double)timeptr.millitm)/1000.0); +// return (double) GetTickCount() / 1000.0; // we can do better here:-) #endif } @@ -394,19 +400,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 -}