• remove strcasestr.c, use home-grown implementation¹, call it stricmp,

and have it return an API-correct const char *
• enhance and stylify comments
• a little KNF and simplifications
• #ifdef DEBUG: replace strchr and strstr with ucstrchr and ucstrstr
  that take and return a non-const char *, and fix the violations
• new cstrchr, cstrstr (take and give const char *)
• new vstrchr, vstrstr (take const or not, give boolean value)
• new afreechk(x) = afreechv(x,x) = if (x1) afree(x2, ATEMP)
• new ksh_isdash(str) = (str != NULL) && !strcmp(str, "-")
• replace the only use of strrchr with inlined code to shrink
• minor man page fixes
• Minix 3 signames are autogenerated with gcc
• rename strlfun.c to strlcpy.c since we don't do strlcat(3) anyway,
  only strlcpy(3), and shorten it
• dot.mkshrc: move MKSH=… down to the export line
  to not disturb the PS1 visual impression ☺
• dot.mkshrc: Lstripcom(): optimise
• bump version

¹) side effect from creating API-correct cstrchr, cstrstr, etc.
   uses goto so it must be better ☻

tested on mirbsd-current via both Makefile and Build.sh
This commit is contained in:
tg
2007-03-04 03:04:28 +00:00
parent 62b347a1b0
commit 83c2ee87f4
25 changed files with 332 additions and 340 deletions

10
exec.c
View File

@ -2,7 +2,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.25 2007/03/04 00:13:15 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.26 2007/03/04 03:04:24 tg Exp $");
static int comexec(struct op *, struct tbl *volatile, const char **,
int volatile);
@ -500,7 +500,7 @@ comexec(struct op *t, struct tbl *volatile tp, const char **ap,
rv = subst_exstat;
goto Leave;
} else if (!tp) {
if (Flag(FRESTRICTED) && strchr(cp, '/')) {
if (Flag(FRESTRICTED) && vstrchr(cp, '/')) {
warningf(true, "%s: restricted", cp);
rv = 1;
goto Leave;
@ -814,7 +814,7 @@ findcom(const char *name, int flags)
char *fpath; /* for function autoloading */
const char *npath;
if (strchr(name, '/') != NULL) {
if (vstrchr(name, '/')) {
insert = 0;
/* prevent FPATH search below */
flags &= ~FC_FUNC;
@ -946,7 +946,7 @@ search(const char *name, const char *lpath,
if (errnop)
*errnop = 0;
if (strchr(name, '/')) {
if (vstrchr(name, '/')) {
if (search_access(name, mode, errnop) == 0)
return (name);
return NULL;
@ -958,7 +958,7 @@ search(const char *name, const char *lpath,
sp = lpath;
while (sp != NULL) {
xp = Xstring(xs, xp);
if (!(p = strchr(sp, ':')))
if (!(p = cstrchr(sp, ':')))
p = sp + strlen(sp);
if (p != sp) {
XcheckN(xs, xp, p - sp);