--- bc-1.06.94.orig/bc/load.c +++ bc-1.06.94/bc/load.c @@ -217,6 +217,7 @@ if (label_no > 65535L) { /* Better message? */ fprintf (stderr,"Program too big.\n"); + checkferror_output(stderr); exit(1); } addbyte ( (char) (label_no & 0xFF)); --- bc-1.06.94.orig/bc/execute.c +++ bc-1.06.94/bc/execute.c @@ -108,6 +108,7 @@ } out_char ('\n'); } + checkferror_output(stdout); } #endif @@ -222,6 +223,7 @@ } } fflush (stdout); + checkferror_output(stdout); break; case 'R' : /* Return from function */ @@ -257,6 +259,7 @@ if (inst == 'W') out_char ('\n'); store_var (4); /* Special variable "last". */ fflush (stdout); + checkferror_output(stdout); pop (); break; @@ -338,6 +341,7 @@ case 'w' : /* Write a string to the output. */ while ((ch = byte(&pc)) != '"') out_schar (ch); fflush (stdout); + checkferror_output(stdout); break; case 'x' : /* Exchange Top of Stack with the one under the tos. */ @@ -545,7 +549,10 @@ { signal (SIGINT, use_quit); if (had_sigint) - printf ("\ninterrupted execution.\n"); + { + printf ("\ninterrupted execution.\n"); + checkferror_output(stdout); + } } } @@ -580,6 +587,7 @@ out_col = 0; /* Saw a new line */ } } + checkferror_input(stdin); /* Classify and preprocess the input character. */ if (isdigit(in_ch)) --- bc-1.06.94.orig/bc/scan.c +++ bc-1.06.94/bc/scan.c @@ -799,6 +799,7 @@ if (bcel_len != 0) history (hist, &histev, H_ENTER, bcel_line); fflush (stdout); + checkferror_output(stdout); } if (bcel_len <= max) @@ -874,6 +875,7 @@ add_history (rl_line); rl_line[rl_len-1] = '\n'; fflush (stdout); + checkferror_output(stdout); } if (rl_len <= max) --- bc-1.06.94.orig/bc/sbc.y +++ bc-1.06.94/bc/sbc.y @@ -86,7 +86,9 @@ if (interactive && !quiet) { show_bc_version (); + checkferror_output(stdout); welcome (); + checkferror_output(stdout); } } | program input_item --- bc-1.06.94.orig/bc/main.c +++ bc-1.06.94/bc/main.c @@ -354,11 +354,17 @@ #ifdef DONTEXIT int save = errno; write (1, "\n(interrupt) use quit to exit.\n", 31); +#ifdef READLINE + rl_initialize (); /* Clear readline buffer */ +#endif +#ifdef LIBEDIT + el_reset (edit); /* Clear editline buffer */ +#endif signal (SIGINT, use_quit); errno = save; #else write (1, "\n(interrupt) Exiting bc.\n", 26); -#if defined(LIBEDIT) +#ifdef LIBEDIT if (edit != NULL) el_end(edit); #endif --- bc-1.06.94.orig/bc/util.c +++ bc-1.06.94/bc/util.c @@ -260,9 +260,10 @@ continue_label = 0; next_label = 1; out_count = 2; - if (compile_only) + if (compile_only) { printf ("@i"); - else + checkferror_output(stdout); + } else init_load (); had_error = FALSE; did_gen = FALSE; @@ -286,6 +287,7 @@ printf ("\n"); out_count = 0; } + checkferror_output(stdout); } else load_code (str); @@ -303,6 +305,7 @@ if (compile_only) { printf ("@r\n"); + checkferror_output(stdout); out_count = 0; } else @@ -341,6 +344,7 @@ } putchar (ch); } + checkferror_output(stdout); } /* Output routines: Write a character CH to the standard output. @@ -371,6 +375,7 @@ } putchar (ch); } + checkferror_output(stdout); } @@ -656,6 +661,7 @@ #ifdef OLD_EQ_OP printf ("Old assignment operatiors are valid. (=-, =+, ...)\n"); #endif + checkferror_output(stdout); } /* bc_malloc will check the return value so all other places do not @@ -720,6 +726,7 @@ fprintf (stderr,"%s %d: ",name,line_no); vfprintf (stderr, str, args); fprintf (stderr, "\n"); + checkferror_output(stderr); had_error = TRUE; va_end (args); } @@ -760,6 +767,7 @@ fprintf (stderr,"%s %d: Error: ",name,line_no); vfprintf (stderr, mesg, args); fprintf (stderr, "\n"); + checkferror_output(stderr); had_error = TRUE; } else @@ -772,6 +780,7 @@ fprintf (stderr,"%s %d: (Warning) ",name,line_no); vfprintf (stderr, mesg, args); fprintf (stderr, "\n"); + checkferror_output(stderr); } va_end (args); } @@ -806,6 +815,7 @@ va_end (args); fprintf (stderr, "\n"); + checkferror_output(stderr); runtime_error = TRUE; } @@ -842,4 +852,5 @@ va_end (args); fprintf (stderr, "\n"); + checkferror_output(stderr); } --- bc-1.06.94.orig/bc/y.tab.h +++ bc-1.06.94/bc/y.tab.h @@ -0,0 +1,137 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + ENDOFLINE = 258, + AND = 259, + OR = 260, + NOT = 261, + STRING = 262, + NAME = 263, + NUMBER = 264, + ASSIGN_OP = 265, + REL_OP = 266, + INCR_DECR = 267, + Define = 268, + Break = 269, + Quit = 270, + Length = 271, + Return = 272, + For = 273, + If = 274, + While = 275, + Sqrt = 276, + Else = 277, + Scale = 278, + Ibase = 279, + Obase = 280, + Auto = 281, + Read = 282, + Random = 283, + Warranty = 284, + Halt = 285, + Last = 286, + Continue = 287, + Print = 288, + Limits = 289, + UNARY_MINUS = 290, + HistoryVar = 291, + Void = 292 + }; +#endif +/* Tokens. */ +#define ENDOFLINE 258 +#define AND 259 +#define OR 260 +#define NOT 261 +#define STRING 262 +#define NAME 263 +#define NUMBER 264 +#define ASSIGN_OP 265 +#define REL_OP 266 +#define INCR_DECR 267 +#define Define 268 +#define Break 269 +#define Quit 270 +#define Length 271 +#define Return 272 +#define For 273 +#define If 274 +#define While 275 +#define Sqrt 276 +#define Else 277 +#define Scale 278 +#define Ibase 279 +#define Obase 280 +#define Auto 281 +#define Read 282 +#define Random 283 +#define Warranty 284 +#define Halt 285 +#define Last 286 +#define Continue 287 +#define Print 288 +#define Limits 289 +#define UNARY_MINUS 290 +#define HistoryVar 291 +#define Void 292 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 54 "bc.y" +{ + char *s_value; + char c_value; + int i_value; + arg_list *a_value; + } +/* Line 1489 of yacc.c. */ +#line 130 "y.tab.h" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + +extern YYSTYPE yylval; + --- bc-1.06.94.orig/bc/scan.l +++ bc-1.06.94/bc/scan.l @@ -111,6 +111,7 @@ if (bcel_len != 0) history (hist, &histev, H_ENTER, bcel_line); fflush (stdout); + checkferror_output(stdout); } if (bcel_len <= max) @@ -186,6 +187,7 @@ add_history (rl_line); rl_line[rl_len-1] = '\n'; fflush (stdout); + checkferror_output(stdout); } if (rl_len <= max) @@ -310,6 +312,7 @@ if (c == EOF) { fprintf (stderr,"EOF encountered in a comment.\n"); + checkferror_output(stderr); break; } } --- bc-1.06.94.orig/debian/changelog +++ bc-1.06.94/debian/changelog @@ -0,0 +1,468 @@ +bc (1.06.94-3.1ubuntu2) karmic; urgency=low + + * Build against libreadline-dev. + + -- Matthias Klose Sat, 19 Sep 2009 22:09:09 +0200 + +bc (1.06.94-3.1) unstable; urgency=low + + * Non-maintainer upload with John's permission. + * Apply patch to restore the .dcrc config file (closes: #472250) + * Merge patch from Ubuntu to notice read and write errors on + input and output (closes: #488735) + * Include the bc manual (HTML) in the bc binary package + + * Bump Standards Version to 3.8.1 + * Bump debhelper compatibility to 7 + * debian/rules: replace "dh_clean -k" with "dh_prep" + * debian/control: Add homepage field + * Fix hyphens in the bc and dc manpages + * Add a watch file + * debian/dc.doc-base: Remove leading whitespace + * debian/dc.doc-base: Move to section Science/Mathematics + + -- Francois Marier Thu, 16 Apr 2009 10:23:39 +1200 + +bc (1.06.94-3) unstable; urgency=low + + * Added "-pbc" to dh_installdirs line for bc in debian/rules. + Fixes build failure with "-j3". + + -- John Hasler Sun, 02 Dec 2007 14:46:56 -0600 + +bc (1.06.94-2) unstable; urgency=low + + * Uncommented dh_md5sums in debian/rules. + + * Corrected menu entries. + + -- John Hasler Fri, 05 Oct 2007 12:29:18 -0500 + +bc (1.06.94-1) unstable; urgency=low + + * New upstream release + + Code cleanup upstream has fixed these + Closes: #357728: bc: Segfaults + Closes: #221781: dc: precision >= 1000000000 does not work + Closes: #429156: dc: segfaults when generating primes + Closes: #296232: dc directory' should print an error + Closes: #301921: 'man bc' typos: "environent", "specifing" + + * Patched use_quit() in main.c to run rl_initialize(). + Closes: #287210: bc: Interrupt should reset the input line + + * BC_LINE_LENGTH=0 disables the multi-line feature. + Closes: #245899: bc: BC_LINE_LENGTH=0 or similar for ``do never split'' + should be added, or the manpage should be fixed + + * Upstream says this in correct POSIX behavior. + Closes: #388487: bc: scale strangeness + + * Applied patch from Justin Pryzby. + Closes: #374818: dc: maintscript prerm arguments + + * Remove '-s' from calls to install in debian/rules. Fixes both bc and dc. + Closes: #436578: bc: not handling nostrip build option (policy 10.1) sid/i386 + + * Upstream has removed the '-E' option. + Closes: #389345: dc: man page formatting bug + + * Added -DDONTEXIT to debian/rules as it is not the default. + + * Man page typos fixed upstream. + + * Added home page (such as it is) to descriptions. + + * Fixed make distclean call in debian/rules. + + -- John Hasler Thu, 23 Aug 2007 15:18:09 -0500 + +bc (1.06-20) unstable; urgency=low + + * Had already fixed menu titles but failed to close the bug. + Closes: #320605: Conformance with menu policy + + * Also had fixed typos. + Closes: #301921: 'man bc' typos: "environent", "specifing" + + -- John Hasler Sat, 7 Oct 2006 10:45:18 -0500 + +bc (1.06-19) unstable; urgency=low + + * Fixed libreadline dependency. + Closes: #326385: please rebuild with libreadline5-dev as build dependency + + -- John Hasler Thu, 17 Nov 2005 15:41:52 -0600 + +bc (1.06-18) unstable; urgency=low + + * Corrected link in copyright file. + + * Fixed capitalization in menu titles. + Closes: #320605: Conformance with menu policy + + -- John Hasler Sun, 28 Aug 2005 18:36:46 -0500 + +bc (1.06-17) unstable; urgency=low + + * New maintainer. + + -- John Hasler Sat, 15 Jan 2005 18:20:00 -0600 + +bc (1.06-16) unstable; urgency=low + + * debian/rules: Applied patch by NIIBE Yutaka to + distinguish between GNU types build and host (Closes: #285304) + + -- Dirk Eddelbuettel Sun, 19 Dec 2004 18:08:47 -0600 + +bc (1.06-15) unstable; urgency=low + + * configure.in: Patch was supposed to be '-I -8' (Closes: #237957) + * Also ran autoconf2.50 to re-create configure + + -- Dirk Eddelbuettel Thu, 29 Apr 2004 20:54:22 -0500 + +bc (1.06-14) unstable; urgency=low + + * configure.in: Applied patch by Andreas Jochens to invoke flex + with argument '-I 8' instead of '-I8' (Closes: #237957) + + -- Dirk Eddelbuettel Mon, 26 Apr 2004 19:55:50 -0500 + +bc (1.06-13) unstable; urgency=low + + * bc/bc.y: Apply patch by Matt Kraai to fix flex issues (Closes: #236991) + * debian/control: Upgraded to Standards-Version: 3.6.1 + * debian/dc.menu: Quoted one more argument (thanks, lintian) + + -- Dirk Eddelbuettel Wed, 10 Mar 2004 21:34:02 -0600 + +bc (1.06-12) unstable; urgency=low + + * configure.in: Avoid time skew via AM_MAINTAINER_MODE (Closes: #208195) + * {bc,dc,lib}/Makefile.am: s/CFLAGS/AM_CFLAGS/,s/YFLAGS/AM_YFLAGS/ + * Ran 'aclocal; autoconf; automake-1.7 --gnu --add-missing --copy' + * doc/bc.1: Patch by N. Francois with two minor corrections (Closes: #215292) + + -- Dirk Eddelbuettel Tue, 14 Oct 2003 20:43:21 -0500 + +bc (1.06-11) unstable; urgency=low + + * doc/dc.{1,texi}: Applied upstream patch by Ken Pizzini (Closes: #100344) + + -- Dirk Eddelbuettel Mon, 12 May 2003 16:01:32 -0500 + +bc (1.06-10) unstable; urgency=low + + * dc/{dc.c,eval.c,dc-proto.h}: Added new upstream patch by Ken Pizzini + which fixes one old and one new bug report(Closes: #135029, #191663) + * dc/dc.c: Corrected function argument to pointer to string + * debian/control: Increased Standards-Version to 3.5.9 + * debian/dc_factor: New example script + + -- Dirk Eddelbuettel Fri, 9 May 2003 20:20:29 -0500 + +bc (1.06-9) unstable; urgency=low + + * dc/dc.c, doc/dc.1: Applied patch by Terran Melconian + for an additional command-line argument, + and rc file handling; also forwarded upstream (Closes: #167274) + + -- Dirk Eddelbuettel Fri, 1 Nov 2002 23:51:51 -0600 + +bc (1.06-8) unstable; urgency=low + + * debian/control: Priority changed to standard as per overrides file + * debian/control: Standards-Version upgraded to 3.5.0 + * debian/copyright: Debian/GNU Linux typo fix (lintian) + + -- Dirk Eddelbuettel Sat, 13 Apr 2002 11:33:49 -0500 + +bc (1.06-7) unstable; urgency=low + + * bc/scan.l, bc/scan.c: Commented out three declarations that are now + also in libreadline 4.2; mini-patch sent upstream (Closes: #100178) + + -- Dirk Eddelbuettel Sat, 9 Jun 2001 06:03:33 -0500 + +bc (1.06-6) unstable; urgency=low + + * The "surprise, another build-depends bug" upload + * debian/control: Added bison to Build-Depends (Closes: #86977) + + -- Dirk Eddelbuettel Thu, 22 Feb 2001 20:43:44 -0600 + +bc (1.06-5) unstable; urgency=low + + * The "there's yet another in the pipeline" revisions + * bc/bc.y: Another small patch from upstream + + -- Dirk Eddelbuettel Mon, 19 Feb 2001 20:05:31 -0600 + +bc (1.06-4) unstable; urgency=low + + * The "Let's make it three uploads in twenty-four hours" revisison + * debian/control: Added file, flex, texinfo, libreadline4-dev (Closes: #86593) + + -- Dirk Eddelbuettel Mon, 19 Feb 2001 08:26:45 -0600 + +bc (1.06-3) unstable; urgency=low + + * bc/load.c: Another small patch from upstream + + -- Dirk Eddelbuettel Sun, 18 Feb 2001 23:04:08 -0600 + +bc (1.06-2) unstable; urgency=low + + * bc/main.c: Applied modified patch from the upstream and CVSh, supplied + in response the to the bug supplied with the bug report (Closes: #86425) + + -- Dirk Eddelbuettel Sun, 18 Feb 2001 10:06:05 -0600 + +bc (1.06-1) unstable; urgency=low + + * Upgraded to new upstream release 1.06 (Closes: #82207) + + -- Dirk Eddelbuettel Sun, 14 Jan 2001 23:03:26 -0600 + +bc (1.05a-13) unstable; urgency=low + + * debian/control: Build-Depends on texi2html, not tetex-bin (Closes: #81196) + + -- Dirk Eddelbuettel Thu, 4 Jan 2001 20:38:12 -0600 + +bc (1.05a-12) unstable; urgency=low + + * debian/control: Added Build-Depends + * debian/dc.menu: Added hints="Calculator" (Closes: #80012) + * debian/bc.menu: Added hints="Calculator" (Closes: #80050) + + -- Dirk Eddelbuettel Tue, 19 Dec 2000 22:09:44 -0600 + +bc (1.05a-11) frozen; urgency=low + + * Argh, 1.05a-10 was meant for frozen - this really closes #57908. + + -- Dirk Eddelbuettel Sun, 13 Feb 2000 17:05:49 -0500 + +bc (1.05a-10) unstable; urgency=low + + * Rebuilt against libreadline4 (Closes: #57908) + + -- Dirk Eddelbuettel Sun, 13 Feb 2000 00:17:31 -0500 + +bc (1.05a-9) unstable; urgency=low + + * Applied upstream patch by Ken Pizzini to correct the + dc.1 manual page (Closes: #48881) + + -- Dirk Eddelbuettel Wed, 3 Nov 1999 22:10:33 -0500 + +bc (1.05a-8) unstable; urgency=low + + * Applied another upstream patch by Phil Nelson ; this + one improves the cosine and cosine and bessel functions + + * debian/rules: make sure we link bc with readline (Closes: #46535) + + -- Dirk Eddelbuettel Sun, 3 Oct 1999 17:00:38 -0400 + +bc (1.05a-7) unstable; urgency=low + + * Applied new upstream patch by Phil Nelson to improve + the raise operation. Thanks to Aaron Digulla for the + report. + + * debian/rules: Adapted to use /usr/share/ following the recommendation + on FHS transition from the Technical Committee + * debian/rules: Test for debhelper >= 2.0.40 for FHS compliance + * debian/control: Upgraded to Debian Policy 3.0.1 + + -- Dirk Eddelbuettel Sat, 2 Oct 1999 09:14:41 -0400 + +bc (1.05a-6) unstable; urgency=low + + * debian/control: Actually changed maintainer name + + -- Dirk Eddelbuettel Fri, 4 Jun 1999 22:54:45 -0400 + +bc (1.05a-5) unstable; urgency=low + + * New maintainer + * debian/rules: Converted to debhelper + * debian/*: Added doc-base support for dc + * debian/{bc,dc}.{post,pre}{inst,rm}: Cosmetic changes + + -- Dirk Eddelbuettel Fri, 28 May 1999 23:47:40 -0400 + +bc (1.05a-4) unstable; urgency=low + + * debian/control (Standards-Version): updated to 2.5.0.0. + * configure.in: changed test for readline to use READLINELIB and not + LIBS so we can link just bc with readline (as dc doesn't use it). + [#31473] + * bc/Makefile.am (LDADD): add @READLINELIB@. + + -- James Troup Sat, 16 Jan 1999 15:19:32 +0000 + +bc (1.05a-3) frozen unstable; urgency=high + + * bc/scan.l (rl_len): int not char, to allow input > 128 characters in + length without crashing. Reported by Wakko Warner + , Jeff Noxon and Camm + Maguire . [#23304, #24113, #27731] + + -- James Troup Mon, 9 Nov 1998 02:45:00 +0000 + +bc (1.05a-2) unstable; urgency=low + + * debian/control (Maintainer): new address. + * debian/copyright: ditto. + * Recompile with ncurses4. + + -- James Troup Fri, 23 Oct 1998 18:27:44 +0100 + +bc (1.05a-1) unstable; urgency=low + + * New upstream version. + * debian/control (Standards-Version): updated to 2.4.1.0. + + -- James Troup Tue, 30 Jun 1998 00:54:37 +0200 + +bc (1.04-4) unstable; urgency=low + + * debian/copyright: correct the FSF's address. + * debian/copyright: refer to bc source package, not hello. + * debian/control (Standards-Version): updated to 2.4.0.0. + + -- James Troup Mon, 2 Mar 1998 18:10:02 +0000 + +bc (1.04-3) unstable; urgency=low + + * Uses pristine upstream source. + * Added menu entries. + * debian/control: Updated Standards-Version to 2.3.0.1. + * debian/control: Shortened dc's long description. + * debian/rules: No longer uses {,}. + * debian/rules: Compile with -g and -Wall. + * debian/rules: Split binary-arch into binary-bc and binary-dc. + * debian/rules: Lots of other minor changes. + * bc/scan.l: Don't use readline when not interactive. (Patch from + Andreas Schwab). This fixes the problem of bc echoing it's input + when used in a pipe [#16069] + * Test/timetest: correct location of bc. (Patch from Karl Heuer) + * lib/number.c: Fix for broken sqrt function. (Patch from Phil Nelson) + + -- James Troup Mon, 29 Dec 1997 19:34:45 +0000 + +bc (1.04-2) unstable; urgency=low + + * Rebuilt with libc6. + * Compiled with readline. + + -- James Troup Mon, 30 Jun 1997 01:21:23 +0100 + +bc (1.04-1) unstable; urgency=low + + * New upstream release. + + -- James Troup Wed, 30 Apr 1997 17:18:39 +0100 + +bc (1.03-14) unstable; urgency=low + + * Made bc flush its output unconditionally (bug #6986). + + -- James Troup Thu, 13 Feb 1997 16:56:49 +0000 + +bc (1.03-13) unstable; urgency=low + + * Corrected location of example files (bug #7041). + + -- James Troup Mon, 3 Feb 1997 02:50:29 +0000 + +bc (1.03-12) unstable; urgency=low + + * Corrected priority (optional -> important). + + -- James Troup Fri, 31 Jan 1997 00:59:11 +0000 + +bc (1.03-11) unstable; urgency=low + + * New maintainer. + * Updated to Standards-Version 2.1.1.2. + * Included Austin Donnelly's fix for bug #6463. + * Fixed dc.1 so mandb can parse it (bug #4991). + + -- James Troup Thu, 30 Jan 1997 04:07:04 +0000 + +Changes for bc-1.03-10: + elf package + * added dependency on libc5 + +Changes for bc-1.03-9: + * rebuilt for elf + +Changes for bc-1.03-8: + +Priority: Routine +Changes: Various administrative changes + changed extended description for the bc package to the one used by GNU. + renamed source package debian.* files + added SECTON field to control files + added /usr/doc/dc with dc.texinfo man Makefile + +Changes for bc-1.03-7: + +1. Fixed problem with debian.rules sed invocation for debian.control + +2. Remove several files created by the build in debian.rules clean: + +Changes for bc-1.03-6: + +1. Cleaned up control file descriptions and extended descriptions. + +Changes for bc-1.03-5: + +1. Changed mode of man pages from 755 to 644 + +Changes for bc-1.03-4: + +1. In debian.rules, added code to fix broken "orig" target. + (This was most likely broken by my bc-1.03-3 changes) (??) + +Changes for bc-1.03-3: + +1. In debian.rules: + + Changed the "d = 2" to "d = 3" to change the bc-1.03- + line in the control files from 2 to 3. + + Changed references to source package files control.bc and + control.dc to pre-pend "debian." to those names. + + Changed references to source package files control.bc and + control.dc to pre-pend "debian." to those names. + + Changed references to source package files postinst.dc and + postrm.dc to pre-pend "debian." to those names. + + Added dependency on clean to source and diff targets. + + Moved "make distclean" to the last action in the clean target + to prevent a failure here from aborting the preceeding cleanup. + +2. Renamed files + + control.bc to debian.control.bc + control.dc to debian.control.bc + postinst.dc to debian.postinst.bc + postrm.dc to debian.postrm.bc + +3. In debian.control.* changed maintainer name. + +This file documents changes since maintenamce of this package +was taken over by Bill Mitchell +beginning with bc-1.03-3. + --- bc-1.06.94.orig/debian/menu.dc +++ bc-1.06.94/debian/menu.dc @@ -0,0 +1 @@ +?package(units):needs="text" section="Applications/Science/Mathematics" title="Dc" command="dc" --- bc-1.06.94.orig/debian/dc_factor +++ bc-1.06.94/debian/dc_factor @@ -0,0 +1,17 @@ +#!/bin/sh +# +# Example taken from http://www.cs.unh.edu/~charpov/Programming/DC/ +# and minimally modified to use dc -e '...' instead of echo '...' | dc +# +# Usage: +# Invoke as 'dc_factor $ARG' and $ARG will be factored +# Example: +# $ ./dc_factor 123456789 +# 3 +# 3 +# 3607 +# 3803 +# +# Dirk Eddelbuettel 09 May 2003 + +dc -e "$1[p]s2[lip/dli%0=1dvsr]s12sid2%0=13sidvsr[dli%0=1lrli2+dsi!>.]ds.xd1<2" --- bc-1.06.94.orig/debian/phil-patch-1 +++ bc-1.06.94/debian/phil-patch-1 @@ -0,0 +1,95 @@ +From: Phil Nelson +To: dia@unix.swx.ch +CC: edd@debian.org, dia@unix.swx.ch +Subject: Re: forwarded message from Aaron Optimizer Digulla +Date: Fri, 1 Oct 1999 11:57:38 -0700 (PDT) + + +Ok, this is a better fix for bc-1.05. It should make solaris bc and GNU bc +calculate the same value with the same math library. Cosine on the GNU bc +is not quite as accurate. I'll fix that soon. + +*** bc1.05/lib/number.c Sun Mar 8 21:21:30 1998 +--- bc1.05.1/lib/number.c Fri Oct 1 11:50:16 1999 +*************** +*** 1082,1087 **** +--- 1082,1088 ---- + bc_num temp, power; + long exponent; + int rscale; ++ int calcscale; + char neg; + + /* Check the exponent for scale digits and convert to a long. */ +*************** +*** 1112,1123 **** + rscale = MIN (num1->n_scale*exponent, MAX(scale, num1->n_scale)); + } + + /* Set initial value of temp. */ + power = copy_num (num1); + while ((exponent & 1) == 0) + { +! bc_multiply (power, power, &power, rscale); + exponent = exponent >> 1; + } + temp = copy_num (power); + exponent = exponent >> 1; +--- 1113,1128 ---- + rscale = MIN (num1->n_scale*exponent, MAX(scale, num1->n_scale)); + } + ++ /* Set calcscale */ ++ calcscale = rscale; ++ + /* Set initial value of temp. */ + power = copy_num (num1); + while ((exponent & 1) == 0) + { +! bc_multiply (power, power, &power, calcscale); + exponent = exponent >> 1; ++ calcscale = 1.55*calcscale; + } + temp = copy_num (power); + exponent = exponent >> 1; +*************** +*** 1126,1135 **** + /* Do the calculation. */ + while (exponent > 0) + { +! bc_multiply (power, power, &power, rscale); + if ((exponent & 1) == 1) +! bc_multiply (temp, power, &temp, rscale); + exponent = exponent >> 1; + } + + /* Assign the value. */ +--- 1131,1141 ---- + /* Do the calculation. */ + while (exponent > 0) + { +! bc_multiply (power, power, &power, calcscale); + if ((exponent & 1) == 1) +! bc_multiply (temp, power, &temp, calcscale); + exponent = exponent >> 1; ++ calcscale = 1.55*calcscale; + } + + /* Assign the value. */ +*************** +*** 1142,1147 **** +--- 1148,1155 ---- + { + free_num (result); + *result = temp; ++ if ((*result)->n_scale > rscale) ++ (*result)->n_scale = rscale; + } + free_num (&power); + } + + +-- +Phil Nelson NetBSD: http://www.netbsd.org +e-mail: phil@cs.wwu.edu Coda: http://www.coda.cs.cmu.edu +http://www.cs.wwu.edu/~phil --- bc-1.06.94.orig/debian/dc.postinst +++ bc-1.06.94/debian/dc.postinst @@ -0,0 +1,25 @@ +#!/bin/sh +# +# This is the postinst script for the Debian GNU/Linux dc package +# +# Written by Dirk Eddelbuettel +# Previous versions written by Bill Mitchell, Austin Donnelly and James Troup + +set -e + +#DEBHELPER# + +case "$1" in + configure|abort-remove|abort-deconfigure) + s="General commands" + install-info --quiet --section "$s" "$s" /usr/share/info/dc.info.gz + ;; + + abort-upgrade) + # Nothing to undo + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + ;; +esac --- bc-1.06.94.orig/debian/maintscript.patch +++ bc-1.06.94/debian/maintscript.patch @@ -0,0 +1,64 @@ +--- /var/lib/dpkg/info/dc.prerm 2005-11-17 17:06:48.000000000 -0500 ++++ /tmp/dc.prerm 2006-06-20 21:52:08.000000000 -0400 +@@ -16,18 +16,10 @@ + + + case "$1" in +- remove|upgrade|remove-in-favour|deconfigure-in-favour) +- # +- install-info --quiet --remove dc +- # +-# if command -v install-docs >/dev/null 2>&1 +-# then +-# install-docs -r dc +-# fi ++remove|upgrade|failed-upgrade|deconfigure) ++ install-info --quiet --remove dc + ;; +- failed-upgrade) +- ;; +- *) ++*) + echo "prerm called with unknown argument \`$1'" >&2 + ;; + + + +--- /var/lib/dpkg/info/dc.postinst 2005-11-17 17:06:48.000000000 -0500 ++++ /tmp/dc.postinst 2006-06-20 21:59:43.000000000 -0400 +@@ -20,28 +20,16 @@ + + + case "$1" in +- configure) +- # +- install-info --quiet --section "General commands" "General commands" \ +- /usr/share/info/dc.info.gz +- # +-# if [ -x /usr/bin/update-menus ] +-# then +-# update-menus +-# fi +- # +-# if command -v install-docs >/dev/null 2>&1 +-# then +-# install-docs -i /usr/share/doc-base/dc +-# fi ++ configure|abort-remove|abort-deconfigure) ++ s="General commands" ++ install-info --quiet --section "$s" "$s" /usr/share/info/dc.info.gz + ;; +- abort-upgrade|abort-remove|abort-deconfigure) ++ ++ abort-upgrade) ++ # Nothing to undo + ;; ++ + *) + echo "postinst called with unknown argument \`$1'" >&2 + ;; + esac +- +- +- +- --- bc-1.06.94.orig/debian/bc.doc-base +++ bc-1.06.94/debian/bc.doc-base @@ -0,0 +1,13 @@ +Document: bc +Title: The GNU BC arbitrary precision calculator +Author: Ken Pizzini +Abstract: GNU bc is an interactive algebraic language with arbitrary + precision which follows the POSIX 1003.2 draft standard, with several + extensions including multi-character variable names, an `else' + statement and full Boolean expressions. GNU bc does not require the + separate GNU dc program. +Section: Science/Mathematics + +Format: HTML +Index: /usr/share/doc/bc/bc.html +Files: /usr/share/doc/bc/bc.html --- bc-1.06.94.orig/debian/rules +++ bc-1.06.94/debian/rules @@ -0,0 +1,118 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# debian/rules file for the Debian/GNU bc package +# Copyright 1999 - 2004 by Dirk Eddelbuettel + +package1 = bc +package2 = dc +deb_bc := $(CURDIR)/debian/$(package1) +deb_dc := $(CURDIR)/debian/$(package2) + +DEB_BUILD_GNU_TYPE = $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) +DEB_HOST_GNU_TYPE = $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) +ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE)) +CONFARGS = --host=$(DEB_HOST_GNU_TYPE) +endif + +#export DH_VERBOSE=1 + + +build: build-stamp +build-stamp: + dh_testdir + ./configure --prefix=/usr --with-readline $(CONFARGS) + $(MAKE) CFLAGS="-O2 -g -Wall -D_POSIX_SOURCE -DDOT_IS_LAST -DDONTEXIT" + (cd doc; texi2html -monolithic -expandinfo -number $(package1).texi) + (cd doc; texi2html -monolithic -expandinfo -number $(package2).texi) + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp install-stamp + [ ! -f Makefile ] || $(MAKE) distclean + dh_clean config.log confdefs.h doc/dc.html doc/bc.html + +install: install-stamp +install-stamp: build-stamp + dh_testdir + dh_testroot + dh_prep + dh_installdirs + # Add here commands to install the package into debian/tmp. + #$(MAKE) prefix=`pwd`/debian/tmp/usr install +# dh_movefiles + touch install-stamp + +binary-indep: build install + +binary-arch: build binary-arch-bc binary-arch-dc + +binary-arch-bc: + + dh_testdir -pbc + dh_prep + dh_installdirs -pbc usr/bin + dh_testroot -pbc + install -p -m 0755 bc/bc $(deb_bc)/usr/bin/. + dh_installdocs -pbc NEWS README AUTHORS \ + doc/bc.html + dh_installexamples -pbc Examples/* + dh_installmenu -pbc +# dh_installemacsen -pbc +# dh_installinit -pbc +# dh_installcron -pbc + dh_installman -pbc doc/bc.1 +# dh_undocumented + dh_installchangelogs -pbc ChangeLog + dh_strip -pbc + dh_link -pbc + dh_compress -pbc + dh_fixperms -pbc + # You may want to make some executables suid here. +# dh_suidregister -pbc + dh_installdeb -pbc +# dh_makeshlibs -pbc + dh_shlibdeps -pbc + dh_gencontrol -pbc + dh_md5sums -pbc + dh_builddeb -pbc + +binary-arch-dc: + + dh_testdir -pdc + dh_prep + dh_installdirs -pdc usr/bin usr/share/info + dh_testroot -pdc + install -p -m 0755 dc/dc $(deb_dc)/usr/bin/. + install -p -m 0644 doc/dc.info $(deb_dc)/usr/share/info/. + dh_installdocs -pdc NEWS README AUTHORS \ + doc/dc.html + dh_installexamples -pdc debian/dc_factor + dh_installmenu -pdc +# dh_installemacsen -pdc +# dh_installinit -pdc +# dh_installcron -pdc + dh_installman -pdc doc/dc.1 +# dh_undocumented + dh_installchangelogs -pdc ChangeLog + dh_strip -pdc + dh_link -pdc + dh_compress -pdc + dh_fixperms -pdc + # You may want to make some executables suid here. +# dh_suidregister -pdc + dh_installdeb -pdc +# dh_makeshlibs -pdc + dh_shlibdeps -pdc + dh_gencontrol -pdc + dh_md5sums -pdc + dh_builddeb -pdc + +source diff: + @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install + + --- bc-1.06.94.orig/debian/menu.bc +++ bc-1.06.94/debian/menu.bc @@ -0,0 +1 @@ +?package(units):needs="text" section="Applications/Science/Mathematics" title="Bc" command="bc" --- bc-1.06.94.orig/debian/dc.postrm +++ bc-1.06.94/debian/dc.postrm @@ -0,0 +1,22 @@ +#! /bin/sh +# +# This is the postrm script for the Debian GNU/Linux dc package +# +# Written by Dirk Eddelbuettel +# Previous versions written by Bill Mitchell, Austin Donnelly and James Troup + +set -e + +#DEBHELPER# + +case "$1" in + purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) +# if [ -x /usr/bin/update-menus ] +# then +# update-menus +# fi + ;; + *) + echo "postrm called with unknown argument \`$1'" >&2 + ;; +esac --- bc-1.06.94.orig/debian/dc.menu +++ bc-1.06.94/debian/dc.menu @@ -0,0 +1 @@ +?package(dc):needs="text" title="Dc" section="Applications/Science/Mathematics" hints="Calculators" command="/usr/bin/dc" --- bc-1.06.94.orig/debian/dc.1.patch +++ bc-1.06.94/debian/dc.1.patch @@ -0,0 +1,74 @@ +--- bc-1.05/doc/dc.1 Tue Sep 15 20:08:18 1998 ++++ bc-1.05+/doc/dc.1 Tue Nov 2 21:56:04 1999 +@@ -2,7 +2,7 @@ + .\" dc.1 - the *roff document processor source for the dc manual + .\" + .\" This file is part of GNU dc. +-.\" Copyright (C) 1994, 1997, 1998 Free Software Foundation, Inc. ++.\" Copyright (C) 1994, 1997, 1998, 1999 Free Software Foundation, Inc. + .\" + .\" This program is free software; you can redistribute it and/or modify + .\" it under the terms of the GNU General Public License as published by +@@ -24,7 +24,10 @@ + .SH NAME + dc \- an arbitrary precision calculator + .SH SYNOPSIS +-dc ++dc [-V] [--version] [-h] [--help] ++ [-e scriptexpression] [--expression=scriptexpression] ++ [-f scriptfile] [--file=scriptfile] ++ [file ...] + .SH DESCRIPTION + .PP + \*(Dc is a reverse-polish desk calculator which supports +@@ -52,6 +55,43 @@ + To enter two numbers in succession, + separate them with spaces or newlines. + These have no meaning as commands. ++.SH OPTIONS ++\*(Dc may be invoked with the following command-line options: ++.TP ++.B -V ++.TP ++.B --version ++Print out the version of \*(dc that is being run and a copyright notice, ++then exit. ++.TP ++.B -h ++.TP ++.B --help ++Print a usage message briefly summarizing these command-line options ++and the bug-reporting address, ++then exit. ++.TP ++.B -e \fIscript\fP ++.TP ++.BI --expression= script ++Add the commands in ++.I script ++to the set of commands to be run while processing the input. ++.TP ++.B -f \fIscript-file\fP ++.TP ++.BI --file= script-file ++Add the commands contained in the file ++.I script-file ++to the set of commands to be run while processing the input. ++.PP ++If any command-line parameters remain after processing the above, ++these parameters are interpreted as the names of input files to ++be processed. ++A file name of ++.B - ++refers to the standard input stream. ++The standard input will processed if no file names are specified. + .PD + .SH + Printing Commands +@@ -443,5 +483,5 @@ + BUGS + .PP + Email bug reports to +-.BR bug-gnu-utils@prep.ai.mit.edu . ++.BR bug-gnu-utils@gnu.org . + Be sure to include the word ``dc'' somewhere in the ``Subject:'' field. --- bc-1.06.94.orig/debian/copyright +++ bc-1.06.94/debian/copyright @@ -0,0 +1,60 @@ +This is Debian GNU/Linux's prepackaged version of the FSF's GNU bc and dc +utilities. GNU bc is an interactive algebraic language with arbitrary +precision. GNU dc is a reverse-polish desk calculator which supports +unlimited precision arithmetic. bc was written by Phil Nelson, Ken Pizzini +wrote dc. + +bc was previously maintained by Bill Mitchell, Austin Donnelly and James +Troup. The current package was put together by Dirk Eddelbuettel + from the GNU sources from + ftp://ftp.gnu.org/pub/gnu/bc/bc-1.06.tar.gz +Changes are documented in the changelog.Debian file, and below. + +James Troup, the previous maintainer made the following changes :- + +o adding support for the Debian package maintenance scheme, by adding + various debian/* files. +o bc/scan.l (rc_len): define as int not char, to allow input > 128 + characters in length without crashing. +o configure.in: changed test for readline to use READLINELIB and not + LIBS so we can link just bc with readline (as dc doesn't use it). +o bc/Makefile.am (LDADD): add @READLINELIB@ + + +Program Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software +Foundation, Inc. +Modifications for Debian Copyright (C) 1997, 1998, 1999 James Troup. +Further modifications for Debian Copyright (C) 1999 Dirk Eddelbuettel. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License with your +Debian GNU/Linux system, in /usr/share/common-licenses/GPL, or with the +Debian GNU/Linux bc source package as the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +MA 02110-1301, USA. + + +Manual (dc.info) Copyright (C) 1984 Free Software Foundation, Inc. + +Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the +entire resulting derived work is distributed under the terms of a +permission notice identical to this one. + +Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions, except that this permission notice may be stated in a +translation approved by the Foundation. --- bc-1.06.94.orig/debian/bc.postrm +++ bc-1.06.94/debian/bc.postrm @@ -0,0 +1,22 @@ +#! /bin/sh +# +# This is the postrm script for the Debian GNU/Linux bc package +# +# Written by Dirk Eddelbuettel +# Previous versions written by Bill Mitchell, Austin Donnelly and James Troup + +set -e + +#DEBHELPER# + +case "$1" in + purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) +# if [ -x /usr/bin/update-menus ] +# then +# update-menus +# fi + ;; + *) + echo "postrm called with unknown argument \`$1'" >&2 + ;; +esac --- bc-1.06.94.orig/debian/dc.doc-base +++ bc-1.06.94/debian/dc.doc-base @@ -0,0 +1,14 @@ +Document: dc +Title: The GNU DC arbitrary precision calculator +Author: Ken Pizzini +Abstract: GNU dc is a reverse-polish desk calculator which supports unlimited + precision arithmetic. It also allows you to define and call macros. + Normally DC reads from the standard input; if any command arguments are + given to it, they are filenames, and DC reads and executes the contents + of the files instead of reading from standard input. All normal output + is to standard output; all error messages are written to standard error. +Section: Science/Mathematics + +Format: HTML +Index: /usr/share/doc/dc/dc.html +Files: /usr/share/doc/dc/dc.html --- bc-1.06.94.orig/debian/compat +++ bc-1.06.94/debian/compat @@ -0,0 +1 @@ +7 --- bc-1.06.94.orig/debian/watch +++ bc-1.06.94/debian/watch @@ -0,0 +1,3 @@ +version=3 +opts=pasv,dversionmangle=s/([0-9]+.[0-9a-z]+)(.[0-9]+)?/$1/ \ +ftp://ftp.gnu.org/pub/gnu/bc/bc-([0-9a-z.]+).tar.gz --- bc-1.06.94.orig/debian/bc.menu +++ bc-1.06.94/debian/bc.menu @@ -0,0 +1 @@ +?package(bc):needs="text" section="Applications/Science/Mathematics" title="Bc" hints="Calculators" command="/usr/bin/bc" --- bc-1.06.94.orig/debian/dc.prerm +++ bc-1.06.94/debian/dc.prerm @@ -0,0 +1,20 @@ +#! /bin/sh +# +# This is the prerm script for the Debian GNU/Linux dc package +# +# Written by Dirk Eddelbuettel +# Previous versions written by Bill Mitchell, Austin Donnelly and James Troup + +set -e + +#DEBHELPER# + +case "$1" in +remove|upgrade|failed-upgrade|deconfigure) + install-info --quiet --remove dc + ;; +*) + echo "prerm called with unknown argument \`$1'" >&2 + ;; + +esac --- bc-1.06.94.orig/debian/bc.postinst +++ bc-1.06.94/debian/bc.postinst @@ -0,0 +1,28 @@ +#!/bin/sh +# +# This is the postinst script for the Debian GNU/Linux bc package +# +# Written by Dirk Eddelbuettel +# Previous versions written by Bill Mitchell, Austin Donnelly and James Troup + +set -e + +#DEBHELPER# + +case "$1" in + configure) +# if [ -x /usr/bin/update-menus ] +# then +# update-menus +# fi + ;; + abort-upgrade|abort-remove|abort-deconfigure) + ;; + *) + echo "postinst called with unknown argument \`$1'" >&2 + ;; +esac + + + + --- bc-1.06.94.orig/debian/control +++ bc-1.06.94/debian/control @@ -0,0 +1,27 @@ +Source: bc +Section: math +Priority: standard +Maintainer: John Hasler +Standards-Version: 3.8.1 +Build-Depends: bison, debhelper (>= 7), file, flex, libreadline-dev, texi2html, texinfo +Homepage: http://www.gnu.org/software/bc + +Package: bc +Architecture: any +Depends: ${shlibs:Depends} +Description: The GNU bc arbitrary precision calculator language + GNU bc is an interactive algebraic language with arbitrary precision which + follows the POSIX 1003.2 draft standard, with several extensions including + multi-character variable names, an `else' statement and full Boolean + expressions. GNU bc does not require the separate GNU dc program. + +Package: dc +Architecture: any +Depends: ${shlibs:Depends} +Description: The GNU dc arbitrary precision reverse-polish calculator + GNU dc is a reverse-polish desk calculator which supports unlimited + precision arithmetic. It also allows you to define and call macros. + . + A reverse-polish calculator stores numbers on a stack. Entering a number + pushes it on the stack. Arithmetic operations pop arguments off the + stack and push the results. --- bc-1.06.94.orig/debian/phil-patch-2 +++ bc-1.06.94/debian/phil-patch-2 @@ -0,0 +1,105 @@ +From: Phil Nelson +To: edd@debian.org +CC: dia@unix.swx.ch +Subject: Re: forwarded message from Aaron Optimizer Digulla +Date: Sat, 2 Oct 1999 19:53:46 -0700 (PDT) + +Hi, + +>Thank you very much for the patch, and the impressive respone time. I just +>made a new Debian package which will propagate through our mirrors over the +>weekend. + +You are welcome, but I thought I said I had a little more work on the math +library! Here is a patch that improves cosine and the bessel functions. + +*** bc1.05/bc/libmath.b Thu Apr 10 14:36:20 1997 +--- bc1.05.1/bc/libmath.b Sat Oct 2 19:51:20 1999 +*************** +*** 158,167 **** + + /* Cosine : cos(x) = sin(x+pi/2) */ + define c(x) { +! auto v; +! scale += 1; + v = s(x+a(1)*2); +! scale -= 1; + return (v/1); + } + +--- 158,168 ---- + + /* Cosine : cos(x) = sin(x+pi/2) */ + define c(x) { +! auto v, z; +! z = scale; +! scale = scale*1.2; + v = s(x+a(1)*2); +! scale = z; + return (v/1); + } + +*************** +*** 244,250 **** + - x^6/(2^6*3!*(n+1)*(n+2)*(n+3)) .... ) + */ + define j(n,x) { +! auto a, d, e, f, i, m, s, v, z + + /* Make n an integer and check for negative n. */ + z = scale; +--- 245,251 ---- + - x^6/(2^6*3!*(n+1)*(n+2)*(n+3)) .... ) + */ + define j(n,x) { +! auto a, b, d, e, f, i, m, s, v, z + + /* Make n an integer and check for negative n. */ + z = scale; +*************** +*** 255,260 **** +--- 256,265 ---- + if (n%2 == 1) m = 1; + } + ++ /* save ibase */ ++ b = ibase; ++ ibase = A; ++ + /* Compute the factor of x^n/(2^n*n!) */ + f = 1; + for (i=2; i<=n; i++) f = f*i; +*************** +*** 264,275 **** + /* Initialize the loop .*/ + v = e = 1; + s = -x*x/4 +! scale = 1.5*z + + /* The Loop.... */ + for (i=1; 1; i++) { + e = e * s / i / (n+i); + if (e == 0) { + scale = z + if (m) return (-f*v/1); + return (f*v/1); +--- 269,281 ---- + /* Initialize the loop .*/ + v = e = 1; + s = -x*x/4 +! scale = 1.5*z + length(f) - scale(f); + + /* The Loop.... */ + for (i=1; 1; i++) { + e = e * s / i / (n+i); + if (e == 0) { ++ ibase = b; + scale = z + if (m) return (-f*v/1); + return (f*v/1); + + +-- +Phil Nelson NetBSD: http://www.netbsd.org +e-mail: phil@cs.wwu.edu Coda: http://www.coda.cs.cmu.edu +http://www.cs.wwu.edu/~phil --- bc-1.06.94.orig/doc/dc.1 +++ bc-1.06.94/doc/dc.1 @@ -26,9 +26,9 @@ .SH NAME dc \- an arbitrary precision calculator .SH SYNOPSIS -dc [-V] [--version] [-h] [--help] - [-e scriptexpression] [--expression=scriptexpression] - [-f scriptfile] [--file=scriptfile] +dc [\-V] [\-\-version] [\-h] [\-\-help] + [\-e scriptexpression] [\-\-expression=scriptexpression] + [\-f scriptfile] [\-\-file=scriptfile] [file ...] .SH DESCRIPTION .PP @@ -501,6 +501,14 @@ because the 2 was stored in an instance of 0:a that was later popped. .SH +FILES +.TP 15 +~/.dcrc +The commands in this file will be executed when +.I dc +is first run. +.PP +.SH BUGS .PP Email bug reports to --- bc-1.06.94.orig/doc/bc.1 +++ bc-1.06.94/doc/bc.1 @@ -545,7 +545,7 @@ variable \fBpi\fR. .RS \f(CW -pi=$(echo "scale=10; 4*a(1)" | bc -l) +pi=$(echo "scale=10; 4*a(1)" | bc \-l) \fR .RE .PP @@ -567,7 +567,7 @@ /* Check the sign of x. */ if (x<0) { m = 1 - x = -x + x = \-x } /* Precondition x. */ @@ -643,7 +643,7 @@ to \fBbc\fR. It also allows for a history of previous lines typed. When this option is selected, \fBbc\fR has one more special variable. This special variable, \fBhistory\fR is the number of lines of history -retained. For \fBreadline\fR, a value of -1 means that an unlimited +retained. For \fBreadline\fR, a value of \-1 means that an unlimited number of history lines are retained. Setting the value of \fBhistory\fR to a positive number restricts the number of history lines to the number given. The value of 0 disables the history @@ -660,7 +660,7 @@ It is not implemented in the traditional way using .I dc(1). This version is a single process which parses and runs a byte code -translation of the program. There is an "undocumented" option (-c) +translation of the program. There is an "undocumented" option (\-c) that causes the program to output the byte code to the standard output instead of running it. It was mainly used for debugging the parser and preparing the math library. @@ -718,7 +718,7 @@ the limits statement to see if the installed version supports them. If it does support the "old style" assignment operators, the statement "a =- 1" will decrement \fBa\fR by 1 instead of setting \fBa\fR to the -value -1. +value \-1. .IP "spaces in numbers" Other implementations of \fBbc\fR allow spaces in numbers. For example, "x=1 3" would assign the value 13 to the variable x. The same statement --- bc-1.06.94.orig/h/number.h +++ bc-1.06.94/h/number.h @@ -150,4 +150,7 @@ _PROTOTYPE(void bc_out_num, (bc_num num, int o_base, void (* out_char)(int), int leading_zero)); +_PROTOTYPE(void checkferror_input, (FILE*)); +_PROTOTYPE(void checkferror_output, (FILE*)); + #endif --- bc-1.06.94.orig/lib/testmul.c +++ bc-1.06.94/lib/testmul.c @@ -1,6 +1,8 @@ /* compute the crossover for recursive and simple multiplication */ #include +#include +#include #include #include "number.h" #ifndef VARARGS @@ -57,6 +59,7 @@ va_end (args); fprintf (stderr, "Runtime error: %s\n", error_mesg); + checkferror_output(stderr); } /* A runtime warning tells of some action taken by the processor that @@ -90,12 +93,14 @@ va_end (args); fprintf (stderr, "Runtime warning: %s\n", error_mesg); + checkferror_output(stderr); } void out_char (int ch) { putchar (ch); + checkferror_output(stdout); } /* Time stuff !!! */ @@ -147,21 +152,28 @@ bc_init_num (&big); bc_int2num (&ten, 10); - if (debug) + if (debug) { fprintf (stderr, "Timings are for %d multiplies\n" "Minimum time is %d seconds\n", test_n, test_time/CLOCKS_PER_SEC); + checkferror_output(stderr); + } /* Two of the same size */ min = 10; max = 500; - if (debug) + if (debug) { fprintf (stderr, "Testing numbers of the same length.\n"); + checkferror_output(stderr); + } while (min < max) { mid = (min+max)/2; - if (debug) fprintf (stderr,"Checking %d...\n", mid); + if (debug) { + fprintf (stderr,"Checking %d...\n", mid); + checkferror_output(stderr); + } bc_int2num (&expo, mid); bc_raise (ten, expo, &num, 0); @@ -183,12 +195,16 @@ if (debug) { fprintf (stderr, "n1 = %d :: n2 = %d\n", n1, n2); fprintf (stderr, "p1 = %f :: p2 = %f\n", permul1, permul2); + checkferror_output(stderr); } } - if (debug) + if (debug) { fprintf (stderr, "Base digits crossover at %d digits\n", min); + checkferror_output(stderr); + } printf ("#define MUL_BASE_DIGITS %d\n", 2*min); + checkferror_output(stdout); #if 0 @@ -204,12 +220,17 @@ min = min / 2; max = 500; - if (debug) + if (debug) { fprintf (stderr, "Testing numbers of the different length.\n"); + checkferror_output(stderr); + } while (min < max) { mid = (min+max)/2; - if (debug) fprintf (stderr, "Checking %d...\n", mid); + if (debug) { + fprintf (stderr, "Checking %d...\n", mid); + checkferror_output(stderr); + } bc_int2num (&expo, mid-smallsize); bc_raise (ten, expo, &num, 0); @@ -231,12 +252,16 @@ if (debug) { fprintf (stderr, "n1 = %d :: n2 = %d\n", n1, n2); fprintf (stderr, "p1 = %f :: p2 = %f\n", permul1, permul2); + checkferror_output(stderr); } } - if (debug) + if (debug) { fprintf (stderr, "Non equal digits crossover at %d total digits\n", min); + checkferror_output(stderr); + } printf ("#define MUL_SMALL_DIGITS = %d\n", min); + checkferror_output(stdout); #endif --- bc-1.06.94.orig/lib/number.c +++ bc-1.06.94/lib/number.c @@ -1778,6 +1778,7 @@ out_char (int c) { putchar(c); + checkferror_output(stdout); } @@ -1787,6 +1788,7 @@ { bc_out_num (num, 10, out_char, 0); out_char ('\n'); + checkferror_output(stdout); } @@ -1801,6 +1803,28 @@ printf ("%s=", name); for (i=0; is_ptr, value->s_len, sizeof *value->s_ptr, stdout); if (newline == DC_WITHNL) putchar('\n'); + checkferror_output(stdout); if (discard_flag == DC_TOSS) dc_free_str(&value); } @@ -176,6 +177,7 @@ } *p++ = c; } + checkferror_input(fp); return dc_makestring(line_buf, (size_t)(p-line_buf)); } --- bc-1.06.94.orig/dc/stack.c +++ bc-1.06.94/dc/stack.c @@ -38,7 +38,10 @@ #include "dc-regdef.h" /* an oft-used error message: */ -#define Empty_Stack fprintf(stderr, "%s: stack empty\n", progname) +#define Empty_Stack do{ \ + fprintf(stderr, "%s: stack empty\n", progname); \ + checkferror_output(stderr); \ + }while(0) /* simple linked-list implementation suffices: */ @@ -94,6 +97,7 @@ if (dc_stack->value.dc_type!=DC_NUMBER || dc_stack->link->value.dc_type!=DC_NUMBER){ fprintf(stderr, "%s: non-numeric value\n", progname); + checkferror_output(stderr); return; } (void)dc_pop(&b); @@ -134,6 +138,7 @@ if (dc_stack->value.dc_type!=DC_NUMBER || dc_stack->link->value.dc_type!=DC_NUMBER){ fprintf(stderr, "%s: non-numeric value\n", progname); + checkferror_output(stderr); return; } (void)dc_pop(&b); @@ -172,6 +177,7 @@ if (dc_stack->value.dc_type!=DC_NUMBER || dc_stack->link->value.dc_type!=DC_NUMBER){ fprintf(stderr, "%s: non-numeric value\n", progname); + checkferror_output(stderr); return 0; } (void)dc_pop(&b); @@ -209,6 +215,7 @@ || dc_stack->link->value.dc_type!=DC_NUMBER || dc_stack->link->link->value.dc_type!=DC_NUMBER){ fprintf(stderr, "%s: non-numeric value\n", progname); + checkferror_output(stderr); return; } (void)dc_pop(&c); @@ -327,6 +334,7 @@ r = dc_register[regid]; if (r==NULL || r->value.dc_type==DC_UNINITIALIZED){ fprintf(stderr, "%s: register ", progname); + checkferror_output(stderr); dc_show_id(stderr, regid, " is empty\n"); return DC_FAIL; } @@ -401,6 +409,7 @@ r = dc_register[stackid]; if (r == NULL){ fprintf(stderr, "%s: stack register ", progname); + checkferror_output(stderr); dc_show_id(stderr, stackid, " is empty\n"); return DC_FAIL; } --- bc-1.06.94.orig/dc/numeric.c +++ bc-1.06.94/dc/numeric.c @@ -124,6 +124,7 @@ bc_init_num((bc_num *)result); if (bc_divide(CastNum(a), CastNum(b), (bc_num *)result, kscale)){ fprintf(stderr, "%s: divide by zero\n", progname); + checkferror_output(stderr); return DC_DOMAIN_ERROR; } return DC_SUCCESS; @@ -146,6 +147,7 @@ if (bc_divmod(CastNum(a), CastNum(b), (bc_num *)quotient, (bc_num *)remainder, kscale)){ fprintf(stderr, "%s: divide by zero\n", progname); + checkferror_output(stderr); return DC_DOMAIN_ERROR; } return DC_SUCCESS; @@ -164,6 +166,7 @@ bc_init_num((bc_num *)result); if (bc_modulo(CastNum(a), CastNum(b), (bc_num *)result, kscale)){ fprintf(stderr, "%s: remainder by zero\n", progname); + checkferror_output(stderr); return DC_DOMAIN_ERROR; } return DC_SUCCESS; @@ -180,8 +183,10 @@ bc_init_num((bc_num *)result); if (bc_raisemod(CastNum(base), CastNum(expo), CastNum(mod), (bc_num *)result, kscale)){ - if (bc_is_zero(CastNum(mod))) + if (bc_is_zero(CastNum(mod))) { fprintf(stderr, "%s: remainder by zero\n", progname); + checkferror_output(stderr); + } return DC_DOMAIN_ERROR; } return DC_SUCCESS; @@ -216,6 +221,7 @@ tmp = bc_copy_num(CastNum(value)); if (!bc_sqrt(&tmp, kscale)){ fprintf(stderr, "%s: square root of negative number\n", progname); + checkferror_output(stderr); bc_free_num(&tmp); return DC_DOMAIN_ERROR; } @@ -419,8 +425,10 @@ { out_char('\0'); /* clear the column counter */ bc_out_num(CastNum(value), obase, out_char, 0); - if (newline_p == DC_WITHNL) + if (newline_p == DC_WITHNL) { putchar ('\n'); + checkferror_output(stdout); + } if (discard_p == DC_TOSS) dc_free_num(&value); } @@ -465,6 +473,7 @@ for (cur=top_of_stack; cur; cur=next) { putchar(cur->digit); + checkferror_output(stdout); next = cur->link; free(cur); } @@ -582,6 +591,7 @@ out_col = 1; } putchar(ch); + checkferror_output(stderr); } } @@ -621,6 +631,7 @@ vfprintf (stderr, mesg, args); va_end (args); fprintf (stderr, "\n"); + checkferror_output(stderr); } @@ -654,6 +665,7 @@ vfprintf (stderr, mesg, args); va_end (args); fprintf (stderr, "\n"); + checkferror_output(stderr); } --- bc-1.06.94.orig/dc/eval.c +++ bc-1.06.94/dc/eval.c @@ -94,12 +94,15 @@ static int input_fil DC_DECLVOID() { + int c; if (input_pushback != EOF){ - int c = input_pushback; + c = input_pushback; input_pushback = EOF; return c; } - return getc(input_fil_fp); + c = getc(input_fil_fp); + checkferror_input(input_fil_fp); + return c; } /* passed as an argument to dc_getnum */ @@ -298,11 +301,13 @@ tmpint = dc_num2int(datum.v.number, DC_TOSS); if (2 <= tmpint && tmpint <= DC_IBASE_MAX) dc_ibase = tmpint; - else + else { fprintf(stderr, "%s: input base must be a number \ between 2 and %d (inclusive)\n", progname, DC_IBASE_MAX); + checkferror_output(stderr); + } } break; case 'k': /* set scale to value on top of stack */ @@ -310,11 +315,12 @@ tmpint = -1; if (datum.dc_type == DC_NUMBER) tmpint = dc_num2int(datum.v.number, DC_TOSS); - if ( ! (tmpint >= 0) ) + if ( ! (tmpint >= 0) ) { fprintf(stderr, "%s: scale must be a nonnegative number\n", progname); - else + checkferror_output(stderr); + } else dc_scale = tmpint; } break; @@ -338,11 +344,12 @@ tmpint = 0; if (datum.dc_type == DC_NUMBER) tmpint = dc_num2int(datum.v.number, DC_TOSS); - if ( ! (tmpint > 1) ) + if ( ! (tmpint > 1) ) { fprintf(stderr, "%s: output base must be a number greater than 1\n", progname); - else + checkferror_output(stderr); + } else dc_obase = tmpint; } break; @@ -383,6 +390,7 @@ fprintf(stderr, "%s: square root of nonnumeric attempted\n", progname); + checkferror_output(stderr); }else if (dc_sqrt(datum.v.number, dc_scale, &tmpnum) == DC_SUCCESS){ dc_free_num(&datum.v.number); datum.v.number = tmpnum; @@ -444,6 +452,7 @@ fprintf(stderr, "%s: Q command requires a number >= 1\n", progname); + checkferror_output(stderr); } break; #if 0 @@ -489,11 +498,12 @@ if (datum.dc_type == DC_NUMBER) tmpint = dc_num2int(datum.v.number, DC_TOSS); if (dc_pop(&datum) == DC_SUCCESS){ - if (tmpint < 0) + if (tmpint < 0) { fprintf(stderr, "%s: array index must be a nonnegative integer\n", progname); - else + checkferror_output(stderr); + } else dc_array_set(peekc, tmpint, datum); } } @@ -505,17 +515,19 @@ tmpint = -1; if (datum.dc_type == DC_NUMBER) tmpint = dc_num2int(datum.v.number, DC_TOSS); - if (tmpint < 0) + if (tmpint < 0) { fprintf(stderr, "%s: array index must be a nonnegative integer\n", progname); - else + checkferror_output(stderr); + } else dc_push(dc_array_get(peekc, tmpint)); } return DC_EATONE; default: /* What did that user mean? */ fprintf(stderr, "%s: ", progname); + checkferror_output(stderr); dc_show_id(stdout, c, " unimplemented\n"); break; } @@ -544,6 +556,7 @@ fprintf(stderr, "%s: eval called with non-string argument\n", progname); + checkferror_output(stderr); return DC_OKAY; } interrupt_seen = 0; @@ -640,6 +653,7 @@ return DC_FAIL; } fprintf(stderr, "%s: unexpected EOS\n", progname); + checkferror_output(stderr); return DC_OKAY; } } @@ -665,6 +679,7 @@ stdin_lookahead = EOF; for (c=getc(fp); c!=EOF; c=peekc){ peekc = getc(fp); + checkferror_input(stdin); /* * The following if() is the only place where ``stdin_lookahead'' * might be set to other than EOF: @@ -716,6 +731,7 @@ return DC_SUCCESS; fprintf(stderr, "%s: Q command argument exceeded \ string execution depth\n", progname); + checkferror_output(stderr); } }else{ dc_garbage("at top of stack", -1); @@ -728,8 +744,11 @@ fprintf(stderr, "%s: Q command argument exceeded string execution depth\n", progname); - if (stdin_lookahead != peekc && fp == stdin) + checkferror_output(stderr); + if (stdin_lookahead != peekc && fp == stdin) { peekc = getc(fp); + checkferror_input(stdin); + } break; case DC_INT: @@ -771,6 +790,7 @@ if (ferror(fp)) goto error_fail; fprintf(stderr, "%s: unexpected EOF\n", progname); + checkferror_output(stderr); return DC_FAIL; } } --- bc-1.06.94.orig/dc/dc.c +++ bc-1.06.94/dc/dc.c @@ -30,6 +30,9 @@ #include "config.h" #include +#include +#include +#include #ifdef HAVE_STDLIB_H # include #endif @@ -61,6 +64,7 @@ bug_report_info DC_DECLVOID() { printf("Email bug reports to: bug-dc@gnu.org .\n"); + checkferror_output(stdout); } static void @@ -71,6 +75,7 @@ This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,\n\ to the extent permitted by law.\n", DC_COPYRIGHT); + checkferror_output(stdout); } /* your generic usage function */ @@ -87,6 +92,30 @@ \n\ ", progname); bug_report_info(); + checkferror_output(f); +} + +static void +try_rcfile(void) +{ + char *homedir; + struct passwd *pw; + char *rcfile; + FILE *input; + + homedir=getenv("HOME"); + if (!homedir) + { + pw=getpwuid(getuid()); + homedir=pw->pw_dir; + } + rcfile=malloc(strlen(homedir)+8); + sprintf(rcfile, "%s/.dcrc", homedir); + if (!(input=fopen(rcfile, "r"))) + return; + if (dc_evalfile(input)) + exit(EXIT_FAILURE); + fclose(input); } /* returns a pointer to one past the last occurance of c in s, @@ -297,6 +326,8 @@ } } + try_rcfile(); + for (; optind < argc; ++optind) { try_file(argv[optind]); did_eval = 1; --- bc-1.06.94.orig/dc/misc.c +++ bc-1.06.94/dc/misc.c @@ -91,6 +91,7 @@ fprintf(fp, "'%c' (%#o)%s", (unsigned int) id, id, suffix); else fprintf(fp, "%#o%s", (unsigned int) id, suffix); + checkferror_output(fp); }