summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3d2d4f9)
raw | patch | inline | side by side (parent: 3d2d4f9)
author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | |
Sat, 7 Mar 2009 13:06:49 +0000 (14:06 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 7 Mar 2009 19:22:42 +0000 (11:22 -0800) |
Add a standard definition of isascii() and use it to replace an open
coded high-bit test in pretty.c. While we're there, write the ESC
char as the more commonly used '\033' instead of as 0x1b to enhance
its grepability.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
coded high-bit test in pretty.c. While we're there, write the ESC
char as the more commonly used '\033' instead of as 0x1b to enhance
its grepability.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-compat-util.h | patch | blob | history | |
pretty.c | patch | blob | history |
diff --git a/git-compat-util.h b/git-compat-util.h
index dcf41277502f5fb8fc99b310ebdaf63b6781b3ea..878d83dd0863570042af80919899b4d6aa57e35b 100644 (file)
--- a/git-compat-util.h
+++ b/git-compat-util.h
}
/* Sane ctype - no locale, and works with signed chars */
+#undef isascii
#undef isspace
#undef isdigit
#undef isalpha
#define GIT_GLOB_SPECIAL 0x08
#define GIT_REGEX_SPECIAL 0x10
#define sane_istest(x,mask) ((sane_ctype[(unsigned char)(x)] & (mask)) != 0)
+#define isascii(x) (((x) & ~0x7f) == 0)
#define isspace(x) sane_istest(x,GIT_SPACE)
#define isdigit(x) sane_istest(x,GIT_DIGIT)
#define isalpha(x) sane_istest(x,GIT_ALPHA)
diff --git a/pretty.c b/pretty.c
index 6cd91491d348b9aabea902c0ea60465074e9c06e..e9540e46da7af16e3aa765d79a5b03a4847975df 100644 (file)
--- a/pretty.c
+++ b/pretty.c
/* High bit set, or ISO-2022-INT */
int non_ascii(int ch)
{
- ch = (ch & 0xff);
- return ((ch & 0x80) || (ch == 0x1b));
+ return !isascii(ch) || ch == '\033';
}
static int is_rfc2047_special(char ch)