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

Reply via email to