Skip to content

Commit 28e9cf6

Browse files
dschogitster
authored andcommitted
Expose the has_non_ascii() function
This function is useful outside of log-tree.c, too. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5dc36a5 commit 28e9cf6

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

commit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ enum cmit_fmt {
6464
};
6565

6666
extern int non_ascii(int);
67+
extern int has_non_ascii(const char *text);
6768
struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
6869
extern char *reencode_commit_message(const struct commit *commit,
6970
const char **encoding_p);

log-tree.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -168,18 +168,6 @@ static unsigned int digits_in_number(unsigned int number)
168168
return result;
169169
}
170170

171-
static int has_non_ascii(const char *s)
172-
{
173-
int ch;
174-
if (!s)
175-
return 0;
176-
while ((ch = *s++) != '\0') {
177-
if (non_ascii(ch))
178-
return 1;
179-
}
180-
return 0;
181-
}
182-
183171
void get_patch_filename(struct commit *commit, int nr, const char *suffix,
184172
struct strbuf *buf)
185173
{

pretty.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,18 @@ int non_ascii(int ch)
8686
return !isascii(ch) || ch == '\033';
8787
}
8888

89+
int has_non_ascii(const char *s)
90+
{
91+
int ch;
92+
if (!s)
93+
return 0;
94+
while ((ch = *s++) != '\0') {
95+
if (non_ascii(ch))
96+
return 1;
97+
}
98+
return 0;
99+
}
100+
89101
static int is_rfc2047_special(char ch)
90102
{
91103
return (non_ascii(ch) || (ch == '=') || (ch == '?') || (ch == '_'));

0 commit comments

Comments
 (0)