[setup - the official Cygwin setup program] branch master, updated. release_2.931-1-g0ee13c62

Jon Turney jturney@sourceware.org
Fri Mar 29 16:07:02 GMT 2024




https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=0ee13c62b3d83f469d2ba0eec10b4bfc3815f263

commit 0ee13c62b3d83f469d2ba0eec10b4bfc3815f263
Author: 赵伟 <qdzhaov@qq.com>
Date:   Fri Mar 29 15:10:18 2024 +0000

    Fix endless loop if helptext doesn't contain a space
    
    If the helptext doesn't have a space in the length of the describption
    we're trying to format, this code spins.


Diff:
---
 libgetopt++/include/getopt++/DefaultFormatter.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libgetopt++/include/getopt++/DefaultFormatter.h b/libgetopt++/include/getopt++/DefaultFormatter.h
index ee2397f5..b7348162 100644
--- a/libgetopt++/include/getopt++/DefaultFormatter.h
+++ b/libgetopt++/include/getopt++/DefaultFormatter.h
@@ -62,8 +62,11 @@ class DefaultFormatter {
       std::string helpmsg = strLookup(anOption->shortHelp());
       while (helpmsg.size() > h_len)
 	{
-	  // TODO: consider using a line breaking strategy here.
-	  int pos = helpmsg.substr(0,h_len).find_last_of(" ");
+          size_t pos = helpmsg.substr(0,h_len).find_last_of(" ");
+          // if there's no space character, working out where to line-break
+          // composing UTF-8 characters is hard, so don't bother trying...
+          if (pos == std::string::npos)
+            break;
 	  theStream << helpmsg.substr(0,pos)
 		    << std::endl << std::string (o_len, ' ');
 	  helpmsg.erase (0,pos+1);



More information about the Cygwin-apps-cvs mailing list