When displaying Chinese help information in Cygwin setup, the program does not respond. The code enters a dead loop.

Brian Inglis Brian.Inglis@SystematicSW.ab.ca
Fri Mar 29 04:01:16 GMT 2024


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



More information about the Cygwin mailing list