Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/bc/dist bc(1): Indent displays with code examples.
details: https://anonhg.NetBSD.org/src/rev/f93638b09c92
branches: trunk
changeset: 958491:f93638b09c92
user: uwe <uwe%NetBSD.org@localhost>
date: Thu Jan 07 20:22:34 2021 +0000
description:
bc(1): Indent displays with code examples.
diffstat:
external/bsd/bc/dist/bc.1 | 18 ++++++++++--------
1 files changed, 10 insertions(+), 8 deletions(-)
diffs (84 lines):
diff -r eb0a3002a622 -r f93638b09c92 external/bsd/bc/dist/bc.1
--- a/external/bsd/bc/dist/bc.1 Thu Jan 07 20:12:59 2021 +0000
+++ b/external/bsd/bc/dist/bc.1 Thu Jan 07 20:22:34 2021 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: bc.1,v 1.4 2021/01/07 20:12:59 uwe Exp $
+.\" $NetBSD: bc.1,v 1.5 2021/01/07 20:22:34 uwe Exp $
.\"
.\" bc.1 - the bc manual
.\"
@@ -726,10 +726,11 @@
definition function for the same name is encountered.
The new definition then replaces the older definition.
A function is defined as follows:
-.Bd -literal
+.Bd -literal -offset indent
define name ( parameters ) { newline
auto_list statement_list }
.Ed
+.Pp
A function call is just an expression of the form
.Do Ar name ( Ar parameters ) Dc .
.Pp
@@ -829,7 +830,7 @@
will allow any number of newlines before and after the opening brace of the
function.
For example, the following definitions are legal.
-.Bd -literal
+.Bd -literal -offset indent
define d (n) { return (2*n); }
define d (n)
{ return (2*n); }
@@ -851,7 +852,7 @@
.Ic define
and the function name.
For example, consider the following session.
-.Bd -literal
+.Bd -literal -offset indent
define py (y) { print "--->", y, "<---", "\n"; }
define void px (x) { print "--->", x, "<---", "\n"; }
py(1)
@@ -860,6 +861,7 @@
px(1)
--->1<---
.Ed
+.Pp
Since
.Ar py
is not a void function, the call of
@@ -938,7 +940,7 @@
.Ar pi
to the shell variable
.Ar pi .
-.Bd -literal
+.Bd -literal -offset indent
pi=$(echo "scale=10; 4*a(1)" | bc -l)
.Ed
.Pp
@@ -946,7 +948,7 @@
math library.
This function is written in POSIX
.Nm .
-.Bd -literal
+.Bd -literal -offset indent
scale = 20
/* Uses the fact that e^x = (e^(x/2))^2
@@ -994,7 +996,7 @@
to implement a simple program for calculating checkbook balances.
This program is best kept in a file so that it can be used many times
without having to retype it at every use.
-.Bd -literal
+.Bd -literal -offset indent
scale=2
print "\enCheck book program!\en"
print " Remember, deposits are negative transactions.\en"
@@ -1014,7 +1016,7 @@
.Ed
.Pp
The following is the definition of the recursive factorial function.
-.Bd -literal
+.Bd -literal -offset indent
define f (x) {
if (x <= 1) return (1);
return (f(x-1) * x);
Home |
Main Index |
Thread Index |
Old Index