[comp.sys.hp] pr bug in HP-UX 2.1

eik@os.is (Einar Kjartansson) (01/29/89)

When I installed 2.1 HP-UX, the behavior of the pr command changed.
Pr now  inserts unwanted tab characters into files that contain
8-bit character codes, when outputting more than one column.

The enclosed shar contains an example, just unwarap it in an empty
directory.

# This is a shell archive.  Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by eik at geysir on Sun Jan 29 09:01:01 1989
#
# This archive contains:
#	Makefile	in		out		
#

LANG=""; export LANG

echo x - Makefile
cat >Makefile <<'@EOF'
all : clean
	pr -2 -l24 < in > out
	shar Makefile in out > Shar
clean :
	-rm Shar
	-rm out

@EOF

chmod 644 Makefile

unpacker=/tmp/unpack$$ ; compile="y"
for uudecode in /bin/uudecode /usr/bin/uudecode /usr/local/bin/uudecode /usr/contrib/bin/uudecode /etc/uudecode /usr/public/bin/uudecode /usr/ucb/bin/uudecode
do if test -s $uudecode
   then unpacker=$uudecode ; compile="n" ; break
   fi
done
pwd=`pwd`; cd /tmp
if test $compile = "y"
then cat >$unpacker.c <<'EOF'
#include <stdio.h>
#define DEC(c)	(((c) - ' ') & 077)
main()
{
	int n;
	char dest[128], a,b,c,d;

	scanf("begin %o ", &n);
	gets(dest);

	if (freopen(dest, "w", stdout) == NULL) {
		perror(dest);
		exit(1);
	}

	while ((n=getchar()) != EOF && (n=DEC(n))!=0)  {
		while (n>0) {
			a = DEC(getchar());
			b = DEC(getchar());
			c = DEC(getchar());
			d = DEC(getchar());
			if (n-- > 0) putchar(a << 2 | b >> 4);
			if (n-- > 0) putchar(b << 4 | c >> 2);
			if (n-- > 0) putchar(c << 6 | d);
		}
		n=getchar();
	}
	exit(0);
}
EOF
echo Compiling unpacker for non-ascii files
cc -o $unpacker $unpacker.c 1>/dev/null 2>&1
rm $unpacker.c
fi
cd $pwd

echo x - in '[non-ASCII]'
$unpacker <<'@eof'
begin 644 in
M0OII\"!E<B!A\"!S971J82!U<' @3W)A8VQE"F=A9VYA<V%F;G-K97)F:2#A
M($A0+73V;'9U;FYI+B *"MYE:7(@<V5M(&AA9F$@:'5G(.$@8? @;F]T82!K
M97)F:? *:&%F:2!S86UB86YD:2!V:? @16EN87(@2VIA<G1A;G-O;BP*<V5M
M(/IT:&QU=&%R(&YO=&5N9&%N]F9N=6T@;V<@:V5M=7(*;?9N;G5M(&%F('-T
M8? N( H*0F5S="!E<B!A\"!B>7)J82#A(&'P(&QE<V$@8O-K:6YA"B)344PL
M('1H92!Q=6ET(')E=F]L=71I;VXB+"!S96T*:.9G="!E<B!A\"!FX2!H:N$@
M2&5L9V$@5&]R9F%S>6YI"F]G('1I;"!E<B#M(&QJ\W-R:71I(';M\&$@=6T*
M<W1O9FYU;FEN82X@($'P(/YV[2!L;VMN=2!G971A"F)Y<FIE;F1U<B!R96YN
M="!G96=N=6T@:V5N;G-L=7-T=6YD"NT@4U%,*E1U=&]R+"!E;B#^8? @97(@
M9F]R<FET(&9Y<FER"E!#+73V;'9U<B!M9? @:/9R\'5M(&1I<VL@;V<@:V5N
M;FER"FWV;FYU;2!344PM<VMI<&%N86WA;&GP+B @4U%,*E1U=&]R"F;F<W0@
6:&KA($AE;&=A(%1O<F9A<WEN:2X@"FWA
 
end
@eof

chmod 644 in

echo x - out '[non-ASCII]'
$unpacker <<'@eof'
begin 644 out
M"@I*86X@,CD@,#DZ,#$@,3DX.2 @(%!A9V4@,0H*"D+Z:? @97(@8? )<V5T
M:F$@=7!P($]R86-L90D@(" @(E-13"P@=&AE('%U:70@<F5V;VQU=&EO;B(L
M"7-E;0IG86=N87-A9FYS:V5R9FD)X2!(4"UT]FQV=6YN:2X)(" @(&CF9W0)
M97(@8? @9N$@:&KA($AE;&=A"51O<F9A<WEN:0H)"0D)(" @(&]G('1I;"!E
M<B#M(&QJ\W-R:71I(';M\&$@=6T*WF5I<B!S96T):&%F82!H=6<@X2!A\"!N
M;W1A(&ME<F9I\ D@(" @<W1O9FYU;FEN82X)($'P(/YV[2!L;VMN=2!G971A
M"FAA9FD@<V%M8F%N9&D@=FGP($5I;F%R($MJ87)T86YS;VXL("!B>7)J96YD
M=7(@<F5N;G0@9V5G;G5M(&ME;FYS;'5S='5N9 IS96T@^G1H;'5T87(@;F]T
M96YD86[V9FYU;2!O9R!K96UU<B @(.T@4U%,*E1U=&]R+ EE;B#^8? @97()
M9F]R<FET(&9Y<FER"FWV;FYU;2!A9B!S=&'P+@D)"2 @("!00RUT]FQV=7(@
M;67P"6CV<O!U;2!D:7-K(&]G(&ME;FYI<@H)"0D)(" @(&WV;FYU;2!344PM
M<VMI<&%N86WA;&GP+B @4U%,*E1U=&]R"D)E<W0@97()8? @8GER:F$)X2!A
M\"!L97-A"6+S:VEN80D@(" @9N9S= EH:N$@2&5L9V$@5&]R9F%S>6YI+@H*
)"@H*"@H*"@H*
 
end
@eof

chmod 644 out

rm -f /tmp/unpack$$
exit 0
-- 
  Einar Kjartansson                           | eik@os.is
  Orkustofnun (National Energy Authority)     | eik@geysir.uucp
  Grensasvegi 9, IS-108 Reykjavik, Iceland    | mcvax!hafro!geysir!eik
  Phone: 354-1-83600    Fax: 354-1-688896    Home: 354-1-16407

wk@hpirs.HP.COM (Wayne Krone) (02/01/89)

> When I installed 2.1 HP-UX, the behavior of the pr command changed.
> Pr now  inserts unwanted tab characters into files that contain
> 8-bit character codes, when outputting more than one column.

Thank you for reporting this problem.  The problem appears to be in
the terminal I/O driver rather than pr.  If you use stty to set the
output mode "tab3" (expand spaces to tabs), a simpler instance of the
problem is shown by:

	$ echo '888\t7'		(replace "888" by 8-bit characters)
	888        7
	$ echo '777\t7'
	777     7

The 8-bit characters are apparently not being counted when a tab is
expanded for display.  A workaround for your problem would be to use
stty to set the tab output mode to "tab0".

I will forward this problem to the appropriate folks.

Wayne Krone
Hewlett-Packard