Added support for displaying non-printable characters
authorChristos Zoulas <christos@ucbvax.Berkeley.EDU>
Thu, 7 Nov 1991 08:09:56 +0000 (00:09 -0800)
committerChristos Zoulas <christos@ucbvax.Berkeley.EDU>
Thu, 7 Nov 1991 08:09:56 +0000 (00:09 -0800)
SCCS-vsn: bin/csh/csh.c 5.33
SCCS-vsn: bin/csh/dir.c 5.17
SCCS-vsn: bin/csh/dol.c 5.18
SCCS-vsn: bin/csh/exec.c 5.21
SCCS-vsn: bin/csh/exp.c 5.15
SCCS-vsn: bin/csh/extern.h 5.11
SCCS-vsn: bin/csh/file.c 5.21
SCCS-vsn: bin/csh/func.c 5.32
SCCS-vsn: bin/csh/glob.c 5.32
SCCS-vsn: bin/csh/lex.c 5.26
SCCS-vsn: bin/csh/misc.c 5.18
SCCS-vsn: bin/csh/proc.c 5.28
SCCS-vsn: bin/csh/sem.c 5.22
SCCS-vsn: bin/csh/set.c 5.17
SCCS-vsn: bin/csh/str.c 5.11

15 files changed:
usr/src/bin/csh/csh.c
usr/src/bin/csh/dir.c
usr/src/bin/csh/dol.c
usr/src/bin/csh/exec.c
usr/src/bin/csh/exp.c
usr/src/bin/csh/extern.h
usr/src/bin/csh/file.c
usr/src/bin/csh/func.c
usr/src/bin/csh/glob.c
usr/src/bin/csh/lex.c
usr/src/bin/csh/misc.c
usr/src/bin/csh/proc.c
usr/src/bin/csh/sem.c
usr/src/bin/csh/set.c
usr/src/bin/csh/str.c

index a937445..f0e3346 100644 (file)
@@ -12,7 +12,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)csh.c      5.32 (Berkeley) %G%";
+static char sccsid[] = "@(#)csh.c      5.33 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -25,6 +25,7 @@ static char sccsid[] = "@(#)csh.c     5.32 (Berkeley) %G%";
 #include <string.h>
 #include <locale.h>
 #include <unistd.h>
 #include <string.h>
 #include <locale.h>
 #include <unistd.h>
+#include <vis.h>
 #if __STDC__
 # include <stdarg.h>
 #else
 #if __STDC__
 # include <stdarg.h>
 #else
@@ -1077,7 +1078,7 @@ mailchk()
            (void) fprintf(cshout, "You have %smail.\n", new ? "new " : "");
        else
            (void) fprintf(cshout, "%s in %s.\n", new ? "New mail" : "Mail",
            (void) fprintf(cshout, "You have %smail.\n", new ? "new " : "");
        else
            (void) fprintf(cshout, "%s in %s.\n", new ? "New mail" : "Mail",
-                          short2str(*vp));
+                          vis_str(*vp));
     }
     chktim = t;
 }
     }
     chktim = t;
 }
@@ -1159,6 +1160,23 @@ closef(oreo)
 }
 
 
 }
 
 
+/*
+ * Print the visible version of a string.
+ */
+int
+vis_fputc(ch, fp)
+    int ch;
+    FILE *fp;
+{
+    char uenc[5];      /* 4 + NULL */
+
+    if (ch & QUOTE) 
+       return fputc(ch & TRIM, fp);
+    (void) vis(uenc, ch & TRIM, 
+              AsciiOnly ? VIS_NOSLASH : (VIS_NLS | VIS_NOSLASH), 0);
+    return fputs(uenc, fp);
+}
+
 /*
  * Move the initial descriptors to their eventual
  * resting places, closin all other units.
 /*
  * Move the initial descriptors to their eventual
  * resting places, closin all other units.
@@ -1223,7 +1241,7 @@ printprompt()
            else {
                if (*cp == '\\' && cp[1] == HIST)
                    cp++;
            else {
                if (*cp == '\\' && cp[1] == HIST)
                    cp++;
-               (void) fputc(*cp | QUOTE, cshout);
+               (void) vis_fputc(*cp | QUOTE, cshout);
            }
     }
     else
            }
     }
     else
index 3376c30..31fdf2f 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)dir.c      5.16 (Berkeley) %G%";
+static char sccsid[] = "@(#)dir.c      5.17 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -59,11 +59,11 @@ dinit(hp)
        (void) fprintf(csherr, "csh: %s\n", path);
        if (hp && *hp) {
            tcp = short2str(hp);
        (void) fprintf(csherr, "csh: %s\n", path);
        if (hp && *hp) {
            tcp = short2str(hp);
-           (void) fprintf(csherr, emsg, tcp);
            if (chdir(tcp) == -1)
                cp = NULL;
            else
                cp = hp;
            if (chdir(tcp) == -1)
                cp = NULL;
            else
                cp = hp;
+           (void) fprintf(csherr, emsg, vis_str(hp));
        }
        else
            cp = NULL;
        }
        else
            cp = NULL;
@@ -150,7 +150,7 @@ skipargs(v, str)
                dirflag |= DIR_LINE;
                break;
            default:
                dirflag |= DIR_LINE;
                break;
            default:
-               stderror(ERR_DIRUS, short2str(**v), str);
+               stderror(ERR_DIRUS, vis_str(**v), str);
                break;
            }
     *v = n;
                break;
            }
     *v = n;
@@ -203,7 +203,7 @@ printdirs()
            cur = len;
        }
        (void) fprintf(cshout, s != dp->di_name ? "~%s%c" : "%s%c",
            cur = len;
        }
        (void) fprintf(cshout, s != dp->di_name ? "~%s%c" : "%s%c",
-               short2str(s), (dirflag & DIR_VERT) ? '\n' : ' ');
+               vis_str(s), (dirflag & DIR_VERT) ? '\n' : ' ');
     } while ((dp = dp->di_prev) != dcwd);
     if (!(dirflag & DIR_VERT))
        (void) fprintf(cshout, "\n");
     } while ((dp = dp->di_prev) != dcwd);
     if (!(dirflag & DIR_VERT))
        (void) fprintf(cshout, "\n");
@@ -215,9 +215,9 @@ dtildepr(home, dir)
 {
 
     if (!eq(home, STRslash) && prefix(home, dir))
 {
 
     if (!eq(home, STRslash) && prefix(home, dir))
-       (void) fprintf(cshout, "~%s", short2str(dir + Strlen(home)));
+       (void) fprintf(cshout, "~%s", vis_str(dir + Strlen(home)));
     else
     else
-       (void) fprintf(cshout, "%s", short2str(dir));
+       (void) fprintf(cshout, "%s", vis_str(dir));
 }
 
 void
 }
 
 void
index 5c49a53..3f27faf 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)dol.c      5.17 (Berkeley) %G%";
+static char sccsid[] = "@(#)dol.c      5.18 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -112,7 +112,7 @@ Dfix1(cp)
     Dv[1] = NULL;
     Dfix2(Dv);
     if (gargc != 1) {
     Dv[1] = NULL;
     Dfix2(Dv);
     if (gargc != 1) {
-       setname(short2str(cp));
+       setname(vis_str(cp));
        stderror(ERR_NAME | ERR_AMBIG);
     }
     cp = Strsave(gargv[0]);
        stderror(ERR_NAME | ERR_AMBIG);
     }
     cp = Strsave(gargv[0]);
@@ -362,7 +362,7 @@ static void
 dolerror(s)
     Char   *s;
 {
 dolerror(s)
     Char   *s;
 {
-    setname(short2str(s));
+    setname(vis_str(s));
     stderror(ERR_NAME | ERR_RANGE);
 }
 
     stderror(ERR_NAME | ERR_RANGE);
 }
 
index cfb253e..f449f69 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)exec.c     5.20 (Berkeley) %G%";
+static char sccsid[] = "@(#)exec.c     5.21 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -102,7 +102,7 @@ doexec(v, t)
     if (gflag) {
        pv = globall(blk);
        if (pv == 0) {
     if (gflag) {
        pv = globall(blk);
        if (pv == 0) {
-           setname(short2str(blk[0]));
+           setname(vis_str(blk[0]));
            stderror(ERR_NAME | ERR_NOMATCH);
        }
        gargv = 0;
            stderror(ERR_NAME | ERR_NOMATCH);
        }
        gargv = 0;
@@ -133,7 +133,7 @@ doexec(v, t)
        av = globall(av);
        if (av == 0) {
            blkfree(pv);
        av = globall(av);
        if (av == 0) {
            blkfree(pv);
-           setname(short2str(expath));
+           setname(vis_str(expath));
            stderror(ERR_NAME | ERR_NOMATCH);
        }
        gargv = 0;
            stderror(ERR_NAME | ERR_NOMATCH);
        }
        gargv = 0;
@@ -217,7 +217,7 @@ pexerr()
 {
     /* Couldn't find the damn thing */
     if (expath) {
 {
     /* Couldn't find the damn thing */
     if (expath) {
-       setname(short2str(expath));
+       setname(vis_str(expath));
        Vexpath = 0;
        xfree((ptr_t) expath);
        expath = 0;
        Vexpath = 0;
        xfree((ptr_t) expath);
        expath = 0;
@@ -609,7 +609,7 @@ dowhich(v, c)
 
     while (*++v) {
        if (vp = adrof1(*v, &aliases)) {
 
     while (*++v) {
        if (vp = adrof1(*v, &aliases)) {
-           (void) fprintf(cshout, "%s: \t aliased to ", short2str(*v));
+           (void) fprintf(cshout, "%s: \t aliased to ", vis_str(*v));
            blkpr(cshout, vp->vec);
            (void) fputc('\n', cshout);
        }
            blkpr(cshout, vp->vec);
            (void) fputc('\n', cshout);
        }
@@ -669,7 +669,7 @@ tellmewhat(lex)
            if (aliased)
                prlex(cshout, lex);
            (void) fprintf(cshout, "%s: shell built-in command.\n", 
            if (aliased)
                prlex(cshout, lex);
            (void) fprintf(cshout, "%s: shell built-in command.\n", 
-                          short2str(sp->word));
+                          vis_str(sp->word));
            sp->word = s0;      /* we save and then restore this */
            return;
        }
            sp->word = s0;      /* we save and then restore this */
            return;
        }
@@ -704,7 +704,7 @@ tellmewhat(lex)
     else {
        if (aliased)
            prlex(cshout, lex);
     else {
        if (aliased)
            prlex(cshout, lex);
-       (void) fprintf(csherr, "%s: Command not found.\n", short2str(sp->word));
+       (void) fprintf(csherr, "%s: Command not found.\n", vis_str(sp->word));
     }
     sp->word = s0;             /* we save and then restore this */
 }
     }
     sp->word = s0;             /* we save and then restore this */
 }
index c215343..6bf110d 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)exp.c      5.14 (Berkeley) %G%";
+static char sccsid[] = "@(#)exp.c      5.15 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -678,7 +678,7 @@ etracc(str, cp, vp)
     Char   *cp;
     Char ***vp;
 {
     Char   *cp;
     Char ***vp;
 {
-    (void) fprintf(csherr, "%s=%s\t", str, cp);
+    (void) fprintf(csherr, "%s=%s\t", str, vis_str(cp));
     blkpr(csherr, *vp);
     (void) fprintf(csherr, "\n");
 }
     blkpr(csherr, *vp);
     (void) fprintf(csherr, "\n");
 }
index b8bc43a..b544e74 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)extern.h    5.10 (Berkeley) %G%
+ *     @(#)extern.h    5.11 (Berkeley) %G%
  */
 
 #include <sys/cdefs.h>
  */
 
 #include <sys/cdefs.h>
@@ -24,6 +24,7 @@ void  printprompt __P((void));
 void   process __P((bool));
 void   rechist __P((void));
 void   untty __P((void));
 void   process __P((bool));
 void   rechist __P((void));
 void   untty __P((void));
+int    vis_fputc __P((int, FILE *));
 
 #ifdef PROF
 void done __P((int));
 
 #ifdef PROF
 void done __P((int));
@@ -315,3 +316,4 @@ char         *short2str __P((Char *));
 char   **short2blk __P((Char **));
 #endif
 char    *short2qstr __P((Char *));
 char   **short2blk __P((Char **));
 #endif
 char    *short2qstr __P((Char *));
+char    *vis_str    __P((Char *));
index 737698f..5b68881 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)file.c     5.20 (Berkeley) %G%";
+static char sccsid[] = "@(#)file.c     5.21 (Berkeley) %G%";
 #endif /* not lint */
 
 #ifdef FILEC
 #endif /* not lint */
 
 #ifdef FILEC
@@ -238,7 +238,7 @@ print_by_column(dir, items, count)
            if (i < count) {
                register int w;
 
            if (i < count) {
                register int w;
 
-               (void) fprintf(cshout, "%s", short2str(items[i]));
+               (void) fprintf(cshout, "%s", vis_str(items[i]));
                (void) fputc(dir ? filetype(dir, items[i]) : ' ', cshout);
                if (c < columns - 1) {  /* last column? */
                    w = Strlen(items[i]) + 1;
                (void) fputc(dir ? filetype(dir, items[i]) : ' ', cshout);
                if (c < columns - 1) {  /* last column? */
                    w = Strlen(items[i]) + 1;
@@ -325,13 +325,13 @@ print_recognized_stuff(recognized_part)
        break;
 
     case 1:                    /* overstrike the ^, erase the [ */
        break;
 
     case 1:                    /* overstrike the ^, erase the [ */
-       (void) fprintf(cshout, "%s", short2str(recognized_part));
+       (void) fprintf(cshout, "%s", vis_str(recognized_part));
        (void) fputc(' ', cshout);
        (void) fputc('\b', cshout);
        break;
 
     default:                   /* overstrike both Characters ^[ */
        (void) fputc(' ', cshout);
        (void) fputc('\b', cshout);
        break;
 
     default:                   /* overstrike both Characters ^[ */
-       (void) fprintf(cshout, "%s", short2str(recognized_part));
+       (void) fprintf(cshout, "%s", vis_str(recognized_part));
        break;
     }
     (void) fflush(cshout);
        break;
     }
     (void) fflush(cshout);
index 5d0f15f..031eaf8 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)func.c     5.31 (Berkeley) %G%";
+static char sccsid[] = "@(#)func.c     5.32 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -182,7 +182,7 @@ doalias(v, t)
     }
     else {
        if (eq(p, STRalias) || eq(p, STRunalias)) {
     }
     else {
        if (eq(p, STRalias) || eq(p, STRunalias)) {
-           setname(short2str(p));
+           setname(vis_str(p));
            stderror(ERR_NAME | ERR_DANGER);
        }
        set1(strip(p), saveblk(v), &aliases);
            stderror(ERR_NAME | ERR_DANGER);
        }
        set1(strip(p), saveblk(v), &aliases);
@@ -248,7 +248,7 @@ doif(v, kp)
     if (eq(*vv, STRthen)) {
        if (*++vv)
            stderror(ERR_NAME | ERR_IMPRTHEN);
     if (eq(*vv, STRthen)) {
        if (*++vv)
            stderror(ERR_NAME | ERR_IMPRTHEN);
-       setname(short2str(STRthen));
+       setname(vis_str(STRthen));
        /*
         * If expression was zero, then scan to else, otherwise just fall into
         * following code.
        /*
         * If expression was zero, then scan to else, otherwise just fall into
         * following code.
@@ -767,7 +767,7 @@ past:
        stderror(ERR_NAME | ERR_NOTFOUND, "end");
 
     case T_GOTO:
        stderror(ERR_NAME | ERR_NOTFOUND, "end");
 
     case T_GOTO:
-       setname(short2str(Sgoal));
+       setname(vis_str(Sgoal));
        stderror(ERR_NAME | ERR_NOTFOUND, "label");
     }
     /* NOTREACHED */
        stderror(ERR_NAME | ERR_NOTFOUND, "label");
     }
     /* NOTREACHED */
@@ -899,10 +899,10 @@ xecho(sep, v)
        register int c;
 
        while (c = *cp++)
        register int c;
 
        while (c = *cp++)
-           (void) fputc(c | QUOTE, cshout);
+           (void) vis_fputc(c | QUOTE, cshout);
 
        if (*v)
 
        if (*v)
-           (void) fputc(sep | QUOTE, cshout);
+           (void) vis_fputc(sep | QUOTE, cshout);
     }
     if (sep && nonl == 0)
        (void) fputc('\n', cshout);
     }
     if (sep && nonl == 0)
        (void) fputc('\n', cshout);
@@ -929,7 +929,7 @@ dosetenv(v, t)
        if (setintr)
            (void) sigsetmask(sigblock((sigset_t) 0) & ~sigmask(SIGINT));
        for (ep = STR_environ; *ep; ep++)
        if (setintr)
            (void) sigsetmask(sigblock((sigset_t) 0) & ~sigmask(SIGINT));
        for (ep = STR_environ; *ep; ep++)
-           (void) fprintf(cshout, "%s\n", short2str(*ep));
+           (void) fprintf(cshout, "%s\n", vis_str(*ep));
        return;
     }
     if ((lp = *v++) == 0)
        return;
     }
     if ((lp = *v++) == 0)
index 7244064..6eecc2a 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)glob.c     5.31 (Berkeley) %G%";
+static char sccsid[] = "@(#)glob.c     5.32 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -82,7 +82,7 @@ globtilde(nv, s)
     if (gethdir(gstart)) {
        blkfree(nv);
        if (*gstart)
     if (gethdir(gstart)) {
        blkfree(nv);
        if (*gstart)
-           stderror(ERR_UNKUSER, short2str(gstart));
+           stderror(ERR_UNKUSER, vis_str(gstart));
        else
            stderror(ERR_NOHOME);
     }
        else
            stderror(ERR_NOHOME);
     }
@@ -302,7 +302,7 @@ handleone(str, vl, action)
 
     switch (action) {
     case G_ERROR:
 
     switch (action) {
     case G_ERROR:
-       setname(short2str(str));
+       setname(vis_str(str));
        blkfree(vl);
        stderror(ERR_NAME | ERR_AMBIG);
        break;
        blkfree(vl);
        stderror(ERR_NAME | ERR_AMBIG);
        break;
@@ -349,7 +349,7 @@ libglob(vl)
        ptr = short2qstr(*vl);
        switch (glob(ptr, gflgs, 0, &globv)) {
        case GLOB_ABEND:
        ptr = short2qstr(*vl);
        switch (glob(ptr, gflgs, 0, &globv)) {
        case GLOB_ABEND:
-           setname(ptr);
+           setname(vis_str(*vl));
            stderror(ERR_NAME | ERR_GLOB);
            /* NOTREACHED */
        case GLOB_NOSPACE:
            stderror(ERR_NAME | ERR_GLOB);
            /* NOTREACHED */
        case GLOB_NOSPACE:
@@ -416,7 +416,7 @@ globone(str, action)
     if ((gflg & G_CSH) && vl != vo)
        blkfree(vo);
     if (vl == NULL) {
     if ((gflg & G_CSH) && vl != vo)
        blkfree(vo);
     if (vl == NULL) {
-       setname(short2str(str));
+       setname(vis_str(str));
        stderror(ERR_NAME | ERR_NOMATCH);
     }
     if (vl[0] == NULL) {
        stderror(ERR_NAME | ERR_NOMATCH);
     }
     if (vl[0] == NULL) {
index 1ddaadc..dcafbe0 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)lex.c      5.25 (Berkeley) %G%";
+static char sccsid[] = "@(#)lex.c      5.26 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -159,7 +159,7 @@ prlex(fp, sp0)
     register struct wordent *sp = sp0->next;
 
     for (;;) {
     register struct wordent *sp = sp0->next;
 
     for (;;) {
-       (void) fprintf(fp, "%s", short2str(sp->word));
+       (void) fprintf(fp, "%s", vis_str(sp->word));
        sp = sp->next;
        if (sp == sp0)
            break;
        sp = sp->next;
        if (sp == sp0)
            break;
@@ -1221,7 +1221,7 @@ gethent(sc)
            return (&hp->Hlex);
        }
     np = putn(event);
            return (&hp->Hlex);
        }
     np = putn(event);
-    seterror(ERR_NOEVENT, short2str(np));
+    seterror(ERR_NOEVENT, vis_str(np));
     return (0);
 }
 
     return (0);
 }
 
@@ -1272,7 +1272,7 @@ findev(cp, anyarg)
            argno++;
        } while (lp->word[0] != '\n');
     }
            argno++;
        } while (lp->word[0] != '\n');
     }
-    seterror(ERR_NOEVENT, short2str(cp));
+    seterror(ERR_NOEVENT, vis_str(cp));
     return (0);
 }
 
     return (0);
 }
 
index 6617192..ce71b1b 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)misc.c     5.17 (Berkeley) %G%";
+static char sccsid[] = "@(#)misc.c     5.18 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -82,7 +82,7 @@ blkpr(fp, av)
 {
 
     for (; *av; av++) {
 {
 
     for (; *av; av++) {
-       (void) fprintf(fp, "%s", short2str(*av));
+       (void) fprintf(fp, "%s", vis_str(*av));
        if (av[1])
            (void) fprintf(fp, " ");
     }
        if (av[1])
            (void) fprintf(fp, " ");
     }
@@ -374,7 +374,7 @@ udvar(name)
     Char   *name;
 {
 
     Char   *name;
 {
 
-    setname(short2str(name));
+    setname(vis_str(name));
     stderror(ERR_NAME | ERR_UNDVAR);
 }
 
     stderror(ERR_NAME | ERR_UNDVAR);
 }
 
index 8a45287..940207c 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)proc.c     5.27 (Berkeley) %G%";
+static char sccsid[] = "@(#)proc.c     5.28 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -149,13 +149,13 @@ found:
            }
            /* PWP: print a newline after ^C */
            else if (jobflags & PINTERRUPTED) {
            }
            /* PWP: print a newline after ^C */
            else if (jobflags & PINTERRUPTED) {
-               (void) fputc('\r' | QUOTE, cshout);
+               (void) vis_fputc('\r' | QUOTE, cshout);
                (void) fputc('\n', cshout);
            }
        }
        else {
            if (jobflags & PNOTIFY || adrof(STRnotify)) {
                (void) fputc('\n', cshout);
            }
        }
        else {
            if (jobflags & PNOTIFY || adrof(STRnotify)) {
-               (void) fputc('\r' | QUOTE, cshout);
+               (void) vis_fputc('\r' | QUOTE, cshout);
                (void) fputc('\n', cshout);
                (void) pprint(pp, NUMBER | NAME | REASON);
                if ((jobflags & PSTOPPED) == 0)
                (void) fputc('\n', cshout);
                (void) pprint(pp, NUMBER | NAME | REASON);
                if ((jobflags & PSTOPPED) == 0)
@@ -729,7 +729,7 @@ pprint(pp, flag)
        }
 prcomd:
        if (flag & NAME) {
        }
 prcomd:
        if (flag & NAME) {
-           (void) fprintf(cshout, "%s", short2str(pp->p_command));
+           (void) fprintf(cshout, "%s", vis_str(pp->p_command));
            if (pp->p_flags & PPOU)
                (void) fprintf(cshout, " |");
            if (pp->p_flags & PERR)
            if (pp->p_flags & PPOU)
                (void) fprintf(cshout, " |");
            if (pp->p_flags & PERR)
@@ -955,7 +955,7 @@ dokill(v, t)
                    break;
 
            if (signum == NSIG) {
                    break;
 
            if (signum == NSIG) {
-               setname(short2str(&v[0][1]));
+               setname(vis_str(&v[0][1]));
                stderror(ERR_NAME | ERR_UNKSIG);
            }
        }
                stderror(ERR_NAME | ERR_UNKSIG);
            }
        }
@@ -1004,7 +1004,7 @@ pkill(v, signum)
            case SIGTTOU:
                if ((jobflags & PRUNNING) == 0) {
                    (void) fprintf(csherr, "%s: Already suspended\n",
            case SIGTTOU:
                if ((jobflags & PRUNNING) == 0) {
                    (void) fprintf(csherr, "%s: Already suspended\n",
-                                  short2str(cp));
+                                  vis_str(cp));
                    err1++;
                    goto cont;
                }
                    err1++;
                    goto cont;
                }
@@ -1018,7 +1018,7 @@ pkill(v, signum)
                goto cont;
            }
            if (killpg((pid_t) pp->p_jobid, signum) < 0) {
                goto cont;
            }
            if (killpg((pid_t) pp->p_jobid, signum) < 0) {
-               (void) fprintf(csherr, "%s: %s\n", short2str(cp),
+               (void) fprintf(csherr, "%s: %s\n", vis_str(cp),
                               strerror(errno));
                err1++;
            }
                               strerror(errno));
                err1++;
            }
index 6079f72..f938cc8 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)sem.c      5.21 (Berkeley) %G%";
+static char sccsid[] = "@(#)sem.c      5.22 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -464,7 +464,7 @@ splicepipe(t, cp)
        if (gflag) {
            pv = globall(blk);
            if (pv == NULL) {
        if (gflag) {
            pv = globall(blk);
            if (pv == NULL) {
-               setname(short2str(blk[0]));
+               setname(vis_str(blk[0]));
                xfree((ptr_t) blk[0]);
                stderror(ERR_NAME | ERR_NOMATCH);
            }
                xfree((ptr_t) blk[0]);
                stderror(ERR_NAME | ERR_NOMATCH);
            }
index 968f614..d23fc46 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)set.c      5.16 (Berkeley) %G%";
+static char sccsid[] = "@(#)set.c      5.17 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -534,7 +534,7 @@ unset1(v, head)
        while (vp = madrof(*v, head->v_left))
            unsetv1(vp), cnt++;
        if (cnt == 0)
        while (vp = madrof(*v, head->v_left))
            unsetv1(vp), cnt++;
        if (cnt == 0)
-           setname(short2str(*v));
+           setname(vis_str(*v));
     }
 }
 
     }
 }
 
index 2498d7b..ee3f336 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)str.c      5.10 (Berkeley) %G%";
+static char sccsid[] = "@(#)str.c      5.11 (Berkeley) %G%";
 #endif /* not lint */
 
 #define MALLOC_INCR    128
 #endif /* not lint */
 
 #define MALLOC_INCR    128
@@ -16,11 +16,13 @@ static char sccsid[] = "@(#)str.c   5.10 (Berkeley) %G%";
  *          This has been a lesson of how to write buggy code!
  */
 
  *          This has been a lesson of how to write buggy code!
  */
 
+#include <sys/types.h>
 #if __STDC__
 # include <stdarg.h>
 #else
 # include <varargs.h>
 #endif
 #if __STDC__
 # include <stdarg.h>
 #else
 # include <varargs.h>
 #endif
+#include <vis.h>
 
 #include "csh.h"
 #include "extern.h"
 
 #include "csh.h"
 #include "extern.h"
@@ -404,3 +406,33 @@ short2qstr(src)
     *dst = 0;
     return (sdst);
 }
     *dst = 0;
     return (sdst);
 }
+
+/*
+ * XXX: Should we worry about QUOTE'd chars?
+ */
+char *
+vis_str(cp)
+    Char *cp;
+{
+    static char *sdst = NULL;
+    static size_t dstsize = 0;
+    size_t n;
+    Char *dp;
+
+    if (cp == NULL)
+       return (NULL);
+    
+    for (dp = cp; *dp++;)
+       continue;
+    n = ((dp - cp) << 2) + 1; /* 4 times + NULL */
+    if (dstsize < n) {
+       sdst = (char *) (dstsize ? 
+                           xrealloc(sdst, (size_t) n * sizeof(char)) :
+                           xmalloc((size_t) n * sizeof(char)));
+       dstsize = n;
+    }
+    (void) strvis(sdst, short2str(cp), 
+                 AsciiOnly ? VIS_NOSLASH : (VIS_NLS | VIS_NOSLASH));
+    return (sdst);
+}
+