bc: hotfix for read()

This fixes the read() function that doesn't terminate on newlines in bc
1.07 (an upstream bug has been reported).  Patch due to educated
guesswork on the diff between 1.06.95 and 1.07.  This fixes building
Linux 4.10 with bc.
This commit is contained in:
Leah Neukirchen 2017-04-06 15:02:39 +02:00
parent 824651e827
commit e3d748a338
2 changed files with 45 additions and 1 deletions

View File

@ -0,0 +1,44 @@
--- bc/execute.c
+++ bc/execute.c
@@ -638,19 +638,19 @@ push_constant (int (*in_char)(VOID), int conv_base)
}
/* Check for the special case of a single digit. */
- if (in_ch < 36)
+ if (in_ch < 16)
{
first_ch = in_ch;
in_ch = in_char();
- if (in_ch < 36 && first_ch >= conv_base)
+ if (in_ch < 16 && first_ch >= conv_base)
first_ch = conv_base - 1;
bc_int2num (&build, (int) first_ch);
}
/* Convert the integer part. */
- while (in_ch < 36)
+ while (in_ch < 16)
{
- if (in_ch < 36 && in_ch >= conv_base) in_ch = conv_base-1;
+ if (in_ch < 16 && in_ch >= conv_base) in_ch = conv_base-1;
bc_multiply (build, mult, &result, 0);
bc_int2num (&temp, (int) in_ch);
bc_add (result, temp, &build, 0);
@@ -665,7 +665,7 @@ push_constant (int (*in_char)(VOID), int conv_base)
divisor = bc_copy_num (_one_);
result = bc_copy_num (_zero_);
digits = 0;
- while (in_ch < 36)
+ while (in_ch < 16)
{
bc_multiply (result, mult, &result, 0);
bc_int2num (&temp, (int) in_ch);
@@ -673,7 +673,7 @@ push_constant (int (*in_char)(VOID), int conv_base)
bc_multiply (divisor, mult, &divisor, 0);
digits++;
in_ch = in_char();
- if (in_ch < 36 && in_ch >= conv_base) in_ch = conv_base-1;
+ if (in_ch < 16 && in_ch >= conv_base) in_ch = conv_base-1;
}
bc_divide (result, divisor, &result, digits);
bc_add (build, result, &build, 0);

View File

@ -1,7 +1,7 @@
# Template file for 'bc'
pkgname=bc
version=1.07
revision=1
revision=2
build_style=gnu-configure
configure_args="--with-readline"
hostmakedepends="ed flex"