Consider OS/2-style path
OS/2 uses 'x:' as a drive prefix and '\' as a directory separator.
This commit is contained in:
18
edit.c
18
edit.c
@ -247,7 +247,7 @@ 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 && !IS_DIR_SEP(words[0][prefix_len - 1]))
|
||||
prefix_len--;
|
||||
use_copy = true;
|
||||
XPinit(l, nwords + 1);
|
||||
@ -323,7 +323,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 = ksh_strchr_dirsep(s)) != NULL) {
|
||||
/* ok, so split into "~foo"/"bar" or "~"/"baz" */
|
||||
*cp++ = 0;
|
||||
/* try to expand the tilde */
|
||||
@ -573,7 +573,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 (IS_DIR_SEP(buf[p]))
|
||||
break;
|
||||
iscmd = p == end;
|
||||
}
|
||||
@ -637,7 +637,7 @@ x_cf_glob(int *flagsp, const char *buf, int buflen, int pos, int *startp,
|
||||
}
|
||||
}
|
||||
|
||||
if (*toglob == '~' && !vstrchr(toglob, '/')) {
|
||||
if (*toglob == '~' && !ksh_vstrchr_dirsep(toglob)) {
|
||||
/* neither for '~foo' (but '~foo/bar') */
|
||||
*flagsp |= XCF_IS_NOSPACE;
|
||||
goto dont_add_glob;
|
||||
@ -727,11 +727,11 @@ x_basename(const char *s, const char *se)
|
||||
return (0);
|
||||
|
||||
/* Skip trailing slashes */
|
||||
for (p = se - 1; p > s && *p == '/'; p--)
|
||||
for (p = se - 1; p > s && IS_DIR_SEP(*p); p--)
|
||||
;
|
||||
for (; p > s && *p != '/'; p--)
|
||||
for (; p > s && !IS_DIR_SEP(*p); p--)
|
||||
;
|
||||
if (*p == '/' && p + 1 < se)
|
||||
if (IS_DIR_SEP(*p) && p + 1 < se)
|
||||
p++;
|
||||
|
||||
return (p - s);
|
||||
@ -2768,7 +2768,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 && !IS_DIR_SEP(words[0][nlen - 1]) &&
|
||||
!(flags & XCF_IS_NOSPACE)) {
|
||||
x_ins(" ");
|
||||
}
|
||||
@ -5381,7 +5381,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 && !IS_DIR_SEP(match[match_len - 1]) &&
|
||||
!(flags & XCF_IS_NOSPACE))
|
||||
rval = putbuf(" ", 1, false);
|
||||
}
|
||||
|
Reference in New Issue
Block a user