compile with WARNS = 2

This commit is contained in:
christos 1999-07-09 03:05:49 +00:00
parent 02a4ec93e9
commit 3d42469030
26 changed files with 215 additions and 209 deletions

View File

@ -1,6 +1,7 @@
# $NetBSD: Makefile,v 1.48 1999/02/05 22:19:47 tron Exp $ # $NetBSD: Makefile,v 1.49 1999/07/09 03:05:49 christos Exp $
# @(#)Makefile 8.4 (Berkeley) 5/5/95 # @(#)Makefile 8.4 (Berkeley) 5/5/95
WARNS=2
YHEADER=1 YHEADER=1
PROG= sh PROG= sh
SHSRCS= alias.c cd.c echo.c error.c eval.c exec.c expand.c \ SHSRCS= alias.c cd.c echo.c error.c eval.c exec.c expand.c \

View File

@ -1,5 +1,5 @@
%{ %{
/* $NetBSD: arith.y,v 1.12 1999/02/05 07:52:52 christos Exp $ */ /* $NetBSD: arith.y,v 1.13 1999/07/09 03:05:49 christos Exp $ */
/*- /*-
* Copyright (c) 1993 * Copyright (c) 1993
@ -42,7 +42,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)arith.y 8.3 (Berkeley) 5/4/95"; static char sccsid[] = "@(#)arith.y 8.3 (Berkeley) 5/4/95";
#else #else
__RCSID("$NetBSD: arith.y,v 1.12 1999/02/05 07:52:52 christos Exp $"); __RCSID("$NetBSD: arith.y,v 1.13 1999/07/09 03:05:49 christos Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -53,9 +53,9 @@ __RCSID("$NetBSD: arith.y,v 1.12 1999/02/05 07:52:52 christos Exp $");
#include "output.h" #include "output.h"
#include "memalloc.h" #include "memalloc.h"
char *arith_buf, *arith_startbuf; const char *arith_buf, *arith_startbuf;
void yyerror __P((char *)); void yyerror __P((const char *));
int yyparse __P((void)); int yyparse __P((void));
#ifdef TESTARITH #ifdef TESTARITH
int main __P((int , char *[])); int main __P((int , char *[]));
@ -64,7 +64,7 @@ int error __P((char *));
int int
arith(s) arith(s)
char *s; const char *s;
{ {
long result; long result;
@ -87,7 +87,7 @@ expcmd(argc, argv)
int argc; int argc;
char **argv; char **argv;
{ {
char *p; const char *p;
char *concat; char *concat;
char **ap; char **ap;
long i; long i;
@ -192,7 +192,7 @@ expr: ARITH_LPAREN expr ARITH_RPAREN = { $$ = $2; }
%% %%
void void
yyerror(s) yyerror(s)
char *s; const char *s;
{ {
yyerrok; yyerrok;

View File

@ -1,4 +1,4 @@
/* $NetBSD: cd.c,v 1.26 1998/07/28 11:41:52 mycroft Exp $ */ /* $NetBSD: cd.c,v 1.27 1999/07/09 03:05:49 christos Exp $ */
/*- /*-
* Copyright (c) 1991, 1993 * Copyright (c) 1991, 1993
@ -41,7 +41,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)cd.c 8.2 (Berkeley) 5/4/95"; static char sccsid[] = "@(#)cd.c 8.2 (Berkeley) 5/4/95";
#else #else
__RCSID("$NetBSD: cd.c,v 1.26 1998/07/28 11:41:52 mycroft Exp $"); __RCSID("$NetBSD: cd.c,v 1.27 1999/07/09 03:05:49 christos Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -83,8 +83,8 @@ cdcmd(argc, argv)
int argc; int argc;
char **argv; char **argv;
{ {
char *dest; const char *dest;
char *path; const char *path;
char *p; char *p;
struct stat statb; struct stat statb;
int print = 0; int print = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: error.c,v 1.21 1999/04/05 15:00:28 mycroft Exp $ */ /* $NetBSD: error.c,v 1.22 1999/07/09 03:05:49 christos Exp $ */
/*- /*-
* Copyright (c) 1991, 1993 * Copyright (c) 1991, 1993
@ -41,7 +41,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)error.c 8.2 (Berkeley) 5/4/95"; static char sccsid[] = "@(#)error.c 8.2 (Berkeley) 5/4/95";
#else #else
__RCSID("$NetBSD: error.c,v 1.21 1999/04/05 15:00:28 mycroft Exp $"); __RCSID("$NetBSD: error.c,v 1.22 1999/07/09 03:05:49 christos Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -72,7 +72,8 @@ volatile int intpending;
char *commandname; char *commandname;
static void exverror __P((int, char *, va_list)) __attribute__((__noreturn__)); static void exverror __P((int, const char *, va_list))
__attribute__((__noreturn__));
/* /*
* Called to raise an exception. Since C doesn't include exceptions, we * Called to raise an exception. Since C doesn't include exceptions, we
@ -130,7 +131,7 @@ onint() {
static void static void
exverror(cond, msg, ap) exverror(cond, msg, ap)
int cond; int cond;
char *msg; const char *msg;
va_list ap; va_list ap;
{ {
CLEAR_PENDING_INT; CLEAR_PENDING_INT;
@ -156,7 +157,7 @@ exverror(cond, msg, ap)
#ifdef __STDC__ #ifdef __STDC__
void void
error(char *msg, ...) error(const char *msg, ...)
#else #else
void void
error(va_alist) error(va_alist)
@ -164,14 +165,14 @@ error(va_alist)
#endif #endif
{ {
#ifndef __STDC__ #ifndef __STDC__
char *msg; const char *msg;
#endif #endif
va_list ap; va_list ap;
#ifdef __STDC__ #ifdef __STDC__
va_start(ap, msg); va_start(ap, msg);
#else #else
va_start(ap); va_start(ap);
msg = va_arg(ap, char *); msg = va_arg(ap, const char *);
#endif #endif
exverror(EXERROR, msg, ap); exverror(EXERROR, msg, ap);
/* NOTREACHED */ /* NOTREACHED */
@ -181,7 +182,7 @@ error(va_alist)
#ifdef __STDC__ #ifdef __STDC__
void void
exerror(int cond, char *msg, ...) exerror(int cond, const char *msg, ...)
#else #else
void void
exerror(va_alist) exerror(va_alist)
@ -190,7 +191,7 @@ exerror(va_alist)
{ {
#ifndef __STDC__ #ifndef __STDC__
int cond; int cond;
char *msg; const char *msg;
#endif #endif
va_list ap; va_list ap;
#ifdef __STDC__ #ifdef __STDC__
@ -198,7 +199,7 @@ exerror(va_alist)
#else #else
va_start(ap); va_start(ap);
cond = va_arg(ap, int); cond = va_arg(ap, int);
msg = va_arg(ap, char *); msg = va_arg(ap, const char *);
#endif #endif
exverror(cond, msg, ap); exverror(cond, msg, ap);
/* NOTREACHED */ /* NOTREACHED */
@ -214,7 +215,7 @@ exerror(va_alist)
struct errname { struct errname {
short errcode; /* error number */ short errcode; /* error number */
short action; /* operation which encountered the error */ short action; /* operation which encountered the error */
char *msg; /* text describing the error */ const char *msg; /* text describing the error */
}; };
@ -281,7 +282,7 @@ STATIC const struct errname errormsg[] = {
* Action describes the operation that got the error. * Action describes the operation that got the error.
*/ */
char * const char *
errmsg(e, action) errmsg(e, action)
int e; int e;
int action; int action;

View File

@ -1,4 +1,4 @@
/* $NetBSD: error.h,v 1.12 1998/07/28 11:41:53 mycroft Exp $ */ /* $NetBSD: error.h,v 1.13 1999/07/09 03:05:49 christos Exp $ */
/*- /*-
* Copyright (c) 1991, 1993 * Copyright (c) 1991, 1993
@ -92,9 +92,9 @@ extern char *commandname; /* name of command--printed on error */
void exraise __P((int)) __attribute__((__noreturn__)); void exraise __P((int)) __attribute__((__noreturn__));
void onint __P((void)); void onint __P((void));
void error __P((char *, ...)) __attribute__((__noreturn__)); void error __P((const char *, ...)) __attribute__((__noreturn__));
void exerror __P((int, char *, ...)) __attribute__((__noreturn__)); void exerror __P((int, const char *, ...)) __attribute__((__noreturn__));
char *errmsg __P((int, int)); const char *errmsg __P((int, int));
/* /*

View File

@ -1,4 +1,4 @@
/* $NetBSD: eval.c,v 1.46 1999/06/26 16:31:47 christos Exp $ */ /* $NetBSD: eval.c,v 1.47 1999/07/09 03:05:49 christos Exp $ */
/*- /*-
* Copyright (c) 1993 * Copyright (c) 1993
@ -41,7 +41,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95"; static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95";
#else #else
__RCSID("$NetBSD: eval.c,v 1.46 1999/06/26 16:31:47 christos Exp $"); __RCSID("$NetBSD: eval.c,v 1.47 1999/07/09 03:05:49 christos Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -684,7 +684,7 @@ evalcommand(cmd, flags, backcmd)
cmdentry.u.index = BLTINCMD; cmdentry.u.index = BLTINCMD;
} else { } else {
static const char PATH[] = "PATH="; static const char PATH[] = "PATH=";
char *path = pathval(); const char *path = pathval();
/* /*
* Modify the command lookup path, if a PATH= assignment * Modify the command lookup path, if a PATH= assignment
@ -764,9 +764,10 @@ evalcommand(cmd, flags, backcmd)
localvars = NULL; localvars = NULL;
INTON; INTON;
if (setjmp(jmploc.loc)) { if (setjmp(jmploc.loc)) {
if (exception == EXSHELLPROC) if (exception == EXSHELLPROC) {
freeparam((struct shparam *)&saveparam); freeparam((volatile struct shparam *)
else { &saveparam);
} else {
freeparam(&shellparam); freeparam(&shellparam);
shellparam = saveparam; shellparam = saveparam;
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: exec.c,v 1.26 1998/07/28 11:41:54 mycroft Exp $ */ /* $NetBSD: exec.c,v 1.27 1999/07/09 03:05:49 christos Exp $ */
/*- /*-
* Copyright (c) 1991, 1993 * Copyright (c) 1991, 1993
@ -41,7 +41,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)exec.c 8.4 (Berkeley) 6/8/95"; static char sccsid[] = "@(#)exec.c 8.4 (Berkeley) 6/8/95";
#else #else
__RCSID("$NetBSD: exec.c,v 1.26 1998/07/28 11:41:54 mycroft Exp $"); __RCSID("$NetBSD: exec.c,v 1.27 1999/07/09 03:05:49 christos Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -117,10 +117,10 @@ STATIC void delete_cmd_entry __P((void));
*/ */
void void
shellexec(argv, envp, path, index) shellexec(argv, envp, path, idx)
char **argv, **envp; char **argv, **envp;
char *path; const char *path;
int index; int idx;
{ {
char *cmdname; char *cmdname;
int e; int e;
@ -131,7 +131,7 @@ shellexec(argv, envp, path, index)
} else { } else {
e = ENOENT; e = ENOENT;
while ((cmdname = padvance(&path, argv[0])) != NULL) { while ((cmdname = padvance(&path, argv[0])) != NULL) {
if (--index < 0 && pathopt == NULL) { if (--idx < 0 && pathopt == NULL) {
tryexec(cmdname, argv, envp); tryexec(cmdname, argv, envp);
if (errno != ENOENT && errno != ENOTDIR) if (errno != ENOENT && errno != ENOTDIR)
e = errno; e = errno;
@ -285,15 +285,16 @@ break2:;
* NULL. * NULL.
*/ */
char *pathopt; const char *pathopt;
char * char *
padvance(path, name) padvance(path, name)
char **path; const char **path;
char *name; const char *name;
{ {
char *p, *q; const char *p;
char *start; char *q;
const char *start;
int len; int len;
if (*path == NULL) if (*path == NULL)
@ -379,17 +380,17 @@ printentry(cmdp, verbose)
struct tblentry *cmdp; struct tblentry *cmdp;
int verbose; int verbose;
{ {
int index; int idx;
char *path; const char *path;
char *name; char *name;
if (cmdp->cmdtype == CMDNORMAL) { if (cmdp->cmdtype == CMDNORMAL) {
index = cmdp->param.index; idx = cmdp->param.index;
path = pathval(); path = pathval();
do { do {
name = padvance(&path, cmdp->cmdname); name = padvance(&path, cmdp->cmdname);
stunalloc(name); stunalloc(name);
} while (--index >= 0); } while (--idx >= 0);
out1str(name); out1str(name);
} else if (cmdp->cmdtype == CMDBUILTIN) { } else if (cmdp->cmdtype == CMDBUILTIN) {
out1fmt("builtin %s", cmdp->cmdname); out1fmt("builtin %s", cmdp->cmdname);
@ -425,10 +426,10 @@ find_command(name, entry, act, path)
char *name; char *name;
struct cmdentry *entry; struct cmdentry *entry;
int act; int act;
char *path; const char *path;
{ {
struct tblentry *cmdp; struct tblentry *cmdp;
int index; int idx;
int prev; int prev;
char *fullname; char *fullname;
struct stat statb; struct stat statb;
@ -482,11 +483,11 @@ find_command(name, entry, act, path)
} }
e = ENOENT; e = ENOENT;
index = -1; idx = -1;
loop: loop:
while ((fullname = padvance(&path, name)) != NULL) { while ((fullname = padvance(&path, name)) != NULL) {
stunalloc(fullname); stunalloc(fullname);
index++; idx++;
if (pathopt) { if (pathopt) {
if (prefix("builtin", pathopt)) { if (prefix("builtin", pathopt)) {
if ((i = find_builtin(name)) < 0) if ((i = find_builtin(name)) < 0)
@ -504,8 +505,8 @@ loop:
} }
} }
/* if rehash, don't redo absolute path names */ /* if rehash, don't redo absolute path names */
if (fullname[0] == '/' && index <= prev) { if (fullname[0] == '/' && idx <= prev) {
if (index < prev) if (idx < prev)
goto loop; goto loop;
TRACE(("searchexec \"%s\": no change\n", name)); TRACE(("searchexec \"%s\": no change\n", name));
goto success; goto success;
@ -546,7 +547,7 @@ loop:
INTOFF; INTOFF;
cmdp = cmdlookup(name, 1); cmdp = cmdlookup(name, 1);
cmdp->cmdtype = CMDNORMAL; cmdp->cmdtype = CMDNORMAL;
cmdp->param.index = index; cmdp->param.index = idx;
INTON; INTON;
goto success; goto success;
} }
@ -618,18 +619,18 @@ changepath(newval)
const char *newval; const char *newval;
{ {
const char *old, *new; const char *old, *new;
int index; int idx;
int firstchange; int firstchange;
int bltin; int bltin;
old = pathval(); old = pathval();
new = newval; new = newval;
firstchange = 9999; /* assume no change */ firstchange = 9999; /* assume no change */
index = 0; idx = 0;
bltin = -1; bltin = -1;
for (;;) { for (;;) {
if (*old != *new) { if (*old != *new) {
firstchange = index; firstchange = idx;
if ((*old == '\0' && *new == ':') if ((*old == '\0' && *new == ':')
|| (*old == ':' && *new == '\0')) || (*old == ':' && *new == '\0'))
firstchange++; firstchange++;
@ -638,9 +639,9 @@ changepath(newval)
if (*new == '\0') if (*new == '\0')
break; break;
if (*new == '%' && bltin < 0 && prefix("builtin", new + 1)) if (*new == '%' && bltin < 0 && prefix("builtin", new + 1))
bltin = index; bltin = idx;
if (*new == ':') { if (*new == ':') {
index++; idx++;
} }
new++, old++; new++, old++;
} }
@ -877,7 +878,7 @@ typecmd(argc, argv)
char **pp; char **pp;
struct alias *ap; struct alias *ap;
int i; int i;
int error = 0; int err = 0;
extern char *const parsekwd[]; extern char *const parsekwd[];
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
@ -911,7 +912,8 @@ typecmd(argc, argv)
switch (entry.cmdtype) { switch (entry.cmdtype) {
case CMDNORMAL: { case CMDNORMAL: {
int j = entry.u.index; int j = entry.u.index;
char *path = pathval(), *name; const char *path = pathval();
char *name;
if (j == -1) if (j == -1)
name = argv[i]; name = argv[i];
else { else {
@ -934,9 +936,9 @@ typecmd(argc, argv)
default: default:
out1str(" not found\n"); out1str(" not found\n");
error |= 127; err |= 127;
break; break;
} }
} }
return error; return err;
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: exec.h,v 1.14 1998/07/28 11:41:54 mycroft Exp $ */ /* $NetBSD: exec.h,v 1.15 1999/07/09 03:05:50 christos Exp $ */
/*- /*-
* Copyright (c) 1991, 1993 * Copyright (c) 1991, 1993
@ -57,13 +57,14 @@ struct cmdentry {
#define DO_ERR 1 /* find_command prints errors */ #define DO_ERR 1 /* find_command prints errors */
#define DO_ABS 2 /* find_command checks absolute paths */ #define DO_ABS 2 /* find_command checks absolute paths */
extern char *pathopt; /* set by padvance */ extern const char *pathopt; /* set by padvance */
extern int exerrno; /* last exec error */ extern int exerrno; /* last exec error */
void shellexec __P((char **, char **, char *, int)) __attribute__((noreturn)); void shellexec __P((char **, char **, const char *, int))
char *padvance __P((char **, char *)); __attribute__((noreturn));
char *padvance __P((const char **, const char *));
int hashcmd __P((int, char **)); int hashcmd __P((int, char **));
void find_command __P((char *, struct cmdentry *, int, char *)); void find_command __P((char *, struct cmdentry *, int, const char *));
int find_builtin __P((char *)); int find_builtin __P((char *));
void hashcd __P((void)); void hashcd __P((void));
void changepath __P((const char *)); void changepath __P((const char *));

View File

@ -1,4 +1,4 @@
/* $NetBSD: expand.c,v 1.47 1999/04/30 17:54:17 he Exp $ */ /* $NetBSD: expand.c,v 1.48 1999/07/09 03:05:50 christos Exp $ */
/*- /*-
* Copyright (c) 1991, 1993 * Copyright (c) 1991, 1993
@ -41,7 +41,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)expand.c 8.5 (Berkeley) 5/15/95"; static char sccsid[] = "@(#)expand.c 8.5 (Berkeley) 5/15/95";
#else #else
__RCSID("$NetBSD: expand.c,v 1.47 1999/04/30 17:54:17 he Exp $"); __RCSID("$NetBSD: expand.c,v 1.48 1999/07/09 03:05:50 christos Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -954,7 +954,7 @@ ifsbreakup(string, arglist)
char *start; char *start;
char *p; char *p;
char *q; char *q;
char *ifs; const char *ifs;
int ifsspc; int ifsspc;
int nulonly; int nulonly;
@ -1119,6 +1119,7 @@ expmeta(enddir, name)
char *name; char *name;
{ {
char *p; char *p;
const char *cp;
char *q; char *q;
char *start; char *start;
char *endname; char *endname;
@ -1192,14 +1193,14 @@ expmeta(enddir, name)
} }
} }
if (enddir == expdir) { if (enddir == expdir) {
p = "."; cp = ".";
} else if (enddir == expdir + 1 && *expdir == '/') { } else if (enddir == expdir + 1 && *expdir == '/') {
p = "/"; cp = "/";
} else { } else {
p = expdir; cp = expdir;
enddir[-1] = '\0'; enddir[-1] = '\0';
} }
if ((dirp = opendir(p)) == NULL) if ((dirp = opendir(cp)) == NULL)
return; return;
if (enddir != expdir) if (enddir != expdir)
enddir[-1] = '/'; enddir[-1] = '/';
@ -1225,9 +1226,8 @@ expmeta(enddir, name)
scopy(dp->d_name, enddir); scopy(dp->d_name, enddir);
addfname(expdir); addfname(expdir);
} else { } else {
char *q; for (p = enddir, cp = dp->d_name;
for (p = enddir, q = dp->d_name; (*p++ = *cp++) != '\0';)
(*p++ = *q++) != '\0';)
continue; continue;
p[-1] = '/'; p[-1] = '/';
expmeta(p, endname); expmeta(p, endname);

View File

@ -1,4 +1,4 @@
/* $NetBSD: expand.h,v 1.11 1999/03/26 15:49:34 christos Exp $ */ /* $NetBSD: expand.h,v 1.12 1999/07/09 03:05:50 christos Exp $ */
/*- /*-
* Copyright (c) 1991, 1993 * Copyright (c) 1991, 1993
@ -69,7 +69,7 @@ void rmescapes __P((char *));
int casematch __P((union node *, char *)); int casematch __P((union node *, char *));
/* From arith.y */ /* From arith.y */
int arith __P((char *)); int arith __P((const char *));
int expcmd __P((int , char **)); int expcmd __P((int , char **));
void arith_lex_reset __P((void)); void arith_lex_reset __P((void));
int yylex __P((void)); int yylex __P((void));

View File

@ -1,4 +1,4 @@
/* $NetBSD: histedit.c,v 1.20 1998/07/28 11:41:55 mycroft Exp $ */ /* $NetBSD: histedit.c,v 1.21 1999/07/09 03:05:50 christos Exp $ */
/*- /*-
* Copyright (c) 1993 * Copyright (c) 1993
@ -41,7 +41,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)histedit.c 8.2 (Berkeley) 5/4/95"; static char sccsid[] = "@(#)histedit.c 8.2 (Berkeley) 5/4/95";
#else #else
__RCSID("$NetBSD: histedit.c,v 1.20 1998/07/28 11:41:55 mycroft Exp $"); __RCSID("$NetBSD: histedit.c,v 1.21 1999/07/09 03:05:50 christos Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -74,7 +74,7 @@ EditLine *el; /* editline cookie */
int displayhist; int displayhist;
static FILE *el_in, *el_out; static FILE *el_in, *el_out;
STATIC char *fc_replace __P((const char *, char *, char *)); STATIC const char *fc_replace __P((const char *, char *, char *));
/* /*
* Set history and editing status. Called whenever the status may * Set history and editing status. Called whenever the status may
@ -186,11 +186,11 @@ histcmd(argc, argv)
extern char *optarg; extern char *optarg;
extern int optind, optopt, optreset; extern int optind, optopt, optreset;
int ch; int ch;
char *editor = NULL; const char *editor = NULL;
HistEvent he; HistEvent he;
int lflg = 0, nflg = 0, rflg = 0, sflg = 0; int lflg = 0, nflg = 0, rflg = 0, sflg = 0;
int i, retval; int i, retval;
char *firststr, *laststr; const char *firststr, *laststr;
int first, last, direction; int first, last, direction;
char *pat = NULL, *repl; /* ksh "fc old=new" crap */ char *pat = NULL, *repl; /* ksh "fc old=new" crap */
static int active = 0; static int active = 0;
@ -366,14 +366,17 @@ histcmd(argc, argv)
out1fmt("%5d ", he.num); out1fmt("%5d ", he.num);
out1str(he.str); out1str(he.str);
} else { } else {
char *s = pat ? const char *s = pat ?
fc_replace(he.str, pat, repl) : (char *)he.str; fc_replace(he.str, pat, repl) : he.str;
char *sp;
if (sflg) { if (sflg) {
if (displayhist) { if (displayhist) {
out2str(s); out2str(s);
} }
evalstring(s);
evalstring(strcpy(stalloc(strlen(s) + 1), s));
free(sp);
if (displayhist && hist) { if (displayhist && hist) {
/* /*
* XXX what about recursive and * XXX what about recursive and
@ -410,7 +413,7 @@ histcmd(argc, argv)
return 0; return 0;
} }
STATIC char * STATIC const char *
fc_replace(s, p, r) fc_replace(s, p, r)
const char *s; const char *s;
char *p, *r; char *p, *r;
@ -447,11 +450,11 @@ not_fcnumber(s)
int int
str_to_event(str, last) str_to_event(str, last)
char *str; const char *str;
int last; int last;
{ {
HistEvent he; HistEvent he;
char *s = str; const char *s = str;
int relative = 0; int relative = 0;
int i, retval; int i, retval;

View File

@ -1,4 +1,4 @@
/* $NetBSD: input.c,v 1.31 1998/05/20 01:36:14 christos Exp $ */ /* $NetBSD: input.c,v 1.32 1999/07/09 03:05:50 christos Exp $ */
/*- /*-
* Copyright (c) 1991, 1993 * Copyright (c) 1991, 1993
@ -41,7 +41,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)input.c 8.3 (Berkeley) 6/9/95"; static char sccsid[] = "@(#)input.c 8.3 (Berkeley) 6/9/95";
#else #else
__RCSID("$NetBSD: input.c,v 1.31 1998/05/20 01:36:14 christos Exp $"); __RCSID("$NetBSD: input.c,v 1.32 1999/07/09 03:05:50 christos Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -181,7 +181,8 @@ static int
preadfd() preadfd()
{ {
int nr; int nr;
parsenextc = parsefile->buf; char *buf = parsefile->buf;
parsenextc = buf;
retry: retry:
#ifndef SMALL #ifndef SMALL
@ -193,11 +194,11 @@ retry:
nr = 0; nr = 0;
else { else {
/* XXX - BUFSIZE should redesign so not necessary */ /* XXX - BUFSIZE should redesign so not necessary */
(void) strcpy(parsenextc, rl_cp); (void) strcpy(buf, rl_cp);
} }
} else } else
#endif #endif
nr = read(parsefile->fd, parsenextc, BUFSIZ - 1); nr = read(parsefile->fd, buf, BUFSIZ - 1);
if (nr <= 0) { if (nr <= 0) {
@ -381,7 +382,7 @@ popstring()
void void
setinputfile(fname, push) setinputfile(fname, push)
char *fname; const char *fname;
int push; int push;
{ {
int fd; int fd;

View File

@ -1,4 +1,4 @@
/* $NetBSD: input.h,v 1.9 1996/10/16 15:45:09 christos Exp $ */ /* $NetBSD: input.h,v 1.10 1999/07/09 03:05:50 christos Exp $ */
/*- /*-
* Copyright (c) 1991, 1993 * Copyright (c) 1991, 1993
@ -56,7 +56,7 @@ int preadbuffer __P((void));
void pungetc __P((void)); void pungetc __P((void));
void pushstring __P((char *, int, void *)); void pushstring __P((char *, int, void *));
void popstring __P((void)); void popstring __P((void));
void setinputfile __P((char *, int)); void setinputfile __P((const char *, int));
void setinputfd __P((int, int)); void setinputfd __P((int, int));
void setinputstring __P((char *, int)); void setinputstring __P((char *, int));
void popfile __P((void)); void popfile __P((void));

View File

@ -1,4 +1,4 @@
/* $NetBSD: jobs.c,v 1.30 1999/04/05 14:59:35 mycroft Exp $ */ /* $NetBSD: jobs.c,v 1.31 1999/07/09 03:05:50 christos Exp $ */
/*- /*-
* Copyright (c) 1991, 1993 * Copyright (c) 1991, 1993
@ -41,7 +41,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)jobs.c 8.5 (Berkeley) 5/4/95"; static char sccsid[] = "@(#)jobs.c 8.5 (Berkeley) 5/4/95";
#else #else
__RCSID("$NetBSD: jobs.c,v 1.30 1999/04/05 14:59:35 mycroft Exp $"); __RCSID("$NetBSD: jobs.c,v 1.31 1999/07/09 03:05:50 christos Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -100,7 +100,7 @@ STATIC int dowait __P((int, struct job *));
STATIC int onsigchild __P((void)); STATIC int onsigchild __P((void));
STATIC int waitproc __P((int, int *)); STATIC int waitproc __P((int, int *));
STATIC void cmdtxt __P((union node *)); STATIC void cmdtxt __P((union node *));
STATIC void cmdputs __P((char *)); STATIC void cmdputs __P((const char *));
/* /*
@ -575,7 +575,7 @@ forkshell(jp, n, mode)
int pid; int pid;
int pgrp; int pgrp;
const char *devnull = _PATH_DEVNULL; const char *devnull = _PATH_DEVNULL;
/* const */ char *nullerr = "Can't open %s"; const char *nullerr = "Can't open %s";
TRACE(("forkshell(%%%d, 0x%lx, %d) called\n", jp - jobtab, (long)n, TRACE(("forkshell(%%%d, 0x%lx, %d) called\n", jp - jobtab, (long)n,
mode)); mode));
@ -975,7 +975,7 @@ cmdtxt(n)
{ {
union node *np; union node *np;
struct nodelist *lp; struct nodelist *lp;
char *p; const char *p;
int i; int i;
char s[2]; char s[2];
@ -1100,9 +1100,10 @@ redir:
STATIC void STATIC void
cmdputs(s) cmdputs(s)
char *s; const char *s;
{ {
char *p, *q; const char *p;
char *q;
char c; char c;
int subtype = 0; int subtype = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: mail.c,v 1.12 1998/01/31 12:36:17 christos Exp $ */ /* $NetBSD: mail.c,v 1.13 1999/07/09 03:05:50 christos Exp $ */
/*- /*-
* Copyright (c) 1991, 1993 * Copyright (c) 1991, 1993
@ -41,7 +41,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)mail.c 8.2 (Berkeley) 5/4/95"; static char sccsid[] = "@(#)mail.c 8.2 (Berkeley) 5/4/95";
#else #else
__RCSID("$NetBSD: mail.c,v 1.12 1998/01/31 12:36:17 christos Exp $"); __RCSID("$NetBSD: mail.c,v 1.13 1999/07/09 03:05:50 christos Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -79,7 +79,7 @@ chkmail(silent)
int silent; int silent;
{ {
int i; int i;
char *mpath; const char *mpath;
char *p; char *p;
char *q; char *q;
struct stackmark smark; struct stackmark smark;

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.33 1999/03/27 13:46:19 christos Exp $ */ /* $NetBSD: main.c,v 1.34 1999/07/09 03:05:50 christos Exp $ */
/*- /*-
* Copyright (c) 1991, 1993 * Copyright (c) 1991, 1993
@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 1993\n\
#if 0 #if 0
static char sccsid[] = "@(#)main.c 8.7 (Berkeley) 7/19/95"; static char sccsid[] = "@(#)main.c 8.7 (Berkeley) 7/19/95";
#else #else
__RCSID("$NetBSD: main.c,v 1.33 1999/03/27 13:46:19 christos Exp $"); __RCSID("$NetBSD: main.c,v 1.34 1999/07/09 03:05:50 christos Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -90,7 +90,7 @@ short profile_buf[16384];
extern int etext(); extern int etext();
#endif #endif
STATIC void read_profile __P((char *)); STATIC void read_profile __P((const char *));
STATIC char *find_dot_file __P((char *)); STATIC char *find_dot_file __P((char *));
int main __P((int, char **)); int main __P((int, char **));
@ -282,7 +282,7 @@ cmdloop(top)
STATIC void STATIC void
read_profile(name) read_profile(name)
char *name; const char *name;
{ {
int fd; int fd;
int xflag_set = 0; int xflag_set = 0;
@ -346,7 +346,7 @@ find_dot_file(basename)
char *basename; char *basename;
{ {
char *fullname; char *fullname;
char *path = pathval(); const char *path = pathval();
struct stat statb; struct stat statb;
/* don't try this for absolute or relative paths */ /* don't try this for absolute or relative paths */

View File

@ -1,5 +1,5 @@
#!/bin/sh - #!/bin/sh -
# $NetBSD: mkbuiltins,v 1.14 1998/03/29 09:27:41 christos Exp $ # $NetBSD: mkbuiltins,v 1.15 1999/07/09 03:05:50 christos Exp $
# #
# Copyright (c) 1991, 1993 # Copyright (c) 1991, 1993
# The Regents of the University of California. All rights reserved. # The Regents of the University of California. All rights reserved.
@ -91,7 +91,7 @@ tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ < $temp |
awk '{ printf "#define %s %d\n", $1, NR-1}' awk '{ printf "#define %s %d\n", $1, NR-1}'
echo ' echo '
struct builtincmd { struct builtincmd {
char *name; const char *name;
int code; int code;
}; };

View File

@ -1,5 +1,5 @@
#!/bin/sh - #!/bin/sh -
# $NetBSD: mktokens,v 1.8 1996/10/16 14:47:49 christos Exp $ # $NetBSD: mktokens,v 1.9 1999/07/09 03:05:50 christos Exp $
# #
# Copyright (c) 1991, 1993 # Copyright (c) 1991, 1993
# The Regents of the University of California. All rights reserved. # The Regents of the University of California. All rights reserved.
@ -80,14 +80,15 @@ const char tokendlist[] = {'
awk '{print "\t" $2 ","}' /tmp/ka$$ awk '{print "\t" $2 ","}' /tmp/ka$$
echo '}; echo '};
char *const tokname[] = {' const char *const tokname[] = {'
sed -e 's/"/\\"/g' \ sed -e 's/"/\\"/g' \
-e 's/[^ ]*[ ][ ]*[^ ]*[ ][ ]*\(.*\)/ "\1",/' \ -e 's/[^ ]*[ ][ ]*[^ ]*[ ][ ]*\(.*\)/ "\1",/' \
/tmp/ka$$ /tmp/ka$$
echo '}; echo '};
' '
sed 's/"//g' /tmp/ka$$ | awk ' sed 's/"//g' /tmp/ka$$ | awk '
/TIF/{print "#define KWDOFFSET " NR-1; print ""; print "char *const parsekwd[] = {"} /TIF/{print "#define KWDOFFSET " NR-1; print "";
print "const char *const parsekwd[] = {"}
/TIF/,/neverfound/{print " \"" $3 "\","}' /TIF/,/neverfound/{print " \"" $3 "\","}'
echo ' 0 echo ' 0
};' };'

View File

@ -1,4 +1,4 @@
/* $NetBSD: myhistedit.h,v 1.6 1997/04/11 22:45:40 christos Exp $ */ /* $NetBSD: myhistedit.h,v 1.7 1999/07/09 03:05:50 christos Exp $ */
/*- /*-
* Copyright (c) 1993 * Copyright (c) 1993
@ -46,5 +46,5 @@ void sethistsize __P((const char *));
void setterm __P((const char *)); void setterm __P((const char *));
int histcmd __P((int, char **)); int histcmd __P((int, char **));
int not_fcnumber __P((char *)); int not_fcnumber __P((char *));
int str_to_event __P((char *, int)); int str_to_event __P((const char *, int));

View File

@ -1,4 +1,4 @@
/* $NetBSD: mystring.c,v 1.13 1997/07/04 21:02:15 christos Exp $ */ /* $NetBSD: mystring.c,v 1.14 1999/07/09 03:05:50 christos Exp $ */
/*- /*-
* Copyright (c) 1991, 1993 * Copyright (c) 1991, 1993
@ -41,7 +41,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)mystring.c 8.2 (Berkeley) 5/4/95"; static char sccsid[] = "@(#)mystring.c 8.2 (Berkeley) 5/4/95";
#else #else
__RCSID("$NetBSD: mystring.c,v 1.13 1997/07/04 21:02:15 christos Exp $"); __RCSID("$NetBSD: mystring.c,v 1.14 1999/07/09 03:05:50 christos Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -122,7 +122,7 @@ number(s)
{ {
if (! is_number(s)) if (! is_number(s))
error("Illegal number: %s", (char *)s); error("Illegal number: %s", s);
return atoi(s); return atoi(s);
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: options.c,v 1.28 1998/07/28 11:41:57 mycroft Exp $ */ /* $NetBSD: options.c,v 1.29 1999/07/09 03:05:50 christos Exp $ */
/*- /*-
* Copyright (c) 1991, 1993 * Copyright (c) 1991, 1993
@ -41,7 +41,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 5/4/95"; static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 5/4/95";
#else #else
__RCSID("$NetBSD: options.c,v 1.28 1998/07/28 11:41:57 mycroft Exp $"); __RCSID("$NetBSD: options.c,v 1.29 1999/07/09 03:05:50 christos Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -292,7 +292,7 @@ setparam(argv)
void void
freeparam(param) freeparam(param)
struct shparam *param; volatile struct shparam *param;
{ {
char **ap; char **ap;
@ -401,12 +401,12 @@ getoptscmd(argc, argv)
} }
STATIC int STATIC int
getopts(optstr, optvar, optfirst, optnext, optptr) getopts(optstr, optvar, optfirst, optnext, optpptr)
char *optstr; char *optstr;
char *optvar; char *optvar;
char **optfirst; char **optfirst;
char ***optnext; char ***optnext;
char **optptr; char **optpptr;
{ {
char *p, *q; char *p, *q;
char c = '?'; char c = '?';
@ -415,7 +415,7 @@ getopts(optstr, optvar, optfirst, optnext, optptr)
int err = 0; int err = 0;
char s[10]; char s[10];
if ((p = *optptr) == NULL || *p == '\0') { if ((p = *optpptr) == NULL || *p == '\0') {
/* Current word is done, advance */ /* Current word is done, advance */
if (*optnext == NULL) if (*optnext == NULL)
return 1; return 1;
@ -483,7 +483,7 @@ bad:
*optnext = NULL; *optnext = NULL;
p = NULL; p = NULL;
out: out:
*optptr = p; *optpptr = p;
fmtstr(s, sizeof(s), "%d", ind); fmtstr(s, sizeof(s), "%d", ind);
err |= setvarsafe("OPTIND", s, VNOFUNC); err |= setvarsafe("OPTIND", s, VNOFUNC);
s[0] = c; s[0] = c;
@ -491,7 +491,7 @@ out:
err |= setvarsafe(optvar, s, 0); err |= setvarsafe(optvar, s, 0);
if (err) { if (err) {
*optnext = NULL; *optnext = NULL;
*optptr = NULL; *optpptr = NULL;
flushall(); flushall();
exraise(EXERROR); exraise(EXERROR);
} }
@ -511,9 +511,10 @@ out:
int int
nextopt(optstring) nextopt(optstring)
char *optstring; const char *optstring;
{ {
char *p, *q; char *p;
const char *q;
char c; char c;
if ((p = optptr) == NULL || *p == '\0') { if ((p = optptr) == NULL || *p == '\0') {

View File

@ -1,4 +1,4 @@
/* $NetBSD: options.h,v 1.12 1999/02/04 00:27:07 cjs Exp $ */ /* $NetBSD: options.h,v 1.13 1999/07/09 03:05:50 christos Exp $ */
/*- /*-
* Copyright (c) 1991, 1993 * Copyright (c) 1991, 1993
@ -108,9 +108,9 @@ extern char *optptr; /* used by nextopt */
void procargs __P((int, char **)); void procargs __P((int, char **));
void optschanged __P((void)); void optschanged __P((void));
void setparam __P((char **)); void setparam __P((char **));
void freeparam __P((struct shparam *)); void freeparam __P((volatile struct shparam *));
int shiftcmd __P((int, char **)); int shiftcmd __P((int, char **));
int setcmd __P((int, char **)); int setcmd __P((int, char **));
int getoptscmd __P((int, char **)); int getoptscmd __P((int, char **));
int nextopt __P((char *)); int nextopt __P((const char *));
void getoptsreset __P((const char *)); void getoptsreset __P((const char *));

View File

@ -1,4 +1,4 @@
/* $NetBSD: parser.c,v 1.42 1999/02/04 16:17:39 christos Exp $ */ /* $NetBSD: parser.c,v 1.43 1999/07/09 03:05:50 christos Exp $ */
/*- /*-
* Copyright (c) 1991, 1993 * Copyright (c) 1991, 1993
@ -41,7 +41,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)parser.c 8.7 (Berkeley) 5/16/95"; static char sccsid[] = "@(#)parser.c 8.7 (Berkeley) 5/16/95";
#else #else
__RCSID("$NetBSD: parser.c,v 1.42 1999/02/04 16:17:39 christos Exp $"); __RCSID("$NetBSD: parser.c,v 1.43 1999/07/09 03:05:50 christos Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -101,14 +101,6 @@ int quoteflag; /* set if (part of) last token was quoted */
int startlinno; /* line # where last token started */ int startlinno; /* line # where last token started */
#define GDB_HACK 1 /* avoid local declarations which gdb can't handle */
#ifdef GDB_HACK
static const char argvars[5] = {(char)CTLVAR, (char)(VSNORMAL|VSQUOTE),
'@', '=', '\0'};
static const char types[] = "}-+?=";
#endif
STATIC union node *list __P((int)); STATIC union node *list __P((int));
STATIC union node *andor __P((void)); STATIC union node *andor __P((void));
STATIC union node *pipeline __P((void)); STATIC union node *pipeline __P((void));
@ -123,7 +115,7 @@ STATIC int xxreadtoken __P((void));
STATIC int readtoken1 __P((int, char const *, char *, int)); STATIC int readtoken1 __P((int, char const *, char *, int));
STATIC int noexpand __P((char *)); STATIC int noexpand __P((char *));
STATIC void synexpect __P((int)) __attribute__((noreturn)); STATIC void synexpect __P((int)) __attribute__((noreturn));
STATIC void synerror __P((char *)) __attribute__((noreturn)); STATIC void synerror __P((const char *)) __attribute__((noreturn));
STATIC void setprompt __P((int)); STATIC void setprompt __P((int));
@ -372,13 +364,11 @@ TRACE(("expecting DO got %s %s\n", tokname[got], got == TWORD ? wordtext : ""));
if (lasttoken != TNL && lasttoken != TSEMI) if (lasttoken != TNL && lasttoken != TSEMI)
synexpect(-1); synexpect(-1);
} else { } else {
#ifndef GDB_HACK static char argvars[5] = {CTLVAR, VSNORMAL|VSQUOTE,
static const char argvars[5] = {CTLVAR, VSNORMAL|VSQUOTE,
'@', '=', '\0'}; '@', '=', '\0'};
#endif
n2 = (union node *)stalloc(sizeof (struct narg)); n2 = (union node *)stalloc(sizeof (struct narg));
n2->type = NARG; n2->type = NARG;
n2->narg.text = (char *)argvars; n2->narg.text = argvars;
n2->narg.backquote = NULL; n2->narg.backquote = NULL;
n2->narg.next = NULL; n2->narg.next = NULL;
n1->nfor.args = n2; n1->nfor.args = n2;
@ -728,12 +718,13 @@ readtoken() {
*/ */
if (t == TWORD && !quoteflag) if (t == TWORD && !quoteflag)
{ {
char * const *pp; const char *const *pp;
for (pp = (char **)parsekwd; *pp; pp++) { for (pp = parsekwd; *pp; pp++) {
if (**pp == *wordtext && equal(*pp, wordtext)) if (**pp == *wordtext && equal(*pp, wordtext))
{ {
lasttoken = t = pp - parsekwd + KWDOFFSET; lasttoken = t = pp -
parsekwd + KWDOFFSET;
TRACE(("keyword %s recognized\n", tokname[t])); TRACE(("keyword %s recognized\n", tokname[t]));
goto out; goto out;
} }
@ -1181,9 +1172,7 @@ parsesub: {
int typeloc; int typeloc;
int flags; int flags;
char *p; char *p;
#ifndef GDB_HACK
static const char types[] = "}-+?="; static const char types[] = "}-+?=";
#endif
c = pgetc(); c = pgetc();
if (c != '(' && c != '{' && !is_name(c) && !is_special(c)) { if (c != '(' && c != '{' && !is_name(c) && !is_special(c)) {
@ -1313,24 +1302,24 @@ parsebackq: {
/* We must read until the closing backquote, giving special /* We must read until the closing backquote, giving special
treatment to some slashes, and then push the string and treatment to some slashes, and then push the string and
reread it as input, interpreting it normally. */ reread it as input, interpreting it normally. */
char *out; char *pout;
int c; int pc;
int savelen; int psavelen;
char *str; char *pstr;
STARTSTACKSTR(out); STARTSTACKSTR(pout);
for (;;) { for (;;) {
if (needprompt) { if (needprompt) {
setprompt(2); setprompt(2);
needprompt = 0; needprompt = 0;
} }
switch (c = pgetc()) { switch (pc = pgetc()) {
case '`': case '`':
goto done; goto done;
case '\\': case '\\':
if ((c = pgetc()) == '\n') { if ((pc = pgetc()) == '\n') {
plinno++; plinno++;
if (doprompt) if (doprompt)
setprompt(2); setprompt(2);
@ -1344,9 +1333,9 @@ parsebackq: {
*/ */
continue; continue;
} }
if (c != '\\' && c != '`' && c != '$' if (pc != '\\' && pc != '`' && pc != '$'
&& (!dblquote || c != '"')) && (!dblquote || pc != '"'))
STPUTC('\\', out); STPUTC('\\', pout);
break; break;
case '\n': case '\n':
@ -1362,14 +1351,14 @@ parsebackq: {
default: default:
break; break;
} }
STPUTC(c, out); STPUTC(pc, pout);
} }
done: done:
STPUTC('\0', out); STPUTC('\0', pout);
savelen = out - stackblock(); psavelen = pout - stackblock();
if (savelen > 0) { if (psavelen > 0) {
str = grabstackstr(out); pstr = grabstackstr(pout);
setinputstring(str, 1); setinputstring(pstr, 1);
} }
} }
nlpp = &bqlist; nlpp = &bqlist;
@ -1531,7 +1520,7 @@ synexpect(token)
STATIC void STATIC void
synerror(msg) synerror(msg)
char *msg; const char *msg;
{ {
if (commandname) if (commandname)
outfmt(&errout, "%s: %d: ", commandname, startlinno); outfmt(&errout, "%s: %d: ", commandname, startlinno);
@ -1556,7 +1545,7 @@ setprompt(which)
* called by editline -- any expansions to the prompt * called by editline -- any expansions to the prompt
* should be added here. * should be added here.
*/ */
char * const char *
getprompt(unused) getprompt(unused)
void *unused; void *unused;
{ {

View File

@ -1,4 +1,4 @@
/* $NetBSD: parser.h,v 1.12 1999/01/25 14:20:56 mycroft Exp $ */ /* $NetBSD: parser.h,v 1.13 1999/07/09 03:05:50 christos Exp $ */
/*- /*-
* Copyright (c) 1991, 1993 * Copyright (c) 1991, 1993
@ -80,4 +80,4 @@ extern int whichprompt; /* 1 == PS1, 2 == PS2 */
union node *parsecmd __P((int)); union node *parsecmd __P((int));
void fixredir __P((union node *, const char *, int)); void fixredir __P((union node *, const char *, int));
int goodname __P((char *)); int goodname __P((char *));
char *getprompt __P((void *)); const char *getprompt __P((void *));

View File

@ -1,4 +1,4 @@
/* $NetBSD: var.c,v 1.22 1999/01/28 18:11:51 kleink Exp $ */ /* $NetBSD: var.c,v 1.23 1999/07/09 03:05:50 christos Exp $ */
/*- /*-
* Copyright (c) 1991, 1993 * Copyright (c) 1991, 1993
@ -41,7 +41,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 5/4/95"; static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 5/4/95";
#else #else
__RCSID("$NetBSD: var.c,v 1.22 1999/01/28 18:11:51 kleink Exp $"); __RCSID("$NetBSD: var.c,v 1.23 1999/07/09 03:05:50 christos Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -78,7 +78,7 @@ __RCSID("$NetBSD: var.c,v 1.22 1999/01/28 18:11:51 kleink Exp $");
struct varinit { struct varinit {
struct var *var; struct var *var;
int flags; int flags;
char *text; const char *text;
void (*func) __P((const char *)); void (*func) __P((const char *));
}; };
@ -133,8 +133,8 @@ const struct varinit varinit[] = {
struct var *vartab[VTABSIZE]; struct var *vartab[VTABSIZE];
STATIC struct var **hashvar __P((char *)); STATIC struct var **hashvar __P((const char *));
STATIC int varequal __P((char *, char *)); STATIC int varequal __P((const char *, const char *));
/* /*
* Initialize the varable symbol tables and import the environment * Initialize the varable symbol tables and import the environment
@ -172,7 +172,7 @@ initvar() {
vpp = hashvar(ip->text); vpp = hashvar(ip->text);
vp->next = *vpp; vp->next = *vpp;
*vpp = vp; *vpp = vp;
vp->text = ip->text; vp->text = strdup(ip->text);
vp->flags = ip->flags; vp->flags = ip->flags;
vp->func = ip->func; vp->func = ip->func;
} }
@ -184,7 +184,7 @@ initvar() {
vpp = hashvar("PS1="); vpp = hashvar("PS1=");
vps1.next = *vpp; vps1.next = *vpp;
*vpp = &vps1; *vpp = &vps1;
vps1.text = geteuid() ? "PS1=$ " : "PS1=# "; vps1.text = strdup(geteuid() ? "PS1=$ " : "PS1=# ");
vps1.flags = VSTRFIXED|VTEXTFIXED; vps1.flags = VSTRFIXED|VTEXTFIXED;
} }
} }
@ -195,7 +195,7 @@ initvar() {
int int
setvarsafe(name, val, flags) setvarsafe(name, val, flags)
char *name, *val; const char *name, *val;
int flags; int flags;
{ {
struct jmploc jmploc; struct jmploc jmploc;
@ -222,10 +222,12 @@ setvarsafe(name, val, flags)
void void
setvar(name, val, flags) setvar(name, val, flags)
char *name, *val; const char *name, *val;
int flags; int flags;
{ {
char *p, *q; const char *p;
const char *q;
char *d;
int len; int len;
int namelen; int namelen;
char *nameeq; char *nameeq;
@ -253,14 +255,14 @@ setvar(name, val, flags)
} else { } else {
len += strlen(val); len += strlen(val);
} }
p = nameeq = ckmalloc(len); d = nameeq = ckmalloc(len);
q = name; q = name;
while (--namelen >= 0) while (--namelen >= 0)
*p++ = *q++; *d++ = *q++;
*p++ = '='; *d++ = '=';
*p = '\0'; *d = '\0';
if (val) if (val)
scopy(val, p); scopy(val, d);
setvareq(nameeq, flags); setvareq(nameeq, flags);
} }
@ -345,7 +347,7 @@ listsetvar(list)
char * char *
lookupvar(name) lookupvar(name)
char *name; const char *name;
{ {
struct var *v; struct var *v;
@ -369,7 +371,7 @@ lookupvar(name)
char * char *
bltinlookup(name, doall) bltinlookup(name, doall)
char *name; const char *name;
int doall; int doall;
{ {
struct strlist *sp; struct strlist *sp;
@ -402,7 +404,8 @@ environment() {
int nenv; int nenv;
struct var **vpp; struct var **vpp;
struct var *vp; struct var *vp;
char **env, **ep; char **env;
char **ep;
nenv = 0; nenv = 0;
for (vpp = vartab ; vpp < vartab + VTABSIZE ; vpp++) { for (vpp = vartab ; vpp < vartab + VTABSIZE ; vpp++) {
@ -499,7 +502,7 @@ exportcmd(argc, argv)
struct var **vpp; struct var **vpp;
struct var *vp; struct var *vp;
char *name; char *name;
char *p; const char *p;
int flag = argv[0][0] == 'r'? VREADONLY : VEXPORT; int flag = argv[0][0] == 'r'? VREADONLY : VEXPORT;
int pflag; int pflag;
@ -578,8 +581,9 @@ mklocal(name)
INTOFF; INTOFF;
lvp = ckmalloc(sizeof (struct localvar)); lvp = ckmalloc(sizeof (struct localvar));
if (name[0] == '-' && name[1] == '\0') { if (name[0] == '-' && name[1] == '\0') {
lvp->text = ckmalloc(sizeof optlist); char *p;
memcpy(lvp->text, optlist, sizeof optlist); p = ckmalloc(sizeof optlist);
lvp->text = memcpy(p, optlist, sizeof optlist);
vp = NULL; vp = NULL;
} else { } else {
vpp = hashvar(name); vpp = hashvar(name);
@ -692,7 +696,7 @@ unsetcmd(argc, argv)
int int
unsetvar(s) unsetvar(s)
char *s; const char *s;
{ {
struct var **vpp; struct var **vpp;
struct var *vp; struct var *vp;
@ -729,7 +733,7 @@ unsetvar(s)
STATIC struct var ** STATIC struct var **
hashvar(p) hashvar(p)
char *p; const char *p;
{ {
unsigned int hashval; unsigned int hashval;
@ -749,7 +753,7 @@ hashvar(p)
STATIC int STATIC int
varequal(p, q) varequal(p, q)
char *p, *q; const char *p, *q;
{ {
while (*p == *q++) { while (*p == *q++) {
if (*p++ == '=') if (*p++ == '=')

View File

@ -1,4 +1,4 @@
/* $NetBSD: var.h,v 1.15 1999/01/25 14:20:56 mycroft Exp $ */ /* $NetBSD: var.h,v 1.16 1999/07/09 03:05:50 christos Exp $ */
/*- /*-
* Copyright (c) 1991, 1993 * Copyright (c) 1991, 1993
@ -112,12 +112,12 @@ extern struct var vhistsize;
#define mpathset() ((vmpath.flags & VUNSET) == 0) #define mpathset() ((vmpath.flags & VUNSET) == 0)
void initvar __P((void)); void initvar __P((void));
void setvar __P((char *, char *, int)); void setvar __P((const char *, const char *, int));
void setvareq __P((char *, int)); void setvareq __P((char *, int));
struct strlist; struct strlist;
void listsetvar __P((struct strlist *)); void listsetvar __P((struct strlist *));
char *lookupvar __P((char *)); char *lookupvar __P((const char *));
char *bltinlookup __P((char *, int)); char *bltinlookup __P((const char *, int));
char **environment __P((void)); char **environment __P((void));
void shprocvar __P((void)); void shprocvar __P((void));
int showvarscmd __P((int, char **)); int showvarscmd __P((int, char **));
@ -127,5 +127,5 @@ void mklocal __P((char *));
void poplocalvars __P((void)); void poplocalvars __P((void));
int setvarcmd __P((int, char **)); int setvarcmd __P((int, char **));
int unsetcmd __P((int, char **)); int unsetcmd __P((int, char **));
int unsetvar __P((char *)); int unsetvar __P((const char *));
int setvarsafe __P((char *, char *, int)); int setvarsafe __P((const char *, const char *, int));