[gnu.bash.bug] fix for bash test

andy@CSVAX.CALTECH.EDU (Andy Fyfe) (06/14/89)

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. */
  }
  
  /*