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:
#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>
#include <string.h>
#include <locale.h>
#include <unistd.h>
#include <string.h>
#include <locale.h>
#include <unistd.h>
#if __STDC__
# include <stdarg.h>
#else
#if __STDC__
# include <stdarg.h>
#else
(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",
+/*
+ * 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.
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);
-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>
(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));
dirflag |= DIR_LINE;
break;
default:
dirflag |= DIR_LINE;
break;
default:
- stderror(ERR_DIRUS, short2str(**v), str);
+ stderror(ERR_DIRUS, vis_str(**v), str);
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");
{
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)));
- (void) fprintf(cshout, "%s", short2str(dir));
+ (void) fprintf(cshout, "%s", vis_str(dir));
-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>
Dv[1] = NULL;
Dfix2(Dv);
if (gargc != 1) {
Dv[1] = NULL;
Dfix2(Dv);
if (gargc != 1) {
- setname(short2str(cp));
stderror(ERR_NAME | ERR_AMBIG);
}
cp = Strsave(gargv[0]);
stderror(ERR_NAME | ERR_AMBIG);
}
cp = Strsave(gargv[0]);
stderror(ERR_NAME | ERR_RANGE);
}
stderror(ERR_NAME | ERR_RANGE);
}
-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>
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;
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;
{
/* 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;
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);
}
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",
sp->word = s0; /* we save and then restore this */
return;
}
sp->word = s0; /* we save and then restore this */
return;
}
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 */
}
-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>
- (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");
}
*
* %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>
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));
char **short2blk __P((Char **));
#endif
char *short2qstr __P((Char *));
char **short2blk __P((Char **));
#endif
char *short2qstr __P((Char *));
+char *vis_str __P((Char *));
-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
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;
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);
-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>
}
else {
if (eq(p, STRalias) || eq(p, STRunalias)) {
}
else {
if (eq(p, STRalias) || eq(p, STRunalias)) {
stderror(ERR_NAME | ERR_DANGER);
}
set1(strip(p), saveblk(v), &aliases);
stderror(ERR_NAME | ERR_DANGER);
}
set1(strip(p), saveblk(v), &aliases);
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.
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 */
register int c;
while (c = *cp++)
register int c;
while (c = *cp++)
- (void) fputc(c | QUOTE, cshout);
+ (void) vis_fputc(c | QUOTE, cshout);
- (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);
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)
-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>
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);
}
switch (action) {
case G_ERROR:
switch (action) {
case G_ERROR:
- setname(short2str(str));
blkfree(vl);
stderror(ERR_NAME | ERR_AMBIG);
break;
blkfree(vl);
stderror(ERR_NAME | ERR_AMBIG);
break;
ptr = short2qstr(*vl);
switch (glob(ptr, gflgs, 0, &globv)) {
case GLOB_ABEND:
ptr = short2qstr(*vl);
switch (glob(ptr, gflgs, 0, &globv)) {
case GLOB_ABEND:
stderror(ERR_NAME | ERR_GLOB);
/* NOTREACHED */
case GLOB_NOSPACE:
stderror(ERR_NAME | ERR_GLOB);
/* NOTREACHED */
case GLOB_NOSPACE:
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));
stderror(ERR_NAME | ERR_NOMATCH);
}
if (vl[0] == NULL) {
stderror(ERR_NAME | ERR_NOMATCH);
}
if (vl[0] == NULL) {
-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>
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;
return (&hp->Hlex);
}
np = putn(event);
return (&hp->Hlex);
}
np = putn(event);
- seterror(ERR_NOEVENT, short2str(np));
+ seterror(ERR_NOEVENT, vis_str(np));
argno++;
} while (lp->word[0] != '\n');
}
argno++;
} while (lp->word[0] != '\n');
}
- seterror(ERR_NOEVENT, short2str(cp));
+ seterror(ERR_NOEVENT, vis_str(cp));
-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>
- (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, " ");
}
- setname(short2str(name));
+ setname(vis_str(name));
stderror(ERR_NAME | ERR_UNDVAR);
}
stderror(ERR_NAME | ERR_UNDVAR);
}
-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>
}
/* 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)
}
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)
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);
}
}
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",
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++;
}
-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>
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);
}
-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>
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));
-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
* This has been a lesson of how to write buggy code!
*/
* This has been a lesson of how to write buggy code!
*/
#if __STDC__
# include <stdarg.h>
#else
# include <varargs.h>
#endif
#if __STDC__
# include <stdarg.h>
#else
# include <varargs.h>
#endif
#include "csh.h"
#include "extern.h"
#include "csh.h"
#include "extern.h"
*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);
+}
+