summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/ksh/c_ksh.c44
-rw-r--r--bin/ksh/c_sh.c16
-rw-r--r--bin/ksh/c_test.c13
-rw-r--r--bin/ksh/c_ulimit.c4
-rw-r--r--bin/ksh/edit.c24
-rw-r--r--bin/ksh/emacs.c12
-rw-r--r--bin/ksh/eval.c20
-rw-r--r--bin/ksh/exec.c55
-rw-r--r--bin/ksh/expr.c10
-rw-r--r--bin/ksh/history.c26
-rw-r--r--bin/ksh/io.c8
-rw-r--r--bin/ksh/jobs.c135
-rw-r--r--bin/ksh/ksh_wait.h4
-rw-r--r--bin/ksh/lex.c12
-rw-r--r--bin/ksh/mail.c4
-rw-r--r--bin/ksh/main.c47
-rw-r--r--bin/ksh/misc.c22
-rw-r--r--bin/ksh/missing.c8
-rw-r--r--bin/ksh/path.c21
-rw-r--r--bin/ksh/shf.c10
-rw-r--r--bin/ksh/siglist.sh4
-rw-r--r--bin/ksh/syn.c40
-rw-r--r--bin/ksh/table.c4
-rw-r--r--bin/ksh/trap.c14
-rw-r--r--bin/ksh/tree.c6
-rw-r--r--bin/ksh/var.c24
-rw-r--r--bin/ksh/vi.c8
-rw-r--r--bin/pdksh/c_ksh.c44
-rw-r--r--bin/pdksh/c_sh.c16
-rw-r--r--bin/pdksh/c_test.c13
-rw-r--r--bin/pdksh/c_ulimit.c4
-rw-r--r--bin/pdksh/edit.c24
-rw-r--r--bin/pdksh/emacs.c12
-rw-r--r--bin/pdksh/eval.c20
-rw-r--r--bin/pdksh/exec.c55
-rw-r--r--bin/pdksh/expr.c10
-rw-r--r--bin/pdksh/history.c26
-rw-r--r--bin/pdksh/io.c8
-rw-r--r--bin/pdksh/jobs.c135
-rw-r--r--bin/pdksh/ksh_wait.h4
-rw-r--r--bin/pdksh/lex.c12
-rw-r--r--bin/pdksh/mail.c4
-rw-r--r--bin/pdksh/main.c47
-rw-r--r--bin/pdksh/misc.c22
-rw-r--r--bin/pdksh/missing.c8
-rw-r--r--bin/pdksh/path.c21
-rw-r--r--bin/pdksh/shf.c10
-rw-r--r--bin/pdksh/siglist.sh4
-rw-r--r--bin/pdksh/syn.c40
-rw-r--r--bin/pdksh/table.c4
-rw-r--r--bin/pdksh/trap.c14
-rw-r--r--bin/pdksh/tree.c6
-rw-r--r--bin/pdksh/var.c24
-rw-r--r--bin/pdksh/vi.c8
54 files changed, 592 insertions, 598 deletions
diff --git a/bin/ksh/c_ksh.c b/bin/ksh/c_ksh.c
index df402d54e1b..5799fce58d0 100644
--- a/bin/ksh/c_ksh.c
+++ b/bin/ksh/c_ksh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: c_ksh.c,v 1.5 1996/11/21 07:59:27 downsj Exp $ */
+/* $OpenBSD: c_ksh.c,v 1.6 1997/06/18 22:42:27 kstailey Exp $ */
/*
* built-in Korn commands: c_*
@@ -76,7 +76,7 @@ c_cd(wp)
* we could try to find another substitution. For now
* we don't
*/
- if ((cp = strstr(current_wd, wp[0])) == (char *) 0) {
+ if ((cp = strstr(current_wd, wp[0])) == NULL) {
bi_errorf("bad substitution");
return 1;
}
@@ -95,10 +95,10 @@ c_cd(wp)
}
Xinit(xs, xp, PATH, ATEMP);
- /* xp will have a bogus value after make_path() - set it to 0
+ /* xp will have a bogus value after make_path() - set it to NULL
* so that if it's used, it will cause a dump
*/
- xp = (char *) 0;
+ xp = NULL;
cdpath = str_val(global("CDPATH"));
do {
@@ -112,7 +112,7 @@ c_cd(wp)
simplify_path(Xstring(xs, xp));
rval = chdir(try = Xstring(xs, xp));
}
- } while (rval < 0 && cdpath != (char *) 0);
+ } while (rval < 0 && cdpath != NULL);
if (rval < 0) {
if (cdnode)
@@ -135,9 +135,9 @@ c_cd(wp)
* so it can't set current_wd when changing to a:foo.
* Handle this by calling getcwd()...
*/
- pwd = ksh_get_wd((char *) 0, 0);
+ pwd = ksh_get_wd(NULL, 0);
#else /* OS2 */
- pwd = (char *) 0;
+ pwd = NULL;
#endif /* OS2 */
} else
#ifdef S_ISLNK
@@ -187,14 +187,14 @@ c_pwd(wp)
}
#ifdef S_ISLNK
p = current_wd[0] ? (physical ? get_phys_path(current_wd) : current_wd)
- : (char *) 0;
+ : NULL;
#else /* S_ISLNK */
- p = current_wd[0] ? current_wd : (char *) 0;
+ p = current_wd[0] ? current_wd : NULL;
#endif /* S_ISLNK */
if (p && eaccess(p, R_OK) < 0)
- p = (char *) 0;
+ p = NULL;
if (!p) {
- p = ksh_get_wd((char *) 0, 0);
+ p = ksh_get_wd(NULL, 0);
if (!p) {
bi_errorf("can't get current directory - %s",
strerror(errno));
@@ -595,7 +595,7 @@ c_typeset(wp)
break;
}
- fieldstr = basestr = (char *) 0;
+ fieldstr = basestr = NULL;
builtin_opt.flags |= GF_PLUSOPT;
/* at&t ksh seems to have 0-9 as options, which are multiplied
* to get a number that is used with -L, -R, -Z or -i (eg, -1R2
@@ -872,7 +872,7 @@ c_alias(wp)
/* "hash -r" means reset all the tracked aliases.. */
if (rflag) {
static const char *const args[] = {
- "unalias", "-ta", (const char *) 0
+ "unalias", "-ta", NULL
};
if (!tflag || *wp) {
@@ -926,7 +926,7 @@ c_alias(wp)
afree((void*)ap->val.s, APERM);
}
/* ignore values for -t (at&t ksh does this) */
- newval = tflag ? search(alias, path, X_OK, (int *) 0)
+ newval = tflag ? search(alias, path, X_OK, NULL)
: val;
if (newval) {
ap->val.s = str_save(newval, APERM);
@@ -1003,7 +1003,7 @@ c_let(wp)
int rv = 1;
long val;
- if (wp[1] == (char *) 0) /* at&t ksh does this */
+ if (wp[1] == NULL) /* at&t ksh does this */
bi_errorf("no arguments");
else
for (wp++; *wp; wp++)
@@ -1044,7 +1044,7 @@ c_jobs(wp)
}
wp += builtin_opt.optind;
if (!*wp)
- if (j_jobs((char *) 0, flag, nflag))
+ if (j_jobs(NULL, flag, nflag))
rv = 1;
else
for (; *wp; wp++)
@@ -1115,7 +1115,7 @@ int
c_kill(wp)
char **wp;
{
- Trap *t = (Trap *) 0;
+ Trap *t = NULL;
char *p;
int lflag = 0;
int i, n, rv, sig;
@@ -1265,12 +1265,12 @@ c_getopts(wp)
return 1;
}
- if (e->loc->next == (struct block *) 0) {
+ if (e->loc->next == NULL) {
internal_errorf(0, "c_getopts: no argv");
return 1;
}
/* Which arguments are we parsing... */
- if (*wp == (char *) 0)
+ if (*wp == NULL)
wp = e->loc->next->argv;
else
*--wp = e->loc->next->argv[0];
@@ -1286,7 +1286,7 @@ c_getopts(wp)
return 1;
}
- user_opt.optarg = (char *) 0;
+ user_opt.optarg = NULL;
optc = ksh_getopt(wp, &user_opt, options);
if (optc >= 0 && optc != '?' && (user_opt.info & GI_PLUS)) {
@@ -1311,7 +1311,7 @@ c_getopts(wp)
getopts_noset = 0;
}
- if (user_opt.optarg == (char *) 0)
+ if (user_opt.optarg == NULL)
unset(global("OPTARG"), 0);
else
setstr(global("OPTARG"), user_opt.optarg);
@@ -1351,7 +1351,7 @@ c_bind(wp)
wp += builtin_opt.optind;
if (*wp == NULL) /* list all */
- rv = x_bind((char*)NULL, (char*)NULL, 0, list);
+ rv = x_bind(NULL, NULL, 0, list);
for (; *wp != NULL; wp++) {
cp = strchr(*wp, '=');
diff --git a/bin/ksh/c_sh.c b/bin/ksh/c_sh.c
index fe090f09277..c488229f66e 100644
--- a/bin/ksh/c_sh.c
+++ b/bin/ksh/c_sh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: c_sh.c,v 1.3 1996/10/13 21:32:18 downsj Exp $ */
+/* $OpenBSD: c_sh.c,v 1.4 1997/06/18 22:42:28 kstailey Exp $ */
/*
* built-in Bourne commands
@@ -185,7 +185,7 @@ c_dot(wp)
if ((cp = wp[builtin_opt.optind]) == NULL)
return 0;
- file = search(cp, path, R_OK, (int *) 0);
+ file = search(cp, path, R_OK, NULL);
if (file == NULL) {
bi_errorf("%s: not found", cp);
return 1;
@@ -199,7 +199,7 @@ c_dot(wp)
;
} else {
argc = 0;
- argv = (char **) 0;
+ argv = NULL;
}
i = include(file, argc, argv, 0);
if (i < 0) { /* should not happen */
@@ -219,8 +219,8 @@ c_wait(wp)
if (ksh_getopt(wp, &builtin_opt, null) == '?')
return 1;
wp += builtin_opt.optind;
- if (*wp == (char *) 0) {
- while (waitfor((char *) 0, &sig) >= 0)
+ if (*wp == NULL) {
+ while (waitfor(NULL, &sig) >= 0)
;
rv = sig;
} else {
@@ -357,7 +357,7 @@ c_read(wp)
/* set prompt in case this is
* called from .profile or $ENV
*/
- set_prompt(PS2, (Source *) 0);
+ set_prompt(PS2, NULL);
pprompt(prompt, 0);
}
} else if (c != EOF)
@@ -526,7 +526,7 @@ c_brkcont(wp)
char **wp;
{
int n, quit;
- struct env *ep, *last_ep = (struct env *) 0;
+ struct env *ep, *last_ep = NULL;
char *arg;
if (ksh_getopt(wp, &builtin_opt, null) == '?')
@@ -643,7 +643,7 @@ c_unset(wp)
}
unset(vp, strchr(id, '[') ? 1 : 0);
} else { /* unset function */
- if (define(id, (struct op *) NULL))
+ if (define(id, NULL))
ret = 1;
}
return ret;
diff --git a/bin/ksh/c_test.c b/bin/ksh/c_test.c
index 63a0c94e80c..a5777f8deec 100644
--- a/bin/ksh/c_test.c
+++ b/bin/ksh/c_test.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: c_test.c,v 1.2 1996/08/19 20:08:47 downsj Exp $ */
+/* $OpenBSD: c_test.c,v 1.3 1997/06/18 22:42:29 kstailey Exp $ */
/*
* test(1); version 7-like -- author Erik Baalbergen
@@ -157,8 +157,7 @@ c_test(wp)
}
if (argc == 1) {
opnd1 = (*te.getopnd)(&te, TO_NONOP, 1);
- res = (*te.eval)(&te, TO_STNZE, opnd1,
- (char *) 0, 1);
+ res = (*te.eval)(&te, TO_STNZE, opnd1, NULL, 1);
if (invert & 1)
res = !res;
return !res;
@@ -517,7 +516,7 @@ test_primary(te, do_eval)
return 0;
}
- return (*te->eval)(te, op, opnd1, (const char *) 0, do_eval);
+ return (*te->eval)(te, op, opnd1, NULL, do_eval);
}
opnd1 = (*te->getopnd)(te, TO_NONOP, do_eval);
if (!opnd1) {
@@ -538,7 +537,7 @@ test_primary(te, do_eval)
(*te->error)(te, -1, "missing expression operator");
return 0;
}
- return (*te->eval)(te, TO_STNZE, opnd1, (const char *) 0, do_eval);
+ return (*te->eval)(te, TO_STNZE, opnd1, NULL, do_eval);
}
/*
@@ -584,7 +583,7 @@ ptest_getopnd(te, op, do_eval)
int do_eval;
{
if (te->pos.wp >= te->wp_end)
- return op == TO_FILTT ? "1" : (const char *) 0;
+ return op == TO_FILTT ? "1" : NULL;
return *te->pos.wp++;
}
@@ -606,7 +605,7 @@ ptest_error(te, offset, msg)
const char *msg;
{
const char *op = te->pos.wp + offset >= te->wp_end ?
- (const char *) 0 : te->pos.wp[offset];
+ NULL : te->pos.wp[offset];
te->flags |= TEF_ERROR;
if (op)
diff --git a/bin/ksh/c_ulimit.c b/bin/ksh/c_ulimit.c
index 040eaccb409..31acaea78c1 100644
--- a/bin/ksh/c_ulimit.c
+++ b/bin/ksh/c_ulimit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: c_ulimit.c,v 1.1 1996/08/14 06:19:10 downsj Exp $ */
+/* $OpenBSD: c_ulimit.c,v 1.2 1997/06/18 22:42:30 kstailey Exp $ */
/*
ulimit -- handle "ulimit" builtin
@@ -107,7 +107,7 @@ c_ulimit(wp)
#ifdef RLIMIT_SWAP
{ "swap(kbytes)", RLIMIT_SWAP, RLIMIT_SWAP, 1024, 'w' },
#endif
- { (char *) 0 }
+ { NULL }
};
static char options[3 + NELEM(limits)];
rlim_t UNINITIALIZED(val);
diff --git a/bin/ksh/edit.c b/bin/ksh/edit.c
index 53c1fcb301a..fbfc8d3a630 100644
--- a/bin/ksh/edit.c
+++ b/bin/ksh/edit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: edit.c,v 1.4 1996/12/14 12:18:07 mickey Exp $ */
+/* $OpenBSD: edit.c,v 1.5 1997/06/18 22:42:31 kstailey Exp $ */
/*
* Command line editing - common code
@@ -459,7 +459,7 @@ x_complete_word(str, slen, is_command, nwordsp, ret)
str, slen, &words);
*nwordsp = nwords;
if (nwords == 0) {
- *ret = (char *) 0;
+ *ret = NULL;
return -1;
}
@@ -490,10 +490,10 @@ x_print_expansions(nwords, words, is_command)
/* Special case for 1 match (prefix is whole word) */
if (nwords == 1)
- prefix_len = x_basename(words[0], (char *) 0);
+ prefix_len = x_basename(words[0], NULL);
/* Any (non-trailing) slashes in non-common word suffixes? */
for (i = 0; i < nwords; i++)
- if (x_basename(words[i] + prefix_len, (char *) 0)
+ if (x_basename(words[i] + prefix_len, NULL)
> prefix_len)
break;
/* All in same directory? */
@@ -505,7 +505,7 @@ x_print_expansions(nwords, words, is_command)
XPinit(l, nwords + 1);
for (i = 0; i < nwords; i++)
XPput(l, words[i] + prefix_len);
- XPput(l, (char *) 0);
+ XPput(l, NULL);
}
}
@@ -585,7 +585,7 @@ x_file_glob(flags, str, slen, wordsp)
}
afree(toglob, ATEMP);
- *wordsp = nwords ? words : (char **) 0;
+ *wordsp = nwords ? words : NULL;
return nwords;
}
@@ -649,7 +649,7 @@ x_command_glob(flags, str, slen, wordsp)
nwords = XPsize(w);
if (!nwords) {
- *wordsp = (char **) 0;
+ *wordsp = NULL;
XPfree(w);
return 0;
}
@@ -667,7 +667,7 @@ x_command_glob(flags, str, slen, wordsp)
alloc(sizeof(struct path_order_info) * nwords, ATEMP);
for (i = 0; i < nwords; i++) {
info[i].word = words[i];
- info[i].base = x_basename(words[i], (char *) 0);
+ info[i].base = x_basename(words[i], NULL);
if (!last_info || info[i].base != last_info->base
|| FILENCMP(words[i],
last_info->word, info[i].base) != 0)
@@ -799,7 +799,7 @@ x_cf_glob(flags, buf, buflen, pos, startp, endp, wordsp, is_commandp)
nwords = (is_command ? x_command_glob : x_file_glob)(flags,
buf + *startp, len, &words);
if (nwords == 0) {
- *wordsp = (char **) 0;
+ *wordsp = NULL;
return 0;
}
@@ -824,7 +824,7 @@ add_glob(str, slen)
bool_t saw_slash = FALSE;
if (slen < 0)
- return (char *) 0;
+ return (NULL);
toglob = str_nsave(str, slen + 1, ATEMP); /* + 1 for "*" */
toglob[slen] = '\0';
@@ -909,7 +909,7 @@ x_basename(s, se)
{
const char *p;
- if (se == (char *) 0)
+ if (se == NULL)
se = s + strlen(s);
if (s == se)
return 0;
@@ -993,7 +993,7 @@ glob_path(flags, pat, wp, path)
/* Check that each match is executable... */
words = (char **) XPptrv(*wp);
for (i = j = oldsize; i < newsize; i++) {
- if (search_access(words[i], X_OK, (int *) 0) >= 0) {
+ if (search_access(words[i], X_OK, NULL) >= 0) {
words[j] = words[i];
if (!(flags & XCF_FULLPATH))
memmove(words[j], words[j] + pathlen,
diff --git a/bin/ksh/emacs.c b/bin/ksh/emacs.c
index f572f87b5f6..32d9c379bd7 100644
--- a/bin/ksh/emacs.c
+++ b/bin/ksh/emacs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: emacs.c,v 1.2 1996/08/19 20:08:48 downsj Exp $ */
+/* $OpenBSD: emacs.c,v 1.3 1997/06/18 22:42:32 kstailey Exp $ */
/*
* Emacs-like command line editing and history
@@ -339,7 +339,7 @@ x_emacs(buf, len)
xlp_valid = TRUE;
xmp = NULL;
x_curprefix = 0;
- macroptr = (char *) 0;
+ macroptr = NULL;
x_histp = histptr + 1;
x_last_command = XFUNC_error;
@@ -422,7 +422,7 @@ x_ins_string(c)
macroptr = x_atab[c>>8][c & CHARMASK];
if (macroptr && !*macroptr) {
/* XXX bell? */
- macroptr = (char *) 0;
+ macroptr = NULL;
}
return KSTD;
}
@@ -1053,7 +1053,7 @@ x_redraw(limit)
if (xbp == xbuf)
{
pprompt(prompt + prompt_skip, 0);
- x_col = promptlen(prompt, (const char **) 0);
+ x_col = promptlen(prompt, NULL);
}
x_displen = xx_cols - 2 - x_col;
xlp_valid = FALSE;
@@ -1736,7 +1736,7 @@ do_complete(flags, type)
int is_command;
int do_glob = 1;
Comp_type t = type;
- char *comp_word = (char *) 0;
+ char *comp_word = NULL;
if (type == CT_COMPLIST) {
do_glob = 0;
@@ -1868,7 +1868,7 @@ x_e_getc()
if (macroptr) {
c = *macroptr++;
if (!*macroptr)
- macroptr = (char *) 0;
+ macroptr = NULL;
} else
c = x_getc();
}
diff --git a/bin/ksh/eval.c b/bin/ksh/eval.c
index b8b339eccda..570905bf200 100644
--- a/bin/ksh/eval.c
+++ b/bin/ksh/eval.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eval.c,v 1.2 1996/08/19 20:08:49 downsj Exp $ */
+/* $OpenBSD: eval.c,v 1.3 1997/06/18 22:42:33 kstailey Exp $ */
/*
* Expansion - quoting, separation, substitution, globbing
@@ -201,7 +201,7 @@ expand(cp, wp, f)
doblank = 0;
make_magic = 0;
word = (f&DOBLANK) ? IFS_WS : IFS_WORD;
- st_head.next = (SubType *) 0;
+ st_head.next = NULL;
st = &st_head;
while (1) {
@@ -292,7 +292,7 @@ expand(cp, wp, f)
end = (char *) wdscan(sp, CSUBST);
endc = *end;
*end = EOS;
- str = snptreef((char *) 0, 64, "%S",
+ str = snptreef(NULL, 64, "%S",
varname - 1);
*end = endc;
errorf("%s: bad substitution", str);
@@ -306,7 +306,7 @@ expand(cp, wp, f)
newst = (SubType *) alloc(
sizeof(SubType), ATEMP);
- newst->next = (SubType *) 0;
+ newst->next = NULL;
newst->prev = st;
st->next = newst;
}
@@ -696,7 +696,7 @@ varsub(xp, sp, word, stypep)
if (sp[0] == '\0') /* Bad variable name */
return -1;
- xp->var = (struct tbl *) 0;
+ xp->var = NULL;
/* ${#var}, string length or array size */
if (sp[0] == '#' && (c = sp[1]) != '\0') {
@@ -845,7 +845,7 @@ comsub(xp, cp)
if ((io->flag&IOTYPE) != IOREAD)
errorf("funny $() command: %s",
- snptreef((char *) 0, 32, "%R", io));
+ snptreef(NULL, 32, "%R", io));
shf = shf_open(name = evalstr(io->name, DOTILDE), O_RDONLY, 0,
SHF_MAPHI|SHF_CLEXEC);
if (shf == NULL)
@@ -854,7 +854,7 @@ comsub(xp, cp)
} else {
int ofd1, pv[2];
openpipe(pv);
- shf = shf_fdopen(pv[0], SHF_RD, (struct shf *) 0);
+ shf = shf_fdopen(pv[0], SHF_RD, NULL);
ofd1 = savefd(1, 0); /* fd 1 may be closed... */
ksh_dup2(pv[1], 1, FALSE);
close(pv[1]);
@@ -1206,7 +1206,7 @@ maybe_expand_tilde(p, dsp, dpp, isassign)
p += 2;
}
*tp = '\0';
- r = (p[0] == EOS || p[0] == CHAR || p[0] == CSUBST) ? tilde(Xstring(ts, tp)) : (char *) 0;
+ r = (p[0] == EOS || p[0] == CHAR || p[0] == CSUBST) ? tilde(Xstring(ts, tp)) : NULL;
Xfree(ts, tp);
if (r) {
while (*r) {
@@ -1243,7 +1243,7 @@ tilde(cp)
dp = homedir(cp);
/* If HOME, PWD or OLDPWD are not set, don't expand ~ */
if (dp == null)
- dp = (char *) 0;
+ dp = NULL;
return dp;
}
@@ -1298,7 +1298,7 @@ alt_expand(wp, start, exp_start, end, fdo)
/* find matching close brace, if any */
if (p) {
- comma = (char *) 0;
+ comma = NULL;
count = 1;
for (p += 2; *p && count; p++) {
if (ISMAGIC(*p)) {
diff --git a/bin/ksh/exec.c b/bin/ksh/exec.c
index d84987cd41c..2ad8f09ceb4 100644
--- a/bin/ksh/exec.c
+++ b/bin/ksh/exec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec.c,v 1.7 1997/01/02 17:37:25 downsj Exp $ */
+/* $OpenBSD: exec.c,v 1.8 1997/06/18 22:42:34 kstailey Exp $ */
/*
* execute command tree
@@ -206,7 +206,7 @@ execute(t, flags)
e->type = E_ERRH;
i = ksh_sigsetjmp(e->jbuf, 0);
if (i) {
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
quitenv();
unwind(i);
/*NOTREACHED*/
@@ -227,7 +227,7 @@ execute(t, flags)
ksh_dup2(pv[0], 0, FALSE);
close(pv[0]);
coproc.write = pv[1];
- coproc.job = (void *) 0;
+ coproc.job = NULL;
if (coproc.readw >= 0)
ksh_dup2(coproc.readw, 1, FALSE);
@@ -241,7 +241,7 @@ execute(t, flags)
++coproc.id;
}
# ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
e->type = E_EXEC; /* no more need for error handler */
# endif /* JOB_SIGS */
@@ -602,7 +602,7 @@ comexec(t, tp, ap, flags)
}
break;
}
- if (include(tp->u.fpath, 0, (char **) 0, 0) < 0) {
+ if (include(tp->u.fpath, 0, NULL, 0) < 0) {
warningf(TRUE,
"%s: can't open function definition file %s - %s",
cp, tp->u.fpath, strerror(errno));
@@ -736,7 +736,7 @@ scriptexec(tp, ap)
shell = str_val(global(EXECSHELL_STR));
if (shell && *shell)
- shell = search(shell, path, X_OK, (int *) 0);
+ shell = search(shell, path, X_OK, NULL);
if (!shell || !*shell)
shell = EXECSHELL;
@@ -763,7 +763,7 @@ scriptexec(tp, ap)
while (*cp && (*cp == ' ' || *cp == '\t'))
cp++;
if (*cp && *cp != '\n') {
- char *a0 = cp, *a1 = (char *) 0;
+ char *a0 = cp, *a1 = NULL;
# ifdef OS2
char *a2 = cp;
# endif /* OS2 */
@@ -799,7 +799,8 @@ scriptexec(tp, ap)
if (a1)
*tp->args-- = a1;
# ifdef OS2
- if (a0 != a2 && search_access(a0, X_OK, (int *) 0))
+ if (a0 != a2 && search_access(a0, X_OK,
+ NULL))
a0 = a2;
# endif /* OS2 */
shell = a0;
@@ -815,7 +816,7 @@ scriptexec(tp, ap)
shell = str_val(global("EXECSHELL"));
if (shell && *shell)
- shell = search(shell, path, X_OK, (int *) 0);
+ shell = search(shell, path, X_OK, NULL);
if (!shell || !*shell) {
shell = p;
*tp->args-- = "/c";
@@ -858,7 +859,7 @@ findfunc(name, h, create)
int create;
{
struct block *l;
- struct tbl *tp = (struct tbl *) 0;
+ struct tbl *tp = NULL;
for (l = e->loc; l; l = l->next) {
tp = tsearch(&l->funs, name, h);
@@ -868,7 +869,7 @@ findfunc(name, h, create)
tp = tenter(&l->funs, name, h);
tp->flag = DEFINED;
tp->type = CFUNC;
- tp->val.t = (struct op *) 0;
+ tp->val.t = NULL;
break;
}
}
@@ -982,7 +983,7 @@ findcom(name, flags)
tp = findfunc(name, h, FALSE);
if (tp && !(tp->flag & ISSET)) {
if ((fpath = str_val(global("FPATH"))) == null) {
- tp->u.fpath = (char *) 0;
+ tp->u.fpath = NULL;
tp->u2.errno_ = 0;
} else
tp->u.fpath = search(name, fpath, R_OK,
@@ -1034,7 +1035,7 @@ findcom(name, flags)
} else if ((flags & FC_FUNC)
&& (fpath = str_val(global("FPATH"))) != null
&& (npath = search(name, fpath, R_OK,
- &tp->u2.errno_)) != (char *) 0)
+ &tp->u2.errno_)) != NULL)
{
/* An undocumented feature of at&t ksh is that it
* searches FPATH if a command is not found, even
@@ -1104,10 +1105,10 @@ search_access(path, mode, errnop)
* exec.c(search())).
*/
static char *xsuffixes[] = { ".ksh", ".exe", ".", ".sh", ".cmd",
- ".com", ".bat", (char *) 0
+ ".com", ".bat", NULL
};
static char *rsuffixes[] = { ".ksh", ".", ".sh", ".cmd", ".bat",
- (char *) 0
+ NULL
};
int i;
char *mpath = (char *) path;
@@ -1253,7 +1254,7 @@ call_builtin(tp, wp)
shf_flush(shl_stdout);
shl_stdout_ok = 0;
builtin_flag = 0;
- builtin_argv0 = (char *) 0;
+ builtin_argv0 = NULL;
return rv;
}
@@ -1277,13 +1278,13 @@ iosetup(iop, tp)
/* Used for tracing and error messages to print expanded cp */
iotmp = *iop;
- iotmp.name = (iotype == IOHERE) ? (char *) 0 : cp;
+ iotmp.name = (iotype == IOHERE) ? NULL : cp;
iotmp.flag |= IONAMEXP;
if (Flag(FXTRACE))
shellf("%s%s\n",
PS4_SUBSTITUTE(str_val(global("PS4"))),
- snptreef((char *) 0, 32, "%R", &iotmp));
+ snptreef(NULL, 32, "%R", &iotmp));
switch (iotype) {
case IOREAD:
@@ -1325,7 +1326,7 @@ iosetup(iop, tp)
&emsg)) < 0)
{
warningf(TRUE, "%s: %s",
- snptreef((char *) 0, 32, "%R", &iotmp), emsg);
+ snptreef(NULL, 32, "%R", &iotmp), emsg);
return -1;
}
break;
@@ -1366,7 +1367,7 @@ iosetup(iop, tp)
if (ksh_dup2(u, iop->unit, TRUE) < 0) {
warningf(TRUE,
"could not finish (dup) redirection %s: %s",
- snptreef((char *) 0, 32, "%R", &iotmp),
+ snptreef(NULL, 32, "%R", &iotmp),
strerror(errno));
if (iotype != IODUP)
close(u);
@@ -1403,7 +1404,7 @@ herein(hname, sub)
int fd;
/* ksh -c 'cat << EOF' can cause this... */
- if (hname == (char *) 0) {
+ if (hname == NULL) {
warningf(TRUE, "here document missing");
return -2; /* special to iosetup(): don't print error */
}
@@ -1434,7 +1435,7 @@ herein(hname, sub)
if (yylex(ONEWORD) != LWORD)
internal_errorf(1, "herein: yylex");
shf_close(shf);
- shf = (struct shf *) 0;
+ shf = NULL;
cp = evalstr(yylval.cp, 0);
/* write expanded input to another temp file */
@@ -1446,11 +1447,11 @@ herein(hname, sub)
shf_puts(cp, shf);
if (shf_close(shf) == EOF) {
close(fd);
- shf = (struct shf *) 0;
+ shf = NULL;
errorf("error writing %s: %s", h->name,
strerror(errno));
}
- shf = (struct shf *) 0;
+ shf = NULL;
quitenv();
} else {
@@ -1473,7 +1474,7 @@ do_selectargs(ap, print_menu)
bool_t print_menu;
{
static const char *const read_args[] = {
- "read", "-r", "REPLY", (char *) 0
+ "read", "-r", "REPLY", NULL
};
char *s;
int i, argct;
@@ -1490,7 +1491,7 @@ do_selectargs(ap, print_menu)
pr_menu(ap);
shellf("%s", str_val(global("PS3")));
if (call_builtin(findcom("read", FC_BI), (char **) read_args))
- return (char *) 0;
+ return (NULL);
s = str_val(global("REPLY"));
if (*s) {
i = atoi(s);
@@ -1629,7 +1630,7 @@ dbteste_getopnd(te, op, do_eval)
char *s = *te->pos.wp;
if (!s)
- return (char *) 0;
+ return (NULL);
te->pos.wp++;
diff --git a/bin/ksh/expr.c b/bin/ksh/expr.c
index 2d70ed1cd1d..6b9dc05b548 100644
--- a/bin/ksh/expr.c
+++ b/bin/ksh/expr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: expr.c,v 1.2 1996/08/19 20:08:50 downsj Exp $ */
+/* $OpenBSD: expr.c,v 1.3 1997/06/18 22:42:34 kstailey Exp $ */
/*
* Korn expression evaluation
@@ -177,7 +177,7 @@ v_evaluate(vp, expr, error_ok)
curstate.expression = curstate.tokp = expr;
curstate.noassign = 0;
curstate.prev = es;
- curstate.evaling = (struct tbl *) 0;
+ curstate.evaling = NULL;
es = &curstate;
newenv(E_ERRH);
@@ -207,7 +207,7 @@ v_evaluate(vp, expr, error_ok)
v = intvar(evalexpr(MAX_PREC));
if (es->tok != END)
- evalerr(ET_UNEXPECTED, (char *) 0);
+ evalerr(ET_UNEXPECTED, NULL);
if (vp->flag & INTEGER)
setint_v(vp, v);
@@ -314,7 +314,7 @@ evalexpr(prec)
vl = es->val;
token();
} else {
- evalerr(ET_UNEXPECTED, (char *) 0);
+ evalerr(ET_UNEXPECTED, NULL);
/*NOTREACHED*/
}
if (es->tok == O_PLUSPLUS || es->tok == O_MINUSMINUS) {
@@ -590,7 +590,7 @@ intvar(vp)
vp->flag |= EXPRINEVAL;
v_evaluate(vq, str_val(vp), FALSE);
vp->flag &= ~EXPRINEVAL;
- es->evaling = (struct tbl *) 0;
+ es->evaling = NULL;
}
return vq;
}
diff --git a/bin/ksh/history.c b/bin/ksh/history.c
index 9ed181165e1..cf5712d7437 100644
--- a/bin/ksh/history.c
+++ b/bin/ksh/history.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: history.c,v 1.5 1997/01/02 18:16:52 downsj Exp $ */
+/* $OpenBSD: history.c,v 1.6 1997/06/18 22:42:35 kstailey Exp $ */
/*
* command history
@@ -80,10 +80,10 @@ c_fc(wp)
{
struct shf *shf;
struct temp UNINITIALIZED(*tf);
- char *p, *editor = (char *) 0;
+ char *p, *editor = NULL;
int gflag = 0, lflag = 0, nflag = 0, sflag = 0, rflag = 0;
int optc;
- char *first = (char *) 0, *last = (char *) 0;
+ char *first = NULL, *last = NULL;
char **hfirst, **hlast, **hp;
while ((optc = ksh_getopt(wp, &builtin_opt, "e:glnrs0,1,2,3,4,5,6,7,8,9,")) != EOF)
@@ -133,7 +133,7 @@ c_fc(wp)
/* Substitute and execute command */
if (sflag) {
- char *pat = (char *) 0, *rep = (char *) 0;
+ char *pat = NULL, *rep = NULL;
if (editor || lflag || nflag || rflag) {
bi_errorf("can't use -e, -l, -n, -r with -s (-e -)");
@@ -301,7 +301,7 @@ hist_execute(cmd)
if ((q = strchr(p, '\n'))) {
*q++ = '\0'; /* kill the newline */
if (!*q) /* ignore trailing newline */
- q = (char *) 0;
+ q = NULL;
}
#ifdef EASY_HISTORY
if (p != cmd)
@@ -383,7 +383,7 @@ hist_get(str, approx, allow_cur)
int approx;
int allow_cur;
{
- char **hp = (char **) 0;
+ char **hp = NULL;
int n;
if (getn(str, &n)) {
@@ -393,18 +393,18 @@ hist_get(str, approx, allow_cur)
hp = hist_get_oldest();
else {
bi_errorf("%s: not in history", str);
- hp = (char **) 0;
+ hp = NULL;
}
} else if (hp > histptr) {
if (approx)
hp = hist_get_newest(allow_cur);
else {
bi_errorf("%s: not in history", str);
- hp = (char **) 0;
+ hp = NULL;
}
} else if (!allow_cur && hp == histptr) {
bi_errorf("%s: invalid range", str);
- hp = (char **) 0;
+ hp = NULL;
}
} else {
int anchored = *str == '?' ? (++str, 0) : 1;
@@ -413,7 +413,7 @@ hist_get(str, approx, allow_cur)
n = findhist(histptr - history - 1, 0, str, anchored);
if (n < 0) {
bi_errorf("%s: not in history", str);
- hp = (char **) 0;
+ hp = NULL;
} else
hp = &history[n];
}
@@ -427,7 +427,7 @@ hist_get_newest(allow_cur)
{
if (histptr < history || (!allow_cur && histptr == history)) {
bi_errorf("no history (yet)");
- return (char **) 0;
+ return (NULL);
}
if (allow_cur)
return histptr;
@@ -440,7 +440,7 @@ hist_get_oldest()
{
if (histptr <= history) {
bi_errorf("no history (yet)");
- return (char **) 0;
+ return (NULL);
}
return history;
}
@@ -594,7 +594,7 @@ sethistfile(name)
void
init_histvec()
{
- if (history == (char **)NULL) {
+ if (history == NULL) {
histsize = HISTORYSIZE;
history = (char **)alloc(histsize*sizeof (char *), APERM);
histptr = history - 1;
diff --git a/bin/ksh/io.c b/bin/ksh/io.c
index a5bfe1569a9..a1757df8875 100644
--- a/bin/ksh/io.c
+++ b/bin/ksh/io.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: io.c,v 1.2 1996/08/19 20:08:51 downsj Exp $ */
+/* $OpenBSD: io.c,v 1.3 1997/06/18 22:42:36 kstailey Exp $ */
/*
* shell buffered IO and formatted output
@@ -93,7 +93,7 @@ bi_errorf(fmt, va_alist)
if ((builtin_flag & SPEC_BI)
|| (Flag(FPOSIX) && (builtin_flag & KEEPASN)))
{
- builtin_argv0 = (char *) 0;
+ builtin_argv0 = NULL;
unwind(LERROR);
}
}
@@ -441,7 +441,7 @@ maketemp(ap)
len = strlen(tmp) + 3 + 20 + 20 + 1;
tp = (struct temp *) alloc(sizeof(struct temp) + len, ap);
tp->name = path = (char *) &tp[1];
- tp->shf = (struct shf *) 0;
+ tp->shf = NULL;
while (1) {
/* Note that temp files need to fit 8.3 DOS limits */
shf_snprintf(path, len, "%s/sh%05u.%03x",
@@ -451,7 +451,7 @@ maketemp(ap)
*/
fd = open(path, O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0600);
if (fd >= 0) {
- tp->shf = shf_fdopen(fd, SHF_WR, (struct shf *) 0);
+ tp->shf = shf_fdopen(fd, SHF_WR, NULL);
break;
}
if (errno != EINTR
diff --git a/bin/ksh/jobs.c b/bin/ksh/jobs.c
index 2b7369df085..b5073966ec3 100644
--- a/bin/ksh/jobs.c
+++ b/bin/ksh/jobs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: jobs.c,v 1.4 1996/11/21 07:59:29 downsj Exp $ */
+/* $OpenBSD: jobs.c,v 1.5 1997/06/18 22:42:37 kstailey Exp $ */
/*
* Process and job control
@@ -165,7 +165,7 @@ static const char *const lookup_msgs[] = {
"no such job",
"ambiguous",
"argument must be %job or process id",
- (char *) 0
+ NULL
};
clock_t j_systime, j_usrtime; /* user and system time of last j_waitjed job */
@@ -231,7 +231,7 @@ j_init(mflagset)
#ifdef JOB_SIGS
sigemptyset(&sm_default);
- sigprocmask(SIG_SETMASK, &sm_default, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &sm_default, NULL);
sigemptyset(&sm_sigchld);
sigaddset(&sm_sigchld, SIGCHLD);
@@ -250,7 +250,7 @@ j_init(mflagset)
/* shl_j is used to do asynchronous notification (used in
* an interrupt handler, so need a distinct shf)
*/
- shl_j = shf_fdopen(2, SHF_WR, (struct shf *) 0);
+ shl_j = shf_fdopen(2, SHF_WR, NULL);
# ifdef TTY_PGRP
if (Flag(FMONITOR) || Flag(FTALKING)) {
@@ -285,7 +285,7 @@ j_exit()
Job *j;
int killed = 0;
- for (j = job_list; j != (Job *) 0; j = j->next) {
+ for (j = job_list; j != NULL; j = j->next) {
if (j->ppid == procpid
&& (j->state == PSTOPPED
|| (j->state == PRUNNING
@@ -452,7 +452,7 @@ exchild(t, flags, close_fd)
#endif /* JOB_SIGS */
p = new_proc();
- p->next = (Proc *) 0;
+ p->next = NULL;
p->state = PRUNNING;
WSTATUS(p->status) = 0;
p->pid = 0;
@@ -514,7 +514,7 @@ exchild(t, flags, close_fd)
}
#endif /* NEED_PGRP_SYNC */
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
errorf("cannot fork - try again");
}
@@ -593,7 +593,7 @@ exchild(t, flags, close_fd)
coproc_cleanup(FALSE);
#endif /* KSH */
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
cleanup_parents_env();
#ifdef TTY_PGRP
@@ -667,7 +667,7 @@ exchild(t, flags, close_fd)
}
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
return rv;
@@ -689,7 +689,7 @@ startlast()
j_startjob(last_job);
}
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
}
@@ -712,7 +712,7 @@ waitlast()
else
internal_errorf(0, "waitlast: not started");
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
return 125; /* not so arbitrary, non-zero value */
}
@@ -720,7 +720,7 @@ waitlast()
rv = j_waitj(j, JW_NONE, "jw:waitlast");
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
return rv;
@@ -744,7 +744,7 @@ waitfor(cp, sigp)
*sigp = 0;
- if (cp == (char *) 0) {
+ if (cp == NULL) {
/* wait for an unspecified job - always returns 0, so
* don't have to worry about exited/signaled jobs
*/
@@ -754,7 +754,7 @@ waitfor(cp, sigp)
break;
if (!j) {
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
return -1;
}
@@ -763,13 +763,13 @@ waitfor(cp, sigp)
flags &= ~JW_ASYNCNOTIFY;
if (j->ppid != procpid) {
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
return -1;
}
} else {
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
if (ecode == JL_NOSUCH)
return -1;
@@ -780,7 +780,7 @@ waitfor(cp, sigp)
rv = j_waitj(j, flags, "jw:waitfor");
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
if (rv < 0) /* we were interrupted */
@@ -805,16 +805,16 @@ j_kill(cp, sig)
sigprocmask(SIG_BLOCK, &sm_sigchld, &omask);
#endif /* JOB_SIGS */
- if ((j = j_lookup(cp, &ecode)) == (Job *) 0) {
+ if ((j = j_lookup(cp, &ecode)) == NULL) {
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
bi_errorf("%s: %s", cp, lookup_msgs[ecode]);
return 1;
}
if (j->pgrp == 0) { /* started when !Flag(FMONITOR) */
- for (p=j->proc_list; p != (Proc *) 0; p = p->next)
+ for (p=j->proc_list; p != NULL; p = p->next)
if (kill(p->pid, sig) < 0) {
bi_errorf("%s: %s", cp, strerror(errno));
rv = 1;
@@ -831,7 +831,7 @@ j_kill(cp, sig)
}
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
return rv;
@@ -853,14 +853,14 @@ j_resume(cp, bg)
sigprocmask(SIG_BLOCK, &sm_sigchld, &omask);
- if ((j = j_lookup(cp, &ecode)) == (Job *) 0) {
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ if ((j = j_lookup(cp, &ecode)) == NULL) {
+ sigprocmask(SIG_SETMASK, &omask, NULL);
bi_errorf("%s: %s", cp, lookup_msgs[ecode]);
return 1;
}
if (j->pgrp == 0) {
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
bi_errorf("job not job-controlled");
return 1;
}
@@ -869,7 +869,7 @@ j_resume(cp, bg)
shprintf("[%d] ", j->job);
running = 0;
- for (p = j->proc_list; p != (Proc *) 0; p = p->next) {
+ for (p = j->proc_list; p != NULL; p = p->next) {
if (p->state == PSTOPPED) {
p->state = PRUNNING;
WSTATUS(p->status) = 0;
@@ -895,8 +895,7 @@ j_resume(cp, bg)
if (ttypgrp_ok && tcsetpgrp(tty_fd, j->pgrp) < 0) {
if (j->flags & JF_SAVEDTTY)
set_tty(tty_fd, &tty_state, TF_NONE);
- sigprocmask(SIG_SETMASK, &omask,
- (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
bi_errorf("1st tcsetpgrp(%d, %d) failed: %s",
tty_fd, (int) j->pgrp, strerror(errno));
return 1;
@@ -906,7 +905,7 @@ j_resume(cp, bg)
j->flags |= JF_FG;
j->flags &= ~JF_KNOWN;
if (j == async_job)
- async_job = (Job *) 0;
+ async_job = NULL;
}
if (j->state == PRUNNING && killpg(j->pgrp, SIGCONT) < 0) {
@@ -925,7 +924,7 @@ j_resume(cp, bg)
}
# endif /* TTY_PGRP */
}
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
bi_errorf("cannot continue job %s: %s",
cp, strerror(err));
return 1;
@@ -938,7 +937,7 @@ j_resume(cp, bg)
# endif /* TTY_PGRP */
rv = j_waitj(j, JW_NONE, "jw:resume");
}
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
return rv;
}
#endif /* JOBS */
@@ -950,7 +949,7 @@ j_stopped_running()
Job *j;
int which = 0;
- for (j = job_list; j != (Job *) 0; j = j->next) {
+ for (j = job_list; j != NULL; j = j->next) {
#ifdef JOBS
if (j->ppid == procpid && j->state == PSTOPPED)
which |= 1;
@@ -993,9 +992,9 @@ j_jobs(cp, slp, nflag)
if (cp) {
int ecode;
- if ((j = j_lookup(cp, &ecode)) == (Job *) 0) {
+ if ((j = j_lookup(cp, &ecode)) == NULL) {
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
bi_errorf("%s: %s", cp, lookup_msgs[ecode]);
return 1;
@@ -1021,7 +1020,7 @@ j_jobs(cp, slp, nflag)
remove_job(j, "jobs");
}
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
return 0;
}
@@ -1054,7 +1053,7 @@ j_notify()
}
shf_flush(shl_out);
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
}
@@ -1072,7 +1071,7 @@ j_async()
async_job->flags |= JF_KNOWN;
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
return async_pid;
@@ -1097,7 +1096,7 @@ j_set_async(j)
async_job = j;
async_pid = j->last_proc->pid;
while (nzombie > child_max) {
- oldest = (Job *) 0;
+ oldest = NULL;
for (jl = job_list; jl; jl = jl->next)
if (jl != async_job && (jl->flags & JF_ZOMBIE)
&& (!oldest || jl->age < oldest->age))
@@ -1311,12 +1310,12 @@ j_sigchld(sig)
ksh_times(&t1);
/* find job and process structures for this pid */
- for (j = job_list; j != (Job *) 0; j = j->next)
- for (p = j->proc_list; p != (Proc *) 0; p = p->next)
+ for (j = job_list; j != NULL; j = j->next)
+ for (p = j->proc_list; p != NULL; p = p->next)
if (p->pid == pid)
goto found;
found:
- if (j == (Job *) 0) {
+ if (j == NULL) {
/* Can occur if process has kids, then execs shell
warningf(TRUE, "bad process waited for (pid = %d)",
pid);
@@ -1375,7 +1374,7 @@ check_job(j)
}
jstate = PRUNNING;
- for (p=j->proc_list; p != (Proc *) 0; p = p->next) {
+ for (p=j->proc_list; p != NULL; p = p->next) {
if (p->state == PRUNNING)
return; /* some processes still running */
if (p->state > jstate)
@@ -1405,7 +1404,7 @@ check_job(j)
* (at leasst, this is what ksh93d thinks)
*/
if (coproc.job == j) {
- coproc.job = (void *) 0;
+ coproc.job = NULL;
/* XXX would be nice to get the closes out of here
* so they aren't done in the signal handler.
* Would mean a check in coproc_getfd() to
@@ -1500,7 +1499,7 @@ j_print(j, how, shf)
else if (j == job_list->next)
jobchar = '-';
- for (p = j->proc_list; p != (Proc *) 0;) {
+ for (p = j->proc_list; p != NULL;) {
coredumped = 0;
switch (p->state) {
case PRUNNING:
@@ -1590,54 +1589,54 @@ j_lookup(cp, ecodep)
if (digit(*cp)) {
job = atoi(cp);
/* Look for last_proc->pid (what $! returns) first... */
- for (j = job_list; j != (Job *) 0; j = j->next)
+ for (j = job_list; j != NULL; j = j->next)
if (j->last_proc && j->last_proc->pid == job)
return j;
/* ...then look for process group (this is non-POSIX),
* but should not break anything (so FPOSIX isn't used).
*/
- for (j = job_list; j != (Job *) 0; j = j->next)
+ for (j = job_list; j != NULL; j = j->next)
if (j->pgrp && j->pgrp == job)
return j;
if (ecodep)
*ecodep = JL_NOSUCH;
- return (Job *) 0;
+ return NULL;
}
if (*cp != '%') {
if (ecodep)
*ecodep = JL_INVALID;
- return (Job *) 0;
+ return NULL;
}
switch (*++cp) {
case '\0': /* non-standard */
case '+':
case '%':
- if (job_list != (Job *) 0)
+ if (job_list != NULL)
return job_list;
break;
case '-':
- if (job_list != (Job *) 0 && job_list->next)
+ if (job_list != NULL && job_list->next)
return job_list->next;
break;
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
job = atoi(cp);
- for (j = job_list; j != (Job *) 0; j = j->next)
+ for (j = job_list; j != NULL; j = j->next)
if (j->job == job)
return j;
break;
case '?': /* %?string */
- last_match = (Job *) 0;
- for (j = job_list; j != (Job *) 0; j = j->next)
- for (p = j->proc_list; p != (Proc *) 0; p = p->next)
- if (strstr(p->command, cp+1) != (char *) 0) {
+ last_match = NULL;
+ for (j = job_list; j != NULL; j = j->next)
+ for (p = j->proc_list; p != NULL; p = p->next)
+ if (strstr(p->command, cp+1) != NULL) {
if (last_match) {
if (ecodep)
*ecodep = JL_AMBIG;
- return (Job *) 0;
+ return NULL;
}
last_match = j;
}
@@ -1647,13 +1646,13 @@ j_lookup(cp, ecodep)
default: /* %string */
len = strlen(cp);
- last_match = (Job *) 0;
- for (j = job_list; j != (Job *) 0; j = j->next)
+ last_match = NULL;
+ for (j = job_list; j != NULL; j = j->next)
if (strncmp(cp, j->proc_list->command, len) == 0) {
if (last_match) {
if (ecodep)
*ecodep = JL_AMBIG;
- return (Job *) 0;
+ return NULL;
}
last_match = j;
}
@@ -1663,7 +1662,7 @@ j_lookup(cp, ecodep)
}
if (ecodep)
*ecodep = JL_NOSUCH;
- return (Job *) 0;
+ return NULL;
}
static Job *free_jobs;
@@ -1679,7 +1678,7 @@ new_job()
int i;
Job *newj, *j;
- if (free_jobs != (Job *) 0) {
+ if (free_jobs != NULL) {
newj = free_jobs;
free_jobs = free_jobs->next;
} else
@@ -1689,7 +1688,7 @@ new_job()
for (i = 1; ; i++) {
for (j = job_list; j && j->job != i; j = j->next)
;
- if (j == (Job *) 0)
+ if (j == NULL)
break;
}
newj->job = i;
@@ -1706,7 +1705,7 @@ new_proc()
{
Proc *p;
- if (free_procs != (Proc *) 0) {
+ if (free_procs != NULL) {
p = free_procs;
free_procs = free_procs->next;
} else
@@ -1730,7 +1729,7 @@ remove_job(j, where)
prev = &job_list;
curr = *prev;
- for (; curr != (Job *) 0 && curr != j; prev = &curr->next, curr = *prev)
+ for (; curr != NULL && curr != j; prev = &curr->next, curr = *prev)
;
if (curr != j) {
internal_errorf(0, "remove_job: job not found (%s)", where);
@@ -1739,7 +1738,7 @@ remove_job(j, where)
*prev = curr->next;
/* free up proc structures */
- for (p = j->proc_list; p != (Proc *) 0; ) {
+ for (p = j->proc_list; p != NULL; ) {
tmp = p;
p = p->next;
tmp->next = free_procs;
@@ -1752,9 +1751,9 @@ remove_job(j, where)
free_jobs = j;
if (j == last_job)
- last_job = (Job *) 0;
+ last_job = NULL;
if (j == async_job)
- async_job = (Job *) 0;
+ async_job = NULL;
}
/* put j in a particular location (taking it out job_list if it is there
@@ -1805,7 +1804,7 @@ kill_job(j)
{
Proc *p;
- for (p = j->proc_list; p != (Proc *) 0; p = p->next)
+ for (p = j->proc_list; p != NULL; p = p->next)
if (p->pid != 0)
(void) kill(p->pid, SIGKILL);
}
@@ -1826,7 +1825,7 @@ fill_command(c, len, t)
else
ap = t->args;
--len; /* save room for the null */
- while (len > 0 && *ap != (char *) 0) {
+ while (len > 0 && *ap != NULL) {
alen = strlen(*ap);
if (alen > len)
alen = len;
diff --git a/bin/ksh/ksh_wait.h b/bin/ksh/ksh_wait.h
index 16fad066768..b5c15a77699 100644
--- a/bin/ksh/ksh_wait.h
+++ b/bin/ksh/ksh_wait.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ksh_wait.h,v 1.1 1996/08/14 06:19:11 downsj Exp $ */
+/* $OpenBSD: ksh_wait.h,v 1.2 1997/06/18 22:42:37 kstailey Exp $ */
/* Wrapper around the ugly sys/wait includes/ifdefs */
@@ -45,7 +45,7 @@ typedef int WAIT_T;
#if !defined(HAVE_WAITPID) && defined(HAVE_WAIT3)
/* always used with p == -1 */
-# define ksh_waitpid(p, s, o) wait3((s), (o), (struct rusage *) 0)
+# define ksh_waitpid(p, s, o) wait3((s), (o), NULL)
#else /* !HAVE_WAITPID && HAVE_WAIT3 */
# define ksh_waitpid(p, s, o) waitpid((p), (s), (o))
#endif /* !HAVE_WAITPID && HAVE_WAIT3 */
diff --git a/bin/ksh/lex.c b/bin/ksh/lex.c
index 3b8a3dd63ee..b342f73709f 100644
--- a/bin/ksh/lex.c
+++ b/bin/ksh/lex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lex.c,v 1.5 1996/11/21 07:59:32 downsj Exp $ */
+/* $OpenBSD: lex.c,v 1.6 1997/06/18 22:42:38 kstailey Exp $ */
/*
* lexical analysis and source input
@@ -574,8 +574,8 @@ Done:
ungetsc(c2);
}
- iop->name = (char *) 0;
- iop->delim = (char *) 0;
+ iop->name = NULL;
+ iop->delim = NULL;
yylval.iop = iop;
return REDIR;
}
@@ -1011,7 +1011,7 @@ getsc_line(s)
#endif /* HISTORY */
}
if (interactive)
- set_prompt(PS2, (Source *) 0);
+ set_prompt(PS2, NULL);
}
void
@@ -1035,8 +1035,8 @@ set_prompt(to, s)
Area *saved_atemp;
ps1 = str_val(global("PS1"));
- shf = shf_sopen((char *) 0, strlen(ps1) * 2,
- SHF_WR | SHF_DYNAMIC, (struct shf *) 0);
+ shf = shf_sopen(NULL, strlen(ps1) * 2,
+ SHF_WR | SHF_DYNAMIC, NULL);
while (*ps1) {
if (*ps1 != '!' || *++ps1 == '!')
shf_putchar(*ps1++, shf);
diff --git a/bin/ksh/mail.c b/bin/ksh/mail.c
index 04033a4f2d3..46e79cd0702 100644
--- a/bin/ksh/mail.c
+++ b/bin/ksh/mail.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mail.c,v 1.3 1997/01/02 17:37:27 downsj Exp $ */
+/* $OpenBSD: mail.c,v 1.4 1997/06/18 22:42:39 kstailey Exp $ */
/*
* Mailbox checking code by Robert J. Gibson, adapted for PD ksh by
@@ -47,7 +47,7 @@ mcheck()
if (getint(global("MAILCHECK"), &mailcheck) < 0)
return;
- now = time((time_t *) 0);
+ now = time(NULL);
if (mlastchkd == 0)
mlastchkd = now;
if (now - mlastchkd >= mailcheck) {
diff --git a/bin/ksh/main.c b/bin/ksh/main.c
index a6bd9369df2..290aa50c83d 100644
--- a/bin/ksh/main.c
+++ b/bin/ksh/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.5 1997/01/02 09:34:03 downsj Exp $ */
+/* $OpenBSD: main.c,v 1.6 1997/06/18 22:42:40 kstailey Exp $ */
/*
* startup, main loop, enviroments and error handling
@@ -109,7 +109,7 @@ main(argc, argv)
/* make sure argv[] is sane */
if (!*argv) {
static const char *empty_argv[] = {
- "pdksh", (char *) 0
+ "pdksh", NULL
};
argv = (char **) empty_argv;
@@ -159,7 +159,7 @@ main(argc, argv)
def_path = DEFAULT__PATH;
#if defined(HAVE_CONFSTR) && defined(_CS_PATH)
{
- size_t len = confstr(_CS_PATH, (char *) 0, 0);
+ size_t len = confstr(_CS_PATH, NULL, 0);
char *new;
if (len > 0) {
@@ -225,7 +225,7 @@ main(argc, argv)
|| stat(pwd, &s_pwd) < 0 || stat(".", &s_dot) < 0
|| s_pwd.st_dev != s_dot.st_dev
|| s_pwd.st_ino != s_dot.st_ino)
- pwdx = (char *) 0;
+ pwdx = NULL;
set_current_wd(pwdx);
if (current_wd[0])
simplify_path(current_wd);
@@ -237,7 +237,7 @@ main(argc, argv)
}
setint(global("PPID"), (long) getppid());
#ifdef KSH
- setint(global("RANDOM"), (long) time((time_t *)0));
+ setint(global("RANDOM"), (long) time(NULL));
#endif /* KSH */
setstr(global(version_param), ksh_version);
@@ -265,7 +265,7 @@ main(argc, argv)
/* this to note if monitor is set on command line (see below) */
Flag(FMONITOR) = 127;
- argi = parse_args(argv, OF_CMDLINE, (int *) 0);
+ argi = parse_args(argv, OF_CMDLINE, NULL);
if (argi < 0)
exit(1);
@@ -283,7 +283,7 @@ main(argc, argv)
* This changes the behavior of 'ksh arg' to search
* the users search path but it can't be helped.
*/
- s->file = search(argv[argi++], path, R_OK, (int *) 0);
+ s->file = search(argv[argi++], path, R_OK, NULL);
if (!s->file || !*s->file)
s->file = argv[argi - 1];
#else
@@ -299,14 +299,13 @@ main(argc, argv)
Flag(FSTDIN) = 1;
s = pushs(SSTDIN, ATEMP);
s->file = "<stdin>";
- s->u.shf = shf_fdopen(0, SHF_RD | can_seek(0),
- (struct shf *) 0);
+ s->u.shf = shf_fdopen(0, SHF_RD | can_seek(0), NULL);
if (isatty(0) && isatty(2)) {
Flag(FTALKING) = 1;
/* The following only if isatty(0) */
s->flags |= SF_TTY;
s->u.shf->flags |= SHF_INTERRUPT;
- s->file = (char *) 0;
+ s->file = NULL;
}
}
@@ -354,22 +353,20 @@ main(argc, argv)
if (!Flag(FPRIVILEGED)
&& strcmp(profile = substitute("$INIT/profile.ksh", 0),
"/profile.ksh"))
- include(profile, 0, (char **) 0, 1);
- else if (include("/etc/profile.ksh", 0, (char **) 0, 1) < 0)
- include("c:/usr/etc/profile.ksh", 0, (char **) 0, 1);
+ include(profile, 0, NULL, 1);
+ else if (include("/etc/profile.ksh", 0, NULL, 1) < 0)
+ include("c:/usr/etc/profile.ksh", 0, NULL, 1);
if (!Flag(FPRIVILEGED))
- include(substitute("$HOME/profile.ksh", 0), 0,
- (char **) 0, 1);
+ include(substitute("$HOME/profile.ksh", 0), 0, NULL, 1);
#else /* OS2 */
- include(KSH_SYSTEM_PROFILE, 0, (char **) 0, 1);
+ include(KSH_SYSTEM_PROFILE, 0, NULL, 1);
if (!Flag(FPRIVILEGED))
- include(substitute("$HOME/.profile", 0), 0,
- (char **) 0, 1);
+ include(substitute("$HOME/.profile", 0), 0, NULL, 1);
#endif /* OS2 */
}
if (Flag(FPRIVILEGED))
- include("/etc/suid_profile", 0, (char **) 0, 1);
+ include("/etc/suid_profile", 0, NULL, 1);
else {
char *env_file;
@@ -388,11 +385,10 @@ main(argc, argv)
#endif /* DEFAULT_ENV */
env_file = substitute(env_file, DOTILDE);
if (*env_file != '\0')
- include(env_file, 0, (char **) 0, 1);
+ include(env_file, 0, NULL, 1);
#ifdef OS2
else if (Flag(FTALKING))
- include(substitute("$HOME/kshrc.ksh", 0), 0,
- (char **) 0, 1);
+ include(substitute("$HOME/kshrc.ksh", 0), 0, NULL, 1);
#endif /* OS2 */
}
@@ -401,8 +397,7 @@ main(argc, argv)
if (restricted) {
static const char *const restr_com[] = {
"typeset", "-r", "PATH",
- "ENV", "SHELL",
- (char *) 0
+ "ENV", "SHELL", NULL
};
shcomexec((char **) restr_com);
/* After typeset command... */
@@ -443,7 +438,7 @@ include(name, argc, argv, intr_ok)
old_argv = e->loc->argv;
old_argc = e->loc->argc;
} else {
- old_argv = (char **) 0;
+ old_argv = NULL;
old_argc = 0;
}
sold = source;
@@ -729,7 +724,7 @@ cleanup_parents_env()
if (ep->savefd[fd] > 0)
close(ep->savefd[fd]);
}
- e->oenv = (struct env *) 0;
+ e->oenv = NULL;
}
/* Called just before an execve cleanup stuff temporary files */
diff --git a/bin/ksh/misc.c b/bin/ksh/misc.c
index 0d5fe74eb7b..634d8488ac2 100644
--- a/bin/ksh/misc.c
+++ b/bin/ksh/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.4 1997/01/02 09:34:07 downsj Exp $ */
+/* $OpenBSD: misc.c,v 1.5 1997/06/18 22:42:40 kstailey Exp $ */
/*
* Miscellaneous functions
@@ -378,7 +378,7 @@ parse_args(argv, what, setargsp)
break;
case 'o':
- if (go.optarg == (char *) 0) {
+ if (go.optarg == NULL) {
/* lone -o: print options
*
* Note that on the command line, -o requires
@@ -453,7 +453,7 @@ parse_args(argv, what, setargsp)
return -1;
}
} else
- array = (char *) 0; /* keep gcc happy */
+ array = NULL; /* keep gcc happy */
if (sortargs) {
for (i = go.optind; argv[i]; i++)
;
@@ -803,7 +803,7 @@ pat_scan(p, pe, match_sep)
if ((*p & 0x80) && strchr("*+?@!", *p & 0x7f))
nest++;
}
- return (const unsigned char *) 0;
+ return NULL;
}
@@ -915,7 +915,7 @@ ksh_getopt_reset(go, flags)
int flags;
{
go->optind = 1;
- go->optarg = (char *) 0;
+ go->optarg = NULL;
go->p = 0;
go->flags = flags;
go->info = 0;
@@ -967,7 +967,7 @@ ksh_getopt(argv, go, options)
go->info |= GI_MINUSMINUS;
return EOF;
}
- if (arg == (char *) 0
+ if (arg == NULL
|| ((flag != '-' || (go->info & GI_PLUS))
&& (!(go->flags & GF_PLUSOPT) || (go->info & GI_MINUS)
|| flag != '+'))
@@ -1006,7 +1006,7 @@ ksh_getopt(argv, go, options)
else if (argv[go->optind])
go->optarg = argv[go->optind++];
else if (*o == ';')
- go->optarg = (char *) 0;
+ go->optarg = NULL;
else {
if (options[0] == ':') {
go->buf[0] = c;
@@ -1035,13 +1035,13 @@ ksh_getopt(argv, go, options)
go->optarg = argv[go->optind - 1] + go->p;
go->p = 0;
} else
- go->optarg = (char *) 0;;
+ go->optarg = NULL;
} else {
if (argv[go->optind] && digit(argv[go->optind][0])) {
go->optarg = argv[go->optind++];
go->p = 0;
} else
- go->optarg = (char *) 0;;
+ go->optarg = NULL;
}
}
return c;
@@ -1277,7 +1277,7 @@ ksh_get_wd(buf, bsize)
errno = EACCES;
if (b != buf)
afree(b, ATEMP);
- return (char *) 0;
+ return NULL;
}
len = strlen(b) + 1;
if (!buf)
@@ -1285,7 +1285,7 @@ ksh_get_wd(buf, bsize)
else if (buf != b) {
if (len > bsize) {
errno = ERANGE;
- return (char *) 0;
+ return NULL;
}
memcpy(buf, b, len);
afree(b, ATEMP);
diff --git a/bin/ksh/missing.c b/bin/ksh/missing.c
index 455403c0de1..5533d5b9a66 100644
--- a/bin/ksh/missing.c
+++ b/bin/ksh/missing.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: missing.c,v 1.1 1996/08/14 06:19:11 downsj Exp $ */
+/* $OpenBSD: missing.c,v 1.2 1997/06/18 22:42:41 kstailey Exp $ */
/*
* Routines which may be missing on some machines
@@ -224,7 +224,7 @@ ksh_times(tms)
tms->tms_cstime = ru.ru_stime.tv_sec * CLK_TCK
+ ru.ru_stime.tv_usec * CLK_TCK / 1000000;
- gettimeofday(&tv, (struct timezone *) 0);
+ gettimeofday(&tv, NULL);
if (base_sec == 0)
base_sec = tv.tv_sec;
rv = (tv.tv_sec - base_sec) * CLK_TCK;
@@ -261,10 +261,10 @@ ksh_opendir(d)
struct stat statb;
if (stat(d, &statb) != 0)
- return (DIR *) 0;
+ return NULL;
if (!S_ISDIR(statb.st_mode)) {
errno = ENOTDIR;
- return (DIR *) 0;
+ return NULL;
}
return opendir(d);
}
diff --git a/bin/ksh/path.c b/bin/ksh/path.c
index 5242ab42cb4..4476964258a 100644
--- a/bin/ksh/path.c
+++ b/bin/ksh/path.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: path.c,v 1.1 1996/08/14 06:19:11 downsj Exp $ */
+/* $OpenBSD: path.c,v 1.2 1997/06/18 22:42:42 kstailey Exp $ */
#include "sh.h"
#include "ksh_stat.h"
@@ -14,8 +14,11 @@
/*
* $Log: path.c,v $
- * Revision 1.1 1996/08/14 06:19:11 downsj
- * Initial revision
+ * Revision 1.2 1997/06/18 22:42:42 kstailey
+ * (foo *)0 -> NULL
+ *
+ * Revision 1.1.1.1 1996/08/14 06:19:11 downsj
+ * Import pdksh 5.2.7.
*
* Revision 1.2 1994/05/19 18:32:40 michael
* Merge complete, stdio replaced, various fixes. (pre autoconf)
@@ -108,7 +111,7 @@ make_path(cwd, file, cdpathp, xsp, phys_pathp)
for (pend = plist; *pend && *pend != PATHSEP; pend++)
;
plen = pend - plist;
- *cdpathp = *pend ? ++pend : (char *) 0;
+ *cdpathp = *pend ? ++pend : NULL;
}
if ((use_cdpath == 0 || !plen || ISRELPATH(plist))
@@ -137,7 +140,7 @@ make_path(cwd, file, cdpathp, xsp, phys_pathp)
memcpy(xp, file, len);
if (!use_cdpath)
- *cdpathp = (char *) 0;
+ *cdpathp = NULL;
return rval;
}
@@ -230,7 +233,7 @@ set_current_wd(path)
int len;
char *p = path;
- if (!p && !(p = ksh_get_wd((char *) 0, 0)))
+ if (!p && !(p = ksh_get_wd(NULL, 0)))
p = null;
len = strlen(p) + 1;
@@ -255,7 +258,7 @@ get_phys_path(path)
xp = do_phys_path(&xs, xp, path);
if (!xp)
- return (char *) 0;
+ return NULL;
if (Xlength(xs, xp) == 0)
Xput(xs, xp, DIRSEP);
@@ -304,7 +307,7 @@ do_phys_path(xsp, xp, path)
if (llen < 0) {
/* EINVAL means it wasn't a symlink... */
if (errno != EINVAL)
- return (char *) 0;
+ return NULL;
continue;
}
lbuf[llen] = '\0';
@@ -313,7 +316,7 @@ do_phys_path(xsp, xp, path)
xp = ISABSPATH(lbuf) ? Xstring(*xsp, xp)
: Xrestpos(*xsp, xp, savepos);
if (!(xp = do_phys_path(xsp, xp, lbuf)))
- return (char *) 0;
+ return NULL;
}
return xp;
}
diff --git a/bin/ksh/shf.c b/bin/ksh/shf.c
index 820139c1b33..4c324158aba 100644
--- a/bin/ksh/shf.c
+++ b/bin/ksh/shf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: shf.c,v 1.1 1996/08/14 06:19:11 downsj Exp $ */
+/* $OpenBSD: shf.c,v 1.2 1997/06/18 22:42:43 kstailey Exp $ */
/*
* Shell file I/O routines
@@ -52,7 +52,7 @@ shf_open(name, oflags, mode, sflags)
: ((oflags & O_ACCMODE) == O_WRONLY ? SHF_WR
: SHF_RDWR);
- return shf_fdopen(fd, sflags, (struct shf *) 0);
+ return shf_fdopen(fd, sflags, NULL);
}
/* Set up the shf structure for a file descriptor. Doesn't fail. */
@@ -87,7 +87,7 @@ shf_fdopen(fd, sflags, shf)
shf->buf = (unsigned char *) alloc(bsize, ATEMP);
sflags |= SHF_ALLOCB;
} else
- shf->buf = (unsigned char *) 0;
+ shf->buf = NULL;
} else {
shf = (struct shf *) alloc(sizeof(struct shf) + bsize, ATEMP);
shf->buf = (unsigned char *) &shf[1];
@@ -536,7 +536,7 @@ shf_getse(buf, bsize, shf)
internal_errorf(1, "shf_getse: flags %x", shf->flags);
if (bsize <= 0)
- return (char *) 0;
+ return NULL;
--bsize; /* save room for null */
do {
@@ -793,7 +793,7 @@ shf_smprintf(fmt, va_alist)
struct shf shf;
va_list args;
- shf_sopen((char *) 0, 0, SHF_WR|SHF_DYNAMIC, &shf);
+ shf_sopen(NULL, 0, SHF_WR|SHF_DYNAMIC, &shf);
SH_VA_START(args, fmt);
shf_vfprintf(&shf, fmt, args);
va_end(args);
diff --git a/bin/ksh/siglist.sh b/bin/ksh/siglist.sh
index 135e920d637..06cd14bbdb2 100644
--- a/bin/ksh/siglist.sh
+++ b/bin/ksh/siglist.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# $OpenBSD: siglist.sh,v 1.2 1996/10/01 02:05:48 downsj Exp $
+# $OpenBSD: siglist.sh,v 1.3 1997/06/18 22:42:44 kstailey Exp $
#
# Script to generate a sorted, complete list of signals, suitable
@@ -32,7 +32,7 @@ sed -n 's/{ QwErTy/{/p' < $out | awk '{print NR, $0}' | sort +2n +0n |
n = $2;
if (n > 0 && n != last) {
while (++last < n) {
- printf "\t{ %d , (char *) 0, `Signal %d` } ,\n", last, last;
+ printf "\t{ %d , NULL, `Signal %d` } ,\n", last, last;
}
print;
}
diff --git a/bin/ksh/syn.c b/bin/ksh/syn.c
index 53b85a20b74..22125924490 100644
--- a/bin/ksh/syn.c
+++ b/bin/ksh/syn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syn.c,v 1.5 1996/11/21 07:59:35 downsj Exp $ */
+/* $OpenBSD: syn.c,v 1.6 1997/06/18 22:42:45 kstailey Exp $ */
/*
* shell parser (C version)
@@ -73,7 +73,7 @@ yyparse()
if (c == 0 && !outtree)
outtree = newtp(TEOF);
else if (c != '\n' && c != 0)
- syntaxerr((char *) 0);
+ syntaxerr(NULL);
}
static struct op *
@@ -86,7 +86,7 @@ pipeline(cf)
if (t != NULL) {
while (token(0) == '|') {
if ((p = get_command(CONTIN)) == NULL)
- syntaxerr((char *) 0);
+ syntaxerr(NULL);
if (tl == NULL)
t = tl = block(TPIPE, t, p, NOWORDS);
else
@@ -107,7 +107,7 @@ andor()
if (t != NULL) {
while ((c = token(0)) == LOGAND || c == LOGOR) {
if ((p = pipeline(CONTIN)) == NULL)
- syntaxerr((char *) 0);
+ syntaxerr(NULL);
t = block(c == LOGAND? TAND: TOR, t, p, NOWORDS);
}
REJECT;
@@ -179,7 +179,7 @@ musthave(c, cf)
int c, cf;
{
if ((token(cf)) != c)
- syntaxerr((char *) 0);
+ syntaxerr(NULL);
}
static struct op *
@@ -268,7 +268,7 @@ get_command(cf)
/* Must be a function */
if (iopn != 0 || XPsize(args) != 1
|| XPsize(vars) != 0)
- syntaxerr((char *) 0);
+ syntaxerr(NULL);
ACCEPT;
/*(*/
musthave(')', 0);
@@ -370,8 +370,8 @@ get_command(cf)
case BANG:
syniocf &= ~(KEYWORD|ALIAS);
t = pipeline(0);
- if (t == (struct op *) 0)
- syntaxerr((char *) 0);
+ if (t == NULL)
+ syntaxerr(NULL);
t = block(TBANG, NOBLOCK, t, NOWORDS);
break;
@@ -433,7 +433,7 @@ dogroup()
else if (c == '{')
c = '}';
else
- syntaxerr((char *) 0);
+ syntaxerr(NULL);
list = c_list();
musthave(c, KEYWORD|ALIAS);
return list;
@@ -448,7 +448,7 @@ thenpart()
t = newtp(0);
t->left = c_list();
if (t->left == NULL)
- syntaxerr((char *) 0);
+ syntaxerr(NULL);
t->right = elsepart();
return (t);
}
@@ -461,7 +461,7 @@ elsepart()
switch (token(KEYWORD|ALIAS|VARASN)) {
case ELSE:
if ((t = c_list()) == NULL)
- syntaxerr((char *) 0);
+ syntaxerr(NULL);
return (t);
case ELIF:
@@ -489,7 +489,7 @@ caselist()
else if (c == '{')
c = '}';
else
- syntaxerr((char *) 0);
+ syntaxerr(NULL);
t = tl = NULL;
while ((tpeek(CONTIN|KEYWORD|ESACONLY)) != c) { /* no ALIAS here */
struct op *tc = casepart(c);
@@ -546,7 +546,7 @@ function_body(name, ksh_func)
|| (*p != EOS && *p != CHAR && *p != QCHAR
&& *p != OQUOTE && *p != CQUOTE))
{
- p = snptreef((char *) 0, 32, "%S", name);
+ p = snptreef(NULL, 32, "%S", name);
yyerror("%s: invalid function name\n", p);
}
Xcheck(xs, xp);
@@ -575,13 +575,13 @@ function_body(name, ksh_func)
old_func_parse = e->flags & EF_FUNC_PARSE;
e->flags |= EF_FUNC_PARSE;
- if ((t->left = get_command(CONTIN)) == (struct op *) 0) {
+ if ((t->left = get_command(CONTIN)) == NULL) {
/* create empty command so foo(): will work */
t->left = newtp(TCOM);
t->args = (char **) alloc(sizeof(char *), ATEMP);
- t->args[0] = (char *) 0;
+ t->args[0] = NULL;
t->vars = (char **) alloc(sizeof(char *), ATEMP);
- t->vars[0] = (char *) 0;
+ t->vars[0] = NULL;
}
if (!old_func_parse)
e->flags &= ~EF_FUNC_PARSE;
@@ -604,7 +604,7 @@ wordlist()
while ((c = token(0)) == LWORD)
XPput(args, yylval.cp);
if (c != '\n' && c != ';')
- syntaxerr((char *) 0);
+ syntaxerr(NULL);
if (XPsize(args) == 0) {
XPfree(args);
return NULL;
@@ -721,7 +721,7 @@ syntaxerr(what)
/*NOTREACHED*/
case LWORD:
- s = snptreef((char *) 0, 32, "%S", yylval.cp);
+ s = snptreef(NULL, 32, "%S", yylval.cp);
break;
case REDIR:
@@ -861,7 +861,7 @@ dbtestp_isa(te, meta)
{
int c = tpeek(ARRAYVAR | (meta == TM_BINOP ? 0 : CONTIN));
int uqword = 0;
- char *save = (char *) 0;
+ char *save = NULL;
int ret = 0;
/* unquoted word? */
@@ -909,7 +909,7 @@ dbtestp_getopnd(te, op, do_eval)
int c = tpeek(ARRAYVAR);
if (c != LWORD)
- return (const char *) 0;
+ return NULL;
ACCEPT;
XPput(*te->pos.av, yylval.cp);
diff --git a/bin/ksh/table.c b/bin/ksh/table.c
index 3b2861bb63f..85f7578e50d 100644
--- a/bin/ksh/table.c
+++ b/bin/ksh/table.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: table.c,v 1.2 1996/08/19 20:08:59 downsj Exp $ */
+/* $OpenBSD: table.c,v 1.3 1997/06/18 22:42:45 kstailey Exp $ */
/*
* dynamic hashed associative table for commands and variables
@@ -126,7 +126,7 @@ tenter(tp, n, h)
p->type = 0;
p->areap = tp->areap;
p->u2.field = 0;
- p->u.array = (struct tbl *)0;
+ p->u.array = NULL;
memcpy(p->name, n, len);
/* enter in tp->tbls */
diff --git a/bin/ksh/trap.c b/bin/ksh/trap.c
index 7933f2d7e31..15128ff49e0 100644
--- a/bin/ksh/trap.c
+++ b/bin/ksh/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.2 1996/08/19 20:09:00 downsj Exp $ */
+/* $OpenBSD: trap.c,v 1.3 1997/06/18 22:42:46 kstailey Exp $ */
/*
* signal handling
@@ -123,7 +123,7 @@ trapsig(i)
(*p->shtrap)(i);
#ifdef V7_SIGNALS
if (sigtraps[i].cursig == trapsig) /* this for SIGCHLD,SIGALRM */
- sigaction(i, &Sigact_trap, (struct sigaction *) 0);
+ sigaction(i, &Sigact_trap, NULL);
#endif /* V7_SIGNALS */
return RETSIGVAL;
}
@@ -203,7 +203,7 @@ runtraps(flag)
fatal_trap = 0;
for (p = sigtraps, i = SIGNALS+1; --i >= 0; p++)
if (p->set && (!flag
- || ((p->flags & flag) && p->trap == (char *) 0)))
+ || ((p->flags & flag) && p->trap == NULL)))
runtrap(p);
}
@@ -217,7 +217,7 @@ runtrap(p)
int UNINITIALIZED(old_changed);
p->set = 0;
- if (trapstr == (char *) 0) { /* SIG_DFL */
+ if (trapstr == NULL) { /* SIG_DFL */
if (p->flags & TF_FATAL) {
/* eg, SIGHUP */
exstat = 128 + i;
@@ -235,7 +235,7 @@ runtrap(p)
if (i == SIGEXIT_ || i == SIGERR_) { /* avoid recursion on these */
old_changed = p->flags & TF_CHANGED;
p->flags &= ~TF_CHANGED;
- p->trap = (char *) 0;
+ p->trap = NULL;
}
oexstat = exstat;
command(trapstr);
@@ -263,7 +263,7 @@ cleartraps()
for (i = SIGNALS+1, p = sigtraps; --i >= 0; p++) {
p->set = 0;
if ((p->flags & TF_USER_SET) && (p->trap && p->trap[0]))
- settrap(p, (char *) 0);
+ settrap(p, NULL);
}
}
@@ -395,7 +395,7 @@ setsig(p, f, flags)
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = KSH_SA_FLAGS;
sigact.sa_handler = f;
- sigaction(p->signal, &sigact, (struct sigaction *) 0);
+ sigaction(p->signal, &sigact, NULL);
}
return 1;
diff --git a/bin/ksh/tree.c b/bin/ksh/tree.c
index 105158787b3..aeb465c87c1 100644
--- a/bin/ksh/tree.c
+++ b/bin/ksh/tree.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tree.c,v 1.2 1996/08/19 20:09:01 downsj Exp $ */
+/* $OpenBSD: tree.c,v 1.3 1997/06/18 22:42:47 kstailey Exp $ */
/*
* command tree climbing
@@ -592,9 +592,9 @@ iocopy(iow, ap)
q = (struct ioword *) alloc(sizeof(*p), ap);
ior[i] = q;
*q = *p;
- if (p->name != (char *) 0)
+ if (p->name != NULL)
q->name = wdcopy(p->name, ap);
- if (p->delim != (char *) 0)
+ if (p->delim != NULL)
q->delim = wdcopy(p->delim, ap);
}
ior[i] = NULL;
diff --git a/bin/ksh/var.c b/bin/ksh/var.c
index 09ec84f0e3b..f458ba93614 100644
--- a/bin/ksh/var.c
+++ b/bin/ksh/var.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: var.c,v 1.3 1996/10/01 02:05:53 downsj Exp $ */
+/* $OpenBSD: var.c,v 1.4 1997/06/18 22:42:48 kstailey Exp $ */
#include "sh.h"
#include "ksh_time.h"
@@ -102,7 +102,7 @@ initvar()
{ "SECONDS", V_SECONDS },
{ "TMOUT", V_TMOUT },
#endif /* KSH */
- { (char *) 0, 0 }
+ { NULL, 0 }
};
int i;
struct tbl *tp;
@@ -255,7 +255,7 @@ local(n, copy)
vp = tenter(&l->vars, n, h);
if (copy && !(vp->flag & DEFINED)) {
struct block *ll = l;
- struct tbl *vq = (struct tbl *) 0;
+ struct tbl *vq = NULL;
while ((ll = ll->next) && !(vq = tsearch(&ll->vars, n, h)))
;
@@ -651,11 +651,11 @@ typeset(var, set, clr, field, base)
if (fake_assign) {
if (t->flag & INTEGER) {
s = str_val(t);
- free_me = (char *) 0;
+ free_me = NULL;
} else {
s = t->val.s + t->type;
free_me = (t->flag & ALLOC) ? t->val.s
- : (char *) 0;
+ : NULL;
}
t->flag &= ~ALLOC;
}
@@ -719,7 +719,7 @@ unset(vp, array_ref)
afree((void *) tmp->val.s, tmp->areap);
afree(tmp, tmp->areap);
}
- vp->u.array = (struct tbl *) 0;
+ vp->u.array = NULL;
}
/* If foo[0] is being unset, the remainder of the array is kept... */
vp->flag &= SPECIAL | (array_ref ? ARRAY|DEFINED : 0);
@@ -867,7 +867,7 @@ getspec(vp)
#ifdef KSH
case V_SECONDS:
vp->flag &= ~SPECIAL;
- setint(vp, (long) (time((time_t *)0) - seconds));
+ setint(vp, (long) (time(NULL) - seconds));
vp->flag |= SPECIAL;
break;
case V_RANDOM:
@@ -910,7 +910,7 @@ setspec(vp)
case V_TMPDIR:
if (tmpdir) {
afree(tmpdir, APERM);
- tmpdir = (char *) 0;
+ tmpdir = NULL;
}
/* Use tmpdir iff it is an absolute path, is writable and
* searchable and is a directory...
@@ -963,7 +963,7 @@ setspec(vp)
break;
case V_SECONDS:
vp->flag &= ~SPECIAL;
- seconds = time((time_t*) 0) - intval(vp);
+ seconds = time(NULL) - intval(vp);
vp->flag |= SPECIAL;
break;
case V_TMOUT:
@@ -992,15 +992,15 @@ unsetspec(vp)
/* should not become unspecial */
if (tmpdir) {
afree(tmpdir, APERM);
- tmpdir = (char *) 0;
+ tmpdir = NULL;
}
break;
#ifdef KSH
case V_MAIL:
- mbset((char *) 0);
+ mbset(NULL);
break;
case V_MAILPATH:
- mpset((char *) 0);
+ mpset(NULL);
break;
case V_TMOUT:
/* at&t ksh doesn't do this. TMOUT becomes unspecial so
diff --git a/bin/ksh/vi.c b/bin/ksh/vi.c
index 4410276a68e..4d3f5803c7a 100644
--- a/bin/ksh/vi.c
+++ b/bin/ksh/vi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vi.c,v 1.3 1996/11/21 07:59:37 downsj Exp $ */
+/* $OpenBSD: vi.c,v 1.4 1997/06/18 22:42:49 kstailey Exp $ */
/*
* vi command editing
@@ -1955,7 +1955,7 @@ expand_word(command)
nwords = x_cf_glob(XCF_COMMAND_FILE|XCF_FULLPATH,
es->cbuf, es->linelen, es->cursor,
- &start, &end, &words, (int *) 0);
+ &start, &end, &words, NULL);
if (nwords == 0) {
vi_error();
return -1;
@@ -2043,12 +2043,12 @@ complete_word(command, count)
*/
if (is_command) {
match = words[count]
- + x_basename(words[count], (char *) 0);
+ + x_basename(words[count], NULL);
/* If more than one possible match, use full path */
for (i = 0; i < nwords; i++)
if (i != count &&
FILECMP(words[i]
- + x_basename(words[i], (char *) 0),
+ + x_basename(words[i], NULL),
match) == 0)
{
match = words[count];
diff --git a/bin/pdksh/c_ksh.c b/bin/pdksh/c_ksh.c
index df402d54e1b..5799fce58d0 100644
--- a/bin/pdksh/c_ksh.c
+++ b/bin/pdksh/c_ksh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: c_ksh.c,v 1.5 1996/11/21 07:59:27 downsj Exp $ */
+/* $OpenBSD: c_ksh.c,v 1.6 1997/06/18 22:42:27 kstailey Exp $ */
/*
* built-in Korn commands: c_*
@@ -76,7 +76,7 @@ c_cd(wp)
* we could try to find another substitution. For now
* we don't
*/
- if ((cp = strstr(current_wd, wp[0])) == (char *) 0) {
+ if ((cp = strstr(current_wd, wp[0])) == NULL) {
bi_errorf("bad substitution");
return 1;
}
@@ -95,10 +95,10 @@ c_cd(wp)
}
Xinit(xs, xp, PATH, ATEMP);
- /* xp will have a bogus value after make_path() - set it to 0
+ /* xp will have a bogus value after make_path() - set it to NULL
* so that if it's used, it will cause a dump
*/
- xp = (char *) 0;
+ xp = NULL;
cdpath = str_val(global("CDPATH"));
do {
@@ -112,7 +112,7 @@ c_cd(wp)
simplify_path(Xstring(xs, xp));
rval = chdir(try = Xstring(xs, xp));
}
- } while (rval < 0 && cdpath != (char *) 0);
+ } while (rval < 0 && cdpath != NULL);
if (rval < 0) {
if (cdnode)
@@ -135,9 +135,9 @@ c_cd(wp)
* so it can't set current_wd when changing to a:foo.
* Handle this by calling getcwd()...
*/
- pwd = ksh_get_wd((char *) 0, 0);
+ pwd = ksh_get_wd(NULL, 0);
#else /* OS2 */
- pwd = (char *) 0;
+ pwd = NULL;
#endif /* OS2 */
} else
#ifdef S_ISLNK
@@ -187,14 +187,14 @@ c_pwd(wp)
}
#ifdef S_ISLNK
p = current_wd[0] ? (physical ? get_phys_path(current_wd) : current_wd)
- : (char *) 0;
+ : NULL;
#else /* S_ISLNK */
- p = current_wd[0] ? current_wd : (char *) 0;
+ p = current_wd[0] ? current_wd : NULL;
#endif /* S_ISLNK */
if (p && eaccess(p, R_OK) < 0)
- p = (char *) 0;
+ p = NULL;
if (!p) {
- p = ksh_get_wd((char *) 0, 0);
+ p = ksh_get_wd(NULL, 0);
if (!p) {
bi_errorf("can't get current directory - %s",
strerror(errno));
@@ -595,7 +595,7 @@ c_typeset(wp)
break;
}
- fieldstr = basestr = (char *) 0;
+ fieldstr = basestr = NULL;
builtin_opt.flags |= GF_PLUSOPT;
/* at&t ksh seems to have 0-9 as options, which are multiplied
* to get a number that is used with -L, -R, -Z or -i (eg, -1R2
@@ -872,7 +872,7 @@ c_alias(wp)
/* "hash -r" means reset all the tracked aliases.. */
if (rflag) {
static const char *const args[] = {
- "unalias", "-ta", (const char *) 0
+ "unalias", "-ta", NULL
};
if (!tflag || *wp) {
@@ -926,7 +926,7 @@ c_alias(wp)
afree((void*)ap->val.s, APERM);
}
/* ignore values for -t (at&t ksh does this) */
- newval = tflag ? search(alias, path, X_OK, (int *) 0)
+ newval = tflag ? search(alias, path, X_OK, NULL)
: val;
if (newval) {
ap->val.s = str_save(newval, APERM);
@@ -1003,7 +1003,7 @@ c_let(wp)
int rv = 1;
long val;
- if (wp[1] == (char *) 0) /* at&t ksh does this */
+ if (wp[1] == NULL) /* at&t ksh does this */
bi_errorf("no arguments");
else
for (wp++; *wp; wp++)
@@ -1044,7 +1044,7 @@ c_jobs(wp)
}
wp += builtin_opt.optind;
if (!*wp)
- if (j_jobs((char *) 0, flag, nflag))
+ if (j_jobs(NULL, flag, nflag))
rv = 1;
else
for (; *wp; wp++)
@@ -1115,7 +1115,7 @@ int
c_kill(wp)
char **wp;
{
- Trap *t = (Trap *) 0;
+ Trap *t = NULL;
char *p;
int lflag = 0;
int i, n, rv, sig;
@@ -1265,12 +1265,12 @@ c_getopts(wp)
return 1;
}
- if (e->loc->next == (struct block *) 0) {
+ if (e->loc->next == NULL) {
internal_errorf(0, "c_getopts: no argv");
return 1;
}
/* Which arguments are we parsing... */
- if (*wp == (char *) 0)
+ if (*wp == NULL)
wp = e->loc->next->argv;
else
*--wp = e->loc->next->argv[0];
@@ -1286,7 +1286,7 @@ c_getopts(wp)
return 1;
}
- user_opt.optarg = (char *) 0;
+ user_opt.optarg = NULL;
optc = ksh_getopt(wp, &user_opt, options);
if (optc >= 0 && optc != '?' && (user_opt.info & GI_PLUS)) {
@@ -1311,7 +1311,7 @@ c_getopts(wp)
getopts_noset = 0;
}
- if (user_opt.optarg == (char *) 0)
+ if (user_opt.optarg == NULL)
unset(global("OPTARG"), 0);
else
setstr(global("OPTARG"), user_opt.optarg);
@@ -1351,7 +1351,7 @@ c_bind(wp)
wp += builtin_opt.optind;
if (*wp == NULL) /* list all */
- rv = x_bind((char*)NULL, (char*)NULL, 0, list);
+ rv = x_bind(NULL, NULL, 0, list);
for (; *wp != NULL; wp++) {
cp = strchr(*wp, '=');
diff --git a/bin/pdksh/c_sh.c b/bin/pdksh/c_sh.c
index fe090f09277..c488229f66e 100644
--- a/bin/pdksh/c_sh.c
+++ b/bin/pdksh/c_sh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: c_sh.c,v 1.3 1996/10/13 21:32:18 downsj Exp $ */
+/* $OpenBSD: c_sh.c,v 1.4 1997/06/18 22:42:28 kstailey Exp $ */
/*
* built-in Bourne commands
@@ -185,7 +185,7 @@ c_dot(wp)
if ((cp = wp[builtin_opt.optind]) == NULL)
return 0;
- file = search(cp, path, R_OK, (int *) 0);
+ file = search(cp, path, R_OK, NULL);
if (file == NULL) {
bi_errorf("%s: not found", cp);
return 1;
@@ -199,7 +199,7 @@ c_dot(wp)
;
} else {
argc = 0;
- argv = (char **) 0;
+ argv = NULL;
}
i = include(file, argc, argv, 0);
if (i < 0) { /* should not happen */
@@ -219,8 +219,8 @@ c_wait(wp)
if (ksh_getopt(wp, &builtin_opt, null) == '?')
return 1;
wp += builtin_opt.optind;
- if (*wp == (char *) 0) {
- while (waitfor((char *) 0, &sig) >= 0)
+ if (*wp == NULL) {
+ while (waitfor(NULL, &sig) >= 0)
;
rv = sig;
} else {
@@ -357,7 +357,7 @@ c_read(wp)
/* set prompt in case this is
* called from .profile or $ENV
*/
- set_prompt(PS2, (Source *) 0);
+ set_prompt(PS2, NULL);
pprompt(prompt, 0);
}
} else if (c != EOF)
@@ -526,7 +526,7 @@ c_brkcont(wp)
char **wp;
{
int n, quit;
- struct env *ep, *last_ep = (struct env *) 0;
+ struct env *ep, *last_ep = NULL;
char *arg;
if (ksh_getopt(wp, &builtin_opt, null) == '?')
@@ -643,7 +643,7 @@ c_unset(wp)
}
unset(vp, strchr(id, '[') ? 1 : 0);
} else { /* unset function */
- if (define(id, (struct op *) NULL))
+ if (define(id, NULL))
ret = 1;
}
return ret;
diff --git a/bin/pdksh/c_test.c b/bin/pdksh/c_test.c
index 63a0c94e80c..a5777f8deec 100644
--- a/bin/pdksh/c_test.c
+++ b/bin/pdksh/c_test.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: c_test.c,v 1.2 1996/08/19 20:08:47 downsj Exp $ */
+/* $OpenBSD: c_test.c,v 1.3 1997/06/18 22:42:29 kstailey Exp $ */
/*
* test(1); version 7-like -- author Erik Baalbergen
@@ -157,8 +157,7 @@ c_test(wp)
}
if (argc == 1) {
opnd1 = (*te.getopnd)(&te, TO_NONOP, 1);
- res = (*te.eval)(&te, TO_STNZE, opnd1,
- (char *) 0, 1);
+ res = (*te.eval)(&te, TO_STNZE, opnd1, NULL, 1);
if (invert & 1)
res = !res;
return !res;
@@ -517,7 +516,7 @@ test_primary(te, do_eval)
return 0;
}
- return (*te->eval)(te, op, opnd1, (const char *) 0, do_eval);
+ return (*te->eval)(te, op, opnd1, NULL, do_eval);
}
opnd1 = (*te->getopnd)(te, TO_NONOP, do_eval);
if (!opnd1) {
@@ -538,7 +537,7 @@ test_primary(te, do_eval)
(*te->error)(te, -1, "missing expression operator");
return 0;
}
- return (*te->eval)(te, TO_STNZE, opnd1, (const char *) 0, do_eval);
+ return (*te->eval)(te, TO_STNZE, opnd1, NULL, do_eval);
}
/*
@@ -584,7 +583,7 @@ ptest_getopnd(te, op, do_eval)
int do_eval;
{
if (te->pos.wp >= te->wp_end)
- return op == TO_FILTT ? "1" : (const char *) 0;
+ return op == TO_FILTT ? "1" : NULL;
return *te->pos.wp++;
}
@@ -606,7 +605,7 @@ ptest_error(te, offset, msg)
const char *msg;
{
const char *op = te->pos.wp + offset >= te->wp_end ?
- (const char *) 0 : te->pos.wp[offset];
+ NULL : te->pos.wp[offset];
te->flags |= TEF_ERROR;
if (op)
diff --git a/bin/pdksh/c_ulimit.c b/bin/pdksh/c_ulimit.c
index 040eaccb409..31acaea78c1 100644
--- a/bin/pdksh/c_ulimit.c
+++ b/bin/pdksh/c_ulimit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: c_ulimit.c,v 1.1 1996/08/14 06:19:10 downsj Exp $ */
+/* $OpenBSD: c_ulimit.c,v 1.2 1997/06/18 22:42:30 kstailey Exp $ */
/*
ulimit -- handle "ulimit" builtin
@@ -107,7 +107,7 @@ c_ulimit(wp)
#ifdef RLIMIT_SWAP
{ "swap(kbytes)", RLIMIT_SWAP, RLIMIT_SWAP, 1024, 'w' },
#endif
- { (char *) 0 }
+ { NULL }
};
static char options[3 + NELEM(limits)];
rlim_t UNINITIALIZED(val);
diff --git a/bin/pdksh/edit.c b/bin/pdksh/edit.c
index 53c1fcb301a..fbfc8d3a630 100644
--- a/bin/pdksh/edit.c
+++ b/bin/pdksh/edit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: edit.c,v 1.4 1996/12/14 12:18:07 mickey Exp $ */
+/* $OpenBSD: edit.c,v 1.5 1997/06/18 22:42:31 kstailey Exp $ */
/*
* Command line editing - common code
@@ -459,7 +459,7 @@ x_complete_word(str, slen, is_command, nwordsp, ret)
str, slen, &words);
*nwordsp = nwords;
if (nwords == 0) {
- *ret = (char *) 0;
+ *ret = NULL;
return -1;
}
@@ -490,10 +490,10 @@ x_print_expansions(nwords, words, is_command)
/* Special case for 1 match (prefix is whole word) */
if (nwords == 1)
- prefix_len = x_basename(words[0], (char *) 0);
+ prefix_len = x_basename(words[0], NULL);
/* Any (non-trailing) slashes in non-common word suffixes? */
for (i = 0; i < nwords; i++)
- if (x_basename(words[i] + prefix_len, (char *) 0)
+ if (x_basename(words[i] + prefix_len, NULL)
> prefix_len)
break;
/* All in same directory? */
@@ -505,7 +505,7 @@ x_print_expansions(nwords, words, is_command)
XPinit(l, nwords + 1);
for (i = 0; i < nwords; i++)
XPput(l, words[i] + prefix_len);
- XPput(l, (char *) 0);
+ XPput(l, NULL);
}
}
@@ -585,7 +585,7 @@ x_file_glob(flags, str, slen, wordsp)
}
afree(toglob, ATEMP);
- *wordsp = nwords ? words : (char **) 0;
+ *wordsp = nwords ? words : NULL;
return nwords;
}
@@ -649,7 +649,7 @@ x_command_glob(flags, str, slen, wordsp)
nwords = XPsize(w);
if (!nwords) {
- *wordsp = (char **) 0;
+ *wordsp = NULL;
XPfree(w);
return 0;
}
@@ -667,7 +667,7 @@ x_command_glob(flags, str, slen, wordsp)
alloc(sizeof(struct path_order_info) * nwords, ATEMP);
for (i = 0; i < nwords; i++) {
info[i].word = words[i];
- info[i].base = x_basename(words[i], (char *) 0);
+ info[i].base = x_basename(words[i], NULL);
if (!last_info || info[i].base != last_info->base
|| FILENCMP(words[i],
last_info->word, info[i].base) != 0)
@@ -799,7 +799,7 @@ x_cf_glob(flags, buf, buflen, pos, startp, endp, wordsp, is_commandp)
nwords = (is_command ? x_command_glob : x_file_glob)(flags,
buf + *startp, len, &words);
if (nwords == 0) {
- *wordsp = (char **) 0;
+ *wordsp = NULL;
return 0;
}
@@ -824,7 +824,7 @@ add_glob(str, slen)
bool_t saw_slash = FALSE;
if (slen < 0)
- return (char *) 0;
+ return (NULL);
toglob = str_nsave(str, slen + 1, ATEMP); /* + 1 for "*" */
toglob[slen] = '\0';
@@ -909,7 +909,7 @@ x_basename(s, se)
{
const char *p;
- if (se == (char *) 0)
+ if (se == NULL)
se = s + strlen(s);
if (s == se)
return 0;
@@ -993,7 +993,7 @@ glob_path(flags, pat, wp, path)
/* Check that each match is executable... */
words = (char **) XPptrv(*wp);
for (i = j = oldsize; i < newsize; i++) {
- if (search_access(words[i], X_OK, (int *) 0) >= 0) {
+ if (search_access(words[i], X_OK, NULL) >= 0) {
words[j] = words[i];
if (!(flags & XCF_FULLPATH))
memmove(words[j], words[j] + pathlen,
diff --git a/bin/pdksh/emacs.c b/bin/pdksh/emacs.c
index f572f87b5f6..32d9c379bd7 100644
--- a/bin/pdksh/emacs.c
+++ b/bin/pdksh/emacs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: emacs.c,v 1.2 1996/08/19 20:08:48 downsj Exp $ */
+/* $OpenBSD: emacs.c,v 1.3 1997/06/18 22:42:32 kstailey Exp $ */
/*
* Emacs-like command line editing and history
@@ -339,7 +339,7 @@ x_emacs(buf, len)
xlp_valid = TRUE;
xmp = NULL;
x_curprefix = 0;
- macroptr = (char *) 0;
+ macroptr = NULL;
x_histp = histptr + 1;
x_last_command = XFUNC_error;
@@ -422,7 +422,7 @@ x_ins_string(c)
macroptr = x_atab[c>>8][c & CHARMASK];
if (macroptr && !*macroptr) {
/* XXX bell? */
- macroptr = (char *) 0;
+ macroptr = NULL;
}
return KSTD;
}
@@ -1053,7 +1053,7 @@ x_redraw(limit)
if (xbp == xbuf)
{
pprompt(prompt + prompt_skip, 0);
- x_col = promptlen(prompt, (const char **) 0);
+ x_col = promptlen(prompt, NULL);
}
x_displen = xx_cols - 2 - x_col;
xlp_valid = FALSE;
@@ -1736,7 +1736,7 @@ do_complete(flags, type)
int is_command;
int do_glob = 1;
Comp_type t = type;
- char *comp_word = (char *) 0;
+ char *comp_word = NULL;
if (type == CT_COMPLIST) {
do_glob = 0;
@@ -1868,7 +1868,7 @@ x_e_getc()
if (macroptr) {
c = *macroptr++;
if (!*macroptr)
- macroptr = (char *) 0;
+ macroptr = NULL;
} else
c = x_getc();
}
diff --git a/bin/pdksh/eval.c b/bin/pdksh/eval.c
index b8b339eccda..570905bf200 100644
--- a/bin/pdksh/eval.c
+++ b/bin/pdksh/eval.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eval.c,v 1.2 1996/08/19 20:08:49 downsj Exp $ */
+/* $OpenBSD: eval.c,v 1.3 1997/06/18 22:42:33 kstailey Exp $ */
/*
* Expansion - quoting, separation, substitution, globbing
@@ -201,7 +201,7 @@ expand(cp, wp, f)
doblank = 0;
make_magic = 0;
word = (f&DOBLANK) ? IFS_WS : IFS_WORD;
- st_head.next = (SubType *) 0;
+ st_head.next = NULL;
st = &st_head;
while (1) {
@@ -292,7 +292,7 @@ expand(cp, wp, f)
end = (char *) wdscan(sp, CSUBST);
endc = *end;
*end = EOS;
- str = snptreef((char *) 0, 64, "%S",
+ str = snptreef(NULL, 64, "%S",
varname - 1);
*end = endc;
errorf("%s: bad substitution", str);
@@ -306,7 +306,7 @@ expand(cp, wp, f)
newst = (SubType *) alloc(
sizeof(SubType), ATEMP);
- newst->next = (SubType *) 0;
+ newst->next = NULL;
newst->prev = st;
st->next = newst;
}
@@ -696,7 +696,7 @@ varsub(xp, sp, word, stypep)
if (sp[0] == '\0') /* Bad variable name */
return -1;
- xp->var = (struct tbl *) 0;
+ xp->var = NULL;
/* ${#var}, string length or array size */
if (sp[0] == '#' && (c = sp[1]) != '\0') {
@@ -845,7 +845,7 @@ comsub(xp, cp)
if ((io->flag&IOTYPE) != IOREAD)
errorf("funny $() command: %s",
- snptreef((char *) 0, 32, "%R", io));
+ snptreef(NULL, 32, "%R", io));
shf = shf_open(name = evalstr(io->name, DOTILDE), O_RDONLY, 0,
SHF_MAPHI|SHF_CLEXEC);
if (shf == NULL)
@@ -854,7 +854,7 @@ comsub(xp, cp)
} else {
int ofd1, pv[2];
openpipe(pv);
- shf = shf_fdopen(pv[0], SHF_RD, (struct shf *) 0);
+ shf = shf_fdopen(pv[0], SHF_RD, NULL);
ofd1 = savefd(1, 0); /* fd 1 may be closed... */
ksh_dup2(pv[1], 1, FALSE);
close(pv[1]);
@@ -1206,7 +1206,7 @@ maybe_expand_tilde(p, dsp, dpp, isassign)
p += 2;
}
*tp = '\0';
- r = (p[0] == EOS || p[0] == CHAR || p[0] == CSUBST) ? tilde(Xstring(ts, tp)) : (char *) 0;
+ r = (p[0] == EOS || p[0] == CHAR || p[0] == CSUBST) ? tilde(Xstring(ts, tp)) : NULL;
Xfree(ts, tp);
if (r) {
while (*r) {
@@ -1243,7 +1243,7 @@ tilde(cp)
dp = homedir(cp);
/* If HOME, PWD or OLDPWD are not set, don't expand ~ */
if (dp == null)
- dp = (char *) 0;
+ dp = NULL;
return dp;
}
@@ -1298,7 +1298,7 @@ alt_expand(wp, start, exp_start, end, fdo)
/* find matching close brace, if any */
if (p) {
- comma = (char *) 0;
+ comma = NULL;
count = 1;
for (p += 2; *p && count; p++) {
if (ISMAGIC(*p)) {
diff --git a/bin/pdksh/exec.c b/bin/pdksh/exec.c
index d84987cd41c..2ad8f09ceb4 100644
--- a/bin/pdksh/exec.c
+++ b/bin/pdksh/exec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec.c,v 1.7 1997/01/02 17:37:25 downsj Exp $ */
+/* $OpenBSD: exec.c,v 1.8 1997/06/18 22:42:34 kstailey Exp $ */
/*
* execute command tree
@@ -206,7 +206,7 @@ execute(t, flags)
e->type = E_ERRH;
i = ksh_sigsetjmp(e->jbuf, 0);
if (i) {
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
quitenv();
unwind(i);
/*NOTREACHED*/
@@ -227,7 +227,7 @@ execute(t, flags)
ksh_dup2(pv[0], 0, FALSE);
close(pv[0]);
coproc.write = pv[1];
- coproc.job = (void *) 0;
+ coproc.job = NULL;
if (coproc.readw >= 0)
ksh_dup2(coproc.readw, 1, FALSE);
@@ -241,7 +241,7 @@ execute(t, flags)
++coproc.id;
}
# ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
e->type = E_EXEC; /* no more need for error handler */
# endif /* JOB_SIGS */
@@ -602,7 +602,7 @@ comexec(t, tp, ap, flags)
}
break;
}
- if (include(tp->u.fpath, 0, (char **) 0, 0) < 0) {
+ if (include(tp->u.fpath, 0, NULL, 0) < 0) {
warningf(TRUE,
"%s: can't open function definition file %s - %s",
cp, tp->u.fpath, strerror(errno));
@@ -736,7 +736,7 @@ scriptexec(tp, ap)
shell = str_val(global(EXECSHELL_STR));
if (shell && *shell)
- shell = search(shell, path, X_OK, (int *) 0);
+ shell = search(shell, path, X_OK, NULL);
if (!shell || !*shell)
shell = EXECSHELL;
@@ -763,7 +763,7 @@ scriptexec(tp, ap)
while (*cp && (*cp == ' ' || *cp == '\t'))
cp++;
if (*cp && *cp != '\n') {
- char *a0 = cp, *a1 = (char *) 0;
+ char *a0 = cp, *a1 = NULL;
# ifdef OS2
char *a2 = cp;
# endif /* OS2 */
@@ -799,7 +799,8 @@ scriptexec(tp, ap)
if (a1)
*tp->args-- = a1;
# ifdef OS2
- if (a0 != a2 && search_access(a0, X_OK, (int *) 0))
+ if (a0 != a2 && search_access(a0, X_OK,
+ NULL))
a0 = a2;
# endif /* OS2 */
shell = a0;
@@ -815,7 +816,7 @@ scriptexec(tp, ap)
shell = str_val(global("EXECSHELL"));
if (shell && *shell)
- shell = search(shell, path, X_OK, (int *) 0);
+ shell = search(shell, path, X_OK, NULL);
if (!shell || !*shell) {
shell = p;
*tp->args-- = "/c";
@@ -858,7 +859,7 @@ findfunc(name, h, create)
int create;
{
struct block *l;
- struct tbl *tp = (struct tbl *) 0;
+ struct tbl *tp = NULL;
for (l = e->loc; l; l = l->next) {
tp = tsearch(&l->funs, name, h);
@@ -868,7 +869,7 @@ findfunc(name, h, create)
tp = tenter(&l->funs, name, h);
tp->flag = DEFINED;
tp->type = CFUNC;
- tp->val.t = (struct op *) 0;
+ tp->val.t = NULL;
break;
}
}
@@ -982,7 +983,7 @@ findcom(name, flags)
tp = findfunc(name, h, FALSE);
if (tp && !(tp->flag & ISSET)) {
if ((fpath = str_val(global("FPATH"))) == null) {
- tp->u.fpath = (char *) 0;
+ tp->u.fpath = NULL;
tp->u2.errno_ = 0;
} else
tp->u.fpath = search(name, fpath, R_OK,
@@ -1034,7 +1035,7 @@ findcom(name, flags)
} else if ((flags & FC_FUNC)
&& (fpath = str_val(global("FPATH"))) != null
&& (npath = search(name, fpath, R_OK,
- &tp->u2.errno_)) != (char *) 0)
+ &tp->u2.errno_)) != NULL)
{
/* An undocumented feature of at&t ksh is that it
* searches FPATH if a command is not found, even
@@ -1104,10 +1105,10 @@ search_access(path, mode, errnop)
* exec.c(search())).
*/
static char *xsuffixes[] = { ".ksh", ".exe", ".", ".sh", ".cmd",
- ".com", ".bat", (char *) 0
+ ".com", ".bat", NULL
};
static char *rsuffixes[] = { ".ksh", ".", ".sh", ".cmd", ".bat",
- (char *) 0
+ NULL
};
int i;
char *mpath = (char *) path;
@@ -1253,7 +1254,7 @@ call_builtin(tp, wp)
shf_flush(shl_stdout);
shl_stdout_ok = 0;
builtin_flag = 0;
- builtin_argv0 = (char *) 0;
+ builtin_argv0 = NULL;
return rv;
}
@@ -1277,13 +1278,13 @@ iosetup(iop, tp)
/* Used for tracing and error messages to print expanded cp */
iotmp = *iop;
- iotmp.name = (iotype == IOHERE) ? (char *) 0 : cp;
+ iotmp.name = (iotype == IOHERE) ? NULL : cp;
iotmp.flag |= IONAMEXP;
if (Flag(FXTRACE))
shellf("%s%s\n",
PS4_SUBSTITUTE(str_val(global("PS4"))),
- snptreef((char *) 0, 32, "%R", &iotmp));
+ snptreef(NULL, 32, "%R", &iotmp));
switch (iotype) {
case IOREAD:
@@ -1325,7 +1326,7 @@ iosetup(iop, tp)
&emsg)) < 0)
{
warningf(TRUE, "%s: %s",
- snptreef((char *) 0, 32, "%R", &iotmp), emsg);
+ snptreef(NULL, 32, "%R", &iotmp), emsg);
return -1;
}
break;
@@ -1366,7 +1367,7 @@ iosetup(iop, tp)
if (ksh_dup2(u, iop->unit, TRUE) < 0) {
warningf(TRUE,
"could not finish (dup) redirection %s: %s",
- snptreef((char *) 0, 32, "%R", &iotmp),
+ snptreef(NULL, 32, "%R", &iotmp),
strerror(errno));
if (iotype != IODUP)
close(u);
@@ -1403,7 +1404,7 @@ herein(hname, sub)
int fd;
/* ksh -c 'cat << EOF' can cause this... */
- if (hname == (char *) 0) {
+ if (hname == NULL) {
warningf(TRUE, "here document missing");
return -2; /* special to iosetup(): don't print error */
}
@@ -1434,7 +1435,7 @@ herein(hname, sub)
if (yylex(ONEWORD) != LWORD)
internal_errorf(1, "herein: yylex");
shf_close(shf);
- shf = (struct shf *) 0;
+ shf = NULL;
cp = evalstr(yylval.cp, 0);
/* write expanded input to another temp file */
@@ -1446,11 +1447,11 @@ herein(hname, sub)
shf_puts(cp, shf);
if (shf_close(shf) == EOF) {
close(fd);
- shf = (struct shf *) 0;
+ shf = NULL;
errorf("error writing %s: %s", h->name,
strerror(errno));
}
- shf = (struct shf *) 0;
+ shf = NULL;
quitenv();
} else {
@@ -1473,7 +1474,7 @@ do_selectargs(ap, print_menu)
bool_t print_menu;
{
static const char *const read_args[] = {
- "read", "-r", "REPLY", (char *) 0
+ "read", "-r", "REPLY", NULL
};
char *s;
int i, argct;
@@ -1490,7 +1491,7 @@ do_selectargs(ap, print_menu)
pr_menu(ap);
shellf("%s", str_val(global("PS3")));
if (call_builtin(findcom("read", FC_BI), (char **) read_args))
- return (char *) 0;
+ return (NULL);
s = str_val(global("REPLY"));
if (*s) {
i = atoi(s);
@@ -1629,7 +1630,7 @@ dbteste_getopnd(te, op, do_eval)
char *s = *te->pos.wp;
if (!s)
- return (char *) 0;
+ return (NULL);
te->pos.wp++;
diff --git a/bin/pdksh/expr.c b/bin/pdksh/expr.c
index 2d70ed1cd1d..6b9dc05b548 100644
--- a/bin/pdksh/expr.c
+++ b/bin/pdksh/expr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: expr.c,v 1.2 1996/08/19 20:08:50 downsj Exp $ */
+/* $OpenBSD: expr.c,v 1.3 1997/06/18 22:42:34 kstailey Exp $ */
/*
* Korn expression evaluation
@@ -177,7 +177,7 @@ v_evaluate(vp, expr, error_ok)
curstate.expression = curstate.tokp = expr;
curstate.noassign = 0;
curstate.prev = es;
- curstate.evaling = (struct tbl *) 0;
+ curstate.evaling = NULL;
es = &curstate;
newenv(E_ERRH);
@@ -207,7 +207,7 @@ v_evaluate(vp, expr, error_ok)
v = intvar(evalexpr(MAX_PREC));
if (es->tok != END)
- evalerr(ET_UNEXPECTED, (char *) 0);
+ evalerr(ET_UNEXPECTED, NULL);
if (vp->flag & INTEGER)
setint_v(vp, v);
@@ -314,7 +314,7 @@ evalexpr(prec)
vl = es->val;
token();
} else {
- evalerr(ET_UNEXPECTED, (char *) 0);
+ evalerr(ET_UNEXPECTED, NULL);
/*NOTREACHED*/
}
if (es->tok == O_PLUSPLUS || es->tok == O_MINUSMINUS) {
@@ -590,7 +590,7 @@ intvar(vp)
vp->flag |= EXPRINEVAL;
v_evaluate(vq, str_val(vp), FALSE);
vp->flag &= ~EXPRINEVAL;
- es->evaling = (struct tbl *) 0;
+ es->evaling = NULL;
}
return vq;
}
diff --git a/bin/pdksh/history.c b/bin/pdksh/history.c
index 9ed181165e1..cf5712d7437 100644
--- a/bin/pdksh/history.c
+++ b/bin/pdksh/history.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: history.c,v 1.5 1997/01/02 18:16:52 downsj Exp $ */
+/* $OpenBSD: history.c,v 1.6 1997/06/18 22:42:35 kstailey Exp $ */
/*
* command history
@@ -80,10 +80,10 @@ c_fc(wp)
{
struct shf *shf;
struct temp UNINITIALIZED(*tf);
- char *p, *editor = (char *) 0;
+ char *p, *editor = NULL;
int gflag = 0, lflag = 0, nflag = 0, sflag = 0, rflag = 0;
int optc;
- char *first = (char *) 0, *last = (char *) 0;
+ char *first = NULL, *last = NULL;
char **hfirst, **hlast, **hp;
while ((optc = ksh_getopt(wp, &builtin_opt, "e:glnrs0,1,2,3,4,5,6,7,8,9,")) != EOF)
@@ -133,7 +133,7 @@ c_fc(wp)
/* Substitute and execute command */
if (sflag) {
- char *pat = (char *) 0, *rep = (char *) 0;
+ char *pat = NULL, *rep = NULL;
if (editor || lflag || nflag || rflag) {
bi_errorf("can't use -e, -l, -n, -r with -s (-e -)");
@@ -301,7 +301,7 @@ hist_execute(cmd)
if ((q = strchr(p, '\n'))) {
*q++ = '\0'; /* kill the newline */
if (!*q) /* ignore trailing newline */
- q = (char *) 0;
+ q = NULL;
}
#ifdef EASY_HISTORY
if (p != cmd)
@@ -383,7 +383,7 @@ hist_get(str, approx, allow_cur)
int approx;
int allow_cur;
{
- char **hp = (char **) 0;
+ char **hp = NULL;
int n;
if (getn(str, &n)) {
@@ -393,18 +393,18 @@ hist_get(str, approx, allow_cur)
hp = hist_get_oldest();
else {
bi_errorf("%s: not in history", str);
- hp = (char **) 0;
+ hp = NULL;
}
} else if (hp > histptr) {
if (approx)
hp = hist_get_newest(allow_cur);
else {
bi_errorf("%s: not in history", str);
- hp = (char **) 0;
+ hp = NULL;
}
} else if (!allow_cur && hp == histptr) {
bi_errorf("%s: invalid range", str);
- hp = (char **) 0;
+ hp = NULL;
}
} else {
int anchored = *str == '?' ? (++str, 0) : 1;
@@ -413,7 +413,7 @@ hist_get(str, approx, allow_cur)
n = findhist(histptr - history - 1, 0, str, anchored);
if (n < 0) {
bi_errorf("%s: not in history", str);
- hp = (char **) 0;
+ hp = NULL;
} else
hp = &history[n];
}
@@ -427,7 +427,7 @@ hist_get_newest(allow_cur)
{
if (histptr < history || (!allow_cur && histptr == history)) {
bi_errorf("no history (yet)");
- return (char **) 0;
+ return (NULL);
}
if (allow_cur)
return histptr;
@@ -440,7 +440,7 @@ hist_get_oldest()
{
if (histptr <= history) {
bi_errorf("no history (yet)");
- return (char **) 0;
+ return (NULL);
}
return history;
}
@@ -594,7 +594,7 @@ sethistfile(name)
void
init_histvec()
{
- if (history == (char **)NULL) {
+ if (history == NULL) {
histsize = HISTORYSIZE;
history = (char **)alloc(histsize*sizeof (char *), APERM);
histptr = history - 1;
diff --git a/bin/pdksh/io.c b/bin/pdksh/io.c
index a5bfe1569a9..a1757df8875 100644
--- a/bin/pdksh/io.c
+++ b/bin/pdksh/io.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: io.c,v 1.2 1996/08/19 20:08:51 downsj Exp $ */
+/* $OpenBSD: io.c,v 1.3 1997/06/18 22:42:36 kstailey Exp $ */
/*
* shell buffered IO and formatted output
@@ -93,7 +93,7 @@ bi_errorf(fmt, va_alist)
if ((builtin_flag & SPEC_BI)
|| (Flag(FPOSIX) && (builtin_flag & KEEPASN)))
{
- builtin_argv0 = (char *) 0;
+ builtin_argv0 = NULL;
unwind(LERROR);
}
}
@@ -441,7 +441,7 @@ maketemp(ap)
len = strlen(tmp) + 3 + 20 + 20 + 1;
tp = (struct temp *) alloc(sizeof(struct temp) + len, ap);
tp->name = path = (char *) &tp[1];
- tp->shf = (struct shf *) 0;
+ tp->shf = NULL;
while (1) {
/* Note that temp files need to fit 8.3 DOS limits */
shf_snprintf(path, len, "%s/sh%05u.%03x",
@@ -451,7 +451,7 @@ maketemp(ap)
*/
fd = open(path, O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0600);
if (fd >= 0) {
- tp->shf = shf_fdopen(fd, SHF_WR, (struct shf *) 0);
+ tp->shf = shf_fdopen(fd, SHF_WR, NULL);
break;
}
if (errno != EINTR
diff --git a/bin/pdksh/jobs.c b/bin/pdksh/jobs.c
index 2b7369df085..b5073966ec3 100644
--- a/bin/pdksh/jobs.c
+++ b/bin/pdksh/jobs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: jobs.c,v 1.4 1996/11/21 07:59:29 downsj Exp $ */
+/* $OpenBSD: jobs.c,v 1.5 1997/06/18 22:42:37 kstailey Exp $ */
/*
* Process and job control
@@ -165,7 +165,7 @@ static const char *const lookup_msgs[] = {
"no such job",
"ambiguous",
"argument must be %job or process id",
- (char *) 0
+ NULL
};
clock_t j_systime, j_usrtime; /* user and system time of last j_waitjed job */
@@ -231,7 +231,7 @@ j_init(mflagset)
#ifdef JOB_SIGS
sigemptyset(&sm_default);
- sigprocmask(SIG_SETMASK, &sm_default, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &sm_default, NULL);
sigemptyset(&sm_sigchld);
sigaddset(&sm_sigchld, SIGCHLD);
@@ -250,7 +250,7 @@ j_init(mflagset)
/* shl_j is used to do asynchronous notification (used in
* an interrupt handler, so need a distinct shf)
*/
- shl_j = shf_fdopen(2, SHF_WR, (struct shf *) 0);
+ shl_j = shf_fdopen(2, SHF_WR, NULL);
# ifdef TTY_PGRP
if (Flag(FMONITOR) || Flag(FTALKING)) {
@@ -285,7 +285,7 @@ j_exit()
Job *j;
int killed = 0;
- for (j = job_list; j != (Job *) 0; j = j->next) {
+ for (j = job_list; j != NULL; j = j->next) {
if (j->ppid == procpid
&& (j->state == PSTOPPED
|| (j->state == PRUNNING
@@ -452,7 +452,7 @@ exchild(t, flags, close_fd)
#endif /* JOB_SIGS */
p = new_proc();
- p->next = (Proc *) 0;
+ p->next = NULL;
p->state = PRUNNING;
WSTATUS(p->status) = 0;
p->pid = 0;
@@ -514,7 +514,7 @@ exchild(t, flags, close_fd)
}
#endif /* NEED_PGRP_SYNC */
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
errorf("cannot fork - try again");
}
@@ -593,7 +593,7 @@ exchild(t, flags, close_fd)
coproc_cleanup(FALSE);
#endif /* KSH */
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
cleanup_parents_env();
#ifdef TTY_PGRP
@@ -667,7 +667,7 @@ exchild(t, flags, close_fd)
}
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
return rv;
@@ -689,7 +689,7 @@ startlast()
j_startjob(last_job);
}
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
}
@@ -712,7 +712,7 @@ waitlast()
else
internal_errorf(0, "waitlast: not started");
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
return 125; /* not so arbitrary, non-zero value */
}
@@ -720,7 +720,7 @@ waitlast()
rv = j_waitj(j, JW_NONE, "jw:waitlast");
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
return rv;
@@ -744,7 +744,7 @@ waitfor(cp, sigp)
*sigp = 0;
- if (cp == (char *) 0) {
+ if (cp == NULL) {
/* wait for an unspecified job - always returns 0, so
* don't have to worry about exited/signaled jobs
*/
@@ -754,7 +754,7 @@ waitfor(cp, sigp)
break;
if (!j) {
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
return -1;
}
@@ -763,13 +763,13 @@ waitfor(cp, sigp)
flags &= ~JW_ASYNCNOTIFY;
if (j->ppid != procpid) {
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
return -1;
}
} else {
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
if (ecode == JL_NOSUCH)
return -1;
@@ -780,7 +780,7 @@ waitfor(cp, sigp)
rv = j_waitj(j, flags, "jw:waitfor");
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
if (rv < 0) /* we were interrupted */
@@ -805,16 +805,16 @@ j_kill(cp, sig)
sigprocmask(SIG_BLOCK, &sm_sigchld, &omask);
#endif /* JOB_SIGS */
- if ((j = j_lookup(cp, &ecode)) == (Job *) 0) {
+ if ((j = j_lookup(cp, &ecode)) == NULL) {
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
bi_errorf("%s: %s", cp, lookup_msgs[ecode]);
return 1;
}
if (j->pgrp == 0) { /* started when !Flag(FMONITOR) */
- for (p=j->proc_list; p != (Proc *) 0; p = p->next)
+ for (p=j->proc_list; p != NULL; p = p->next)
if (kill(p->pid, sig) < 0) {
bi_errorf("%s: %s", cp, strerror(errno));
rv = 1;
@@ -831,7 +831,7 @@ j_kill(cp, sig)
}
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
return rv;
@@ -853,14 +853,14 @@ j_resume(cp, bg)
sigprocmask(SIG_BLOCK, &sm_sigchld, &omask);
- if ((j = j_lookup(cp, &ecode)) == (Job *) 0) {
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ if ((j = j_lookup(cp, &ecode)) == NULL) {
+ sigprocmask(SIG_SETMASK, &omask, NULL);
bi_errorf("%s: %s", cp, lookup_msgs[ecode]);
return 1;
}
if (j->pgrp == 0) {
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
bi_errorf("job not job-controlled");
return 1;
}
@@ -869,7 +869,7 @@ j_resume(cp, bg)
shprintf("[%d] ", j->job);
running = 0;
- for (p = j->proc_list; p != (Proc *) 0; p = p->next) {
+ for (p = j->proc_list; p != NULL; p = p->next) {
if (p->state == PSTOPPED) {
p->state = PRUNNING;
WSTATUS(p->status) = 0;
@@ -895,8 +895,7 @@ j_resume(cp, bg)
if (ttypgrp_ok && tcsetpgrp(tty_fd, j->pgrp) < 0) {
if (j->flags & JF_SAVEDTTY)
set_tty(tty_fd, &tty_state, TF_NONE);
- sigprocmask(SIG_SETMASK, &omask,
- (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
bi_errorf("1st tcsetpgrp(%d, %d) failed: %s",
tty_fd, (int) j->pgrp, strerror(errno));
return 1;
@@ -906,7 +905,7 @@ j_resume(cp, bg)
j->flags |= JF_FG;
j->flags &= ~JF_KNOWN;
if (j == async_job)
- async_job = (Job *) 0;
+ async_job = NULL;
}
if (j->state == PRUNNING && killpg(j->pgrp, SIGCONT) < 0) {
@@ -925,7 +924,7 @@ j_resume(cp, bg)
}
# endif /* TTY_PGRP */
}
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
bi_errorf("cannot continue job %s: %s",
cp, strerror(err));
return 1;
@@ -938,7 +937,7 @@ j_resume(cp, bg)
# endif /* TTY_PGRP */
rv = j_waitj(j, JW_NONE, "jw:resume");
}
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
return rv;
}
#endif /* JOBS */
@@ -950,7 +949,7 @@ j_stopped_running()
Job *j;
int which = 0;
- for (j = job_list; j != (Job *) 0; j = j->next) {
+ for (j = job_list; j != NULL; j = j->next) {
#ifdef JOBS
if (j->ppid == procpid && j->state == PSTOPPED)
which |= 1;
@@ -993,9 +992,9 @@ j_jobs(cp, slp, nflag)
if (cp) {
int ecode;
- if ((j = j_lookup(cp, &ecode)) == (Job *) 0) {
+ if ((j = j_lookup(cp, &ecode)) == NULL) {
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
bi_errorf("%s: %s", cp, lookup_msgs[ecode]);
return 1;
@@ -1021,7 +1020,7 @@ j_jobs(cp, slp, nflag)
remove_job(j, "jobs");
}
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
return 0;
}
@@ -1054,7 +1053,7 @@ j_notify()
}
shf_flush(shl_out);
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
}
@@ -1072,7 +1071,7 @@ j_async()
async_job->flags |= JF_KNOWN;
#ifdef JOB_SIGS
- sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
+ sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
return async_pid;
@@ -1097,7 +1096,7 @@ j_set_async(j)
async_job = j;
async_pid = j->last_proc->pid;
while (nzombie > child_max) {
- oldest = (Job *) 0;
+ oldest = NULL;
for (jl = job_list; jl; jl = jl->next)
if (jl != async_job && (jl->flags & JF_ZOMBIE)
&& (!oldest || jl->age < oldest->age))
@@ -1311,12 +1310,12 @@ j_sigchld(sig)
ksh_times(&t1);
/* find job and process structures for this pid */
- for (j = job_list; j != (Job *) 0; j = j->next)
- for (p = j->proc_list; p != (Proc *) 0; p = p->next)
+ for (j = job_list; j != NULL; j = j->next)
+ for (p = j->proc_list; p != NULL; p = p->next)
if (p->pid == pid)
goto found;
found:
- if (j == (Job *) 0) {
+ if (j == NULL) {
/* Can occur if process has kids, then execs shell
warningf(TRUE, "bad process waited for (pid = %d)",
pid);
@@ -1375,7 +1374,7 @@ check_job(j)
}
jstate = PRUNNING;
- for (p=j->proc_list; p != (Proc *) 0; p = p->next) {
+ for (p=j->proc_list; p != NULL; p = p->next) {
if (p->state == PRUNNING)
return; /* some processes still running */
if (p->state > jstate)
@@ -1405,7 +1404,7 @@ check_job(j)
* (at leasst, this is what ksh93d thinks)
*/
if (coproc.job == j) {
- coproc.job = (void *) 0;
+ coproc.job = NULL;
/* XXX would be nice to get the closes out of here
* so they aren't done in the signal handler.
* Would mean a check in coproc_getfd() to
@@ -1500,7 +1499,7 @@ j_print(j, how, shf)
else if (j == job_list->next)
jobchar = '-';
- for (p = j->proc_list; p != (Proc *) 0;) {
+ for (p = j->proc_list; p != NULL;) {
coredumped = 0;
switch (p->state) {
case PRUNNING:
@@ -1590,54 +1589,54 @@ j_lookup(cp, ecodep)
if (digit(*cp)) {
job = atoi(cp);
/* Look for last_proc->pid (what $! returns) first... */
- for (j = job_list; j != (Job *) 0; j = j->next)
+ for (j = job_list; j != NULL; j = j->next)
if (j->last_proc && j->last_proc->pid == job)
return j;
/* ...then look for process group (this is non-POSIX),
* but should not break anything (so FPOSIX isn't used).
*/
- for (j = job_list; j != (Job *) 0; j = j->next)
+ for (j = job_list; j != NULL; j = j->next)
if (j->pgrp && j->pgrp == job)
return j;
if (ecodep)
*ecodep = JL_NOSUCH;
- return (Job *) 0;
+ return NULL;
}
if (*cp != '%') {
if (ecodep)
*ecodep = JL_INVALID;
- return (Job *) 0;
+ return NULL;
}
switch (*++cp) {
case '\0': /* non-standard */
case '+':
case '%':
- if (job_list != (Job *) 0)
+ if (job_list != NULL)
return job_list;
break;
case '-':
- if (job_list != (Job *) 0 && job_list->next)
+ if (job_list != NULL && job_list->next)
return job_list->next;
break;
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
job = atoi(cp);
- for (j = job_list; j != (Job *) 0; j = j->next)
+ for (j = job_list; j != NULL; j = j->next)
if (j->job == job)
return j;
break;
case '?': /* %?string */
- last_match = (Job *) 0;
- for (j = job_list; j != (Job *) 0; j = j->next)
- for (p = j->proc_list; p != (Proc *) 0; p = p->next)
- if (strstr(p->command, cp+1) != (char *) 0) {
+ last_match = NULL;
+ for (j = job_list; j != NULL; j = j->next)
+ for (p = j->proc_list; p != NULL; p = p->next)
+ if (strstr(p->command, cp+1) != NULL) {
if (last_match) {
if (ecodep)
*ecodep = JL_AMBIG;
- return (Job *) 0;
+ return NULL;
}
last_match = j;
}
@@ -1647,13 +1646,13 @@ j_lookup(cp, ecodep)
default: /* %string */
len = strlen(cp);
- last_match = (Job *) 0;
- for (j = job_list; j != (Job *) 0; j = j->next)
+ last_match = NULL;
+ for (j = job_list; j != NULL; j = j->next)
if (strncmp(cp, j->proc_list->command, len) == 0) {
if (last_match) {
if (ecodep)
*ecodep = JL_AMBIG;
- return (Job *) 0;
+ return NULL;
}
last_match = j;
}
@@ -1663,7 +1662,7 @@ j_lookup(cp, ecodep)
}
if (ecodep)
*ecodep = JL_NOSUCH;
- return (Job *) 0;
+ return NULL;
}
static Job *free_jobs;
@@ -1679,7 +1678,7 @@ new_job()
int i;
Job *newj, *j;
- if (free_jobs != (Job *) 0) {
+ if (free_jobs != NULL) {
newj = free_jobs;
free_jobs = free_jobs->next;
} else
@@ -1689,7 +1688,7 @@ new_job()
for (i = 1; ; i++) {
for (j = job_list; j && j->job != i; j = j->next)
;
- if (j == (Job *) 0)
+ if (j == NULL)
break;
}
newj->job = i;
@@ -1706,7 +1705,7 @@ new_proc()
{
Proc *p;
- if (free_procs != (Proc *) 0) {
+ if (free_procs != NULL) {
p = free_procs;
free_procs = free_procs->next;
} else
@@ -1730,7 +1729,7 @@ remove_job(j, where)
prev = &job_list;
curr = *prev;
- for (; curr != (Job *) 0 && curr != j; prev = &curr->next, curr = *prev)
+ for (; curr != NULL && curr != j; prev = &curr->next, curr = *prev)
;
if (curr != j) {
internal_errorf(0, "remove_job: job not found (%s)", where);
@@ -1739,7 +1738,7 @@ remove_job(j, where)
*prev = curr->next;
/* free up proc structures */
- for (p = j->proc_list; p != (Proc *) 0; ) {
+ for (p = j->proc_list; p != NULL; ) {
tmp = p;
p = p->next;
tmp->next = free_procs;
@@ -1752,9 +1751,9 @@ remove_job(j, where)
free_jobs = j;
if (j == last_job)
- last_job = (Job *) 0;
+ last_job = NULL;
if (j == async_job)
- async_job = (Job *) 0;
+ async_job = NULL;
}
/* put j in a particular location (taking it out job_list if it is there
@@ -1805,7 +1804,7 @@ kill_job(j)
{
Proc *p;
- for (p = j->proc_list; p != (Proc *) 0; p = p->next)
+ for (p = j->proc_list; p != NULL; p = p->next)
if (p->pid != 0)
(void) kill(p->pid, SIGKILL);
}
@@ -1826,7 +1825,7 @@ fill_command(c, len, t)
else
ap = t->args;
--len; /* save room for the null */
- while (len > 0 && *ap != (char *) 0) {
+ while (len > 0 && *ap != NULL) {
alen = strlen(*ap);
if (alen > len)
alen = len;
diff --git a/bin/pdksh/ksh_wait.h b/bin/pdksh/ksh_wait.h
index 16fad066768..b5c15a77699 100644
--- a/bin/pdksh/ksh_wait.h
+++ b/bin/pdksh/ksh_wait.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ksh_wait.h,v 1.1 1996/08/14 06:19:11 downsj Exp $ */
+/* $OpenBSD: ksh_wait.h,v 1.2 1997/06/18 22:42:37 kstailey Exp $ */
/* Wrapper around the ugly sys/wait includes/ifdefs */
@@ -45,7 +45,7 @@ typedef int WAIT_T;
#if !defined(HAVE_WAITPID) && defined(HAVE_WAIT3)
/* always used with p == -1 */
-# define ksh_waitpid(p, s, o) wait3((s), (o), (struct rusage *) 0)
+# define ksh_waitpid(p, s, o) wait3((s), (o), NULL)
#else /* !HAVE_WAITPID && HAVE_WAIT3 */
# define ksh_waitpid(p, s, o) waitpid((p), (s), (o))
#endif /* !HAVE_WAITPID && HAVE_WAIT3 */
diff --git a/bin/pdksh/lex.c b/bin/pdksh/lex.c
index 3b8a3dd63ee..b342f73709f 100644
--- a/bin/pdksh/lex.c
+++ b/bin/pdksh/lex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lex.c,v 1.5 1996/11/21 07:59:32 downsj Exp $ */
+/* $OpenBSD: lex.c,v 1.6 1997/06/18 22:42:38 kstailey Exp $ */
/*
* lexical analysis and source input
@@ -574,8 +574,8 @@ Done:
ungetsc(c2);
}
- iop->name = (char *) 0;
- iop->delim = (char *) 0;
+ iop->name = NULL;
+ iop->delim = NULL;
yylval.iop = iop;
return REDIR;
}
@@ -1011,7 +1011,7 @@ getsc_line(s)
#endif /* HISTORY */
}
if (interactive)
- set_prompt(PS2, (Source *) 0);
+ set_prompt(PS2, NULL);
}
void
@@ -1035,8 +1035,8 @@ set_prompt(to, s)
Area *saved_atemp;
ps1 = str_val(global("PS1"));
- shf = shf_sopen((char *) 0, strlen(ps1) * 2,
- SHF_WR | SHF_DYNAMIC, (struct shf *) 0);
+ shf = shf_sopen(NULL, strlen(ps1) * 2,
+ SHF_WR | SHF_DYNAMIC, NULL);
while (*ps1) {
if (*ps1 != '!' || *++ps1 == '!')
shf_putchar(*ps1++, shf);
diff --git a/bin/pdksh/mail.c b/bin/pdksh/mail.c
index 04033a4f2d3..46e79cd0702 100644
--- a/bin/pdksh/mail.c
+++ b/bin/pdksh/mail.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mail.c,v 1.3 1997/01/02 17:37:27 downsj Exp $ */
+/* $OpenBSD: mail.c,v 1.4 1997/06/18 22:42:39 kstailey Exp $ */
/*
* Mailbox checking code by Robert J. Gibson, adapted for PD ksh by
@@ -47,7 +47,7 @@ mcheck()
if (getint(global("MAILCHECK"), &mailcheck) < 0)
return;
- now = time((time_t *) 0);
+ now = time(NULL);
if (mlastchkd == 0)
mlastchkd = now;
if (now - mlastchkd >= mailcheck) {
diff --git a/bin/pdksh/main.c b/bin/pdksh/main.c
index a6bd9369df2..290aa50c83d 100644
--- a/bin/pdksh/main.c
+++ b/bin/pdksh/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.5 1997/01/02 09:34:03 downsj Exp $ */
+/* $OpenBSD: main.c,v 1.6 1997/06/18 22:42:40 kstailey Exp $ */
/*
* startup, main loop, enviroments and error handling
@@ -109,7 +109,7 @@ main(argc, argv)
/* make sure argv[] is sane */
if (!*argv) {
static const char *empty_argv[] = {
- "pdksh", (char *) 0
+ "pdksh", NULL
};
argv = (char **) empty_argv;
@@ -159,7 +159,7 @@ main(argc, argv)
def_path = DEFAULT__PATH;
#if defined(HAVE_CONFSTR) && defined(_CS_PATH)
{
- size_t len = confstr(_CS_PATH, (char *) 0, 0);
+ size_t len = confstr(_CS_PATH, NULL, 0);
char *new;
if (len > 0) {
@@ -225,7 +225,7 @@ main(argc, argv)
|| stat(pwd, &s_pwd) < 0 || stat(".", &s_dot) < 0
|| s_pwd.st_dev != s_dot.st_dev
|| s_pwd.st_ino != s_dot.st_ino)
- pwdx = (char *) 0;
+ pwdx = NULL;
set_current_wd(pwdx);
if (current_wd[0])
simplify_path(current_wd);
@@ -237,7 +237,7 @@ main(argc, argv)
}
setint(global("PPID"), (long) getppid());
#ifdef KSH
- setint(global("RANDOM"), (long) time((time_t *)0));
+ setint(global("RANDOM"), (long) time(NULL));
#endif /* KSH */
setstr(global(version_param), ksh_version);
@@ -265,7 +265,7 @@ main(argc, argv)
/* this to note if monitor is set on command line (see below) */
Flag(FMONITOR) = 127;
- argi = parse_args(argv, OF_CMDLINE, (int *) 0);
+ argi = parse_args(argv, OF_CMDLINE, NULL);
if (argi < 0)
exit(1);
@@ -283,7 +283,7 @@ main(argc, argv)
* This changes the behavior of 'ksh arg' to search
* the users search path but it can't be helped.
*/
- s->file = search(argv[argi++], path, R_OK, (int *) 0);
+ s->file = search(argv[argi++], path, R_OK, NULL);
if (!s->file || !*s->file)
s->file = argv[argi - 1];
#else
@@ -299,14 +299,13 @@ main(argc, argv)
Flag(FSTDIN) = 1;
s = pushs(SSTDIN, ATEMP);
s->file = "<stdin>";
- s->u.shf = shf_fdopen(0, SHF_RD | can_seek(0),
- (struct shf *) 0);
+ s->u.shf = shf_fdopen(0, SHF_RD | can_seek(0), NULL);
if (isatty(0) && isatty(2)) {
Flag(FTALKING) = 1;
/* The following only if isatty(0) */
s->flags |= SF_TTY;
s->u.shf->flags |= SHF_INTERRUPT;
- s->file = (char *) 0;
+ s->file = NULL;
}
}
@@ -354,22 +353,20 @@ main(argc, argv)
if (!Flag(FPRIVILEGED)
&& strcmp(profile = substitute("$INIT/profile.ksh", 0),
"/profile.ksh"))
- include(profile, 0, (char **) 0, 1);
- else if (include("/etc/profile.ksh", 0, (char **) 0, 1) < 0)
- include("c:/usr/etc/profile.ksh", 0, (char **) 0, 1);
+ include(profile, 0, NULL, 1);
+ else if (include("/etc/profile.ksh", 0, NULL, 1) < 0)
+ include("c:/usr/etc/profile.ksh", 0, NULL, 1);
if (!Flag(FPRIVILEGED))
- include(substitute("$HOME/profile.ksh", 0), 0,
- (char **) 0, 1);
+ include(substitute("$HOME/profile.ksh", 0), 0, NULL, 1);
#else /* OS2 */
- include(KSH_SYSTEM_PROFILE, 0, (char **) 0, 1);
+ include(KSH_SYSTEM_PROFILE, 0, NULL, 1);
if (!Flag(FPRIVILEGED))
- include(substitute("$HOME/.profile", 0), 0,
- (char **) 0, 1);
+ include(substitute("$HOME/.profile", 0), 0, NULL, 1);
#endif /* OS2 */
}
if (Flag(FPRIVILEGED))
- include("/etc/suid_profile", 0, (char **) 0, 1);
+ include("/etc/suid_profile", 0, NULL, 1);
else {
char *env_file;
@@ -388,11 +385,10 @@ main(argc, argv)
#endif /* DEFAULT_ENV */
env_file = substitute(env_file, DOTILDE);
if (*env_file != '\0')
- include(env_file, 0, (char **) 0, 1);
+ include(env_file, 0, NULL, 1);
#ifdef OS2
else if (Flag(FTALKING))
- include(substitute("$HOME/kshrc.ksh", 0), 0,
- (char **) 0, 1);
+ include(substitute("$HOME/kshrc.ksh", 0), 0, NULL, 1);
#endif /* OS2 */
}
@@ -401,8 +397,7 @@ main(argc, argv)
if (restricted) {
static const char *const restr_com[] = {
"typeset", "-r", "PATH",
- "ENV", "SHELL",
- (char *) 0
+ "ENV", "SHELL", NULL
};
shcomexec((char **) restr_com);
/* After typeset command... */
@@ -443,7 +438,7 @@ include(name, argc, argv, intr_ok)
old_argv = e->loc->argv;
old_argc = e->loc->argc;
} else {
- old_argv = (char **) 0;
+ old_argv = NULL;
old_argc = 0;
}
sold = source;
@@ -729,7 +724,7 @@ cleanup_parents_env()
if (ep->savefd[fd] > 0)
close(ep->savefd[fd]);
}
- e->oenv = (struct env *) 0;
+ e->oenv = NULL;
}
/* Called just before an execve cleanup stuff temporary files */
diff --git a/bin/pdksh/misc.c b/bin/pdksh/misc.c
index 0d5fe74eb7b..634d8488ac2 100644
--- a/bin/pdksh/misc.c
+++ b/bin/pdksh/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.4 1997/01/02 09:34:07 downsj Exp $ */
+/* $OpenBSD: misc.c,v 1.5 1997/06/18 22:42:40 kstailey Exp $ */
/*
* Miscellaneous functions
@@ -378,7 +378,7 @@ parse_args(argv, what, setargsp)
break;
case 'o':
- if (go.optarg == (char *) 0) {
+ if (go.optarg == NULL) {
/* lone -o: print options
*
* Note that on the command line, -o requires
@@ -453,7 +453,7 @@ parse_args(argv, what, setargsp)
return -1;
}
} else
- array = (char *) 0; /* keep gcc happy */
+ array = NULL; /* keep gcc happy */
if (sortargs) {
for (i = go.optind; argv[i]; i++)
;
@@ -803,7 +803,7 @@ pat_scan(p, pe, match_sep)
if ((*p & 0x80) && strchr("*+?@!", *p & 0x7f))
nest++;
}
- return (const unsigned char *) 0;
+ return NULL;
}
@@ -915,7 +915,7 @@ ksh_getopt_reset(go, flags)
int flags;
{
go->optind = 1;
- go->optarg = (char *) 0;
+ go->optarg = NULL;
go->p = 0;
go->flags = flags;
go->info = 0;
@@ -967,7 +967,7 @@ ksh_getopt(argv, go, options)
go->info |= GI_MINUSMINUS;
return EOF;
}
- if (arg == (char *) 0
+ if (arg == NULL
|| ((flag != '-' || (go->info & GI_PLUS))
&& (!(go->flags & GF_PLUSOPT) || (go->info & GI_MINUS)
|| flag != '+'))
@@ -1006,7 +1006,7 @@ ksh_getopt(argv, go, options)
else if (argv[go->optind])
go->optarg = argv[go->optind++];
else if (*o == ';')
- go->optarg = (char *) 0;
+ go->optarg = NULL;
else {
if (options[0] == ':') {
go->buf[0] = c;
@@ -1035,13 +1035,13 @@ ksh_getopt(argv, go, options)
go->optarg = argv[go->optind - 1] + go->p;
go->p = 0;
} else
- go->optarg = (char *) 0;;
+ go->optarg = NULL;
} else {
if (argv[go->optind] && digit(argv[go->optind][0])) {
go->optarg = argv[go->optind++];
go->p = 0;
} else
- go->optarg = (char *) 0;;
+ go->optarg = NULL;
}
}
return c;
@@ -1277,7 +1277,7 @@ ksh_get_wd(buf, bsize)
errno = EACCES;
if (b != buf)
afree(b, ATEMP);
- return (char *) 0;
+ return NULL;
}
len = strlen(b) + 1;
if (!buf)
@@ -1285,7 +1285,7 @@ ksh_get_wd(buf, bsize)
else if (buf != b) {
if (len > bsize) {
errno = ERANGE;
- return (char *) 0;
+ return NULL;
}
memcpy(buf, b, len);
afree(b, ATEMP);
diff --git a/bin/pdksh/missing.c b/bin/pdksh/missing.c
index 455403c0de1..5533d5b9a66 100644
--- a/bin/pdksh/missing.c
+++ b/bin/pdksh/missing.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: missing.c,v 1.1 1996/08/14 06:19:11 downsj Exp $ */
+/* $OpenBSD: missing.c,v 1.2 1997/06/18 22:42:41 kstailey Exp $ */
/*
* Routines which may be missing on some machines
@@ -224,7 +224,7 @@ ksh_times(tms)
tms->tms_cstime = ru.ru_stime.tv_sec * CLK_TCK
+ ru.ru_stime.tv_usec * CLK_TCK / 1000000;
- gettimeofday(&tv, (struct timezone *) 0);
+ gettimeofday(&tv, NULL);
if (base_sec == 0)
base_sec = tv.tv_sec;
rv = (tv.tv_sec - base_sec) * CLK_TCK;
@@ -261,10 +261,10 @@ ksh_opendir(d)
struct stat statb;
if (stat(d, &statb) != 0)
- return (DIR *) 0;
+ return NULL;
if (!S_ISDIR(statb.st_mode)) {
errno = ENOTDIR;
- return (DIR *) 0;
+ return NULL;
}
return opendir(d);
}
diff --git a/bin/pdksh/path.c b/bin/pdksh/path.c
index 5242ab42cb4..4476964258a 100644
--- a/bin/pdksh/path.c
+++ b/bin/pdksh/path.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: path.c,v 1.1 1996/08/14 06:19:11 downsj Exp $ */
+/* $OpenBSD: path.c,v 1.2 1997/06/18 22:42:42 kstailey Exp $ */
#include "sh.h"
#include "ksh_stat.h"
@@ -14,8 +14,11 @@
/*
* $Log: path.c,v $
- * Revision 1.1 1996/08/14 06:19:11 downsj
- * Initial revision
+ * Revision 1.2 1997/06/18 22:42:42 kstailey
+ * (foo *)0 -> NULL
+ *
+ * Revision 1.1.1.1 1996/08/14 06:19:11 downsj
+ * Import pdksh 5.2.7.
*
* Revision 1.2 1994/05/19 18:32:40 michael
* Merge complete, stdio replaced, various fixes. (pre autoconf)
@@ -108,7 +111,7 @@ make_path(cwd, file, cdpathp, xsp, phys_pathp)
for (pend = plist; *pend && *pend != PATHSEP; pend++)
;
plen = pend - plist;
- *cdpathp = *pend ? ++pend : (char *) 0;
+ *cdpathp = *pend ? ++pend : NULL;
}
if ((use_cdpath == 0 || !plen || ISRELPATH(plist))
@@ -137,7 +140,7 @@ make_path(cwd, file, cdpathp, xsp, phys_pathp)
memcpy(xp, file, len);
if (!use_cdpath)
- *cdpathp = (char *) 0;
+ *cdpathp = NULL;
return rval;
}
@@ -230,7 +233,7 @@ set_current_wd(path)
int len;
char *p = path;
- if (!p && !(p = ksh_get_wd((char *) 0, 0)))
+ if (!p && !(p = ksh_get_wd(NULL, 0)))
p = null;
len = strlen(p) + 1;
@@ -255,7 +258,7 @@ get_phys_path(path)
xp = do_phys_path(&xs, xp, path);
if (!xp)
- return (char *) 0;
+ return NULL;
if (Xlength(xs, xp) == 0)
Xput(xs, xp, DIRSEP);
@@ -304,7 +307,7 @@ do_phys_path(xsp, xp, path)
if (llen < 0) {
/* EINVAL means it wasn't a symlink... */
if (errno != EINVAL)
- return (char *) 0;
+ return NULL;
continue;
}
lbuf[llen] = '\0';
@@ -313,7 +316,7 @@ do_phys_path(xsp, xp, path)
xp = ISABSPATH(lbuf) ? Xstring(*xsp, xp)
: Xrestpos(*xsp, xp, savepos);
if (!(xp = do_phys_path(xsp, xp, lbuf)))
- return (char *) 0;
+ return NULL;
}
return xp;
}
diff --git a/bin/pdksh/shf.c b/bin/pdksh/shf.c
index 820139c1b33..4c324158aba 100644
--- a/bin/pdksh/shf.c
+++ b/bin/pdksh/shf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: shf.c,v 1.1 1996/08/14 06:19:11 downsj Exp $ */
+/* $OpenBSD: shf.c,v 1.2 1997/06/18 22:42:43 kstailey Exp $ */
/*
* Shell file I/O routines
@@ -52,7 +52,7 @@ shf_open(name, oflags, mode, sflags)
: ((oflags & O_ACCMODE) == O_WRONLY ? SHF_WR
: SHF_RDWR);
- return shf_fdopen(fd, sflags, (struct shf *) 0);
+ return shf_fdopen(fd, sflags, NULL);
}
/* Set up the shf structure for a file descriptor. Doesn't fail. */
@@ -87,7 +87,7 @@ shf_fdopen(fd, sflags, shf)
shf->buf = (unsigned char *) alloc(bsize, ATEMP);
sflags |= SHF_ALLOCB;
} else
- shf->buf = (unsigned char *) 0;
+ shf->buf = NULL;
} else {
shf = (struct shf *) alloc(sizeof(struct shf) + bsize, ATEMP);
shf->buf = (unsigned char *) &shf[1];
@@ -536,7 +536,7 @@ shf_getse(buf, bsize, shf)
internal_errorf(1, "shf_getse: flags %x", shf->flags);
if (bsize <= 0)
- return (char *) 0;
+ return NULL;
--bsize; /* save room for null */
do {
@@ -793,7 +793,7 @@ shf_smprintf(fmt, va_alist)
struct shf shf;
va_list args;
- shf_sopen((char *) 0, 0, SHF_WR|SHF_DYNAMIC, &shf);
+ shf_sopen(NULL, 0, SHF_WR|SHF_DYNAMIC, &shf);
SH_VA_START(args, fmt);
shf_vfprintf(&shf, fmt, args);
va_end(args);
diff --git a/bin/pdksh/siglist.sh b/bin/pdksh/siglist.sh
index 135e920d637..06cd14bbdb2 100644
--- a/bin/pdksh/siglist.sh
+++ b/bin/pdksh/siglist.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# $OpenBSD: siglist.sh,v 1.2 1996/10/01 02:05:48 downsj Exp $
+# $OpenBSD: siglist.sh,v 1.3 1997/06/18 22:42:44 kstailey Exp $
#
# Script to generate a sorted, complete list of signals, suitable
@@ -32,7 +32,7 @@ sed -n 's/{ QwErTy/{/p' < $out | awk '{print NR, $0}' | sort +2n +0n |
n = $2;
if (n > 0 && n != last) {
while (++last < n) {
- printf "\t{ %d , (char *) 0, `Signal %d` } ,\n", last, last;
+ printf "\t{ %d , NULL, `Signal %d` } ,\n", last, last;
}
print;
}
diff --git a/bin/pdksh/syn.c b/bin/pdksh/syn.c
index 53b85a20b74..22125924490 100644
--- a/bin/pdksh/syn.c
+++ b/bin/pdksh/syn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syn.c,v 1.5 1996/11/21 07:59:35 downsj Exp $ */
+/* $OpenBSD: syn.c,v 1.6 1997/06/18 22:42:45 kstailey Exp $ */
/*
* shell parser (C version)
@@ -73,7 +73,7 @@ yyparse()
if (c == 0 && !outtree)
outtree = newtp(TEOF);
else if (c != '\n' && c != 0)
- syntaxerr((char *) 0);
+ syntaxerr(NULL);
}
static struct op *
@@ -86,7 +86,7 @@ pipeline(cf)
if (t != NULL) {
while (token(0) == '|') {
if ((p = get_command(CONTIN)) == NULL)
- syntaxerr((char *) 0);
+ syntaxerr(NULL);
if (tl == NULL)
t = tl = block(TPIPE, t, p, NOWORDS);
else
@@ -107,7 +107,7 @@ andor()
if (t != NULL) {
while ((c = token(0)) == LOGAND || c == LOGOR) {
if ((p = pipeline(CONTIN)) == NULL)
- syntaxerr((char *) 0);
+ syntaxerr(NULL);
t = block(c == LOGAND? TAND: TOR, t, p, NOWORDS);
}
REJECT;
@@ -179,7 +179,7 @@ musthave(c, cf)
int c, cf;
{
if ((token(cf)) != c)
- syntaxerr((char *) 0);
+ syntaxerr(NULL);
}
static struct op *
@@ -268,7 +268,7 @@ get_command(cf)
/* Must be a function */
if (iopn != 0 || XPsize(args) != 1
|| XPsize(vars) != 0)
- syntaxerr((char *) 0);
+ syntaxerr(NULL);
ACCEPT;
/*(*/
musthave(')', 0);
@@ -370,8 +370,8 @@ get_command(cf)
case BANG:
syniocf &= ~(KEYWORD|ALIAS);
t = pipeline(0);
- if (t == (struct op *) 0)
- syntaxerr((char *) 0);
+ if (t == NULL)
+ syntaxerr(NULL);
t = block(TBANG, NOBLOCK, t, NOWORDS);
break;
@@ -433,7 +433,7 @@ dogroup()
else if (c == '{')
c = '}';
else
- syntaxerr((char *) 0);
+ syntaxerr(NULL);
list = c_list();
musthave(c, KEYWORD|ALIAS);
return list;
@@ -448,7 +448,7 @@ thenpart()
t = newtp(0);
t->left = c_list();
if (t->left == NULL)
- syntaxerr((char *) 0);
+ syntaxerr(NULL);
t->right = elsepart();
return (t);
}
@@ -461,7 +461,7 @@ elsepart()
switch (token(KEYWORD|ALIAS|VARASN)) {
case ELSE:
if ((t = c_list()) == NULL)
- syntaxerr((char *) 0);
+ syntaxerr(NULL);
return (t);
case ELIF:
@@ -489,7 +489,7 @@ caselist()
else if (c == '{')
c = '}';
else
- syntaxerr((char *) 0);
+ syntaxerr(NULL);
t = tl = NULL;
while ((tpeek(CONTIN|KEYWORD|ESACONLY)) != c) { /* no ALIAS here */
struct op *tc = casepart(c);
@@ -546,7 +546,7 @@ function_body(name, ksh_func)
|| (*p != EOS && *p != CHAR && *p != QCHAR
&& *p != OQUOTE && *p != CQUOTE))
{
- p = snptreef((char *) 0, 32, "%S", name);
+ p = snptreef(NULL, 32, "%S", name);
yyerror("%s: invalid function name\n", p);
}
Xcheck(xs, xp);
@@ -575,13 +575,13 @@ function_body(name, ksh_func)
old_func_parse = e->flags & EF_FUNC_PARSE;
e->flags |= EF_FUNC_PARSE;
- if ((t->left = get_command(CONTIN)) == (struct op *) 0) {
+ if ((t->left = get_command(CONTIN)) == NULL) {
/* create empty command so foo(): will work */
t->left = newtp(TCOM);
t->args = (char **) alloc(sizeof(char *), ATEMP);
- t->args[0] = (char *) 0;
+ t->args[0] = NULL;
t->vars = (char **) alloc(sizeof(char *), ATEMP);
- t->vars[0] = (char *) 0;
+ t->vars[0] = NULL;
}
if (!old_func_parse)
e->flags &= ~EF_FUNC_PARSE;
@@ -604,7 +604,7 @@ wordlist()
while ((c = token(0)) == LWORD)
XPput(args, yylval.cp);
if (c != '\n' && c != ';')
- syntaxerr((char *) 0);
+ syntaxerr(NULL);
if (XPsize(args) == 0) {
XPfree(args);
return NULL;
@@ -721,7 +721,7 @@ syntaxerr(what)
/*NOTREACHED*/
case LWORD:
- s = snptreef((char *) 0, 32, "%S", yylval.cp);
+ s = snptreef(NULL, 32, "%S", yylval.cp);
break;
case REDIR:
@@ -861,7 +861,7 @@ dbtestp_isa(te, meta)
{
int c = tpeek(ARRAYVAR | (meta == TM_BINOP ? 0 : CONTIN));
int uqword = 0;
- char *save = (char *) 0;
+ char *save = NULL;
int ret = 0;
/* unquoted word? */
@@ -909,7 +909,7 @@ dbtestp_getopnd(te, op, do_eval)
int c = tpeek(ARRAYVAR);
if (c != LWORD)
- return (const char *) 0;
+ return NULL;
ACCEPT;
XPput(*te->pos.av, yylval.cp);
diff --git a/bin/pdksh/table.c b/bin/pdksh/table.c
index 3b2861bb63f..85f7578e50d 100644
--- a/bin/pdksh/table.c
+++ b/bin/pdksh/table.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: table.c,v 1.2 1996/08/19 20:08:59 downsj Exp $ */
+/* $OpenBSD: table.c,v 1.3 1997/06/18 22:42:45 kstailey Exp $ */
/*
* dynamic hashed associative table for commands and variables
@@ -126,7 +126,7 @@ tenter(tp, n, h)
p->type = 0;
p->areap = tp->areap;
p->u2.field = 0;
- p->u.array = (struct tbl *)0;
+ p->u.array = NULL;
memcpy(p->name, n, len);
/* enter in tp->tbls */
diff --git a/bin/pdksh/trap.c b/bin/pdksh/trap.c
index 7933f2d7e31..15128ff49e0 100644
--- a/bin/pdksh/trap.c
+++ b/bin/pdksh/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.2 1996/08/19 20:09:00 downsj Exp $ */
+/* $OpenBSD: trap.c,v 1.3 1997/06/18 22:42:46 kstailey Exp $ */
/*
* signal handling
@@ -123,7 +123,7 @@ trapsig(i)
(*p->shtrap)(i);
#ifdef V7_SIGNALS
if (sigtraps[i].cursig == trapsig) /* this for SIGCHLD,SIGALRM */
- sigaction(i, &Sigact_trap, (struct sigaction *) 0);
+ sigaction(i, &Sigact_trap, NULL);
#endif /* V7_SIGNALS */
return RETSIGVAL;
}
@@ -203,7 +203,7 @@ runtraps(flag)
fatal_trap = 0;
for (p = sigtraps, i = SIGNALS+1; --i >= 0; p++)
if (p->set && (!flag
- || ((p->flags & flag) && p->trap == (char *) 0)))
+ || ((p->flags & flag) && p->trap == NULL)))
runtrap(p);
}
@@ -217,7 +217,7 @@ runtrap(p)
int UNINITIALIZED(old_changed);
p->set = 0;
- if (trapstr == (char *) 0) { /* SIG_DFL */
+ if (trapstr == NULL) { /* SIG_DFL */
if (p->flags & TF_FATAL) {
/* eg, SIGHUP */
exstat = 128 + i;
@@ -235,7 +235,7 @@ runtrap(p)
if (i == SIGEXIT_ || i == SIGERR_) { /* avoid recursion on these */
old_changed = p->flags & TF_CHANGED;
p->flags &= ~TF_CHANGED;
- p->trap = (char *) 0;
+ p->trap = NULL;
}
oexstat = exstat;
command(trapstr);
@@ -263,7 +263,7 @@ cleartraps()
for (i = SIGNALS+1, p = sigtraps; --i >= 0; p++) {
p->set = 0;
if ((p->flags & TF_USER_SET) && (p->trap && p->trap[0]))
- settrap(p, (char *) 0);
+ settrap(p, NULL);
}
}
@@ -395,7 +395,7 @@ setsig(p, f, flags)
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = KSH_SA_FLAGS;
sigact.sa_handler = f;
- sigaction(p->signal, &sigact, (struct sigaction *) 0);
+ sigaction(p->signal, &sigact, NULL);
}
return 1;
diff --git a/bin/pdksh/tree.c b/bin/pdksh/tree.c
index 105158787b3..aeb465c87c1 100644
--- a/bin/pdksh/tree.c
+++ b/bin/pdksh/tree.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tree.c,v 1.2 1996/08/19 20:09:01 downsj Exp $ */
+/* $OpenBSD: tree.c,v 1.3 1997/06/18 22:42:47 kstailey Exp $ */
/*
* command tree climbing
@@ -592,9 +592,9 @@ iocopy(iow, ap)
q = (struct ioword *) alloc(sizeof(*p), ap);
ior[i] = q;
*q = *p;
- if (p->name != (char *) 0)
+ if (p->name != NULL)
q->name = wdcopy(p->name, ap);
- if (p->delim != (char *) 0)
+ if (p->delim != NULL)
q->delim = wdcopy(p->delim, ap);
}
ior[i] = NULL;
diff --git a/bin/pdksh/var.c b/bin/pdksh/var.c
index 09ec84f0e3b..f458ba93614 100644
--- a/bin/pdksh/var.c
+++ b/bin/pdksh/var.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: var.c,v 1.3 1996/10/01 02:05:53 downsj Exp $ */
+/* $OpenBSD: var.c,v 1.4 1997/06/18 22:42:48 kstailey Exp $ */
#include "sh.h"
#include "ksh_time.h"
@@ -102,7 +102,7 @@ initvar()
{ "SECONDS", V_SECONDS },
{ "TMOUT", V_TMOUT },
#endif /* KSH */
- { (char *) 0, 0 }
+ { NULL, 0 }
};
int i;
struct tbl *tp;
@@ -255,7 +255,7 @@ local(n, copy)
vp = tenter(&l->vars, n, h);
if (copy && !(vp->flag & DEFINED)) {
struct block *ll = l;
- struct tbl *vq = (struct tbl *) 0;
+ struct tbl *vq = NULL;
while ((ll = ll->next) && !(vq = tsearch(&ll->vars, n, h)))
;
@@ -651,11 +651,11 @@ typeset(var, set, clr, field, base)
if (fake_assign) {
if (t->flag & INTEGER) {
s = str_val(t);
- free_me = (char *) 0;
+ free_me = NULL;
} else {
s = t->val.s + t->type;
free_me = (t->flag & ALLOC) ? t->val.s
- : (char *) 0;
+ : NULL;
}
t->flag &= ~ALLOC;
}
@@ -719,7 +719,7 @@ unset(vp, array_ref)
afree((void *) tmp->val.s, tmp->areap);
afree(tmp, tmp->areap);
}
- vp->u.array = (struct tbl *) 0;
+ vp->u.array = NULL;
}
/* If foo[0] is being unset, the remainder of the array is kept... */
vp->flag &= SPECIAL | (array_ref ? ARRAY|DEFINED : 0);
@@ -867,7 +867,7 @@ getspec(vp)
#ifdef KSH
case V_SECONDS:
vp->flag &= ~SPECIAL;
- setint(vp, (long) (time((time_t *)0) - seconds));
+ setint(vp, (long) (time(NULL) - seconds));
vp->flag |= SPECIAL;
break;
case V_RANDOM:
@@ -910,7 +910,7 @@ setspec(vp)
case V_TMPDIR:
if (tmpdir) {
afree(tmpdir, APERM);
- tmpdir = (char *) 0;
+ tmpdir = NULL;
}
/* Use tmpdir iff it is an absolute path, is writable and
* searchable and is a directory...
@@ -963,7 +963,7 @@ setspec(vp)
break;
case V_SECONDS:
vp->flag &= ~SPECIAL;
- seconds = time((time_t*) 0) - intval(vp);
+ seconds = time(NULL) - intval(vp);
vp->flag |= SPECIAL;
break;
case V_TMOUT:
@@ -992,15 +992,15 @@ unsetspec(vp)
/* should not become unspecial */
if (tmpdir) {
afree(tmpdir, APERM);
- tmpdir = (char *) 0;
+ tmpdir = NULL;
}
break;
#ifdef KSH
case V_MAIL:
- mbset((char *) 0);
+ mbset(NULL);
break;
case V_MAILPATH:
- mpset((char *) 0);
+ mpset(NULL);
break;
case V_TMOUT:
/* at&t ksh doesn't do this. TMOUT becomes unspecial so
diff --git a/bin/pdksh/vi.c b/bin/pdksh/vi.c
index 4410276a68e..4d3f5803c7a 100644
--- a/bin/pdksh/vi.c
+++ b/bin/pdksh/vi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vi.c,v 1.3 1996/11/21 07:59:37 downsj Exp $ */
+/* $OpenBSD: vi.c,v 1.4 1997/06/18 22:42:49 kstailey Exp $ */
/*
* vi command editing
@@ -1955,7 +1955,7 @@ expand_word(command)
nwords = x_cf_glob(XCF_COMMAND_FILE|XCF_FULLPATH,
es->cbuf, es->linelen, es->cursor,
- &start, &end, &words, (int *) 0);
+ &start, &end, &words, NULL);
if (nwords == 0) {
vi_error();
return -1;
@@ -2043,12 +2043,12 @@ complete_word(command, count)
*/
if (is_command) {
match = words[count]
- + x_basename(words[count], (char *) 0);
+ + x_basename(words[count], NULL);
/* If more than one possible match, use full path */
for (i = 0; i < nwords; i++)
if (i != count &&
FILECMP(words[i]
- + x_basename(words[i], (char *) 0),
+ + x_basename(words[i], NULL),
match) == 0)
{
match = words[count];