Re: [dev] [bug] sbase / expr: loss of leading zeros in string operations

From: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Sun, 7 Jan 2024 15:34:44 +0100

On Sun, Jan 07, 2024 at 01:20:21PM +0100, fomha4_AT_0w.se wrote:
> Hello,
>
> Thanks for the software.
>
> For your information, with the latest and also with earlier sbase:
>
> Expected:
>
> $ expr 00003 : '.*'
> 5
> $ expr 00003 : '\(.*\)'
> 00003
>
> $ expr 00003x : '\(.*\)'
> 00003x
>
> Observed:
>
> $ ./expr 00003 : '.*'
> 1
> $ ./expr 00003 : '\(.*\)'
> 3
>
> $ ./expr 00003x : '\(.*\)'
> 00003x
>
> The leading zeros are lost if the argument looks like a number.
>
> Regards, fomha4
>

Thanks, the issue seems to be in lex() I think:
http://git.suckless.org/sbase/file/expr.c.html#l175

If anyone can write the patch it would be appreciated.

-- 
Kind regards,
Hiltjo
Received on Sun Jan 07 2024 - 15:34:44 CET

This archive was generated by hypermail 2.3.0 : Sun Jan 07 2024 - 15:36:09 CET