summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2013-12-17 17:51:48 -0200
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2013-12-17 17:51:48 -0200
commit99ba5822c84c6716ee51af93115a0bb0984464ef (patch)
tree62fe03f59163bdeb313d919017fc7f8240568ae7
parent0947bae12627aa819ff81845b10fcf0af5e924be (diff)
getopt: fix line wrapping issues in help strings.
-rw-r--r--src/lib/ecore/ecore_getopt.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/lib/ecore/ecore_getopt.c b/src/lib/ecore/ecore_getopt.c
index 36baeb5e5..2a7850f48 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);