Pádraig Brady <[email protected]> writes:

> On signed char platforms, 0xFF was converted to -1
> which matches MBBUF_EOF, causing fold to stop processing.
>
> * NEWS: Mention the bug fix.
> * gl/lib/mbbuf.h: Avoid sign extension on signed char platforms.
> * tests/fold/fold-characters.sh: Adjust test case.
> Reported at https://src.fedoraproject.org/rpms/coreutils/pull-request/20
> ---
>  NEWS                          | 3 +++
>  gl/lib/mbbuf.h                | 2 +-
>  tests/fold/fold-characters.sh | 9 +++++----
>  3 files changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/NEWS b/NEWS
> index 7eb70b6d1..340115ecc 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -4,6 +4,9 @@ GNU coreutils NEWS                                    -*- 
> outline -*-
>  
>  ** Bug fixes
>  
> +  'fold' will no longer truncate output when encountering 0xFF bytes.
> +  [bug introduced in coreutils-9.8]
> +
>    'kill --help' now has links to valid anchors in the html manual.
>    [bug introduced in coreutils-9.10]
>  
> diff --git a/gl/lib/mbbuf.h b/gl/lib/mbbuf.h
> index 9054fc92e..ea4b7e708 100644
> --- a/gl/lib/mbbuf.h
> +++ b/gl/lib/mbbuf.h
> @@ -96,7 +96,7 @@ mbbuf_get_char (mbbuf_t *mbbuf)
>    else
>      {
>        /* Assume the program will emit the byte, but keep the error flag.  */
> -      g.ch = mbbuf->buffer[mbbuf->offset++];
> +      g.ch = (unsigned char) mbbuf->buffer[mbbuf->offset++];

Oops, my bad.

Couldn't we make the buffer member 'unsigned char *' and avoid the cast?
I think that would be a bit cleaner.

Collin

Reply via email to