git: 8ea6c1154094 - main - usr.bin/bc: remove OpenBSD derived bc and dc commands
Date: Sun, 24 Nov 2024 22:08:32 UTC
The branch main has been updated by se: URL: https://cgit.FreeBSD.org/src/commit/?id=8ea6c115409450ff58a8c6b5e818319d181c6bff commit 8ea6c115409450ff58a8c6b5e818319d181c6bff Author: Stefan Eßer <se@FreeBSD.org> AuthorDate: 2024-11-24 21:38:23 +0000 Commit: Stefan Eßer <se@FreeBSD.org> CommitDate: 2024-11-24 21:38:23 +0000 usr.bin/bc: remove OpenBSD derived bc and dc commands In 2020, an improved implementation of the bc and dc commands developed by Gavin D. Howard has been imported into FreeBSD. It has replaced the OpenBSD-derived versions of these commands in all currently supported FreeBSD releases. The OpenBSD versions could still be built using the WITHOUT_GH_BC option. There have been no reports of problems or unexpected deviations from the OpenBSD version for some time, therefore keeping the OpenBSD version is no longer required in FreeBSD. This commit removes the option to build the OpenBSD version and corresponding source files from -CURRENT. No MFC is planned, all currently released FreeBSD versions should retain the build option. The WITHOUT_GH_BC option is no longer accepted and will cause make buildworld to fail. Reviewed by: des, emaste Approved by: des Relnotes: yes Differential Revision: https://reviews.freebsd.org/D46876 --- ObsoleteFiles.inc | 7 + UPDATING | 5 + share/man/man5/src.conf.5 | 6 - share/mk/src.opts.mk | 1 - tools/build/mk/OptionalObsoleteFiles.inc | 8 - tools/build/options/WITHOUT_GH_BC | 5 - usr.bin/Makefile | 5 - usr.bin/bc/Makefile | 14 - usr.bin/bc/Makefile.depend | 17 - usr.bin/bc/bc.1 | 413 ------- usr.bin/bc/bc.library | 272 ----- usr.bin/bc/bc.y | 1214 -------------------- usr.bin/bc/extern.h | 46 - usr.bin/bc/pathnames.h | 20 - usr.bin/bc/scan.l | 368 ------- usr.bin/bc/tty.c | 64 -- usr.bin/dc/Makefile | 12 - usr.bin/dc/Makefile.depend | 18 - usr.bin/dc/bcode.c | 1773 ------------------------------ usr.bin/dc/bcode.h | 103 -- usr.bin/dc/dc.1 | 555 ---------- usr.bin/dc/dc.c | 154 --- usr.bin/dc/extern.h | 63 -- usr.bin/dc/inout.c | 446 -------- usr.bin/dc/mem.c | 140 --- usr.bin/dc/stack.c | 370 ------- usr.bin/dc/tests/Makefile | 6 - usr.bin/dc/tests/bcode.sh | 142 --- usr.bin/dc/tests/inout.sh | 100 -- 29 files changed, 12 insertions(+), 6335 deletions(-) diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index 1378d6b6dcfa..5362ba0e5955 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -51,6 +51,13 @@ # xargs -n1 | sort | uniq -d; # done +# 20241124: library and tests of OpenBSD dc +OLD_FILES+=usr/share/misc/bc.library +OLD_FILES+=usr/tests/usr.bin/dc/Kyuafile +OLD_FILES+=usr/tests/usr.bin/dc/bcode +OLD_FILES+=usr/tests/usr.bin/dc/inout +OLD_DIRS+=usr/tests/usr.bin/dc + # 20241119: rewrite mv tests OLD_FILES+=usr/tests/bin/mv/legacy_test diff --git a/UPDATING b/UPDATING index 1fb14a96880b..2a67a65a92ed 100644 --- a/UPDATING +++ b/UPDATING @@ -27,6 +27,11 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 15.x IS SLOW: world, or to merely disable the most expensive debugging functionality at runtime, run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) +20241124: + The OpenBSD derived bc and dc implementations and the WITHOUT_GH_BC + option that allowed building them instead of the advanced version + imported more than 4 years ago have been removed. + 20241025: The support for the rc_fast_and_loose variable has been removed from rc.subr(8). Users setting rc_fast_and_loose on their systems are diff --git a/share/man/man5/src.conf.5 b/share/man/man5/src.conf.5 index a1465b0729a3..88df18b3142e 100644 --- a/share/man/man5/src.conf.5 +++ b/share/man/man5/src.conf.5 @@ -712,12 +712,6 @@ and .Xr ftpd 8 . .It Va WITHOUT_GAMES Do not build games. -.It Va WITHOUT_GH_BC -Install the traditional FreeBSD -.Xr bc 1 -and -.Xr dc 1 -programs instead of the enhanced versions. .It Va WITHOUT_GNU_DIFF Do not build GNU .Xr diff3 1 ; diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index f8877153f17f..f3141884cd00 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -101,7 +101,6 @@ __DEFAULT_YES_OPTIONS = \ FREEBSD_UPDATE \ FTP \ GAMES \ - GH_BC \ GNU_DIFF \ GOOGLETEST \ GPIO \ diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index e326155b26a4..864057692566 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -2071,14 +2071,6 @@ OLD_FILES+=usr/share/man/man8/strfile.8.gz OLD_FILES+=usr/share/man/man8/unstr.8.gz .endif -.if ${MK_GH_BC} == no -OLD_FILES+=usr/share/misc/bc.library -OLD_FILES+=usr/tests/usr.bin/dc/Kyuafile -OLD_FILES+=usr/tests/usr.bin/dc/bcode -OLD_FILES+=usr/tests/usr.bin/dc/inout -OLD_DIRS+=usr/tests/usr.bin/dc -.endif - .if ${MK_GOOGLETEST} == no OLD_FILES+=usr/include/private/gmock/gmock-actions.h OLD_FILES+=usr/include/private/gmock/gmock-cardinalities.h diff --git a/tools/build/options/WITHOUT_GH_BC b/tools/build/options/WITHOUT_GH_BC deleted file mode 100644 index 2618257ec71d..000000000000 --- a/tools/build/options/WITHOUT_GH_BC +++ /dev/null @@ -1,5 +0,0 @@ -Install the traditional FreeBSD -.Xr bc 1 -and -.Xr dc 1 -programs instead of the enhanced versions. diff --git a/usr.bin/Makefile b/usr.bin/Makefile index 3cd91f8019e3..9baa90aab499 100644 --- a/usr.bin/Makefile +++ b/usr.bin/Makefile @@ -207,12 +207,7 @@ SUBDIR.${MK_GAMES}+= number SUBDIR.${MK_GAMES}+= pom SUBDIR.${MK_GAMES}+= primes SUBDIR.${MK_GAMES}+= random -.if ${MK_GH_BC} == "yes" SUBDIR+= gh-bc -.else -SUBDIR.${MK_OPENSSL}+= bc -SUBDIR.${MK_OPENSSL}+= dc -.endif .if ${MK_GNU_DIFF} == "no" SUBDIR+= diff3 .endif diff --git a/usr.bin/bc/Makefile b/usr.bin/bc/Makefile deleted file mode 100644 index 098308b4604b..000000000000 --- a/usr.bin/bc/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# $OpenBSD: Makefile,v 1.7 2013/09/19 16:12:00 otto Exp $ - -PROG= bc -SRCS= bc.y scan.l tty.c -CFLAGS+= -I. -I${.CURDIR} - -LIBADD= edit - -NO_WMISSING_VARIABLE_DECLARATIONS= - -FILES+= bc.library -FILESDIR=${SHAREDIR}/misc - -.include <bsd.prog.mk> diff --git a/usr.bin/bc/Makefile.depend b/usr.bin/bc/Makefile.depend deleted file mode 100644 index 7b1781905d71..000000000000 --- a/usr.bin/bc/Makefile.depend +++ /dev/null @@ -1,17 +0,0 @@ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - lib/libedit \ - usr.bin/yacc.host \ - - -.include <dirdeps.mk> - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.bin/bc/bc.1 b/usr.bin/bc/bc.1 deleted file mode 100644 index 97bb3bf62c56..000000000000 --- a/usr.bin/bc/bc.1 +++ /dev/null @@ -1,413 +0,0 @@ -.\" $OpenBSD: bc.1,v 1.32 2015/11/17 05:45:35 mmcc Exp $ -.\" -.\" Copyright (C) Caldera International Inc. 2001-2002. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code and documentation must retain the above -.\" copyright notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed or owned by Caldera -.\" International, Inc. -.\" 4. Neither the name of Caldera International, Inc. nor the names of other -.\" contributors may be used to endorse or promote products derived from -.\" this software without specific prior written permission. -.\" -.\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA -.\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR -.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -.\" IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT, -.\" INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING -.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd November 21, 2015 -.Dt BC 1 -.Os -.Sh NAME -.Nm bc -.Nd arbitrary-precision arithmetic language and calculator -.Sh SYNOPSIS -.Nm bc -.Op Fl chlv -.Op Fl e Ar expression -.Op Ar file ... -.Sh DESCRIPTION -.Nm -is an interactive processor for a language which resembles -C but provides unlimited precision arithmetic. -It takes input from any expressions on the command line and -any files given, then reads the standard input. -.Pp -Options available: -.Bl -tag -width Ds -.It Fl c -.Nm -is actually a preprocessor for -.Xr dc 1 , -which it invokes automatically, unless the -.Fl c -.Pq compile only -option is present. -In this case the generated -.Xr dc 1 -instructions are sent to the standard output, -instead of being interpreted by a running -.Xr dc 1 -process. -.It Fl e Ar expression , Fl Fl expression Ar expression -Evaluate -.Ar expression . -If multiple -.Fl e -options are specified, they are processed in the order given, -separated by newlines. -.It Fl h , Fl Fl help -Prints usage information. -.It Fl l , Fl Fl mathlib -Allow specification of an arbitrary precision math library. -The definitions in the library are available to command line -expressions. -.It Fl v , Fl Fl version -Prints version information. -.El -.Pp -The syntax for -.Nm -programs is as follows: -.Sq L -means letter a-z; -.Sq E -means expression; -.Sq S -means statement. -As a non-portable extension, it is possible to use long names -in addition to single letter names. -A long name is a sequence starting with a lowercase letter -followed by any number of lowercase letters and digits. -The underscore character -.Pq Sq _ -counts as a letter. -.Pp -Comments -.Bd -unfilled -offset indent -compact -are enclosed in /* and */ -are enclosed in # and the next newline -.Ed -.Pp -The newline is not part of the line comment, -which in itself is a non-portable extension. -.Pp -Names -.Bd -unfilled -offset indent -compact -simple variables: L -array elements: L [ E ] -The words `ibase', `obase', and `scale' -The word `last' or a single dot -.Ed -.Pp -Other operands -.Bd -unfilled -offset indent -compact -arbitrarily long numbers with optional sign and decimal point -( E ) -sqrt ( E ) -length ( E ) number of significant decimal digits -scale ( E ) number of digits right of decimal point -L ( E , ... , E ) -.Ed -.Pp -The sequence -.Sq \e<newline><whitespace> -is ignored within numbers. -.Pp -Operators -.Pp -The following arithmetic and logical operators can be used. -The semantics of the operators is the same as in the C language. -They are listed in order of decreasing precedence. -Operators in the same group have the same precedence. -.Bl -column "= += \-= *= /= %= ^=" "Associativity" "multiply, divide, modulus" -offset indent -.It Sy "Operator" Ta Sy "Associativity" Ta Sy "Description" -.It "++ \-\-" Ta "none" Ta "increment, decrement" -.It "\-" Ta "none" Ta "unary minus" -.It "^" Ta "right" Ta "power" -.It "* / %" Ta "left" Ta "multiply, divide, modulus" -.It "+ \-" Ta "left" Ta "plus, minus" -.It "= += -= *= /= %= ^=" Ta "right" Ta "assignment" -.It "== <= >= != < >" Ta "none" Ta "relational" -.It "!" Ta "none" Ta "boolean not" -.It "&&" Ta "left" Ta "boolean and" -.It "||" Ta "left" Ta "boolean or" -.El -.Pp -Note the following: -.Bl -bullet -offset indent -.It -The relational operators may appear in any expression. -The -.St -p1003.1-2008 -standard only allows them in the conditional expression of an -.Sq if , -.Sq while -or -.Sq for -statement. -.It -The relational operators have a lower precedence than the assignment -operators. -This has the consequence that the expression -.Sy a = b < c -is interpreted as -.Sy (a = b) < c , -which is probably not what the programmer intended. -.It -In contrast with the C language, the relational operators all have -the same precedence, and are non-associative. -The expression -.Sy a < b < c -will produce a syntax error. -.It -The boolean operators (!, && and ||) are non-portable extensions. -.It -The boolean not -(!) operator has much lower precedence than the same operator in the -C language. -This has the consequence that the expression -.Sy !a < b -is interpreted as -.Sy !(a < b) . -Prudent programmers use parentheses when writing expressions involving -boolean operators. -.El -.Pp -Statements -.Bd -unfilled -offset indent -compact -E -{ S ; ... ; S } -if ( E ) S -if ( E ) S else S -while ( E ) S -for ( E ; E ; E ) S -null statement -break -continue -quit -a string of characters, enclosed in double quotes -print E ,..., E -.Ed -.Pp -A string may contain any character, except double quote. -The if statement with an else branch is a non-portable extension. -All three E's in a for statement may be empty. -This is a non-portable extension. -The continue and print statements are also non-portable extensions. -.Pp -The print statement takes a list of comma-separated expressions. -Each expression in the list is evaluated and the computed -value is printed and assigned to the variable `last'. -No trailing newline is printed. -The expression may also be a string enclosed in double quotes. -Within these strings the following escape sequences may be used: -.Sq \ea -for bell (alert), -.Sq \eb -for backspace, -.Sq \ef -for formfeed, -.Sq \en -for newline, -.Sq \er -for carriage return, -.Sq \et -for tab, -.Sq \eq -for double quote and -.Sq \e\e -for backslash. -Any other character following a backslash will be ignored. -Strings will not be assigned to `last'. -.Pp -Function definitions -.Bd -unfilled -offset indent -define L ( L ,..., L ) { - auto L, ... , L - S; ... S - return ( E ) -} -.Ed -.Pp -As a non-portable extension, the opening brace of the define statement -may appear on the next line. -The return statement may also appear in the following forms: -.Bd -unfilled -offset indent -return -return () -return E -.Ed -.Pp -The first two are equivalent to the statement -.Dq return 0 . -The last form is a non-portable extension. -Not specifying a return statement is equivalent to writing -.Dq return (0) . -.Pp -Functions available in the math library, which is loaded by specifying the -.Fl l -flag on the command line -.Pp -.Bl -tag -width j(n,x) -offset indent -compact -.It s(x) -sine -.It c(x) -cosine -.It e(x) -exponential -.It l(x) -log -.It a(x) -arctangent -.It j(n,x) -Bessel function -.El -.Pp -All function arguments are passed by value. -.Pp -The value of a statement that is an expression is printed -unless the main operator is an assignment. -The value printed is assigned to the special variable `last'. -This is a non-portable extension. -A single dot may be used as a synonym for `last'. -Either semicolons or newlines may separate statements. -Assignment to -.Ar scale -influences the number of digits to be retained on arithmetic -operations in the manner of -.Xr dc 1 . -Assignments to -.Ar ibase -or -.Ar obase -set the input and output number radix respectively. -.Pp -The same letter may be used as an array, a function, -and a simple variable simultaneously. -All variables are global to the program. -`Auto' variables are pushed down during function calls. -When using arrays as function arguments -or defining them as automatic variables, -empty square brackets must follow the array name. -.Pp -For example -.Bd -literal -offset indent -scale = 20 -define e(x){ - auto a, b, c, i, s - a = 1 - b = 1 - s = 1 - for(i=1; 1==1; i++){ - a = a*x - b = b*i - c = a/b - if(c == 0) return(s) - s = s+c - } -} -.Ed -.Pp -defines a function to compute an approximate value of -the exponential function and -.Pp -.Dl for(i=1; i<=10; i++) e(i) -.Pp -prints approximate values of the exponential function of -the first ten integers. -.Bd -literal -offset indent -$ bc -l -e 'scale = 500; 2 * a(2^10000)' -e quit -.Ed -.Pp -prints an approximation of pi. -.Sh COMMAND LINE EDITING -.Nm -supports interactive command line editing, via the -.Xr editline 3 -library. -It is enabled by default if input is from a tty. -Previous lines can be recalled and edited with the arrow keys, -and other GNU Emacs-style editing keys may be used as well. -.Pp -The -.Xr editline 3 -library is configured with a -.Pa .editrc -file \- refer to -.Xr editrc 5 -for more information. -.Sh FILES -.Bl -tag -width /usr/share/misc/bc.library -compact -.It Pa /usr/share/misc/bc.library -math library, read when the -.Fl l -option is specified on the command line. -.El -.Sh COMPATIBILITY -The -.Fl q -and -.Fl Fl quiet -options are no-ops for compatibility with some other implementations of -.Nm -and their use is discouraged. -.Sh SEE ALSO -.Xr dc 1 -.Sh STANDARDS -The -.Nm -utility is compliant with the -.St -p1003.1-2008 -specification. -.Pp -The flags -.Op Fl ce , -as well as the parts noted above, -are extensions to that specification. -.Sh HISTORY -The -.Nm -command first appeared in -.At v6 . -A complete rewrite of the -.Nm -command first appeared in -.Ox 3.5 . -.Sh AUTHORS -.An -nosplit -The original version of the -.Nm -command was written by -.An Robert Morris -and -.An Lorinda Cherry . -The current version of the -.Nm -utility was written by -.An Otto Moerbeek . -.Sh BUGS -The -.Ql quit -statement is interpreted when read, not when executed. -.Pp -Some non-portable extensions, as found in the GNU version of the -.Nm -utility are not implemented (yet). diff --git a/usr.bin/bc/bc.library b/usr.bin/bc/bc.library deleted file mode 100644 index 539de20a7e0c..000000000000 --- a/usr.bin/bc/bc.library +++ /dev/null @@ -1,272 +0,0 @@ -/* $OpenBSD: bc.library,v 1.4 2012/03/14 07:35:53 otto Exp $ */ - -/* - * Copyright (C) Caldera International Inc. 2001-2002. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code and documentation must retain the above - * copyright notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed or owned by Caldera - * International, Inc. - * 4. Neither the name of Caldera International, Inc. nor the names of other - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA - * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT, - * INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - */ - -scale = 20 -define e(x) { - auto a, b, c, d, e, g, t, w, y, r - - r = ibase - ibase = A - t = scale - scale = 0 - if (x > 0) scale = (0.435*x)/1 - scale = scale + t + length(scale + t) + 1 - - w = 0 - if (x < 0) { - x = -x - w = 1 - } - y = 0 - while (x > 2) { - x = x/2 - y = y + 1 - } - - a = 1 - b = 1 - c = b - d = 1 - e = 1 - for (a = 1; 1 == 1; a++) { - b = b*x - c = c*a + b - d = d*a - g = c/d - if (g == e) { - g = g/1 - while (y--) { - g = g*g - } - scale = t - ibase = r - if (w == 1) return (1/g) - return (g/1) - } - e = g - } -} - -define l(x) { - auto a, b, c, d, e, f, g, u, s, t, r - r = ibase - ibase = A - if (x <= 0) { - a = (1 - 10^scale) - ibase = r - return (a) - } - t = scale - - f = 1 - if (x < 1) { - s = scale(x) - } else { - s = length(x)-scale(x) - } - scale = 0 - a = (2.31*s)/1 /* estimated integer part of the answer */ - s = t + length(a) + 2 /* estimated length of the answer */ - while (x > 2) { - scale = 0 - scale = (length(x) + scale(x))/2 + 1 - if (scale < s) scale = s - x = sqrt(x) - f = f*2 - } - while (x < .5) { - scale = 0 - scale = scale(x)/2 + 1 - if (scale < s) scale = s - x = sqrt(x) - f = f*2 - } - - scale = 0 - scale = t + length(f) + length((1.05*(t+length(f))/1)) + 1 - u = (x - 1)/(x + 1) - s = u*u - scale = t + 2 - b = 2*f - c = b - d = 1 - e = 1 - for (a = 3; 1 == 1 ; a = a + 2) { - b = b*s - c = c*a + d*b - d = d*a - g = c/d - if (g == e) { - scale = t - ibase = r - return (u*c/d) - } - e = g - } -} - -define s(x) { - auto a, b, c, s, t, y, p, n, i, r - r = ibase - ibase = A - t = scale - y = x/.7853 - s = t + length(y) - scale(y) - if (s < t) s = t - scale = s - p = a(1) - - scale = 0 - if (x >= 0) n = (x/(2*p) + 1)/2 - if (x < 0) n = (x/(2*p) - 1)/2 - x = x - 4*n*p - if (n % 2 != 0) x = -x - - scale = t + length(1.2*t) - scale(1.2*t) - y = -x*x - a = x - b = 1 - s = x - for (i =3 ; 1 == 1; i = i + 2) { - a = a*y - b = b*i*(i - 1) - c = a/b - if (c == 0) { - scale = t - ibase = r - return (s/1) - } - s = s + c - } -} - -define c(x) { - auto t, r - r = ibase - ibase = A - t = scale - scale = scale + 1 - x = s(x + 2*a(1)) - scale = t - ibase = r - return (x/1) -} - -define a(x) { - auto a, b, c, d, e, f, g, s, t, r - if (x == 0) return(0) - - r = ibase - ibase = A - if (x == 1) { - if (scale < 52) { - a = .7853981633974483096156608458198757210492923498437764/1 - ibase = r - return (a) - } - } - t = scale - f = 1 - while (x > .5) { - scale = scale + 1 - x = -(1 - sqrt(1. + x*x))/x - f = f*2 - } - while (x < -.5) { - scale = scale + 1 - x = -(1 - sqrt(1. + x*x))/x - f = f*2 - } - s = -x*x - b = f - c = f - d = 1 - e = 1 - for (a = 3; 1 == 1; a = a + 2) { - b = b*s - c = c*a + d*b - d = d*a - g = c/d - if (g == e) { - ibase = r - scale = t - return (x*c/d) - } - e = g - } -} - -define j(n,x) { - auto a, b, c, d, e, g, i, s, k, t, r - - r = ibase - ibase = A - t = scale - k = 1.36*x + 1.16*t - n - k = length(k) - scale(k) - if (k > 0) scale = scale + k - - s = -x*x/4 - if (n < 0) { - n = -n - x = -x - } - a = 1 - c = 1 - for (i = 1; i <= n; i++) { - a = a*x - c = c*2*i - } - b = a - d = 1 - e = 1 - for (i = 1; 1; i++) { - a = a*s - b = b*i*(n + i) + a - c = c*i*(n + i) - g = b/c - if (g == e) { - ibase = r - scale = t - return (g/1) - } - e = g - } -} -/* vim: set filetype=bc shiftwidth=8 noexpandtab: */ diff --git a/usr.bin/bc/bc.y b/usr.bin/bc/bc.y deleted file mode 100644 index c270330281a8..000000000000 --- a/usr.bin/bc/bc.y +++ /dev/null @@ -1,1214 +0,0 @@ -%{ -/* $OpenBSD: bc.y,v 1.46 2014/10/14 15:35:18 deraadt Exp $ */ - -/* - * Copyright (c) 2003, Otto Moerbeek <otto@drijf.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* - * This implementation of bc(1) uses concepts from the original 4.4 - * BSD bc(1). The code itself is a complete rewrite, based on the - * Posix defined bc(1) grammar. Other differences include type safe - * usage of pointers to build the tree of emitted code, typed yacc - * rule values, dynamic allocation of all data structures and a - * completely rewritten lexical analyzer using lex(1). - * - * Some effort has been made to make sure that the generated code is - * the same as the code generated by the older version, to provide - * easy regression testing. - */ - -#include <sys/types.h> -#include <sys/wait.h> - -#include <ctype.h> -#include <err.h> -#include <errno.h> -#include <getopt.h> -#include <histedit.h> -#include <limits.h> -#include <search.h> -#include <signal.h> -#include <stdarg.h> -#include <string.h> -#include <unistd.h> -#include <stdlib.h> - -#include "extern.h" -#include "pathnames.h" - -#define BC_VER "1.1-FreeBSD" -#define END_NODE ((ssize_t) -1) -#define CONST_STRING ((ssize_t) -2) -#define ALLOC_STRING ((ssize_t) -3) - -extern char *yytext; -extern FILE *yyin; - -struct tree { - union { - char *astr; - const char *cstr; - } u; - ssize_t index; *** 5631 LINES SKIPPED ***