X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=filename.c;h=68fdadbf68fbaed1c3f489bf5be556a6f6290f00;hb=HEAD;hp=14e85e32cc2da274adc87a059a20f4ccf65e5c2e;hpb=42ae3d9177e50dc7fecfc3881da7dc19e9ce3261;p=platform%2Fupstream%2Fless.git diff --git a/filename.c b/filename.c index 14e85e3..68fdadb 100755 --- a/filename.c +++ b/filename.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2012 Mark Nudelman + * Copyright (C) 1984-2014 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -481,17 +481,25 @@ bin_file(f) if (lseek(f, (off_t)0, SEEK_SET) == BAD_LSEEK) return (0); n = read(f, data, sizeof(data)); - pend = &data[n]; - for (p = data; p < pend; ) + if (n <= 0) + return (0); + if (utf_mode) + { + bin_count = utf_bin_count(data, n); + } else { - LWCHAR c = step_char(&p, +1, pend); - if (ctldisp == OPT_ONPLUS && IS_CSI_START(c)) + pend = &data[n]; + for (p = data; p < pend; ) { - do { - c = step_char(&p, +1, pend); - } while (p < pend && is_ansi_middle(c)); - } else if (binary_char(c)) - bin_count++; + LWCHAR c = step_char(&p, +1, pend); + if (ctldisp == OPT_ONPLUS && IS_CSI_START(c)) + { + do { + c = step_char(&p, +1, pend); + } while (p < pend && is_ansi_middle(c)); + } else if (binary_char(c)) + bin_count++; + } } /* * Call it a binary file if there are more than 5 binary characters