🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Andy Fyfe Wed, 14 Jun 1989 00:08
fix for bash test
#90
Author: Andy Fyfe
Date: Wed, 14 Jun 1989 00:08
118 lines
2664 bytes
bash test was giving -o a higher precedence the -a.  The following
patch fixes this.  In the functions "and" and "or", advance was called
once with 0 and once with 1.  I've made both 1 which is more conservative,
but I think both can be 0.

*** save/test.c	Tue Jun 13 16:38:28 1989
--- test.c	Tue Jun 13 16:53:23 1989
***************
*** 568,604 ****
  }
  
  /*
!  * or:
!  *	or '-o' term
   *	term
   */
  static int
! or ()
  {
    auto int value;
  
    value = term ();
!   while (pos < argc && '-' == argv[pos][0] && 'o' == argv[pos][1] && '\000' == argv[pos][2]) {
!     advance(0);
!     value = TRUTH_OR (value, term ());
    }
    return (TRUE == value);
  }
  
  /*
!  * and:
!  *	and '-a' or
!  *	or
   */
  static int
! and()
  {
    auto int value;
  
!   value = or();
!   while (pos < argc && '-' == argv[pos][0] && 'a' == argv[pos][1] && '\000' == argv[pos][2]) {
      advance(1);
!     value = TRUTH_AND (value, or());
    }
    return (TRUE == value);
  }
--- 568,604 ----
  }
  
  /*
!  * and:
!  *	and '-a' term
   *	term
   */
  static int
! and ()
  {
    auto int value;
  
    value = term ();
!   while (pos < argc && '-' == argv[pos][0] && 'a' == argv[pos][1] && '\000' == argv[pos][2]) {
!     advance(1);
!     value = TRUTH_AND (value, term ());
    }
    return (TRUE == value);
  }
  
  /*
!  * or:
!  *	or '-o' and
!  *	and
   */
  static int
! or()
  {
    auto int value;
  
!   value = and();
!   while (pos < argc && '-' == argv[pos][0] && 'o' == argv[pos][1] && '\000' == argv[pos][2]) {
      advance(1);
!     value = TRUTH_OR (value, and());
    }
    return (TRUE == value);
  }
***************
*** 606,612 ****
  /*
   * expr:
   *	'!' expr
!  *	and
   */
  int
  expr()
--- 606,612 ----
  /*
   * expr:
   *	'!' expr
!  *	or
   */
  int
  expr()
***************
*** 624,630 ****
      /* This has to be rewritten to handle the TRUTH and FALSE stuff. */
      value ^= (TRUE);
    }
!   return value ^ and();		/* Same with this. */
  }
  
  /*
--- 624,630 ----
      /* This has to be rewritten to handle the TRUTH and FALSE stuff. */
      value ^= (TRUE);
    }
!   return value ^ or();		/* Same with this. */
  }
  
  /*
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads