git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] Expose the has_non_ascii() function

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Aug 10, 2009, 16:22 UTC
Message-ID
<7388ff3756d6a431fc9a640a4fa02a70d1e54106.1249921206u.git.johannes.schindelin@gmx.de>
In-Reply-To
<cover.1249921206u.git.johannes.schindelin@gmx.de>
This function is useful outside of log-tree.c, too.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 commit.h   |    1 +
 log-tree.c |   12 ------------
 pretty.c   |   12 ++++++++++++
 3 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/commit.h b/commit.h
index 8bfdf0e..d1674d7 100644
--- a/commit.h
+++ b/commit.h
@@ -64,6 +64,7 @@ enum cmit_fmt {
 };
 
 extern int non_ascii(int);
+extern int has_non_ascii(const char *text);
 struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
 extern char *reencode_commit_message(const struct commit *commit,
 				     const char **encoding_p);
diff --git a/log-tree.c b/log-tree.c
index 6f73c17..a3b4c06 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -168,18 +168,6 @@ static unsigned int digits_in_number(unsigned int number)
 	return result;
 }
 
-static int has_non_ascii(const char *s)
-{
-	int ch;
-	if (!s)
-		return 0;
-	while ((ch = *s++) != '\0') {
-		if (non_ascii(ch))
-			return 1;
-	}
-	return 0;
-}
-
 void get_patch_filename(struct commit *commit, int nr, const char *suffix,
 			struct strbuf *buf)
 {
diff --git a/pretty.c b/pretty.c
index 1aa9c3f..ec0affe 100644
--- a/pretty.c
+++ b/pretty.c
@@ -86,6 +86,18 @@ int non_ascii(int ch)
 	return !isascii(ch) || ch == '\033';
 }
 
+int has_non_ascii(const char *s)
+{
+	int ch;
+	if (!s)
+		return 0;
+	while ((ch = *s++) != '\0') {
+		if (non_ascii(ch))
+			return 1;
+	}
+	return 0;
+}
+
 static int is_rfc2047_special(char ch)
 {
 	return (non_ascii(ch) || (ch == '=') || (ch == '?') || (ch == '_'));
-- 
1.6.3.2.734.g770e
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 2 of 3 in “Fix cover letters when they contain non-ASCII”
  1. 0/2 Fix cover letters when they contain non-ASCIIJohannes Schindelin, Aug 10, 2009
  2. 1/2 Expose the has_non_ascii() functionJohannes Schindelin, Aug 10, 2009
  3. 2/2 Correctly mark cover letters' encodings if they are not pure ASCIIJohannes Schindelin, Aug 10, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.