public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
To: cygwin@cygwin.com
Cc: 赵伟 <qdzhaov@qq.com>
Subject: Re: When displaying Chinese help information in Cygwin setup, the program does not respond. The code enters a dead loop.
Date: Thu, 28 Mar 2024 22:01:16 -0600	[thread overview]
Message-ID: <977c901f-4733-4c17-960c-91b652024bff@SystematicSW.ab.ca> (raw)
In-Reply-To: <tencent_1D4A1965D169D6E2B9F6CA21B7160E3A8C09@qq.com>

On 2024-03-28 09:26, 赵伟 via Cygwin wrote:
> When displaying Chinese help information, the program does not respond.
> The code enters a dead loop in file 
> "libgetopt++/include/getopt++/DefaultFormatter.h",
> because some Chinese help information does not contain spaces.
> diff --git a/libgetopt++/include/getopt++/DefaultFormatter.h b/libgetopt++/include/getopt++/DefaultFormatter.h
> index ee2397f5..19ac67e1 100644
> --- a/libgetopt++/include/getopt++/DefaultFormatter.h
> +++ b/libgetopt++/include/getopt++/DefaultFormatter.h
> @@ -64,6 +64,7 @@ class DefaultFormatter {
>         {
>           // TODO: consider using a line breaking strategy here.
>           int pos = helpmsg.substr(0,h_len).find_last_of(" ");
> +         if (pos <= 0) break;
>           theStream << helpmsg.substr(0,pos)
>                     << std::endl << std::string (o_len, ' ');
>           helpmsg.erase (0,pos+1);

It seems that the best approach for Chinese translations would be to:

- add spaces at sentence or word breaks in translations before 35 or 45 bytes, 
if that is the length unit, worth of characters are output in each column; or

- add a language dependent line breaking strategy, to honour characters not to 
be placed at the beginning or ends of lines or split; or

- split between characters, as with long strings in other languages.

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer     but when there is no more to cut
                                 -- Antoine de Saint-Exupéry


      reply	other threads:[~2024-03-29  4:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-28 15:26 When displaying Chinese help information, " =?gb18030?B?1dTOsA==?=
2024-03-29  4:01 ` Brian Inglis [this message]

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=977c901f-4733-4c17-960c-91b652024bff@SystematicSW.ab.ca \
    --to=brian.inglis@systematicsw.ab.ca \
    --cc=cygwin@cygwin.com \
    --cc=qdzhaov@qq.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).