Module Name:    src
Committed By:   dholland
Date:           Mon Sep  7 17:56:52 UTC 2009

Modified Files:
        src/usr.bin/ldd: ldd.1 ldd.c

Log Message:
Add an -o option that behaves like nm -o. Implementation from a suggestion
by jmcneill (thanks!); ok mrg. Closes PR 41994.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/ldd/ldd.1
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/ldd/ldd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/ldd/ldd.1
diff -u src/usr.bin/ldd/ldd.1:1.16 src/usr.bin/ldd/ldd.1:1.17
--- src/usr.bin/ldd/ldd.1:1.16	Sun Aug 23 15:37:39 2009
+++ src/usr.bin/ldd/ldd.1	Mon Sep  7 17:56:52 2009
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ldd.1,v 1.16 2009/08/23 15:37:39 wiz Exp $
+.\"	$NetBSD: ldd.1,v 1.17 2009/09/07 17:56:52 dholland Exp $
 .\"
 .\" Copyright (c) 1998 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd August 23, 2009
+.Dd September 7, 2009
 .Dt LDD 1
 .Os
 .Sh NAME
@@ -35,6 +35,7 @@
 .Nd list dynamic object dependencies
 .Sh SYNOPSIS
 .Nm
+.Op Fl o
 .Op Fl f Ar format
 .Ar program ...
 .Sh DESCRIPTION
@@ -93,6 +94,16 @@
 and
 .Sy \et
 are recognized and have their usual meaning.
+.Pp
+The
+.Fl o
+option is an alias for
+.Fl f
+.Ar \&%a:-l\&%o.\&%m =\*[Gt] \&%p\en ,
+which makes
+.Nm
+behave analogously to
+.Ic nm Fl o .
 .Sh SEE ALSO
 .Xr ld 1 ,
 .Xr ld.elf_so 1 ,

Index: src/usr.bin/ldd/ldd.c
diff -u src/usr.bin/ldd/ldd.c:1.9 src/usr.bin/ldd/ldd.c:1.10
--- src/usr.bin/ldd/ldd.c:1.9	Sat Aug 22 06:52:16 2009
+++ src/usr.bin/ldd/ldd.c	Mon Sep  7 17:56:52 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: ldd.c,v 1.9 2009/08/22 06:52:16 mrg Exp $	*/
+/*	$NetBSD: ldd.c,v 1.10 2009/09/07 17:56:52 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: ldd.c,v 1.9 2009/08/22 06:52:16 mrg Exp $");
+__RCSID("$NetBSD: ldd.c,v 1.10 2009/09/07 17:56:52 dholland Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -114,13 +114,13 @@
 int
 main(int argc, char **argv)
 {
-	char *fmt1 = NULL, *fmt2 = NULL;
+	const char *fmt1 = NULL, *fmt2 = NULL;
 	int c;
 
 #ifdef DEBUG
 	debug = 1;
 #endif
-	while ((c = getopt(argc, argv, "f:")) != -1) {
+	while ((c = getopt(argc, argv, "f:o")) != -1) {
 		switch (c) {
 		case 'f':
 			if (fmt1) {
@@ -130,6 +130,11 @@
 			} else
 				fmt1 = optarg;
 			break;
+		case 'o':
+			if (fmt1 || fmt2)
+				errx(1, "Cannot use -o and -f together");
+			fmt1 = "%a:-l%o.%m => %p\n";
+			break;
 		default:
 			usage();
 			/*NOTREACHED*/

Reply via email to