Skip to content

Commit

Permalink
Merge branch 'js/maint-cover-letter-non-ascii'
Browse files Browse the repository at this point in the history
* js/maint-cover-letter-non-ascii:
  Correctly mark cover letters' encodings if they are not pure ASCII
  Expose the has_non_ascii() function
  • Loading branch information
Junio C Hamano committed Aug 16, 2009
2 parents 14683af + 0a7f448 commit 228f9c9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
4 changes: 4 additions & 0 deletions builtin-log.c
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,10 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
log_write_email_headers(rev, head, &subject_start, &extra_headers,
&need_8bit_cte);

for (i = 0; !need_8bit_cte && i < nr; i++)
if (has_non_ascii(list[i]->buffer))
need_8bit_cte = 1;

msg = body;
pp_user_info(NULL, CMIT_FMT_EMAIL, &sb, committer, DATE_RFC2822,
encoding);
Expand Down
1 change: 1 addition & 0 deletions commit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 0 additions & 12 deletions log-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
12 changes: 12 additions & 0 deletions pretty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 == '_'));
Expand Down

0 comments on commit 228f9c9

Please sign in to comment.