pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/44312: dired patches for portable mg



>Number:         44312
>Category:       pkg
>Synopsis:       dired patches for portable mg
>Confidential:   no
>Severity:       non-critical
>Priority:       high
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jan 02 19:10:00 +0000 2011
>Originator:     Loganaden (Logan) Velvindron
>Release:        5.1 with pkgsrc from -current
>Organization:
Wandering Ninja
>Environment:
NetBSD  5.1 NetBSD 5.1 (GENERIC) #7: Sun Jan  2 17:10:14 MUST 2011  
root@:/usr/src/sys/arch/i386/compile/GENERIC i386

>Description:
portable mg lacks dired patches that I worked on for openbsd's mg. 

It makes a couple of sanity checks, and aligns the pointer on the file name 
which is much less annoying and is closer to Emacs dired.

See kjell's commit:
http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/mg/dired.c.diff?r1=1.45;r2=1.46

http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/mg/file.c.diff?r1=1.71;r2=1.72
>How-To-Repeat:
None
>Fix:
$NetBSD: patch-aa,v 1.1.1.1 2009/02/13 11:04:14 abs Exp $

--- dired.c.orig        2011-01-02 18:02:33.000000000 +0000
+++ dired.c
@@ -570,11 +570,11 @@ d_makename(struct line *lp, char *fn, si
        ep = lp->l_text + llength(lp);
        p++; /* skip action letter, if any */
        for (i = 0; i < NAME_FIELD; i++) {
-               while (p < ep && isspace(*p))
+               while (p < ep && isspace((unsigned char)*p))
                        p++;
-               while (p < ep && !isspace(*p))
+               while (p < ep && !isspace((unsigned char)*p))
                        p++;
-               while (p < ep && isspace(*p))
+               while (p < ep && isspace((unsigned char)*p))
                        p++;
                if (p == ep)
                        return (ABORT);
@@ -593,8 +593,14 @@ dired_(char *dname)
        struct buffer   *bp;
        FILE    *dirpipe;
        char     line[256];
-       int      len, ret;
+       int      len, ret, counter, warp;
+       counter = warp = 0;
 
+       if ((fopen(dname,"r")) == NULL) {
+               if (errno == EACCES)
+                       ewprintf("Permission denied");
+               return (NULL);
+       }
        if ((dname = adjustname(dname, FALSE)) == NULL) {
                ewprintf("Bad directory name");
                return (NULL);
@@ -642,13 +648,26 @@ dired_(char *dname)
        while (fgets(&line[2], sizeof(line) - 2, dirpipe) != NULL) {
                line[strcspn(line, "\n")] = '\0'; /* remove ^J   */
                (void) addline(bp, line);
+               if ((strrchr(line, ' ')) != NULL) {
+                       counter++;
+                       if ((strcmp((strrchr(line, ' ')), " ..")) == 0)
+                               warp = counter;
+               }
+       }
+       if ((strrchr(line, ' ')) != NULL) {
+               if (strcmp((strrchr(line, ' ')), " ..") == 0)
+                       warp = counter - 1;
        }
+       if ((strrchr(line, ' ')) != NULL)
+               bp->b_doto = strrchr(line, ' ') - line + 1;
        if (pclose(dirpipe) == -1) {
                ewprintf("Problem closing pipe to ls : %s",
                    strerror(errno));
                return (NULL);
        }
        bp->b_dotp = bfirstlp(bp);
+       while (warp--)
+               bp->b_dotp = lforw(bp->b_dotp);
        (void)strlcpy(bp->b_fname, dname, sizeof(bp->b_fname));
        (void)strlcpy(bp->b_cwd, dname, sizeof(bp->b_cwd));
        if ((bp->b_modes[1] = name_mode("dired")) == NULL) {


$NetBSD$

--- file.c.orig 2011-01-02 18:02:39.000000000 +0000
+++ file.c
@@ -219,10 +219,12 @@ readin(char *fname)
 
        for (wp = wheadp; wp != NULL; wp = wp->w_wndp) {
                if (wp->w_bufp == curbp) {
-                       wp->w_dotp = wp->w_linep = bfirstlp(curbp);
-                       wp->w_doto = 0;
-                       wp->w_markp = NULL;
-                       wp->w_marko = 0;
+                       if ((fisdir(fname)) != TRUE) {
+                               wp->w_dotp = wp->w_linep = bfirstlp(curbp);
+                               wp->w_doto = 0;
+                               wp->w_markp = NULL;
+                               wp->w_marko = 0;
+                               }
                }
        }
 



Home | Main Index | Thread Index | Old Index