All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zdenek Kabelac <zkabelac@sourceware.org>
To: lvm-devel@redhat.com
Subject: main - man-generator: decorate optional option prefixes
Date: Mon, 19 Apr 2021 13:00:50 +0000 (GMT)	[thread overview]
Message-ID: <20210419130050.7BFE43969019@sourceware.org> (raw)

Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=efd0939583484b85ddb8ed3ebb7cda0db51cf473
Commit:        efd0939583484b85ddb8ed3ebb7cda0db51cf473
Parent:        679116a9b859888a893de83236a8966063046f2b
Author:        Zdenek Kabelac <zkabelac@redhat.com>
AuthorDate:    Thu Apr 15 20:00:09 2021 +0200
Committer:     Zdenek Kabelac <zkabelac@redhat.com>
CommitterDate: Mon Apr 19 14:37:08 2021 +0200

man-generator: decorate optional option prefixes

Enhance man typography decoration of optional option
prefixes like --[raid]writebeind and use regular font to render []
as these are not part of the option name itself.
---
 tools/command.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/tools/command.c b/tools/command.c
index e776edaa2..556f22e95 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -2445,6 +2445,7 @@ static const char *_man_long_opt_name(const char *cmdname, int opt_enum)
 {
 	static char long_opt_name[LONG_OPT_NAME_LEN];
 	const char *long_opt;
+	int i;
 
 	memset(&long_opt_name, 0, sizeof(long_opt_name));
 
@@ -2481,6 +2482,25 @@ static const char *_man_long_opt_name(const char *cmdname, int opt_enum)
 		break;
 	}
 
+	if (strchr(long_opt, '[')) {
+		for (i = 0; i < sizeof(long_opt_name); ++long_opt, ++i) {
+			if (i < (sizeof(long_opt_name) - 8))
+				switch(*long_opt) {
+				case '[':
+					strcpy(long_opt_name + i, "\\fP[\\fB");
+					i += 6;
+					continue;
+				case ']':
+					strcpy(long_opt_name + i, "\\fP]\\fB");
+					i += 6;
+					continue;
+				}
+			long_opt_name[i] = *long_opt;
+		}
+		long_opt_name[i] = 0;
+		return long_opt_name;
+	}
+
 	return long_opt;
 }
 



                 reply	other threads:[~2021-04-19 13:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210419130050.7BFE43969019@sourceware.org \
    --to=zkabelac@sourceware.org \
    --cc=lvm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.