This is an initial attempt at fixing the problem.

Can you test this diff ? Please reverse the diff
for warping the dot before applying this one.

Index: src/usr.bin/mg/dired.c
===================================================================
RCS file: /cvs/src/usr.bin/mg/dired.c,v
retrieving revision 1.48
diff -u -p -r1.48 dired.c
--- src/usr.bin/mg/dired.c      23 Jan 2011 00:45:03 -0000      1.48
+++ src/usr.bin/mg/dired.c      24 Aug 2011 21:46:05 -0000
@@ -600,10 +600,13 @@ dired_(char *dname)
 {
        struct buffer   *bp;
        FILE    *dirpipe;
-       char     line[256];
-       int      len, ret, counter, warp;
+       char     line[256], tmp[256], ini[256];
+       int      len, ret, counter, warp, pos;
+       char    *meta, *orig;
+       meta = "(){} ";
        counter = 0;
        warp = 0;
+       pos = 0;
 
        if ((fopen(dname,"r")) == NULL) {
                if (errno == EACCES)
@@ -627,7 +630,20 @@ dired_(char *dname)
        if (bclear(bp) != TRUE)
                return (NULL);
        bp->b_flag |= BFREADONLY;
+
+       (void) strlcpy(ini, dname, sizeof(ini));
+       while (strpbrk(&ini[pos], meta) != NULL) {
+               pos = strpbrk(&ini[pos], meta) - &ini[0];
+               (void) strlcpy(tmp, &ini[pos], sizeof(tmp));
+               ini[pos] = '\\';
+               ini[pos+1] = '\0';
+               (void) strlcat(&ini[pos], tmp, sizeof(ini));
+               pos += 2;
+       }
+       orig = dname;
+       dname = &ini[0];
        ret = snprintf(line, sizeof(line), "ls -al %s", dname);
+       dname = orig;
        if (ret < 0 || ret  >= sizeof(line)) {
                ewprintf("Path too long");
                return (NULL);

Reply via email to