On 27/01/2026 18:10, Pádraig Brady wrote:
On 26/01/2026 16:01, [email protected] wrote:
Can that highlighting not be made to work when there is only
one space between option and description?
I'll apply the attached to our highlighting matcher,
which makes --long-option matching a bit more strict,
thus avoiding the issue.
We also need similar tightening of the highlighting in
various translated dd --help output, which is done in the attached.
cheers,
Padraig
From cd841c54b8b41700cd635311db3dd87340c8fbda Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email protected]>
Date: Fri, 30 Jan 2026 17:34:28 +0000
Subject: [PATCH] doc: improve highlighting of dd --help translations
* src/system.h (oputs_): Ensure we're not matching '-' in
translated descriptions. Also support highlighting only
dd "foo=bar" when the description is separated with a single space.
---
src/system.h | 30 +++++++++++++++++++++++++-----
1 file changed, 25 insertions(+), 5 deletions(-)
diff --git a/src/system.h b/src/system.h
index 6a84d1cc3..e52990d44 100644
--- a/src/system.h
+++ b/src/system.h
@@ -567,28 +567,48 @@ oputs_ (MAYBE_UNUSED char const *program, char const *option)
return;
}
+ bool double_space = true;
char const *first_word = option + strspn (option, " \t\n");
char const *option_text = strchr (option, '-');
- if (!option_text)
- option_text = first_word; /* for dd option syntax. */
+ if (!option_text) /* for dd(1) option syntax. */
+ {
+ option_text = first_word;
+ /* Just match first word to support single spaced
+ translated dd "foo=bar description" format. */
+ double_space = false;
+ }
+ else if (option_text != first_word) /* for test(1) option syntax. */
+ {
+ /* Ensure only a single space before '-', to avoid matching
+ within descriptions for translated dd option syntax. */
+ char const *s = first_word;
+ while (s < option_text && !(isspace (*s) && isspace (*(s + 1))))
+ s++;
+ if (s < option_text)
+ {
+ /* Probably mismatched dd format. */
+ option_text = first_word;
+ double_space = false;
+ }
+ }
+
size_t anchor_len = strcspn (option_text, ",=[ \n");
/* Set highlighted text up to spacing after the full option text.
Any single space is included in highlighted text,
double space or TAB or newline terminates the option text. */
- bool long_option = false;
char const *desc_text = option_text + anchor_len;
while (*desc_text && *desc_text != '\n')
{
if (*desc_text == '-' && *(desc_text + 1) == '-')
- long_option = true;
+ double_space = false;
if (isspace (*desc_text))
{
if (*desc_text == '\t' || isspace (*(desc_text + 1)))
break;
/* With long options we restrict the match as some translations
delimit a long option and description with a single space. */
- if (long_option && *(desc_text + 1) != '-')
+ if (!double_space && *(desc_text + 1) != '-')
break;
}
--
2.52.0