Fix the initial line
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
diff --git a/src/buf_text.c b/src/buf_text.c
index bc8d046..472339d 100644
--- a/src/buf_text.c
+++ b/src/buf_text.c
@@ -261,34 +261,29 @@ bool git_buf_text_gather_stats(
/* Counting loop */
while (scan < end) {
unsigned char c = *scan++;
- if (c == '\r') {
- stats->cr++;
- if (scan < end && *scan == '\n')
- stats->crlf++;
- continue;
- }
- if (c == '\n') {
- stats->lf++;
- continue;
- }
- if (c == 127)
- /* DEL */
- stats->nonprintable++;
- else if (c < 32) {
- switch (c) {
- /* BS, HT, ESC and FF */
- case '\b': case '\t': case '\033': case '\014':
+
+ if (c > 0x1F && c != 0x7F)
+ stats->printable++;
+ else switch (c) {
+ case '\0':
+ stats->nul++;
+ stats->nonprintable++;
+ break;
+ case '\n':
+ stats->lf++;
+ break;
+ case '\r':
+ stats->cr++;
+ if (scan < end && *scan == '\n')
+ stats->crlf++;
+ break;
+ case '\t': case '\f': case '\v': case '\b': case 0x1b: /*ESC*/
stats->printable++;
break;
- case 0:
- stats->nul++;
- /* fall through */
default:
stats->nonprintable++;
+ break;
}
- }
- else
- stats->printable++;
}
return (stats->nul > 0 ||