Theo de Raadt wrote: > I do not like your style of adjusting the counter with -= > > the character counting approach looks fragile. > > I suspect some of these refactorings are better if MULTIPLE *printf > calls are used, instead of one call. > > Cut the call into two at the %n
Ok, same approach as with the brltty port. It looks better indeed and avoids forgetting \0. Is this better? Index: misc/uniutils/Makefile =================================================================== RCS file: /cvs/ports/misc/uniutils/Makefile,v retrieving revision 1.9 diff -u -p -u -p -r1.9 Makefile --- misc/uniutils/Makefile 28 Jun 2021 21:34:19 -0000 1.9 +++ misc/uniutils/Makefile 11 Sep 2021 06:58:02 -0000 @@ -3,7 +3,7 @@ COMMENT= Unicode utilities DISTNAME= uniutils-2.27 -REVISION= 3 +REVISION= 4 CATEGORIES= misc HOMEPAGE= http://billposer.org/Software/unidesc.html Index: misc/uniutils/patches/patch-ExplicateUTF8_c =================================================================== RCS file: misc/uniutils/patches/patch-ExplicateUTF8_c diff -N misc/uniutils/patches/patch-ExplicateUTF8_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ misc/uniutils/patches/patch-ExplicateUTF8_c 11 Sep 2021 06:58:02 -0000 @@ -0,0 +1,21 @@ +$OpenBSD$ + +Remove %n format-specifier from snprintf + +Index: ExplicateUTF8.c +--- ExplicateUTF8.c.orig ++++ ExplicateUTF8.c +@@ -214,7 +214,12 @@ main(int ac, char **av){ + printf("%s ",tempstr); + } + printf("\n"); +- printf("This is padded to 32 places with %d zeros: %n%s\n",(32-GotBits),&spaces,binfmtl(ch)); ++ char buf[128]; ++ int buf_size = sizeof(buf); ++ spaces = snprintf(buf,buf_size,"This is padded to 32 places with %d zeros: ",(32-GotBits)); ++ if(spaces>0) ++ snprintf(buf + spaces,buf_size - spaces,"%s",binfmtl(ch)); ++ printf("%s\n",buf); + sprintf(tempstr," "); + sprintf(tempstr,"%08lX",ch); + tempstr[28] = tempstr[7];