* [PATCH setup] Fix Chinese Help Message fall in dead loop .
@ 2024-03-29 1:40 =?gb18030?B?1dTOsA==?=
2024-03-29 3:48 ` Brian Inglis
2024-03-29 16:32 ` Jon Turney
0 siblings, 2 replies; 4+ messages in thread
From: =?gb18030?B?1dTOsA==?= @ 2024-03-29 1:40 UTC (permalink / raw)
To: =?gb18030?B?Y3lnd2luLWFwcHM=?=
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb18030", Size: 806 bytes --]
---
libgetopt++/include/getopt++/DefaultFormatter.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/libgetopt++/include/getopt++/DefaultFormatter.h b/libgetopt++/include/getopt++/DefaultFormatter.h
index ee2397f5..43c253a5 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)break; /*In Chinese Helpmsg,may has no space,so pos ==0,and code will fall in dead loop here*/
theStream << helpmsg.substr(0,pos)
<< std::endl << std::string (o_len, ' ');
helpmsg.erase (0,pos+1);
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH setup] Fix Chinese Help Message fall in dead loop .
2024-03-29 1:40 [PATCH setup] Fix Chinese Help Message fall in dead loop =?gb18030?B?1dTOsA==?=
@ 2024-03-29 3:48 ` Brian Inglis
2024-03-29 16:32 ` Jon Turney
1 sibling, 0 replies; 4+ messages in thread
From: Brian Inglis @ 2024-03-29 3:48 UTC (permalink / raw)
To: cygwin-apps
On 2024-03-28 19:40, 赵伟 via Cygwin-apps wrote:
> ---
> libgetopt++/include/getopt++/DefaultFormatter.h | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/libgetopt++/include/getopt++/DefaultFormatter.h b/libgetopt++/include/getopt++/DefaultFormatter.h
> index ee2397f5..43c253a5 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)break; /*In Chinese Helpmsg,may has no space,so pos ==0,and code will fall in dead loop here*/
> 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] 4+ messages in thread
* Re: [PATCH setup] Fix Chinese Help Message fall in dead loop .
2024-03-29 1:40 [PATCH setup] Fix Chinese Help Message fall in dead loop =?gb18030?B?1dTOsA==?=
2024-03-29 3:48 ` Brian Inglis
@ 2024-03-29 16:32 ` Jon Turney
1 sibling, 0 replies; 4+ messages in thread
From: Jon Turney @ 2024-03-29 16:32 UTC (permalink / raw)
To: 赵伟; +Cc: cygwin-apps
On 29/03/2024 01:40, 赵伟 via Cygwin-apps wrote:
> ---
> libgetopt++/include/getopt++/DefaultFormatter.h | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/libgetopt++/include/getopt++/DefaultFormatter.h b/libgetopt++/include/getopt++/DefaultFormatter.h
> index ee2397f5..43c253a5 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)break; /*In Chinese Helpmsg,may has no space,so pos ==0,and code will fall in dead loop here*/
> theStream << helpmsg.substr(0,pos)
> << std::endl << std::string (o_len, ' ');
> helpmsg.erase (0,pos+1);
> --
> 2.43.0
Thanks very much for bug report, and the patch!
Did you actually try this? When I tested this it didn't help, as
std::string::substr() returns std::string::npos (numerically, -1), not 0
when it cannot find a match.
So, I applied a slightly modified version of the patch.
Please try https://cygwin.com/setup/setup-2.931-1-g0ee13c.x86_64.exe
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH setup] Fix Chinese Help Message fall in dead loop .
@ 2024-03-29 1:35 =?gb18030?B?1dTOsA==?=
0 siblings, 0 replies; 4+ messages in thread
From: =?gb18030?B?1dTOsA==?= @ 2024-03-29 1:35 UTC (permalink / raw)
To: =?gb18030?B?Y3lnd2luLWFwcHM=?=
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb18030", Size: 1166 bytes --]
---
libgetopt++/include/getopt++/DefaultFormatter.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/libgetopt++/include/getopt++/DefaultFormatter.h b/libgetopt++/include/getopt++/DefaultFormatter.h
index ee2397f5..43c253a5 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)break; /*In Chinese Helpmsg,may has no space,so pos ==0,and code will fall in dead loop here*/
theStream << helpmsg.substr(0,pos)
<< std::endl << std::string (o_len, ' ');
helpmsg.erase (0,pos+1);
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-03-29 16:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-29 1:40 [PATCH setup] Fix Chinese Help Message fall in dead loop =?gb18030?B?1dTOsA==?=
2024-03-29 3:48 ` Brian Inglis
2024-03-29 16:32 ` Jon Turney
-- strict thread matches above, loose matches on Subject: below --
2024-03-29 1:35 =?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).