collective R54 release preparation multi-merger:

install both lksh and mksh manpages from Build.sh (Martijn Dekker)
spelling fixes (Larry Hynes)
manpage improvements (Martijn Dekker)
initial port to Harvey-OS’ APEX (Ronald G. Minnich, Elbing Miss, Álvaro Jurado)
more from komh’s OS/2 port (KO Myung-Hun)
This commit is contained in:
tg
2016-11-11 23:31:39 +00:00
parent 3aac3c30b5
commit 7b4bee7e58
13 changed files with 178 additions and 93 deletions

31
edit.c
View File

@ -28,7 +28,7 @@
#ifndef MKSH_NO_CMDLINE_EDITING
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.310 2016/11/11 21:13:21 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.311 2016/11/11 23:31:33 tg Exp $");
/*
* in later versions we might use libtermcap for this, but since external
@ -258,7 +258,8 @@ x_print_expansions(int nwords, char * const *words, bool is_command)
break;
/* All in same directory? */
if (i == nwords) {
while (prefix_len > 0 && words[0][prefix_len - 1] != '/')
while (prefix_len > 0 &&
!mksh_cdirsep(words[0][prefix_len - 1]))
prefix_len--;
use_copy = true;
XPinit(l, nwords + 1);
@ -338,7 +339,7 @@ x_glob_hlp_tilde_and_rem_qchar(char *s, bool magic_flag)
* and if so, discern "~foo/bar" and "~/baz" from "~blah";
* if we have a directory part (the former), try to expand
*/
if (*s == '~' && (cp = strchr(s, '/')) != NULL) {
if (*s == '~' && (cp = mksh_sdirsep(s)) != NULL) {
/* ok, so split into "~foo"/"bar" or "~"/"baz" */
*cp++ = 0;
/* try to expand the tilde */
@ -593,7 +594,7 @@ x_locate_word(const char *buf, int buflen, int pos, int *startp,
* like file globbing.
*/
for (p = start; p < end; p++)
if (buf[p] == '/')
if (mksh_cdirsep(buf[p]))
break;
iscmd = p == end;
}
@ -657,7 +658,7 @@ x_cf_glob(int *flagsp, const char *buf, int buflen, int pos, int *startp,
}
}
if (*toglob == '~' && !vstrchr(toglob, '/')) {
if (*toglob == '~' && !mksh_vdirsep(toglob)) {
/* neither for '~foo' (but '~foo/bar') */
*flagsp |= XCF_IS_NOSPACE;
goto dont_add_glob;
@ -746,13 +747,15 @@ x_basename(const char *s, const char *se)
if (s == se)
return (0);
/* Skip trailing slashes */
for (p = se - 1; p > s && *p == '/'; p--)
;
for (; p > s && *p != '/'; p--)
;
if (*p == '/' && p + 1 < se)
p++;
/* skip trailing directory separators */
p = se - 1;
while (p > s && mksh_cdirsep(*p))
--p;
/* drop last component */
while (p > s && !mksh_cdirsep(*p))
--p;
if (mksh_cdirsep(*p) && p + 1 < se)
++p;
return (p - s);
}
@ -2783,7 +2786,7 @@ do_complete(
* append a space if this is a single non-directory match
* and not a parameter or homedir substitution
*/
if (nwords == 1 && words[0][nlen - 1] != '/' &&
if (nwords == 1 && !mksh_cdirsep(words[0][nlen - 1]) &&
!(flags & XCF_IS_NOSPACE)) {
x_ins(T1space);
}
@ -5404,7 +5407,7 @@ complete_word(int cmd, int count)
* append a space if this is a non-directory match
* and not a parameter or homedir substitution
*/
if (match_len > 0 && match[match_len - 1] != '/' &&
if (match_len > 0 && !mksh_cdirsep(match[match_len - 1]) &&
!(flags & XCF_IS_NOSPACE))
rval = putbuf(T1space, 1, false);
}