1010c7a263951539d2740461e685b6ba83ea1656 — Simon Ser a month ago d4e63a2
parser/arithm: fix comparison operators

> and < were recognized before >= and <=. For this reason, >= and <= were never
parsed (since they are prefixes of < and >).

Closes: https://github.com/emersion/mrsh/issues/86
2 files changed, 7 insertions(+), 8 deletions(-)

M parser/arithm.c
M test/arithm.sh
M parser/arithm.c => parser/arithm.c +5 -5
@@ 254,14 254,14 @@ }
  
  	enum mrsh_arithm_binop_type type;
- 	if (parse_char(state, '<')) {
- 		type = MRSH_ARITHM_BINOP_LESS;
- 	} else if (parse_str(state, "<=")) {
+ 	if (parse_str(state, "<=")) {
  		type = MRSH_ARITHM_BINOP_LESSEQ;
- 	} else if (parse_char(state, '>')) {
- 		type = MRSH_ARITHM_BINOP_GREAT;
+ 	} else if (parse_char(state, '<')) {
+ 		type = MRSH_ARITHM_BINOP_LESS;
  	} else if (parse_str(state, ">=")) {
  		type = MRSH_ARITHM_BINOP_GREATEQ;
+ 	} else if (parse_char(state, '>')) {
+ 		type = MRSH_ARITHM_BINOP_GREAT;
  	} else {
  		return left;
  	}

M test/arithm.sh => test/arithm.sh +2 -3
@@ 9,10 9,9 @@ echo "2<<5 =" $((2<<5))
  echo "2>>5 =" $((2>>5))
  echo "2<5 =" $((2<5))
- # https://github.com/emersion/mrsh/issues/86
- #echo "2<=5 =" $((2<=5))
+ echo "2<=5 =" $((2<=5))
  echo "2>5 =" $((2>5))
- #echo "2>=5 =" $((2>=5))
+ echo "2>=5 =" $((2>=5))
  echo "2==5 =" $((2==5))
  echo "2!=5 =" $((2!=5))
  echo "2&5 =" $((2&5))