ports/162050: [patch] misc/lv directory opening problem fix
Koichiro IWAO
meta at club.kyutech.ac.jp
Thu Oct 27 08:10:11 UTC 2011
>Number: 162050
>Category: ports
>Synopsis: [patch] misc/lv directory opening problem fix
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Thu Oct 27 08:10:09 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator: Koichiro IWAO
>Release: FreeBSD 8.2-RELEASE-p1 amd64
>Organization:
Kyushu Institute of Technology
>Environment:
System: FreeBSD rose.club.kyutech.ac.jp 8.2-RELEASE-p1 FreeBSD 8.2-RELEASE-p1 #1: Mon Apr 25 03:31:52 JST 2011 root at rose.club.kyutech.ac.jp:/usr/obj/usr/src/sys/MASAKIKERNEL amd64
>Description:
misc/lv tries viewing directories by force.
>How-To-Repeat:
See differences between `less /` and `lv /`.
I don't know whether author made to behave like this on purpose,
anyway my patch makes lv to behave more less-like.
>Fix:
See an attached patch.
--- lv.patch begins here ---
diff -ruN --exclude='*~' /tmp/lv451/src/lv.c src/lv.c
--- /tmp/lv451/src/lv.c 2004-01-05 16:30:15.000000000 +0900
+++ src/lv.c 2011-05-27 02:21:37.000000000 +0900
@@ -2,6 +2,7 @@
* lv.c
*
* All rights reserved. Copyright (C) 1996 by NARITA Tomio.
+ * Copyright (C) Oct 27, 2011 Koichiro IWAO. All rights reserved.
* $Id: lv.c,v 1.10 2004/01/05 07:30:15 nrt Exp $
*/
/*
@@ -89,16 +90,35 @@
grep_mode = FALSE;
}
+private boolean_t isDirectory(byte **file) {
+ struct stat buf;
+ stat((unsigned char *)file, &buf);
+ if (S_ISDIR(buf.st_mode)) {
+ fprintf(stderr, "%s is a directory\n", file);
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
private boolean_t LvOpen( conf_t *conf )
{
+ boolean_t flagIsDirectory = FALSE;
+
if( NULL != conf->file ){
+ if( TRUE == isDirectory( *conf->file ) ){
+ flagIsDirectory = TRUE;
+ }
if( NULL == (conf->st = StreamOpen( *conf->file )) ){
while( NULL != *(++conf->file) ){
- if( NULL != (conf->st = StreamOpen( *conf->file )) )
- return TRUE;
+ if( NULL != (conf->st = StreamOpen( *conf->file )) ){
+ if( TRUE == isDirectory( *conf->file ) ){
+ flagIsDirectory = TRUE;
+ }
+ }
}
- return FALSE;
}
+ return (TRUE == flagIsDirectory ? FALSE : TRUE);
} else {
conf->st = StreamReconnectStdin();
}
--- lv.patch ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list