Article View: gnu.bash.bug
Article #90fix for bash test
From: Andy Fyfe
Date: Wed, 14 Jun 1989 00:08
Date: Wed, 14 Jun 1989 00:08
118 lines
2664 bytes
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. */
}
/*
Technical Details
Message-ID:
<8906140008.AA10192@csvax.caltech.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!CSVAX.CALTECH.EDU!andyShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!CSVAX.CALTECH.EDU!andy From: andy@CSVAX.CALTECH.EDU (Andy Fyfe) Newsgroups: gnu.bash.bug Subject: fix for bash test Message-ID: <8906140008.AA10192@csvax.caltech.edu> Date: 14 Jun 89 00:08:59 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 118