barbieri pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=99ba5822c84c6716ee51af93115a0bb0984464ef

commit 99ba5822c84c6716ee51af93115a0bb0984464ef
Author: Gustavo Sverzut Barbieri <barbi...@profusion.mobi>
Date:   Tue Dec 17 17:51:48 2013 -0200

    getopt: fix line wrapping issues in help strings.
---
 src/lib/ecore/ecore_getopt.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/lib/ecore/ecore_getopt.c b/src/lib/ecore/ecore_getopt.c
index 36baeb5..2a7850f 100644
--- a/src/lib/ecore/ecore_getopt.c
+++ b/src/lib/ecore/ecore_getopt.c
@@ -141,7 +141,11 @@ _ecore_getopt_help_line(FILE       *fp,
                    len -= i;
                    used += i;
 
-                   if (linebreak)
+                   /* if we start the line (linebreak is true) with a space
+                    * other than newline or tab, ignore it.
+                    */
+                   if ((linebreak) && (i == 1) &&
+                       (space[0] != '\n') && (space[0] != '\t'))
                      {
                         linebreak = 0;
                         continue;
@@ -170,6 +174,14 @@ _ecore_getopt_help_line(FILE       *fp,
                    else if (used < total)
                      fputc(space[0], fp);
                 }
+              else if ((!linebreak) && (todo < len))
+                {
+                   /* if not start of line and not last line, wrap line
+                    * and try again. This avoids spliting words unless they
+                    * are bigger than the available line width.
+                    */
+                   break;
+                }
               else
                 {
                    i = fwrite(text, 1, i, fp);

-- 


Reply via email to