On 21/11/2007, at 10:48 PM, Otto Moerbeek wrote:
I think dump should 'vis' the filenames it prints.

        -Otto



I've been looking at this and have a small patch to restore/ interactive.c in the formatf() function.

I have done what Otto said - vis()d the filenames (I have done so by lifting the strnvis() code from rwho.)

I am working on 4.2 RELEASE + errata patches code so I will be behind ... I am quite sure there are better ways to do it - there are a lot of choices!

The hanging of xterm happens because - I think - the character code is 0x98 - looks like "Start of String" (if I read /usr/xenocara/app/ xterm/ctlseqs.txt correctly) - so xterm hangs around waiting for the rest of the string - you can get out of it by pressing ESC and then ENTER (then you get "Unknown command ; type ? for help".)

Feedback, cluesticks, etc., appreciated.  Thanks.

(Just done some more testing before posting and realized that I have only looked at verbose mode ls, so still got more work to do - but it only seems to be verbose mode that causes the xterm hang, and I'd like feedback anyway.)

restore > ls
./testd3:
xx?xx.txt

restore > verbose
verbose mode on
restore > ls
./testd3:
31 ./ 2 ../ 30 xx\M^Xxx.txt <!----- used to hang after the 2nd x was printed

The patch:

# diff -uw /usr/src/sbin/restore/interactive.c interactive.c
--- /usr/src/sbin/restore/interactive.c Fri Jun 17 02:51:21 2005
+++ interactive.c       Fri Nov 30 10:01:24 2007
@@ -54,6 +54,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <vis.h>

 #include "restore.h"
 #include "extern.h"
@@ -652,6 +653,9 @@
        int width, bigino, haveprefix, havepostfix;
        int i, j, w, precision = 0, columns, lines;

+       char vis_file[4 * FILENAME_MAX + 1];
+       int vis_file_len=0;
+
        width = 0;
        haveprefix = 0;
        havepostfix = 0;
@@ -660,8 +664,12 @@
        for (fp = &list[0]; fp < endlist; fp++) {
                if (bigino < fp->fnum)
                        bigino = fp->fnum;
-               if (width < fp->len)
-                       width = fp->len;
+
+               strnvis(vis_file,fp->fname,sizeof vis_file,VIS_SAFE);
+               vis_file_len=strlen(vis_file);
+               if (width < vis_file_len)
+                       width = vis_file_len;
+
                if (fp->prefix != ' ')
                        haveprefix = 1;
                if (fp->postfix != ' ')
@@ -692,7 +700,9 @@
                                putc(fp->prefix, stderr);
                                fp->len++;
                        }
-                       fprintf(stderr, "%s", fp->fname);
+ strnvis(vis_file,fp->fname,sizeof vis_file,VIS_SAFE);
+                       fprintf(stderr, "%s", vis_file);
+
                        if (havepostfix) {
                                putc(fp->postfix, stderr);
                                fp->len++;

Reply via email to