"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/frontend/input.cc" between
gnuchess-6.2.5.tar.gz and gnuchess-6.2.6.tar.gz

About: GNU Chess is a chess-playing program.

input.cc  (gnuchess-6.2.5):input.cc  (gnuchess-6.2.6)
/* GNU Chess 5.0 - input.c - Input thread and related /* input.c
Copyright (c) 2002 Free Software Foundation, Inc.
GNU Chess is based on the two research programs GNU Chess frontend
Cobalt by Chua Kong-Sian and Gazebo by Stuart Cracraft.
Copyright (C) 2001-2020 Free Software Foundation, Inc.
GNU Chess is free software; you can redistribute it and/or modify GNU Chess is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option) the Free Software Foundation; either version 3, or (at your option)
any later version. any later version.
GNU Chess is distributed in the hope that it will be useful, GNU Chess is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
skipping to change at line 45 skipping to change at line 45
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <assert.h> #include <assert.h>
#include <signal.h> #include <signal.h>
#include "common.h" #include "common.h"
#include "components.h" #include "components.h"
#include "gettext.h"
#define _(str) gettext (str)
#ifdef HAVE_LIBREADLINE #ifdef HAVE_LIBREADLINE
# ifdef HAVE_READLINE_READLINE_H # ifdef HAVE_READLINE_READLINE_H
# include <readline/readline.h> # include <readline/readline.h>
# include <readline/history.h> # include <readline/history.h>
# else # else
extern char* readline(char *); extern char* readline(char *);
extern void add_history(char *); extern void add_history(char *);
# endif # endif
#endif #endif
skipping to change at line 98 skipping to change at line 101
#endif /* HAVE_LIBREADLINE */ #endif /* HAVE_LIBREADLINE */
/* The generic input routine */ /* The generic input routine */
void getline_standard(char *p) void getline_standard(char *p)
{ {
if (!(flags & XBOARD)) { if (!(flags & XBOARD)) {
fputs(p, stdout); fputs(p, stdout);
fflush(stdout); fflush(stdout);
} }
fgets(userinputstr, MAXSTR, stdin); char *s = fgets(userinputstr, MAXSTR, stdin); // TODO Handle return value
} }
/* /*
* Sends a char string message from the input to the frontend. * Sends a char string message from the input to the frontend.
* The message must be a command or a move. * The message must be a command or a move.
*/ */
int SendToFrontend( char msg[] ) int SendToFrontend( char msg[] )
{ {
int outError=0; int outError=0;
int msg_size = strlen( msg ); int msg_size = strlen( msg );
skipping to change at line 148 skipping to change at line 151
while (!(flags & QUIT)) { while (!(flags & QUIT)) {
if (!(flags & XBOARD)) { if (!(flags & XBOARD)) {
pthread_mutex_lock( &input_mutex ); pthread_mutex_lock( &input_mutex );
while ( !wait_for_input ) while ( !wait_for_input )
pthread_cond_wait( &input_cond, &input_mutex ); pthread_cond_wait( &input_cond, &input_mutex );
pthread_mutex_unlock( &input_mutex ); pthread_mutex_unlock( &input_mutex );
sprintf(prompt,"%s (%d) : ", sprintf(prompt,"%s (%d) : ",
RealSide ? "Black" : "White", RealSide ? _("Black") : _("White"),
(RealGameCnt+1)/2 + 1 ); (RealGameCnt+1)/2 + 1 );
} else {
sprintf(prompt,"");
} }
get_line(prompt); get_line(prompt);
SendToFrontend( userinputstr ); SendToFrontend( userinputstr );
#ifdef HAVE_LIBREADLINE #ifdef HAVE_LIBREADLINE
SendToFrontend( "\n" ); SendToFrontend( "\n" );
#endif #endif
pthread_mutex_lock( &input_mutex ); pthread_mutex_lock( &input_mutex );
wait_for_input = 0; wait_for_input = 0;
pthread_mutex_unlock( &input_mutex ); pthread_mutex_unlock( &input_mutex );
/* TODO Improve this test */ /* TODO Improve this test */
 End of changes. 6 change blocks. 
8 lines changed or deleted 9 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)