public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* When displaying Chinese help information, the program does not respond. The code enters a dead loop.
@ 2024-03-28 15:26 =?gb18030?B?1dTOsA==?=
  2024-03-29  4:01 ` When displaying Chinese help information in Cygwin setup, " Brian Inglis
  0 siblings, 1 reply; 3+ messages in thread
From: =?gb18030?B?1dTOsA==?= @ 2024-03-28 15:26 UTC (permalink / raw)
  To: =?gb18030?B?Y3lnd2luQGN5Z3dpbi5jb20=?=

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb18030", Size: 1159 bytes --]

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);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: When displaying Chinese help information in Cygwin setup, the program does not respond. The code enters a dead loop.
  2024-03-28 15:26 When displaying Chinese help information, the program does not respond. The code enters a dead loop =?gb18030?B?1dTOsA==?=
@ 2024-03-29  4:01 ` Brian Inglis
  0 siblings, 0 replies; 3+ messages in thread
From: Brian Inglis @ 2024-03-29  4:01 UTC (permalink / raw)
  To: cygwin; +Cc: 赵伟

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* When displaying Chinese help information, the program does not respond. The code enters a dead loop.
@ 2024-03-28 15:23 =?gb18030?B?1dTOsA==?=
  0 siblings, 0 replies; 3+ messages in thread
From: =?gb18030?B?1dTOsA==?= @ 2024-03-28 15:23 UTC (permalink / raw)
  To: =?gb18030?B?Y3lnd2luQGN5Z3dpbi5jb20=?=

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb18030", Size: 1191 bytes --]

When displaying Chinese help information, the program does not respond.&nbsp;
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 {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // TODO: consider using a line breaking strategy here.
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int pos = helpmsg.substr(0,h_len).find_last_of(" ");
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(pos<=0)break;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; theStream << helpmsg.substr(0,pos)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; << std::endl << std::string (o_len, ' ');
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; helpmsg.erase (0,pos+1);

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-29  4:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-28 15:26 When displaying Chinese help information, the program does not respond. The code enters a dead loop =?gb18030?B?1dTOsA==?=
2024-03-29  4:01 ` When displaying Chinese help information in Cygwin setup, " Brian Inglis
  -- strict thread matches above, loose matches on Subject: below --
2024-03-28 15:23 When displaying Chinese help information, " =?gb18030?B?1dTOsA==?=

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).