Skip to content

Commit 0c124cb

Browse files
Unique-Usmangitster
authored andcommitted
version: replace manual ASCII checks with isprint() for clarity
Since the isprint() function checks for printable characters, let's replace the existing hardcoded ASCII checks with it. However, since the original checks also handled spaces, we need to account for spaces explicitly in the new check. Mentored-by: Christian Couder <[email protected]> Signed-off-by: Usman Akinyemi <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e63e621 commit 0c124cb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

version.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "version.h"
33
#include "version-def.h"
44
#include "strbuf.h"
5+
#include "sane-ctype.h"
56

67
const char git_version_string[] = GIT_VERSION;
78
const char git_built_from_commit_string[] = GIT_BUILT_FROM_COMMIT;
@@ -29,7 +30,7 @@ const char *git_user_agent_sanitized(void)
2930
strbuf_addstr(&buf, git_user_agent());
3031
strbuf_trim(&buf);
3132
for (size_t i = 0; i < buf.len; i++) {
32-
if (buf.buf[i] <= 32 || buf.buf[i] >= 127)
33+
if (!isprint(buf.buf[i]) || buf.buf[i] == ' ')
3334
buf.buf[i] = '.';
3435
}
3536
agent = buf.buf;

0 commit comments

Comments
 (0)