X-Git-Url: http://winboard.nl/cgi-bin?p=polyglot.git;a=blobdiff_plain;f=util.c;fp=util.c;h=a3fb3ba779f247ff1efc9a88be4bce67a1f75aef;hp=28e56b5ad452b0ac6aa7973ab7094054707a0483;hb=471c4c42e267be298ce20951d5a352acd6b55190;hpb=5b56e51eeae04c352b95b1706b9d69b61feba3e9 diff --git a/util.c b/util.c index 28e56b5..a3fb3ba 100644 --- a/util.c +++ b/util.c @@ -24,6 +24,7 @@ #include "main.h" #include "util.h" +#include "gui.h" // macros @@ -197,16 +198,19 @@ void my_fatal(const char format[], ...) { CONSTRUCT_ARG_STRING(format,string); - fprintf(stderr,"%s",string); my_log("POLYGLOT %s",string); + // This should be gui_send but this does not work. + // Why? + + fprintf(stderr,"tellusererror POLYGLOT: %s",string); if (Error) { // recursive error my_log("POLYGLOT *** RECURSIVE ERROR ***\n"); exit(EXIT_FAILURE); // abort(); } else { - Error = TRUE; - quit(); + Error = TRUE; + quit(); } } @@ -474,4 +478,39 @@ double my_timer_elapsed_real(const my_timer_t * timer) { } +void my_dequote(char *out, const char *in, const char *special){ + const char *p; + char *q; + char c; + p=in; + q=out; + while((c=*(p++))){ + if(c=='\\' && strchr(special,*p)){ + *(q++)=*(p++); + }else{ + *(q++)=c; + } + } + *q='\0'; +} + +void my_quote(char *out, const char *in, const char *special){ + const char *p; + char *q; + char c; + p=in; + q=out; + while(q-out< StringSize-2 && (c=*(p++))){ + if(c=='\\'){ + if(*p!=0 && strchr(special,*p)){ + *(q++)='\\'; + } + }else if(strchr(special,c)){ + *(q++)='\\'; + } + *(q++)=c; + } + *q='\0'; +} +