void-packages/srcpkgs/bc/patches/read.patch
Leah Neukirchen e3d748a338 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.
2017-04-06 15:03:53 +02:00

44 lines
1.4 KiB
Diff

--- 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);