svn commit: r334636 - head/usr.bin/indent

Piotr Pawel Stefaniak pstef at FreeBSD.org
Mon Jun 4 21:05:58 UTC 2018


Author: pstef
Date: Mon Jun  4 21:05:56 2018
New Revision: 334636
URL: https://svnweb.freebsd.org/changeset/base/334636

Log:
  indent(1): add --version option
  
  There exist multi-platform programs that check indent's version in order to
  know what they can expect from it. GNU indent provides that via --version,
  so implement the same option here.

Modified:
  head/usr.bin/indent/args.c
  head/usr.bin/indent/indent.1

Modified: head/usr.bin/indent/args.c
==============================================================================
--- head/usr.bin/indent/args.c	Mon Jun  4 20:55:25 2018	(r334635)
+++ head/usr.bin/indent/args.c	Mon Jun  4 21:05:56 2018	(r334636)
@@ -58,6 +58,8 @@ __FBSDID("$FreeBSD$");
 #include "indent_globs.h"
 #include "indent.h"
 
+#define INDENT_VERSION	"2.0"
+
 /* profile types */
 #define	PRO_SPECIAL	1	/* special case */
 #define	PRO_BOOL	2	/* boolean */
@@ -76,6 +78,7 @@ __FBSDID("$FreeBSD$");
 static void scan_profile(FILE *);
 
 #define	KEY_FILE		5	/* only used for args */
+#define VERSION			6	/* only used for args */
 
 const char *option_source = "?";
 
@@ -97,6 +100,7 @@ struct pro {
 
     {"T", PRO_SPECIAL, 0, KEY, 0},
     {"U", PRO_SPECIAL, 0, KEY_FILE, 0},
+    {"-version", PRO_SPECIAL, 0, VERSION, 0},
     {"P", PRO_SPECIAL, 0, IGN, 0},
     {"bacc", PRO_BOOL, false, ON, &blanklines_around_conditional_compilation},
     {"badp", PRO_BOOL, false, ON, &blanklines_after_declarations_at_proctop},
@@ -301,6 +305,10 @@ found:
 		goto need_param;
 	    add_typedefs_from_file(param_start);
 	    break;
+
+	case VERSION:
+	    printf("FreeBSD indent %s\n", INDENT_VERSION);
+	    exit(0);
 
 	default:
 	    errx(1, "set_option: internal error: p_special %d", p->p_special);

Modified: head/usr.bin/indent/indent.1
==============================================================================
--- head/usr.bin/indent/indent.1	Mon Jun  4 20:55:25 2018	(r334635)
+++ head/usr.bin/indent/indent.1	Mon Jun  4 21:05:56 2018	(r334636)
@@ -30,7 +30,7 @@
 .\"	@(#)indent.1	8.1 (Berkeley) 7/1/93
 .\" $FreeBSD$
 .\"
-.Dd August 7, 2017
+.Dd June 4, 2018
 .Dt INDENT 1
 .Os
 .Sh NAME
@@ -90,6 +90,7 @@
 .Op Fl U Ns Ar file
 .Op Fl ut | Fl nut
 .Op Fl v | Fl \&nv
+.Op Fl -version
 .Sh DESCRIPTION
 The
 .Nm
@@ -491,6 +492,10 @@ reports when it splits one line of input into two or m
 and gives some size statistics at completion.
 The default is
 .Fl \&nv .
+.It Fl -version
+Causes
+.Nm
+to print its version number and exit.
 .El
 .Pp
 You may set up your own `profile' of defaults to


More information about the svn-src-all mailing list