[PATCH 5/4] move sane_truncate_line to utf8_truncate_line

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Mark Lodato <lodatom@xxxxxxxxx>
---

As promised, here are the additional patches to move the function name to the
same line as the hunk header.

 diff.c |   14 ++------------
 utf8.c |   13 +++++++++++++
 utf8.h |    2 ++
 3 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/diff.c b/diff.c
index 377ec1e..74c77bc 100644
--- a/diff.c
+++ b/diff.c
@@ -1015,20 +1015,10 @@ const char *diff_get_color(int diff_use_color, enum color_diff ix)
 
 static unsigned long sane_truncate_line(struct emit_callback *ecb, char *line, unsigned long len)
 {
-	const char *cp;
-	unsigned long allot;
-	size_t l = len;
-
 	if (ecb->truncate)
 		return ecb->truncate(line, len);
-	cp = line;
-	allot = l;
-	while (0 < l) {
-		(void) utf8_width(&cp, &l);
-		if (!cp)
-			break; /* truncated in the middle? */
-	}
-	return allot - l;
+	else
+		return utf8_truncate_line(line, len);
 }
 
 static void find_lno(const char *line, struct emit_callback *ecbdata)
diff --git a/utf8.c b/utf8.c
index 8acbc66..d70ee9b 100644
--- a/utf8.c
+++ b/utf8.c
@@ -482,3 +482,16 @@ char *reencode_string(const char *in, const char *out_encoding, const char *in_e
 	return out;
 }
 #endif
+
+unsigned long utf8_truncate_line(const char *line, unsigned long len)
+{
+	const char *cp = line;
+	unsigned long allot = len;
+	size_t l = len;
+	while (0 < l) {
+		(void) utf8_width(&cp, &l);
+		if (!cp)
+			break; /* truncated in the middle? */
+	}
+	return allot - l;
+}
diff --git a/utf8.h b/utf8.h
index 81f2c82..929e2df 100644
--- a/utf8.h
+++ b/utf8.h
@@ -19,4 +19,6 @@ char *reencode_string(const char *in, const char *out_encoding, const char *in_e
 #define reencode_string(a,b,c) NULL
 #endif
 
+unsigned long utf8_truncate_line(const char *line, unsigned long len);
+
 #endif
-- 
1.7.9.4

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]