This command echo 'for(;;) {}' |./bc/bc produces a segfault on RH and SuSE. This patch, extracted from debian, fixes it. --- bc-1.06.orig/bc/main.c +++ bc-1.06/bc/main.c @@ -93,6 +93,9 @@ switch (optch) { + case 0: /* Long option setting a var. */ + break; + case 'c': /* compile only */ compile_only = TRUE; break; --- bc-1.06.orig/bc/bc.y +++ bc-1.06/bc/bc.y @@ -203,7 +203,7 @@ { if ($4 & 2) warn ("Comparison in first for expression"); - if ($4 >= 0) + if ($4 <= 0) generate ("p"); $4 = next_label++; sprintf (genstr, "N%1d:", $4); @@ -211,7 +211,7 @@ } opt_expression ';' { - if ($7 < 0) generate ("1"); + if ($7 &16 ) generate ("1"); $7 = next_label++; sprintf (genstr, "B%1d:J%1d:", $7, break_label); generate (genstr); --- bc-1.06.orig/bc/scan.l +++ bc-1.06/bc/scan.l @@ -44,7 +44,9 @@ #endif /* Force . as last for now. */ -#define DOT_IS_LAST +/* edd 9 June 2001 commented out for GNU readline-4.2 + #define DOT_IS_LAST +*/ /* We want to define our own yywrap. */ #undef yywrap @@ -143,7 +145,9 @@ /* Definitions for readline access. */ extern FILE *rl_instream; -_PROTOTYPE(char *readline, (char *)); +/* edd 9 June 2001 commented out for GNU readline-4.2 + _PROTOTYPE(char *readline, (char *)); +*/ /* rl_input puts upto MAX characters into BUF with the number put in BUF placed in *RESULT. If the yy input file is the same as --- bc-1.06.orig/bc/load.c +++ bc-1.06/bc/load.c @@ -156,7 +156,7 @@ long label_no; long vaf_name; /* variable, array or function number. */ long func; - program_counter save_adr; + static program_counter save_adr; /* Initialize. */ str = code;