Commit 6550565a by crazymaster

Fix gather_stats

parent d6d34cd0
...@@ -261,29 +261,34 @@ bool git_buf_text_gather_stats( ...@@ -261,29 +261,34 @@ bool git_buf_text_gather_stats(
/* Counting loop */ /* Counting loop */
while (scan < end) { while (scan < end) {
unsigned char c = *scan++; unsigned char c = *scan++;
if (c == '\r') {
if ((c > 0x1F && c < 0x7F) || c > 0x9f) stats->cr++;
stats->printable++; if (scan < end && *scan == '\n')
else switch (c) { stats->crlf++;
case '\0': continue;
stats->nul++; }
stats->nonprintable++; if (c == '\n') {
break; stats->lf++;
case '\n': continue;
stats->lf++; }
break; if (c == 127)
case '\r': /* DEL */
stats->cr++; stats->nonprintable++;
if (scan < end && *scan == '\n') else if (c < 32) {
stats->crlf++; switch (c) {
break; /* BS, HT, ESC and FF */
case '\t': case '\f': case '\v': case '\b': case 0x1b: /*ESC*/ case '\b': case '\t': case '\033': case '\014':
stats->printable++; stats->printable++;
break; break;
case 0:
stats->nul++;
/* fall through */
default: default:
stats->nonprintable++; stats->nonprintable++;
break;
} }
}
else
stats->printable++;
} }
return (stats->nul > 0 || return (stats->nul > 0 ||
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment