From 0a2a4b2364f822d1e852ac84f2f313b045ef0d73 Mon Sep 17 00:00:00 2001 From: pstef Date: Mon, 4 Jun 2018 21:05:56 +0000 Subject: [PATCH] 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. --- usr.bin/indent/args.c | 8 ++++++++ usr.bin/indent/indent.1 | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/usr.bin/indent/args.c b/usr.bin/indent/args.c index 62cb3b62008..2a6d07ef54e 100644 --- a/usr.bin/indent/args.c +++ b/usr.bin/indent/args.c @@ -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}, @@ -302,6 +306,10 @@ set_option(char *arg) 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); } diff --git a/usr.bin/indent/indent.1 b/usr.bin/indent/indent.1 index 85c28dfb946..6180b4baa9e 100644 --- a/usr.bin/indent/indent.1 +++ b/usr.bin/indent/indent.1 @@ -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 more lines of output, 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 -- 2.45.0