Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/historical/nawk/bin Use literal for formatting the ...
details: https://anonhg.NetBSD.org/src/rev/7e85e2d99f45
branches: trunk
changeset: 353801:7e85e2d99f45
user: abhinav <abhinav%NetBSD.org@localhost>
date: Tue May 23 14:11:08 2017 +0000
description:
Use literal for formatting the examples
Based on OpenBSD awk(1) man page.
Ok wiz@
diffstat:
external/historical/nawk/bin/awk.1 | 57 +++++++++++++++++++++++--------------
1 files changed, 35 insertions(+), 22 deletions(-)
diffs (90 lines):
diff -r fa208f7b6c1d -r 7e85e2d99f45 external/historical/nawk/bin/awk.1
--- a/external/historical/nawk/bin/awk.1 Tue May 23 13:55:32 2017 +0000
+++ b/external/historical/nawk/bin/awk.1 Tue May 23 14:11:08 2017 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: awk.1,v 1.4 2015/04/06 14:36:41 wiz Exp $
+.\" $NetBSD: awk.1,v 1.5 2017/05/23 14:11:08 abhinav Exp $
.\"
.\" Copyright (C) Lucent Technologies 1997
.\" All Rights Reserved
@@ -22,7 +22,7 @@
.\" ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
.\" THIS SOFTWARE.
.\"
-.Dd April 6, 2015
+.Dd May 18, 2017
.Dt AWK 1
.Os
.Sh NAME
@@ -661,8 +661,8 @@
.El
.Ss Functions
Functions may be defined (at the position of a pattern-action statement) thus:
-.Bd -filled -offset indent
-.Ic function foo(a, b, c) { ...; return x }
+.Bd -literal -offset indent
+function foo(a, b, c) { ...; return x }
.Ed
.Pp
Parameters are passed by value if scalar and by reference if array name;
@@ -671,29 +671,42 @@
Thus local variables may be created by providing excess parameters in
the function definition.
.Sh EXAMPLES
-.Bl -tag -width indent -compact
-.It Ic length($0) \*[Gt] 72
-Print lines longer than 72 characters.
+Print lines longer than 72 characters:
+.Pp
+.Dl length($0) > 72
+.Pp
+Print first two fields in opposite order:
.Pp
-.It Ic \&{ print $2, $1 \&}
-Print first two fields in opposite order.
+.Dl { print $2, $1 }
.Pp
-.It Ic BEGIN { FS = \&",[ \et]*|[ \et]+\&" }
-.It Ic "\ \ \ \ \ \ {" print \&$2, \&$1 }
-Same, with input fields separated by comma and/or blanks and tabs.
+Same, with input fields separated by comma and/or blanks and tabs:
+.Bd -literal -offset indent
+BEGIN { FS = ",[ \et]*|[ \et]+" }
+ { print $2, $1 }
+.Ed
.Pp
-.It Ic "\ \ \ \ {" s += $1 }
-.It Ic END { print \&"sum is\&", s, \&" average is\ \&",\ s/NR\ }
-Add up first column, print sum and average.
+Add up first column, print sum and average:
+.Bd -literal -offset indent
+{ s += $1 }
+END { print "sum is", s, " average is", s/NR }
+.Ed
+.Pp
+Print all lines between start/stop pairs:
+.Pp
+.Dl /start/, /stop/
.Pp
-.It Ic /start/, /stop/
-Print all lines between start/stop pairs.
+Simulate echo(1):
+.Bd -literal -offset indent
+BEGIN { # Simulate echo(1)
+ for (i = 1; i < ARGC; i++) printf "%s ", ARGV[i]
+ printf "\en"
+ exit }
+.Ed
.Pp
-.It Ic BEGIN { # Simulate echo(1)
-.It Ic "\ \ \ \ " for (i = 1; i \*[Lt] ARGC;\ i++)\ printf\ \&"%s\ \&",\ ARGV[i]
-.It Ic "\ \ \ \ " printf \&"\en\&"
-.It Ic "\ \ \ \ " exit }
-.El
+Print an error message to standard error:
+.Bd -literal -offset indent
+{ print "error!" > "/dev/stderr" }
+.Ed
.Sh SEE ALSO
.Xr egrep 1 ,
.Xr lex 1 ,
Home |
Main Index |
Thread Index |
Old Index