[tlbuild] Test failing on NetBSD

Marc Baudoin babafou at babafou.eu.org
Sun Jan 10 13:22:31 CET 2021


Bruno Haible <bruno at clisp.org> écrit :
> 
> Your program is using iscntrl() in the "C" locale. What you are discovering
> is that in NetBSD the "C" locale apparently has ISO-8859-1 encoding, whereas
> in the other systems you have tried it has US-ASCII or UTF-8 encoding.

Not sure locale is the issue.

> Additionally, your code above has undefined behaviour on platforms where
> 'char' is signed. Per POSIX and ISO C, you must cast the 'char' argument
> to 'unsigned char' before passing it to any of the <ctype.h> functions:
>   iscntrl ( (unsigned char) buf[i] )

Right.

Changed char to unsigned char:

-----------------------------------------------------------------

#include <ctype.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>

int main ( void )
{
   int fd = open ( "postV3.afm" , O_RDONLY ) ;
   unsigned char buf[BUFSIZ] ;
   int n ;
   while ( n = read ( fd , buf , sizeof ( buf ) ) )
   {
      for ( int i = 0 ; i < n ; i ++ )
      {
         printf ( "%c\t%d\n" , buf[i] , iscntrl ( buf[i] ) ) ;
      }
   }
   close ( fd ) ;
}

-----------------------------------------------------------------

Now it prints this:

[...]
P       0
a       0
l       0
l       0
e       0
        0
J       0
<BF>    0	<<< was 2 before
r       0
g       0
e       0
n       0
s       0
e       0
n       0
[...]

So I don't understand even more what the problem in
texk/web2c/pdftexdir/ttf2afm.c might be.


More information about the tlbuild mailing list.