public inbox for cygwin-apps-cvs@sourceware.org
help / color / mirror / Atom feed
* [setup - the official Cygwin setup program] branch master, updated. release_2.931-1-g0ee13c62
@ 2024-03-29 16:07 Jon Turney
  0 siblings, 0 replies; only message in thread
From: Jon Turney @ 2024-03-29 16:07 UTC (permalink / raw)
  To: cygwin-apps-cvs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1449 bytes --]




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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-03-29 16:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-29 16:07 [setup - the official Cygwin setup program] branch master, updated. release_2.931-1-g0ee13c62 Jon Turney

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