cleanup: add isascii()
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>
This commit is contained in:
parent
3d2d4f96d2
commit
c2e9364a06
@ -319,6 +319,7 @@ static inline int has_extension(const char *filename, const char *ext)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Sane ctype - no locale, and works with signed chars */
|
/* Sane ctype - no locale, and works with signed chars */
|
||||||
|
#undef isascii
|
||||||
#undef isspace
|
#undef isspace
|
||||||
#undef isdigit
|
#undef isdigit
|
||||||
#undef isalpha
|
#undef isalpha
|
||||||
@ -332,6 +333,7 @@ extern unsigned char sane_ctype[256];
|
|||||||
#define GIT_GLOB_SPECIAL 0x08
|
#define GIT_GLOB_SPECIAL 0x08
|
||||||
#define GIT_REGEX_SPECIAL 0x10
|
#define GIT_REGEX_SPECIAL 0x10
|
||||||
#define sane_istest(x,mask) ((sane_ctype[(unsigned char)(x)] & (mask)) != 0)
|
#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 isspace(x) sane_istest(x,GIT_SPACE)
|
||||||
#define isdigit(x) sane_istest(x,GIT_DIGIT)
|
#define isdigit(x) sane_istest(x,GIT_DIGIT)
|
||||||
#define isalpha(x) sane_istest(x,GIT_ALPHA)
|
#define isalpha(x) sane_istest(x,GIT_ALPHA)
|
||||||
|
3
pretty.c
3
pretty.c
@ -75,8 +75,7 @@ static int get_one_line(const char *msg)
|
|||||||
/* High bit set, or ISO-2022-INT */
|
/* High bit set, or ISO-2022-INT */
|
||||||
int non_ascii(int ch)
|
int non_ascii(int ch)
|
||||||
{
|
{
|
||||||
ch = (ch & 0xff);
|
return !isascii(ch) || ch == '\033';
|
||||||
return ((ch & 0x80) || (ch == 0x1b));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int is_rfc2047_special(char ch)
|
static int is_rfc2047_special(char ch)
|
||||||
|
Loading…
Reference in New Issue
Block a user