Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.
/ bc Public archive
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions bc-1.06-dc_ibase.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
--- bc-1.06/dc/numeric.c.dc_ibase 2007-08-22 08:37:57.000000000 +0200
+++ bc-1.06/dc/numeric.c 2007-08-22 08:37:40.000000000 +0200
@@ -285,6 +285,8 @@ dc_getnum DC_DECLARG((input, ibase, read
int digit;
int decimal;
int c;
+ int c_buff = 0;
+ int multi = 0;

bc_init_num(&tmp);
bc_init_num(&build);
@@ -302,6 +304,9 @@ dc_getnum DC_DECLARG((input, ibase, read
}
while (isspace(c))
c = (*input)();
+ c_buff = (*input)();
+ if (isdigit(c_buff) || ('A' <= c_buff && c_buff <= 'F') || c_buff == '.')
+ multi = 1;
for (;;){
if (isdigit(c))
digit = c - '0';
@@ -309,10 +314,15 @@ dc_getnum DC_DECLARG((input, ibase, read
digit = 10 + c - 'A';
else
break;
- c = (*input)();
+ digit = multi ? (digit >= ibase ? ibase -1 : digit) : digit;
bc_int2num(&tmp, digit);
bc_multiply(result, base, &result, 0);
bc_add(result, tmp, &result, 0);
+ if (c_buff) {
+ c = c_buff;
+ c_buff = 0;
+ } else
+ c = (*input)();
}
if (c == '.'){
bc_free_num(&build);
@@ -321,13 +331,18 @@ dc_getnum DC_DECLARG((input, ibase, read
build = bc_copy_num(_zero_);
decimal = 0;
for (;;){
- c = (*input)();
+ if (c_buff) {
+ c = c_buff;
+ c_buff = 0;
+ } else
+ c = (*input)();
if (isdigit(c))
digit = c - '0';
else if ('A' <= c && c <= 'F')
digit = 10 + c - 'A';
else
break;
+ digit = digit >= ibase ? ibase -1 : digit;
bc_int2num(&tmp, digit);
bc_multiply(build, base, &build, 0);
bc_add(build, tmp, &build, 0);
14 changes: 14 additions & 0 deletions bc-1.07.1-readline-echo-empty.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff -Naur bc-1.07.1/bc/scan.l bc-1.07.1-new/bc/scan.l
--- bc-1.07.1/bc/scan.l 2017-04-07 22:20:02.000000000 +0000
+++ bc-1.07.1-new/bc/scan.l 2021-08-14 12:12:33.860991777 +0000
@@ -170,6 +170,10 @@
if (rl_len != 1)
add_history (rl_line);
rl_line[rl_len-1] = '\n';
+ /* readline doesn't echo empty lines without a prompt,
+ so do so here. */
+ if (rl_len == 1)
+ putchar ('\n');
fflush (stdout);
}

Binary file added bc-1.08.1.tar.xz
Binary file not shown.
6 changes: 6 additions & 0 deletions bc.changes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
* Thu Jan 23 2025 Matti Lehtimäki <matti.lehtimaki@jolla.com> - 1.08.1
- [bc] Update to version 1.08.1. JB#50417

* Wed Mar 12 2014 David Greaves <david.greaves@jolla.com> - 1.06.95
- [bc] Package bc properly. Fixes MER#1256
- [packaging] add rpm packaging
34 changes: 17 additions & 17 deletions rpm/bc.spec → bc.spec
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ BuildRequires: bison
BuildRequires: ed
BuildRequires: flex
BuildRequires: readline-devel
BuildRequires: texinfo
Url: ftp://ftp.gnu.org/pub/gnu/bc
Version: 1.06.95
Version: 1.08.1
Release: 1
Summary: GNU Command Line Calculator
License: GPL-2.0+
Group: Productivity/Scientific/Math
Source: bc-%{version}.tar.bz2
License: GPLv3+
Source: bc-%{version}.tar.xz
Patch1: bc-1.06-dc_ibase.patch
Patch2: bc-1.07.1-readline-echo-empty.diff

%description
bc is an interpreter that supports numbers of arbitrary precision and
Expand All @@ -30,22 +32,20 @@ the next operator is read in, which "pops" its arguments off the stack
and "pushes" its results back onto the stack.

%prep
%setup -n %{name}-%{version}/%{name}
%autosetup -p1 -n %{name}-%{version}

%build
./configure CFLAGS="$RPM_OPT_FLAGS" \
--with-readline \
--prefix=/usr \
--mandir=%{_mandir} \
--build=%{_target_cpu}-suse-linux
rm bc/libmath.h
make
%configure --with-readline
%make_build

%install
make install DESTDIR=$RPM_BUILD_ROOT
%make_install

rm -Rf %{buildroot}%{_datadir}/info
rm -Rf %{buildroot}%{_datadir}/man

%files
%defattr(-,root,root)
%doc AUTHORS COPYING ChangeLog NEWS README COPYING.LIB FAQ
/usr/bin/bc
/usr/bin/dc
%license COPYING COPYING.LIB
%doc AUTHORS ChangeLog NEWS README FAQ
%{_bindir}/bc
%{_bindir}/dc
6 changes: 0 additions & 6 deletions bc/AUTHORS

This file was deleted.

Loading