• 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

View File

@ -3,7 +3,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.44 2007/03/04 00:13:16 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.45 2007/03/04 03:04:25 tg Exp $");
Trap sigtraps[NSIG + 1];
static struct sigaction Sigact_ign, Sigact_trap;
@ -18,20 +18,20 @@ static void writehistfile(int, char *);
static int sprinkle(int);
#endif
static int hist_execute(char *);
static int hist_replace(char **, const char *, const char *, int);
static char **hist_get(const char *, int, int);
static char **hist_get_oldest(void);
static void histbackup(void);
static int hist_execute(char *);
static int hist_replace(char **, const char *, const char *, int);
static char **hist_get(const char *, int, int);
static char **hist_get_oldest(void);
static void histbackup(void);
static char **current; /* current position in history[] */
static int hstarted; /* set after hist_init() called */
static Source *hist_source;
static char **current; /* current position in history[] */
static int hstarted; /* set after hist_init() called */
static Source *hist_source;
#if HAVE_PERSISTENT_HISTORY
static char *hname; /* current name of history file */
static int histfd;
static int hsize;
static char *hname; /* current name of history file */
static int histfd;
static int hsize;
#endif
int
@ -56,7 +56,7 @@ c_fc(const char **wp)
switch (optc) {
case 'e':
p = builtin_opt.optarg;
if (strcmp(p, "-") == 0)
if (ksh_isdash(p))
sflag++;
else {
size_t len = strlen(p);