From owner-freebsd-bugs@FreeBSD.ORG Thu Mar 15 01:50:03 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E3FDF106564A for ; Thu, 15 Mar 2012 01:50:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id CD72F8FC0A for ; Thu, 15 Mar 2012 01:50:03 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q2F1o36t095630 for ; Thu, 15 Mar 2012 01:50:03 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q2F1o3Vl095629; Thu, 15 Mar 2012 01:50:03 GMT (envelope-from gnats) Date: Thu, 15 Mar 2012 01:50:03 GMT Message-Id: <201203150150.q2F1o3Vl095629@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: dfilter@FreeBSD.ORG (dfilter service) Cc: Subject: Re: bin/159227: commit references a PR X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: dfilter service List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Mar 2012 01:50:04 -0000 The following reply was made to PR bin/159227; it has been noted by GNATS. From: dfilter@FreeBSD.ORG (dfilter service) To: bug-followup@FreeBSD.org Cc: Subject: Re: bin/159227: commit references a PR Date: Thu, 15 Mar 2012 01:43:53 +0000 (UTC) Author: kevlo Date: Thu Mar 15 01:43:44 2012 New Revision: 232994 URL: http://svn.freebsd.org/changeset/base/232994 Log: - Fix an erroneous invocation of the editline. - Fix wrong scaling in the bc.library. - Let length(0.000) conform to what gnu bc does. PR: bin/159227 Submitted by: AIDA Shinra Modified: head/usr.bin/bc/bc.library head/usr.bin/bc/bc.y head/usr.bin/dc/bcode.c Modified: head/usr.bin/bc/bc.library ============================================================================== --- head/usr.bin/bc/bc.library Wed Mar 14 23:55:25 2012 (r232993) +++ head/usr.bin/bc/bc.library Thu Mar 15 01:43:44 2012 (r232994) @@ -46,7 +46,9 @@ define e(x) { r = ibase ibase = A t = scale - scale = t + .434*x + 1 + scale = 0 + if (x > 0) scale = (0.435*x)/1 + scale = scale + t + 1 w = 0 if (x < 0) { @@ -95,26 +97,33 @@ define l(x) { t = scale f = 1 - scale = scale + scale(x) - length(x) + 1 - s = scale + if (x < 1) { + s = scale(x) + } else { + s = length(x) - scale(x) + } + scale = 0 + a = (2.31*s)/1 /* estimated integer part of the answer */ + s = t + length(a) + 2 /* estimated length of the answer */ while (x > 2) { - s = s + (length(x) - scale(x))/2 + 1 - if (s > 0) scale = s + scale=0 + scale = (length(x) + scale(x))/2 + 1 + if (scale < s) scale = s x = sqrt(x) f = f*2 } while (x < .5) { - s = s + (length(x) - scale(x))/2 + 1 - if (s > 0) scale = s + scale = 0 + scale = scale(x)/2 + 1 + if (scale < s) scale = s x = sqrt(x) f = f*2 } - scale = t + length(f) - scale(f) + 1 + scale = t + length(f) + length(t + length(f)) + 1 u = (x - 1)/(x + 1) - - scale = scale + 1.1*length(t) - 1.1*scale(t) s = u*u + scale = t + 2 b = 2*f c = b d = 1 @@ -261,3 +270,4 @@ define j(n,x) { e = g } } +/* vim: set filetype=bc shiftwidth=8 noexpandtab: */ Modified: head/usr.bin/bc/bc.y ============================================================================== --- head/usr.bin/bc/bc.y Wed Mar 14 23:55:25 2012 (r232993) +++ head/usr.bin/bc/bc.y Thu Mar 15 01:43:44 2012 (r232994) @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "extern.h" #include "pathnames.h" @@ -1093,7 +1094,7 @@ sigchld(int signo) switch (signo) { default: for (;;) { - pid = waitpid(dc, &status, WCONTINUED); + pid = waitpid(dc, &status, WUNTRACED); if (pid == -1) { if (errno == EINTR) continue; @@ -1181,16 +1182,6 @@ main(int argc, char *argv[]) dup(p[1]); close(p[0]); close(p[1]); - if (interactive) { - el = el_init("bc", stdin, stderr, stderr); - hist = history_init(); - history(hist, &he, H_SETSIZE, 100); - el_set(el, EL_HIST, history, hist); - el_set(el, EL_EDITOR, "emacs"); - el_set(el, EL_SIGNAL, 1); - el_set(el, EL_PROMPT, dummy_prompt); - el_source(el, NULL); - } } else { close(STDIN_FILENO); dup(p[0]); @@ -1200,6 +1191,16 @@ main(int argc, char *argv[]) err(1, "cannot find dc"); } } + if (interactive) { + el = el_init("bc", stdin, stderr, stderr); + hist = history_init(); + history(hist, &he, H_SETSIZE, 100); + el_set(el, EL_HIST, history, hist); + el_set(el, EL_EDITOR, "emacs"); + el_set(el, EL_SIGNAL, 1); + el_set(el, EL_PROMPT, dummy_prompt); + el_source(el, NULL); + } yywrap(); return (yyparse()); } Modified: head/usr.bin/dc/bcode.c ============================================================================== --- head/usr.bin/dc/bcode.c Wed Mar 14 23:55:25 2012 (r232993) +++ head/usr.bin/dc/bcode.c Thu Mar 15 01:43:44 2012 (r232994) @@ -693,7 +693,7 @@ count_digits(const struct number *n) u_int i; if (BN_is_zero(n->number)) - return (1); + return (n->scale ? n->scale : 1); int_part = new_number(); fract_part = new_number(); _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"