summaryrefslogtreecommitdiffstats
path: root/contrib/less/filename.c
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2009-05-09 01:35:27 +0000
committerdelphij <delphij@FreeBSD.org>2009-05-09 01:35:27 +0000
commit810e5a84b4607c4d0fc76e9a418ae9fd2b0eeeb2 (patch)
tree5e0628caeff31611fab89dbdf72053148a59a873 /contrib/less/filename.c
parent8583a840068803e7fd9e0fc2452605bca6e822d8 (diff)
downloadFreeBSD-src-810e5a84b4607c4d0fc76e9a418ae9fd2b0eeeb2.zip
FreeBSD-src-810e5a84b4607c4d0fc76e9a418ae9fd2b0eeeb2.tar.gz
Update to less v429.
Diffstat (limited to 'contrib/less/filename.c')
-rw-r--r--contrib/less/filename.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/contrib/less/filename.c b/contrib/less/filename.c
index aa45b76..72e9797 100644
--- a/contrib/less/filename.c
+++ b/contrib/less/filename.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2007 Mark Nudelman
+ * Copyright (C) 1984-2008 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.
@@ -52,6 +52,7 @@ extern int force_open;
extern int secure;
extern int use_lessopen;
extern int ctldisp;
+extern int utf_mode;
extern IFILE curr_ifile;
extern IFILE old_ifile;
#if SPACES_IN_FILENAMES
@@ -469,23 +470,26 @@ fcomplete(s)
bin_file(f)
int f;
{
- int i;
int n;
int bin_count = 0;
- unsigned char data[256];
+ char data[256];
+ char* p;
+ char* pend;
if (!seekable(f))
return (0);
if (lseek(f, (off_t)0, SEEK_SET) == BAD_LSEEK)
return (0);
n = read(f, data, sizeof(data));
- for (i = 0; i < n; i++)
+ pend = &data[n];
+ for (p = data; p < pend; )
{
- char c = data[i];
+ LWCHAR c = step_char(&p, +1, pend);
if (ctldisp == OPT_ONPLUS && IS_CSI_START(c))
{
- while (++i < n && is_ansi_middle(data[i]))
- continue;
+ do {
+ c = step_char(&p, +1, pend);
+ } while (p < pend && is_ansi_middle(c));
} else if (binary_char(c))
bin_count++;
}
@@ -827,20 +831,27 @@ open_altfile(filename, pf, pfd)
ch_ungetchar(-1);
if ((lessopen = lgetenv("LESSOPEN")) == NULL)
return (NULL);
- if (strcmp(filename, "-") == 0)
- return (NULL);
if (*lessopen == '|')
{
/*
* If LESSOPEN starts with a |, it indicates
* a "pipe preprocessor".
*/
-#if HAVE_FILENO
- lessopen++;
- returnfd = 1;
-#else
+#if !HAVE_FILENO
error("LESSOPEN pipe is not supported", NULL_PARG);
return (NULL);
+#else
+ lessopen++;
+ returnfd = 1;
+ if (*lessopen == '-') {
+ /*
+ * Lessopen preprocessor will accept "-" as a filename.
+ */
+ lessopen++;
+ } else {
+ if (strcmp(filename, "-") == 0)
+ return (NULL);
+ }
#endif
}
OpenPOWER on IntegriCloud