Re: [hackers] [sbase] [PATCH] tr: Fix multiple ranges with different lengths

From: Quentin Rameau <quinq_AT_fifth.space>
Date: Sat, 22 Oct 2016 22:01:55 +0200

Hi Michael,

> A bug was introduced in bc4c293fe59de042c1ac71793d33bb685c4fb915
> causing the range length for the next set to be used instead of the
> first one. This causes issues when choosing the replacement rune when
> the ranges are of different lengths.
>
> This also fixes range expressions in the form [a-z], which get
> encoded as four ranges '[', 'a'..'z', ']', causing all a-z characters
> to get mapped to ']'. This form is occasionally used in shell
> scripts, including the syscalltbl.sh script used to build linux.
> ---
> tr.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tr.c b/tr.c
> index a633d74..c235215 100644
> --- a/tr.c
> +++ b/tr.c
> _AT_@ -213,7 +213,7 @@ read:
> }
> if (argc == 1 && sflag)
> goto write;
> - for (i = 0, off1 = 0; i < set1ranges; i++, off1 +=
> rangelen(set1[i])) {
> + for (i = 0, off1 = 0; i < set1ranges; off1 +=
> rangelen(set1[i]), i++) { if (set1[i].start <= r && r <= set1[i].end)
> { if (dflag) {
> if (cflag)

Looks good!
Received on Sat Oct 22 2016 - 22:01:55 CEST

This archive was generated by hypermail 2.3.0 : Sat Oct 22 2016 - 22:12:14 CEST