Skip to content

Commit 315837c

Browse files
committed
bc-1.06.95
1 parent 2cb62cf commit 315837c

33 files changed

+1061
-741
lines changed

AUTHORS

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
Phil Nelson <philnelson@acm.org> wrote bc, including the number.c
22
source in the "lib" directory.
33

4-
Ken Pizzini wrote dc.
4+
Ken Pizzini <ken@gnu.org> wrote dc, making use of the lib/number.c
5+
code that Phil Nelson wrote to handle the actual multiprecision
6+
arithmetic.

ChangeLog

+48
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,51 @@
1+
Mon Sep 4 19:27:49 2006 Ken Pizzini <ken@gnu.org>
2+
* configure.in: re-factor how version numbers are handled; add errno.h
3+
and strtol() checks; add doc-texi-ver.incl output
4+
* bc/bcdefs.h: Prefer <string.h> over <strings.h>
5+
* bc/execute.c, bc/load.c, bc/main.c, bc/proto.h, bc/scan.l,
6+
bc/storage.c, bc/util.c, bc/warranty.c: De-lint some with "const"
7+
declarations, "static" declarations, and un-shadowing a few global
8+
variables and functions
9+
* dc/dc.c: add "static" keyword on flush_okay() function declaration,
10+
just for good hygene
11+
* dc/numeric.c: Reworked to avoid breaking C99 type-punning rules
12+
13+
Wed Jun 14 08:21:17 2006 Ken Pizzini <ken@gnu.org>
14+
* dc/numeric.c (dc_int2data): rework code so that C99 compilers
15+
stop whining about the type punning
16+
* dc/dc.c (flush_okay): add "static" keyword as a matter of good
17+
coding hygene
18+
19+
Sun Jun 11 21:40:37 2006 Ken Pizzini <ken@gnu.org>
20+
* doc/bc.1: strip release version information which is not being
21+
automatically kept up-to-date
22+
* doc/dc.1: don't capitalize Dc or DC
23+
24+
Sun Jun 11 09:07:26 2006 Ken Pizzini <ken@gnu.org>
25+
* doc/bc.texi, doc/dc.texi, doc/texi-ver.incl.in, doc/Makefile.am:
26+
make version text in texinfo-based documentation auto-derive from
27+
configure.in
28+
* configure.in: update to use more modern automake/autoconf
29+
directives; factor out version numbers so that AC_SUBST and
30+
AC_OUTPUT kcan be used to create doc/texi-ver.incl
31+
* doc/Makefile.am: automake does (now) have a mechanism to
32+
auto-include declared man pages in the dist tarball, so
33+
remove FIXME block
34+
35+
Sun Jun 11 03:04:18 2006 Ken Pizzini <ken@gnu.org>
36+
* lib/Makefile.am: testmul, specialnumber, multidigits.h are
37+
autogenerated by special request (only), and "make clean" should
38+
remove them
39+
* lib/testmul.c: CLOCKS_PER_SEC is typically a "long" value, so make
40+
test_time wide enough to hold it; add missing #include directives
41+
* lib/number.c: silly warning clean-up:
42+
+ declare rt_warn() and rt_error() to take a CONST char* first
43+
argument
44+
+ neither _bc_rec_mul() nor _bc_simp_mul() use the full_scale
45+
argument, so remove it in the function definitions and invocations
46+
+ some C libraries define an index() function; use a different index
47+
variable name to avoid gratuitous namespace shadowing
48+
149
Sun Jun 4 13:56:58 2006 Ken Pizzini <ken@gnu.org>
250
* doc/dc.texi: document new DC_LINE_LENGTH variable; mention
351
traditional dc's handling of P with a numeric input

Makefile.in

+5-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ am__remove_distdir = \
6565
{ test ! -d $(distdir) \
6666
|| { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
6767
&& rm -fr $(distdir); }; }
68-
DIST_ARCHIVES = $(distdir).tar.gz
68+
DIST_ARCHIVES = $(distdir).tar.gz $(distdir).tar.bz2
6969
GZIP_ENV = --best
7070
distuninstallcheck_listfiles = find . -type f -print
7171
distcleancheck_listfiles = find . -type f -print
@@ -77,12 +77,14 @@ AUTOCONF = @AUTOCONF@
7777
AUTOHEADER = @AUTOHEADER@
7878
AUTOMAKE = @AUTOMAKE@
7979
AWK = @AWK@
80+
BC_VERSION = @BC_VERSION@
8081
CC = @CC@
8182
CCDEPMODE = @CCDEPMODE@
8283
CFLAGS = @CFLAGS@
8384
CPP = @CPP@
8485
CPPFLAGS = @CPPFLAGS@
8586
CYGPATH_W = @CYGPATH_W@
87+
DC_VERSION = @DC_VERSION@
8688
DEFS = @DEFS@
8789
DEPDIR = @DEPDIR@
8890
ECHO_C = @ECHO_C@
@@ -342,6 +344,7 @@ distclean-tags:
342344
distdir: $(DISTFILES)
343345
$(am__remove_distdir)
344346
mkdir $(distdir)
347+
$(mkdir_p) $(distdir)/doc
345348
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
346349
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
347350
list='$(DISTFILES)'; for file in $$list; do \
@@ -394,7 +397,6 @@ distdir: $(DISTFILES)
394397
dist-gzip: distdir
395398
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
396399
$(am__remove_distdir)
397-
398400
dist-bzip2: distdir
399401
tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
400402
$(am__remove_distdir)
@@ -414,6 +416,7 @@ dist-zip: distdir
414416

415417
dist dist-all: distdir
416418
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
419+
tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
417420
$(am__remove_distdir)
418421

419422
# This target untars the dist file and tries a VPATH configuration. Then

bc/Makefile.in

+2
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,14 @@ AUTOCONF = @AUTOCONF@
8080
AUTOHEADER = @AUTOHEADER@
8181
AUTOMAKE = @AUTOMAKE@
8282
AWK = @AWK@
83+
BC_VERSION = @BC_VERSION@
8384
CC = @CC@
8485
CCDEPMODE = @CCDEPMODE@
8586
CFLAGS = @CFLAGS@
8687
CPP = @CPP@
8788
CPPFLAGS = @CPPFLAGS@
8889
CYGPATH_W = @CYGPATH_W@
90+
DC_VERSION = @DC_VERSION@
8991
DEFS = @DEFS@
9092
DEPDIR = @DEPDIR@
9193
ECHO_C = @ECHO_C@

bc/bcdefs.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636
#include <stdio.h>
3737
#include <sys/types.h>
3838
#include <ctype.h>
39-
#ifdef HAVE_STRINGS_H
40-
#include <strings.h>
41-
#else
39+
#ifdef HAVE_STRING_H
4240
#include <string.h>
41+
#else
42+
#include <strings.h>
4343
#endif
4444
#ifdef HAVE_LIMITS_H
4545
#include <limits.h>

bc/execute.c

+15-15
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ stop_execution (sig)
4848
/* Get the current byte and advance the PC counter. */
4949

5050
unsigned char
51-
byte (pc)
52-
program_counter *pc;
51+
byte (p)
52+
program_counter *p;
5353
{
54-
return (functions[pc->pc_func].f_body[pc->pc_addr++]);
54+
return (functions[p->pc_func].f_body[p->pc_addr++]);
5555
}
5656

5757

@@ -694,8 +694,8 @@ push_constant (in_char, conv_base)
694694
the constant. */
695695

696696
void
697-
push_b10_const (pc)
698-
program_counter *pc;
697+
push_b10_const (progctr)
698+
program_counter *progctr;
699699
{
700700
bc_num build;
701701
program_counter look_pc;
@@ -704,7 +704,7 @@ push_b10_const (pc)
704704
char *ptr;
705705

706706
/* Count the digits and get things ready. */
707-
look_pc = *pc;
707+
look_pc = *progctr;
708708
kdigits = 0;
709709
kscale = 0;
710710
inchar = byte (&look_pc);
@@ -723,29 +723,29 @@ push_b10_const (pc)
723723
}
724724
}
725725

726-
/* Get the first character again and move the pc. */
727-
inchar = byte(pc);
726+
/* Get the first character again and move the progctr. */
727+
inchar = byte(progctr);
728728

729729
/* Secial cases of 0, 1, and A-F single inputs. */
730730
if (kdigits == 1 && kscale == 0)
731731
{
732732
if (inchar == 0)
733733
{
734734
push_copy (_zero_);
735-
inchar = byte(pc);
735+
inchar = byte(progctr);
736736
return;
737737
}
738738
if (inchar == 1) {
739739
push_copy (_one_);
740-
inchar = byte(pc);
740+
inchar = byte(progctr);
741741
return;
742742
}
743743
if (inchar > 9)
744744
{
745745
bc_init_num (&build);
746746
bc_int2num (&build, inchar);
747747
push_num (build);
748-
inchar = byte(pc);
748+
inchar = byte(progctr);
749749
return;
750750
}
751751
}
@@ -772,7 +772,7 @@ push_b10_const (pc)
772772
else
773773
*ptr++ = inchar;
774774
}
775-
inchar = byte(pc);
775+
inchar = byte(progctr);
776776
}
777777
push_num (build);
778778
}
@@ -781,11 +781,11 @@ push_b10_const (pc)
781781
/* Put the correct value on the stack for C_CODE. Frees TOS num. */
782782

783783
void
784-
assign (c_code)
785-
char c_code;
784+
assign (code)
785+
char code;
786786
{
787787
bc_free_num (&ex_stack->s_num);
788-
if (c_code)
788+
if (code)
789789
ex_stack->s_num = bc_copy_num (_one_);
790790
else
791791
ex_stack->s_num = bc_copy_num (_zero_);

bc/libmath.h

+46-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,46 @@
1-
{0}
1+
{"@iK20:s2:p@r",
2+
"@iF1,5.6,7,8,9,10,11,12,13,14,15[l0:KA:#Z1:l0:s7:pKA:s0:pl5:C1,0:",
3+
"s14:pl7:s0:pl14:RN1:l5:0<Z2:1s12:pl5:ns5:pN2:l2:s15:pK6:l15:+",
4+
"K.44:l5:*+s13:pl5:cS1+s2:pN3:l5:1>Z4:l10:1+s10:pl5:K2:/s5:pl2:",
5+
"1+s2:pJ3:N4:l13:s2:p1l5:+s14:pl5:s6:p1s8:pK2:s11:pN6:1B7:J5:N8:",
6+
"l11:i11:pJ6:N7:l6:l5:*s6:l8:l11:*s8:/s9:pl9:0=Z9:l10:0>Z10:N11:",
7+
"l10:d10:Z12:l14:l14:*s14:pJ11:N12:N10:l15:s2:pl12:Z13:1l14:/R",
8+
"N13:l14:1/RN9:l14:l9:+s14:pJ8:N5:0R]@r",
9+
"@iF2,5.7,9,10,11,12,13,14,15[l0:KA:#Z1:l0:s7:pKA:s0:pl5:C2,0:",
10+
"s14:pl7:s0:pl14:RN1:l5:0{Z2:1K10:l2:^-1/RN2:l2:s15:pK6:l2:+s2:",
11+
"pK2:s10:p0s11:pN3:l5:K2:}Z4:l10:K2:*s10:pl5:cRs5:pJ3:N4:N5:l5:",
12+
"K.5:{Z6:l10:K2:*s10:pl5:cRs5:pJ5:N6:l5:1-l5:1+/s13:s14:pl13:l13:",
13+
"*s12:pK3:s11:pN8:1B9:J7:N10:l11:K2:+s11:pJ8:N9:l13:l12:*s13:l11:",
14+
"/s9:pl9:0=Z11:l10:l14:*s14:pl15:s2:pl14:1/RN11:l14:l9:+s14:pJ10:N7:",
15+
"0R]@r",
16+
"@iF3,5.7,9,11,12,13,16,14,15[l0:KA:#Z1:l0:s7:pKA:s0:pl5:C3,0:",
17+
"s14:pl7:s0:pl14:RN1:l2:s15:pK1.1:l15:*K2:+s2:p1C4,0:s14:pl5:0",
18+
"<Z2:1s12:pl5:ns5:pN2:0s2:pl5:l14:/K2:+K4:/s13:pl5:K4:l13:*l14:",
19+
"*-s5:pl13:K2:%Z3:l5:ns5:pN3:l15:K2:+s2:pl5:s9:s14:pl5:nl5:*s16:",
20+
"pK3:s11:pN5:1B6:J4:N7:l11:K2:+s11:pJ5:N6:l9:l16:l11:l11:1-*/*",
21+
"s9:pl9:0=Z8:l15:s2:pl12:Z9:l14:n1/RN9:l14:1/RN8:l14:l9:+s14:p",
22+
"J7:N4:0R]@r",
23+
"@iF5,5.7,14,15[l0:KA:#Z1:l0:s7:pKA:s0:pl5:C5,0:s14:pl7:s0:pl14:",
24+
"RN1:l2:s15:pl2:K1.2:*s2:pl5:1C4,0:K2:*+C3,0:s14:pl15:s2:pl14:",
25+
"1/R0R]@r",
26+
"@iF4,5.6,7,9,10,11,12,13,16,14,15[l0:KA:#Z1:l0:s7:pKA:s0:pl5:",
27+
"C4,0:s14:pl7:s0:pl14:RN1:1s12:pl5:0<Z2:1ns12:pl5:ns5:pN2:l5:1",
28+
"=Z3:l2:K25:{Z4:K.7853981633974483096156608:l12:/RN4:l2:K40:{Z5:",
29+
"K.7853981633974483096156608458198757210492:l12:/RN5:l2:K60:{Z6:",
30+
"K.785398163397448309615660845819875721049292349843776455243736",
31+
":l12:/RN6:N3:l5:K.2:=Z7:l2:K25:{Z8:K.1973955598498807583700497",
32+
":l12:/RN8:l2:K40:{Z9:K.1973955598498807583700497651947902934475",
33+
":l12:/RN9:l2:K60:{Z10:K.197395559849880758370049765194790293447585103787852101517688",
34+
":l12:/RN10:N7:l2:s15:pl5:K.2:>Z11:l15:K5:+s2:pK.2:C4,0:s6:pN11:",
35+
"l15:K3:+s2:pN12:l5:K.2:>Z13:l10:1+s10:pl5:K.2:-1l5:K.2:*+/s5:",
36+
"pJ12:N13:l5:s13:s14:pl5:nl5:*s16:pK3:s11:pN15:1B16:J14:N17:l11:",
37+
"K2:+s11:pJ15:N16:l13:l16:*s13:l11:/s9:pl9:0=Z18:l15:s2:pl10:l6:",
38+
"*l14:+l12:/RN18:l14:l9:+s14:pJ17:N14:0R]@r",
39+
"@iF6,13,5.6,7,8,9,10,11,12,16,14,15[l0:KA:#Z1:l0:s7:pKA:s0:pl13:",
40+
"l5:C6,00:s14:pl7:s0:pl14:RN1:l2:s15:p0s2:pl13:1/s13:pl13:0<Z2:",
41+
"l13:ns13:pl13:K2:%1=Z3:1s12:pN3:N2:1s10:pK2:s11:pN5:l11:l13:{",
42+
"B6:J4:N7:l11:i11:pJ5:N6:l10:l11:*s10:pJ7:N4:K1.5:l15:*s2:pl5:",
43+
"l13:^K2:l13:^/l10:/s10:p1s9:s14:pl5:nl5:*K4:/s16:pK1.5:l15:*l10:",
44+
"cL+l10:cS-s2:p1s11:pN9:1B10:J8:N11:l11:i11:pJ9:N10:l9:l16:*l11:",
45+
"/l13:l11:+/s9:pl9:0=Z12:l15:s2:pl12:Z13:l10:nl14:*1/RN13:l10:",
46+
"l14:*1/RN12:l14:l9:+s14:pJ11:N8:0R]@r",0}

bc/load.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,21 @@ init_load ()
5151

5252
/* addbyte adds one BYTE to the current code segment. */
5353
void
54-
addbyte (byte)
55-
int byte;
54+
addbyte (thebyte)
55+
int thebyte;
5656
{
57-
int pc;
57+
int prog_addr;
5858
bc_function *f;
5959
char *new_body;
6060

6161
/* If there was an error, don't continue. */
6262
if (had_error) return;
6363

6464
/* Calculate the segment and offset. */
65-
pc = load_adr.pc_addr++;
65+
prog_addr = load_adr.pc_addr++;
6666
f = &functions[load_adr.pc_func];
6767

68-
if (pc >= f->f_body_size)
68+
if (prog_addr >= f->f_body_size)
6969
{
7070
f->f_body_size *= 2;
7171
new_body = (char *) bc_malloc (f->f_body_size);
@@ -74,8 +74,8 @@ addbyte (byte)
7474
f->f_body = new_body;
7575
}
7676

77-
/* Store the byte. */
78-
f->f_body[pc] = (char) (byte & 0xff);
77+
/* Store the thebyte. */
78+
f->f_body[prog_addr] = (char) (thebyte & 0xff);
7979
f->f_code_size++;
8080
}
8181

@@ -126,7 +126,7 @@ def_label (lab)
126126

127127
long
128128
long_val (str)
129-
char **str;
129+
const char **str;
130130
{ int val = 0;
131131
char neg = FALSE;
132132

@@ -149,9 +149,9 @@ long_val (str)
149149

150150
void
151151
load_code (code)
152-
char *code;
152+
const char *code;
153153
{
154-
char *str;
154+
const char *str;
155155
long ap_name; /* auto or parameter name. */
156156
long label_no;
157157
long vaf_name; /* variable, array or function number. */

bc/main.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ static struct option long_options[] =
5858
};
5959

6060

61-
void
62-
usage (char *progname)
61+
static void
62+
usage (const char *progname)
6363
{
6464
printf ("usage: %s [options] [file ...]\n%s%s%s%s%s%s%s", progname,
6565
" -h --help print this usage and exit\n",
@@ -72,7 +72,7 @@ usage (char *progname)
7272
}
7373

7474

75-
void
75+
static void
7676
parse_args (argc, argv)
7777
int argc;
7878
char **argv;
@@ -163,7 +163,7 @@ main (argc, argv)
163163
char *argv[];
164164
{
165165
char *env_value;
166-
char *env_argv[30];
166+
const char *env_argv[30];
167167
int env_argc;
168168

169169
/* Interactive? */

0 commit comments

Comments
 (0)