ChangeLog tclspice.c:
Fix fprintf by the bg thread in tclspice
This commit is contained in:
parent
da89dcc6c5
commit
fcae1791c5
|
|
@ -1,3 +1,8 @@
|
|||
2003-06-25 Stefan Jones <stefan.jones@multigig.com>
|
||||
|
||||
* tclspice.c :
|
||||
Fix printing while running a background thread, seen eg. in Magic-7.2
|
||||
|
||||
2001-12-04 Emmanuel Rouat <emmanuel.rouat@wanadoo.fr>
|
||||
|
||||
* maths/cmaths/Makefile.am (noinst_PROGRAMS): test programs
|
||||
|
|
|
|||
|
|
@ -326,15 +326,17 @@ static int spicetoblt(ClientData clientData, Tcl_Interp *interp,
|
|||
/* Main spice command executions and thread control */
|
||||
/*****************************************************************/
|
||||
|
||||
static pthread_t tid;
|
||||
static pthread_t tid, bgtid=(pthread_t)0;
|
||||
static bool fl_running = FALSE;
|
||||
static bool fl_exited = TRUE;
|
||||
|
||||
|
||||
static void *_thread_run(void *string){
|
||||
fl_exited = FALSE;
|
||||
bgtid = pthread_self();
|
||||
cp_evloop((char *)string);
|
||||
FREE(string);
|
||||
bgtid = (pthread_t)0;
|
||||
fl_exited = TRUE;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1360,8 +1362,9 @@ int tcl_vfprintf(FILE *f, const char *fmt, va_list args_in)
|
|||
char *outptr, *bigstr = NULL, *finalstr = NULL;
|
||||
int i, nchars, result, escapes = 0;
|
||||
|
||||
if(f != stdout && f != stderr)
|
||||
vfprintf(f,fmt,args_in);
|
||||
if((f != stdout && f != stderr) ||
|
||||
( fl_running && bgtid == pthread_self()) )
|
||||
return vfprintf(f,fmt,args_in);
|
||||
|
||||
strcpy (outstr + 19, (f == stderr) ? "err \"" : "out \"");
|
||||
outptr = outstr;
|
||||
|
|
@ -1457,6 +1460,9 @@ void tcl_stdflush(FILE *f)
|
|||
static char stdstr[] = "flush stdxxx";
|
||||
char *stdptr = stdstr + 9;
|
||||
|
||||
if ( fl_running && bgtid == pthread_self())
|
||||
return;
|
||||
|
||||
Tcl_SaveResult(spice_interp, &state);
|
||||
strcpy(stdptr, (f == stderr) ? "err" : "out");
|
||||
Tcl_Eval(spice_interp, stdstr);
|
||||
|
|
|
|||
Loading…
Reference in New Issue