14
14
#ifndef WIN32
15
15
#include <netinet/tcp.h>
16
16
#include <pthread.h>
17
- #if !defined( PTHREAD_MUTEX_RECURSIVE ) && defined( PTHREAD_MUTEX_RECURSIVE_NP )
17
+ #ifndef PTHREAD_MUTEX_RECURSIVE
18
18
#define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP
19
19
#endif
20
20
#else
@@ -241,8 +241,9 @@ I check() { //in suspended execution mode: allows checking of state at time
241
241
fCheck = ofCheck ;
242
242
R 0 ; }
243
243
244
+ static I fln = 0 ;
244
245
I lines (FILE * f ) {
245
- S a = 0 ;I n = 0 ;PDA p = 0 ; while (-1 != line (f ,& a ,& n ,& p )){} R 0 ;}
246
+ S a = 0 ;I n = 0 ;PDA p = 0 ; fln = 1 ; while (-1 != line (f ,& a ,& n ,& p )){fln = 0 ; } R 0 ;}
246
247
//You could put lines(stdin) in main() to have not-multiplexed command-line-only input
247
248
248
249
I line (FILE * f , S * a , I * n , PDA * p ) { //just starting or just executed: *a=*n=*p=0, intermediate is non-zero
@@ -252,6 +253,7 @@ I line(FILE*f, S*a, I*n, PDA*p) { //just starting or just executed: *a=*n=*p=0,
252
253
I o = isatty (STDIN ); //display results to stdout?
253
254
254
255
if (-1 == (c = getline_ (& s ,& m ,f ))) GC ;
256
+ if (fln && (s [0 ]== '#' && s [1 ]== '!' )) GC ;
255
257
if (s [0 ]== '\\' && s [1 ]== '\n' ) {
256
258
if (!fCheck && fLoad ) { c = -1 ; GC ; } //escape file load
257
259
if (fCheck ) { fCheck -- ;R 0 ; } //escape suspended execution with single backslash
@@ -409,6 +411,7 @@ I attend() { //K3.2 uses fcntl somewhere
409
411
if (pthread_create (& thread , NULL , timer_thread , NULL )){
410
412
perror ("Create timer thread" ); abort (); }
411
413
414
+ fln = 1 ;
412
415
for (;;) { // main loop
413
416
scrLim = 0 ;
414
417
read_fds = master ; // copy it
@@ -421,6 +424,7 @@ I attend() { //K3.2 uses fcntl somewhere
421
424
if (FD_ISSET (i , & read_fds )) {
422
425
if (i == STDIN ) {
423
426
nbytes = line (stdin ,& a ,& n ,& q );
427
+ fln = 0 ;
424
428
if (nbytes <=0 ){
425
429
if (!IPC_PORT && !HTTP_PORT ) exit (0 ); //Catch CTRL+D
426
430
else FD_CLR (i ,& master );} }
0 commit comments