From d91dfdc72d9abeb6733b72c9bef81ccee55b9735 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Wed, 31 Mar 2010 22:31:44 +0200 Subject: [PATCH] Allow escape sequences in telluser(error) messages The routine EscapeExpand was moved to backend.c, and applied to the message received from the engine. --- backend.c | 15 +++++++++++++++ backend.h | 1 + xboard.c | 13 ------------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/backend.c b/backend.c index 7672207..031141a 100644 --- a/backend.c +++ b/backend.c @@ -1351,6 +1351,19 @@ establish() } } +void EscapeExpand(char *p, char *q) +{ // [HGM] initstring: routine to shape up string arguments + while(*p++ = *q++) if(p[-1] == '\\') + switch(*q++) { + case 'n': p[-1] = '\n'; break; + case 'r': p[-1] = '\r'; break; + case 't': p[-1] = '\t'; break; + case '\\': p[-1] = '\\'; break; + case 0: *p = 0; return; + default: p[-1] = q[-1]; break; + } +} + void show_bytes(fp, buf, count) FILE *fp; @@ -7334,11 +7347,13 @@ if(appData.debugMode) fprintf(debugFP, "nodes = %d, %lld\n", (int) programStats. * Look for communication commands */ if (!strncmp(message, "telluser ", 9)) { + EscapeExpand(message+9, message+9); // [HGM] esc: allow escape sequences in popup box DisplayNote(message + 9); return; } if (!strncmp(message, "tellusererror ", 14)) { cps->userError = 1; + EscapeExpand(message+14, message+14); // [HGM] esc: allow escape sequences in popup box DisplayError(message + 14, 0); return; } diff --git a/backend.h b/backend.h index c35d2bc..41a34dc 100644 --- a/backend.h +++ b/backend.h @@ -189,6 +189,7 @@ void DisplayBothClocks P((void)); void EditPositionMenuEvent P((ChessSquare selection, int x, int y)); void DropMenuEvent P((ChessSquare selection, int x, int y)); int ParseTimeControl P((char *tc, int ti, int mps)); +void EscapeExpand(char *p, char *q); void ProcessICSInitScript P((FILE * f)); void EditCommentEvent P((void)); void ReplaceComment P((int index, char *text)); diff --git a/xboard.c b/xboard.c index 1d66ed2..5f14af0 100644 --- a/xboard.c +++ b/xboard.c @@ -1704,19 +1704,6 @@ void InitDrawingSizes(BoardSize boardSize, int flags) } #endif -void EscapeExpand(char *p, char *q) -{ // [HGM] initstring: routine to shape up string arguments - while(*p++ = *q++) if(p[-1] == '\\') - switch(*q++) { - case 'n': p[-1] = '\n'; break; - case 'r': p[-1] = '\r'; break; - case 't': p[-1] = '\t'; break; - case '\\': p[-1] = '\\'; break; - case 0: *p = 0; return; - default: p[-1] = q[-1]; break; - } -} - int main(argc, argv) int argc; -- 1.7.0.4