[PATCH 3/7] scanner: fix descriptions to proper wrap at < 72 position

y y
Thu Feb 9 09:27:49 PST 2012


From: Tiago Vignatti <tiago.vignatti at intel.com>

Signed-off-by: Tiago Vignatti <tiago.vignatti at intel.com>
---
 src/scanner.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/scanner.c b/src/scanner.c
index f88fb4d..13bb0cf 100644
--- a/src/scanner.c
+++ b/src/scanner.c
@@ -139,7 +139,8 @@ uppercase_dup(const char *src)
 static void
 desc_dump(char *src, int startcol)
 {
-	int i, j = 0, col = startcol, line = 0, len;
+	int i, j = 0, col = startcol, line = 0, len = 0;
+	char nextword[30];
 
 	/* Strip leading space */
 	for (i = 0; isspace(src[i]); i++)
@@ -150,10 +151,18 @@ desc_dump(char *src, int startcol)
 		if (isspace(src[i]) && isspace(src[i + 1]))
 		    continue;
 
-		if (isspace(src[i]))
+		if (isspace(src[i])) {
 			src[i] = ' ';
 
-		if (col > 72 && isspace(src[i])) {
+			/* get next word length to properly wrap the text */
+			for (j = 0; isalnum(src[i + 1 + j]); j++) {
+				nextword[j] = src[i + 1 + j];
+			}
+			nextword[j] = '\0';
+			len = strlen(nextword);
+		}
+
+		if (col + len > 72 && isspace(src[i])) {
 			if (src[i+1]) {
 				putchar('\n');
 				for (j = 0; j < startcol; j++)
-- 
1.7.5.4



More information about the wayland-devel mailing list