{"thread":{"id":"18192","subject":"[PATCH] cleanup: add isascii()","startedAt":"2009-03-07T13:06:49Z","lastAt":"2009-03-07T13:06:49Z","messageCount":1,"participants":["René Scharfe"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"107299","messageId":"1236431209.20373.9.camel@ubuntu.ubuntu-domain","threadId":"18192","inReplyTo":null,"subject":"[PATCH] cleanup: add isascii()","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2009-03-07T13:06:49Z","receivedAt":"2009-03-07T13:06:49Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Add a standard definition of isascii() and use it to replace an open\ncoded high-bit test in pretty.c.  While we're there, write the ESC\nchar as the more commonly used '\\033' instead of as 0x1b to enhance\nits grepability.\n\nSigned-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>\n---\n git-compat-util.h |    2 ++\n pretty.c          |    3 +--\n 2 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex dcf4127..878d83d 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -319,6 +319,7 @@ static inline int has_extension(const char *filename, const char *ext)\n }\n \n /* Sane ctype - no locale, and works with signed chars */\n+#undef isascii\n #undef isspace\n #undef isdigit\n #undef isalpha\n@@ -332,6 +333,7 @@ extern unsigned char sane_ctype[256];\n #define GIT_GLOB_SPECIAL 0x08\n #define GIT_REGEX_SPECIAL 0x10\n #define sane_istest(x,mask) ((sane_ctype[(unsigned char)(x)] & (mask)) != 0)\n+#define isascii(x) (((x) & ~0x7f) == 0)\n #define isspace(x) sane_istest(x,GIT_SPACE)\n #define isdigit(x) sane_istest(x,GIT_DIGIT)\n #define isalpha(x) sane_istest(x,GIT_ALPHA)\ndiff --git a/pretty.c b/pretty.c\nindex f499294..c018408 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -83,8 +83,7 @@ static int get_one_line(const char *msg)\n /* High bit set, or ISO-2022-INT */\n int non_ascii(int ch)\n {\n-\tch = (ch & 0xff);\n-\treturn ((ch & 0x80) || (ch == 0x1b));\n+\treturn !isascii(ch) || ch == '\\033';\n }\n \n static int is_rfc2047_special(char ch)\n-- \n1.6.2\n"}]}