[Toybox] strings tests and bugfixes

Ilya Kuzmich ilya.kuzmich at gmail.com
Wed May 31 23:34:53 PDT 2017


On 01/06, Rob Landley wrote:
> On 05/28/2017 11:25 PM, Ilya Kuzmich wrote:
> > Found and fixed some strings bugs. duh.
> 
> Sorry for the delay, I started a new Japanese class at the local
> community college (one of those compressed summer session things) and
> between that and $DAYJOB everything else is mostly just on weekends
> right now. :)
> 
> I glanced at this one to see if it was trivial to apply but:
> 
> -    if (nread < 1) break;
> +    if (nread < 1) {
> +      if (count == wlen) xputc('\n');
> +      break;
> +    }
> 
> We have \n at the end of strings already? Under what circumstances would
> it _not_ output them?
> 
>   make strings
>   $ diff -u <(./strings strings) <(strings strings) | wc
>   	0	0	0
current implementation doesn't output newline if last byte does matches:
if (((toybuf[i] >= 32) && (toybuf[i] <= 126)) || (toybuf[i] == '\t')) {

for example:

$ echo -n 'fooo' | strings
fooo
$ echo -n 'fooo' | ./toybox strings
fooo$
# note the missing newline

> 
> As for the offset+1 bit...
> 
>   $ ./strings -o strings | head -n 3
>       567 /lib64/ld-linux-x86-64.so.2
>       646 g"X7
>      1600 libc.so.6
>   $ strings -o strings | head -n 3
>      1070 /lib64/ld-linux-x86-64.so.2
>      1207 g"X7
>      3101 libc.so.6
> 
> I don't see how +1 addresses that? (Or what exactly is going on there.)
gnu strings use octal offsets by default
toybox strings use decimal, but one-off:

$ echo fooo | ./toybox strings -o
     -1 fooo

> 
> Rob



More information about the Toybox mailing list