Hi!

Currently 'expr' always tries to evaluate its arguments as numbers
even when the operation performed will require strings. This leads
to couple different bugs reported on [dev][0].

First: `expr 00003 : '.*'` should evaluate to the length of the
string but currently it evaluates to 1.

Second: `expr 00003 : '\(.*\)'` should return the whole matched
substring but currently it evaluates to 3.

Both of these can be fixed by only trying to evaluate the strings
as numbers when they are expected to be numbers. This also gives a
nice reduction in lines of code.

[0]: https://lists.suckless.org/dev/2401/35511.html
 
expr.c | 86 ++++++++++++++++++----------------------------------------
1 file changed, 27 insertions(+), 59 deletions(-)



Reply via email to