Subject: Re: replacement for bc(1), dc(1), diff(1), and diff(3)
To: Otto Moerbeek <otto@drijf.net>
From: Otto Moerbeek <otto@drijf.net>
List: tech-userlevel
Date: 03/27/2005 14:11:18
On Sun, 27 Mar 2005, Otto Moerbeek wrote:
> > We haven't even begun to talk about POSIX compliance. The above tests
> > show that OpenBSD doesn't comply with the POSIX output requirement
> > that the \ in continuation numbers is also to be counted in the line
> > length. So a line of a maximum of 70 characters, the default output
> > line size, should have 69 digits and one \. OpenBSD bc has 70 digits
> > and the \.
>
> IMO Posix is ambiguous:
>
> "Very large numbers shall be split across lines with 70 characters per
> line in the POSIX locale; other locales may split at different
> character boundaries. Lines that are continued shall end with a
> backslash ( '\' )."
>
> I copied the behaviour from the original (4.2 iirc) BSD dc(1). Although
> dc(1) and bc(1) are completly new implementations, I tried to stay close
> to these originals. But if I'm wrong in this, I'm happy to change that.
>
Hmmm, I am a bit confused.. Let's count, first OpenBSD bc(1):
[otto@fonzo:15]$ bc
10^70
100000000000000000000000000000000000000000000000000000000000000000000\
00
[otto@fonzo:16]$
1234567890123456789012345678901234567890123456789012345678901234567890
OpenBSD bc(1) outputs 69 digits, a backslash, followed by two digits.
Line lenght is 70.
But with GNU bc:
om@xs3:~$ bc
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
10^70
10000000000000000000000000000000000000000000000000000000000000000000\
000
om@xs3:~$
1234567890123456789012345678901234567890123456789012345678901234567890
That's 68 digits, a backslash and 3 digits.
Line lenght is 69
I am not counting the newlines, as you can see.
-Otto