diff options
author | crazymaster <ken.i54k@gmail.com> | 2013-07-15 07:41:39 +0900 |
---|---|---|
committer | crazymaster <ken.i54k@gmail.com> | 2013-07-15 07:44:08 +0900 |
commit | b74d4478df8c6d62c96b3bd067ae1987209583a6 (patch) | |
tree | 35f97889f0762c16aa73a15b9a0fe02faf9a4dc0 /src/buf_text.c | |
parent | 19bee769d49467704f4d8ee36965c548cb40e3c6 (diff) | |
download | libgit2-b74d4478df8c6d62c96b3bd067ae1987209583a6.tar.gz |
Fix the initial line
Diffstat (limited to 'src/buf_text.c')
-rw-r--r-- | src/buf_text.c | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/src/buf_text.c b/src/buf_text.c index bc8d04680..472339def 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 || |