On Sat, Jun 19 2021, Charlene Wendling <[email protected]> wrote:
> Hi,
>
> From macppc bulk logs:
>
>> unireverse.c:173:10: warning: result of comparison of constant -1
>> with expression of type 'char' is always false
>
> On macppc the unireverse runtime goes like this:
>
>> $ printf "infinite\nloop" | unireverse
>> etinifni
>> pool
> [hangs forever]
>
> On macppc and arm* char is unsigned by default, so a looped getc(3)
> call in unireverse never reaches EOF there. Using an int instead of a
> char to store the return value of getc(3) solves that issue.
>
> OK?

ok

> Charlène.
>
> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/misc/uniutils/Makefile,v
> retrieving revision 1.8
> diff -u -p -u -p -r1.8 Makefile
> --- Makefile  12 Jul 2019 20:47:54 -0000      1.8
> +++ Makefile  19 Jun 2021 19:23:22 -0000
> @@ -3,7 +3,7 @@
>  COMMENT=     Unicode utilities
>  
>  DISTNAME=    uniutils-2.27
> -REVISION=    2
> +REVISION=    3
>  CATEGORIES=  misc
>  
>  HOMEPAGE=    http://billposer.org/Software/unidesc.html
> Index: patches/patch-unireverse_c
> ===================================================================
> RCS file: patches/patch-unireverse_c
> diff -N patches/patch-unireverse_c
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-unireverse_c        19 Jun 2021 19:23:22 -0000
> @@ -0,0 +1,17 @@
> +$OpenBSD$
> +
> +Fix an infinite loop on archs where char is unsigned by default (arm*
> +and powerpc), because EOF (-1) could not be reached by getc(3).
> +
> +Index: unireverse.c
> +--- unireverse.c.orig
> ++++ unireverse.c
> +@@ -151,7 +151,7 @@ int main(int ac, char **av) {
> + 
> + char * GetLine(FILE *fp, int *LineLength)
> + {
> +-  char c;
> ++  int c;
> +   int Available;
> +   int CharsRead;
> +   char *Line;
>

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to