Use upstream style macro/function names
modified: edit.c modified: eval.c modified: exec.c modified: main.c modified: misc.c modified: sh.h
This commit is contained in:
parent
2c5474b326
commit
4c61aeebe5
18
edit.c
18
edit.c
@ -251,7 +251,7 @@ x_print_expansions(int nwords, char * const *words, bool is_command)
|
|||||||
break;
|
break;
|
||||||
/* All in same directory? */
|
/* All in same directory? */
|
||||||
if (i == nwords) {
|
if (i == nwords) {
|
||||||
while (prefix_len > 0 && !IS_DIR_SEP(words[0][prefix_len - 1]))
|
while (prefix_len > 0 && !mksh_dirsep(words[0][prefix_len - 1]))
|
||||||
prefix_len--;
|
prefix_len--;
|
||||||
use_copy = true;
|
use_copy = true;
|
||||||
XPinit(l, nwords + 1);
|
XPinit(l, nwords + 1);
|
||||||
@ -327,7 +327,7 @@ x_glob_hlp_tilde_and_rem_qchar(char *s, bool magic_flag)
|
|||||||
* and if so, discern "~foo/bar" and "~/baz" from "~blah";
|
* and if so, discern "~foo/bar" and "~/baz" from "~blah";
|
||||||
* if we have a directory part (the former), try to expand
|
* if we have a directory part (the former), try to expand
|
||||||
*/
|
*/
|
||||||
if (*s == '~' && (cp = ksh_strchr_dirsep(s)) != NULL) {
|
if (*s == '~' && (cp = mksh_strchr_dirsep(s)) != NULL) {
|
||||||
/* ok, so split into "~foo"/"bar" or "~"/"baz" */
|
/* ok, so split into "~foo"/"bar" or "~"/"baz" */
|
||||||
*cp++ = 0;
|
*cp++ = 0;
|
||||||
/* try to expand the tilde */
|
/* try to expand the tilde */
|
||||||
@ -577,7 +577,7 @@ x_locate_word(const char *buf, int buflen, int pos, int *startp,
|
|||||||
* like file globbing.
|
* like file globbing.
|
||||||
*/
|
*/
|
||||||
for (p = start; p < end; p++)
|
for (p = start; p < end; p++)
|
||||||
if (IS_DIR_SEP(buf[p]))
|
if (mksh_dirsep(buf[p]))
|
||||||
break;
|
break;
|
||||||
iscmd = p == end;
|
iscmd = p == end;
|
||||||
}
|
}
|
||||||
@ -641,7 +641,7 @@ x_cf_glob(int *flagsp, const char *buf, int buflen, int pos, int *startp,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*toglob == '~' && !ksh_vstrchr_dirsep(toglob)) {
|
if (*toglob == '~' && !mksh_vstrchr_dirsep(toglob)) {
|
||||||
/* neither for '~foo' (but '~foo/bar') */
|
/* neither for '~foo' (but '~foo/bar') */
|
||||||
*flagsp |= XCF_IS_NOSPACE;
|
*flagsp |= XCF_IS_NOSPACE;
|
||||||
goto dont_add_glob;
|
goto dont_add_glob;
|
||||||
@ -731,11 +731,11 @@ x_basename(const char *s, const char *se)
|
|||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
/* Skip trailing slashes */
|
/* Skip trailing slashes */
|
||||||
for (p = se - 1; p > s && IS_DIR_SEP(*p); p--)
|
for (p = se - 1; p > s && mksh_dirsep(*p); p--)
|
||||||
;
|
;
|
||||||
for (; p > s && !IS_DIR_SEP(*p); p--)
|
for (; p > s && !mksh_dirsep(*p); p--)
|
||||||
;
|
;
|
||||||
if (IS_DIR_SEP(*p) && p + 1 < se)
|
if (mksh_dirsep(*p) && p + 1 < se)
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
return (p - s);
|
return (p - s);
|
||||||
@ -2800,7 +2800,7 @@ do_complete(
|
|||||||
* append a space if this is a single non-directory match
|
* append a space if this is a single non-directory match
|
||||||
* and not a parameter or homedir substitution
|
* and not a parameter or homedir substitution
|
||||||
*/
|
*/
|
||||||
if (nwords == 1 && !IS_DIR_SEP(words[0][nlen - 1]) &&
|
if (nwords == 1 && !mksh_dirsep(words[0][nlen - 1]) &&
|
||||||
!(flags & XCF_IS_NOSPACE)) {
|
!(flags & XCF_IS_NOSPACE)) {
|
||||||
x_ins(" ");
|
x_ins(" ");
|
||||||
}
|
}
|
||||||
@ -5443,7 +5443,7 @@ complete_word(int cmd, int count)
|
|||||||
* append a space if this is a non-directory match
|
* append a space if this is a non-directory match
|
||||||
* and not a parameter or homedir substitution
|
* and not a parameter or homedir substitution
|
||||||
*/
|
*/
|
||||||
if (match_len > 0 && !IS_DIR_SEP(match[match_len - 1]) &&
|
if (match_len > 0 && !mksh_dirsep(match[match_len - 1]) &&
|
||||||
!(flags & XCF_IS_NOSPACE))
|
!(flags & XCF_IS_NOSPACE))
|
||||||
rval = putbuf(" ", 1, false);
|
rval = putbuf(" ", 1, false);
|
||||||
}
|
}
|
||||||
|
10
eval.c
10
eval.c
@ -1535,7 +1535,7 @@ globit(XString *xs, /* dest string */
|
|||||||
* SunOS 4.1.3 does this...
|
* SunOS 4.1.3 does this...
|
||||||
*/
|
*/
|
||||||
if ((check & GF_EXCHECK) && xp > Xstring(*xs, xp) &&
|
if ((check & GF_EXCHECK) && xp > Xstring(*xs, xp) &&
|
||||||
IS_DIR_SEP(xp[-1]) && !S_ISDIR(lstatb.st_mode) &&
|
mksh_dirsep(xp[-1]) && !S_ISDIR(lstatb.st_mode) &&
|
||||||
(!S_ISLNK(lstatb.st_mode) ||
|
(!S_ISLNK(lstatb.st_mode) ||
|
||||||
stat_check() < 0 || !S_ISDIR(statb.st_mode)))
|
stat_check() < 0 || !S_ISDIR(statb.st_mode)))
|
||||||
return;
|
return;
|
||||||
@ -1545,7 +1545,7 @@ globit(XString *xs, /* dest string */
|
|||||||
* directory
|
* directory
|
||||||
*/
|
*/
|
||||||
if (((check & GF_MARKDIR) && (check & GF_GLOBBED)) &&
|
if (((check & GF_MARKDIR) && (check & GF_GLOBBED)) &&
|
||||||
xp > Xstring(*xs, xp) && !IS_DIR_SEP(xp[-1]) &&
|
xp > Xstring(*xs, xp) && !mksh_dirsep(xp[-1]) &&
|
||||||
(S_ISDIR(lstatb.st_mode) ||
|
(S_ISDIR(lstatb.st_mode) ||
|
||||||
(S_ISLNK(lstatb.st_mode) && stat_check() > 0 &&
|
(S_ISLNK(lstatb.st_mode) && stat_check() > 0 &&
|
||||||
S_ISDIR(statb.st_mode)))) {
|
S_ISDIR(statb.st_mode)))) {
|
||||||
@ -1560,11 +1560,11 @@ globit(XString *xs, /* dest string */
|
|||||||
|
|
||||||
if (xp > Xstring(*xs, xp))
|
if (xp > Xstring(*xs, xp))
|
||||||
*xp++ = '/';
|
*xp++ = '/';
|
||||||
while (IS_DIR_SEP(*sp)) {
|
while (mksh_dirsep(*sp)) {
|
||||||
Xcheck(*xs, xp);
|
Xcheck(*xs, xp);
|
||||||
*xp++ = *sp++;
|
*xp++ = *sp++;
|
||||||
}
|
}
|
||||||
np = ksh_strchr_dirsep(sp);
|
np = mksh_strchr_dirsep(sp);
|
||||||
if (np != NULL) {
|
if (np != NULL) {
|
||||||
se = np;
|
se = np;
|
||||||
/* don't assume '/', can be multiple kinds */
|
/* don't assume '/', can be multiple kinds */
|
||||||
@ -1672,7 +1672,7 @@ maybe_expand_tilde(const char *p, XString *dsp, char **dpp, bool isassign)
|
|||||||
|
|
||||||
Xinit(ts, tp, 16, ATEMP);
|
Xinit(ts, tp, 16, ATEMP);
|
||||||
/* : only for DOASNTILDE form */
|
/* : only for DOASNTILDE form */
|
||||||
while (p[0] == CHAR && !IS_DIR_SEP(p[1]) && (!isassign || p[1] != ':'))
|
while (p[0] == CHAR && !mksh_dirsep(p[1]) && (!isassign || p[1] != ':'))
|
||||||
{
|
{
|
||||||
Xcheck(ts, tp);
|
Xcheck(ts, tp);
|
||||||
*tp++ = p[1];
|
*tp++ = p[1];
|
||||||
|
8
exec.c
8
exec.c
@ -703,7 +703,7 @@ comexec(struct op *t, struct tbl * volatile tp, const char **ap,
|
|||||||
rv = subst_exstat;
|
rv = subst_exstat;
|
||||||
goto Leave;
|
goto Leave;
|
||||||
} else if (!tp) {
|
} else if (!tp) {
|
||||||
if (Flag(FRESTRICTED) && ksh_vstrchr_dirsep(cp)) {
|
if (Flag(FRESTRICTED) && mksh_vstrchr_dirsep(cp)) {
|
||||||
warningf(true, "%s: %s", cp, "restricted");
|
warningf(true, "%s: %s", cp, "restricted");
|
||||||
rv = 1;
|
rv = 1;
|
||||||
goto Leave;
|
goto Leave;
|
||||||
@ -993,7 +993,7 @@ scriptexec(struct op *tp, const char **ap)
|
|||||||
* Search shell/interpreter name without directory in PATH
|
* Search shell/interpreter name without directory in PATH
|
||||||
* if specified path does not exist
|
* if specified path does not exist
|
||||||
*/
|
*/
|
||||||
if (ksh_vstrchr_dirsep(sh) && !search_path(sh, path, X_OK, NULL)) {
|
if (mksh_vstrchr_dirsep(sh) && !search_path(sh, path, X_OK, NULL)) {
|
||||||
cp = search_path(_getname(sh), path, X_OK, NULL);
|
cp = search_path(_getname(sh), path, X_OK, NULL);
|
||||||
if (cp)
|
if (cp)
|
||||||
sh = cp;
|
sh = cp;
|
||||||
@ -1183,7 +1183,7 @@ findcom(const char *name, int flags)
|
|||||||
char *fpath;
|
char *fpath;
|
||||||
union mksh_cchack npath;
|
union mksh_cchack npath;
|
||||||
|
|
||||||
if (ksh_vstrchr_dirsep(name)) {
|
if (mksh_vstrchr_dirsep(name)) {
|
||||||
insert = 0;
|
insert = 0;
|
||||||
/* prevent FPATH search below */
|
/* prevent FPATH search below */
|
||||||
flags &= ~FC_FUNC;
|
flags &= ~FC_FUNC;
|
||||||
@ -1330,7 +1330,7 @@ search_path(const char *name, const char *lpath,
|
|||||||
size_t namelen;
|
size_t namelen;
|
||||||
int ec = 0, ev;
|
int ec = 0, ev;
|
||||||
|
|
||||||
if (ksh_vstrchr_dirsep(name)) {
|
if (mksh_vstrchr_dirsep(name)) {
|
||||||
if ((ec = search_access(name, mode)) == 0) {
|
if ((ec = search_access(name, mode)) == 0) {
|
||||||
search_path_ok:
|
search_path_ok:
|
||||||
if (errnop)
|
if (errnop)
|
||||||
|
2
main.c
2
main.c
@ -225,7 +225,7 @@ main_init(int argc, const char *argv[], Source **sp, struct block **lp)
|
|||||||
ccp = kshname;
|
ccp = kshname;
|
||||||
goto begin_parse_kshname;
|
goto begin_parse_kshname;
|
||||||
while ((i = ccp[argi++])) {
|
while ((i = ccp[argi++])) {
|
||||||
if (IS_DIR_SEP(i)) {
|
if (mksh_dirsep(i)) {
|
||||||
ccp += argi;
|
ccp += argi;
|
||||||
begin_parse_kshname:
|
begin_parse_kshname:
|
||||||
argi = 0;
|
argi = 0;
|
||||||
|
28
misc.c
28
misc.c
@ -387,7 +387,7 @@ parse_args(const char **argv,
|
|||||||
*/
|
*/
|
||||||
if (*p != '-')
|
if (*p != '-')
|
||||||
for (q = p; *q; )
|
for (q = p; *q; )
|
||||||
if (IS_DIR_SEP(*q++))
|
if (mksh_dirsep(*q++))
|
||||||
p = q;
|
p = q;
|
||||||
Flag(FLOGIN) = (*p == '-');
|
Flag(FLOGIN) = (*p == '-');
|
||||||
opts = cmd_opts;
|
opts = cmd_opts;
|
||||||
@ -1440,14 +1440,14 @@ do_realpath(const char *upath)
|
|||||||
|
|
||||||
while (*ip) {
|
while (*ip) {
|
||||||
/* skip slashes in input */
|
/* skip slashes in input */
|
||||||
while (IS_DIR_SEP(*ip))
|
while (mksh_dirsep(*ip))
|
||||||
++ip;
|
++ip;
|
||||||
if (!*ip)
|
if (!*ip)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* get next pathname component from input */
|
/* get next pathname component from input */
|
||||||
tp = ip;
|
tp = ip;
|
||||||
while (*ip && !IS_DIR_SEP(*ip))
|
while (*ip && !mksh_dirsep(*ip))
|
||||||
++ip;
|
++ip;
|
||||||
len = ip - tp;
|
len = ip - tp;
|
||||||
|
|
||||||
@ -1459,7 +1459,7 @@ do_realpath(const char *upath)
|
|||||||
else if (len == 2 && tp[1] == '.') {
|
else if (len == 2 && tp[1] == '.') {
|
||||||
/* strip off last pathname component */
|
/* strip off last pathname component */
|
||||||
while (xp > Xstring(xs, xp))
|
while (xp > Xstring(xs, xp))
|
||||||
if (IS_DIR_SEP(*--xp))
|
if (mksh_dirsep(*--xp))
|
||||||
break;
|
break;
|
||||||
/* then continue with the next one */
|
/* then continue with the next one */
|
||||||
continue;
|
continue;
|
||||||
@ -1482,7 +1482,7 @@ do_realpath(const char *upath)
|
|||||||
/* lstat failed */
|
/* lstat failed */
|
||||||
if (errno == ENOENT) {
|
if (errno == ENOENT) {
|
||||||
/* because the pathname does not exist */
|
/* because the pathname does not exist */
|
||||||
while (IS_DIR_SEP(*ip))
|
while (mksh_dirsep(*ip))
|
||||||
/* skip any trailing slashes */
|
/* skip any trailing slashes */
|
||||||
++ip;
|
++ip;
|
||||||
/* no more components left? */
|
/* no more components left? */
|
||||||
@ -1542,7 +1542,7 @@ do_realpath(const char *upath)
|
|||||||
/* assert: xp == xs.beg => start of path */
|
/* assert: xp == xs.beg => start of path */
|
||||||
|
|
||||||
/* exactly two leading slashes? (SUSv4 3.266) */
|
/* exactly two leading slashes? (SUSv4 3.266) */
|
||||||
if (IS_DIR_SEP(ip[1]) && !IS_DIR_SEP(ip[2])) {
|
if (mksh_dirsep(ip[1]) && !mksh_dirsep(ip[2])) {
|
||||||
/* keep them, e.g. for UNC pathnames */
|
/* keep them, e.g. for UNC pathnames */
|
||||||
Xput(xs, xp, '/');
|
Xput(xs, xp, '/');
|
||||||
}
|
}
|
||||||
@ -1567,7 +1567,7 @@ do_realpath(const char *upath)
|
|||||||
* if source path had a trailing slash, check if target path
|
* if source path had a trailing slash, check if target path
|
||||||
* is not a non-directory existing file
|
* is not a non-directory existing file
|
||||||
*/
|
*/
|
||||||
if (ip > ipath && IS_DIR_SEP(ip[-1])) {
|
if (ip > ipath && mksh_dirsep(ip[-1])) {
|
||||||
if (stat(Xstring(xs, xp), &sb)) {
|
if (stat(Xstring(xs, xp), &sb)) {
|
||||||
if (errno != ENOENT)
|
if (errno != ENOENT)
|
||||||
goto notfound;
|
goto notfound;
|
||||||
@ -1638,7 +1638,7 @@ make_path(const char *cwd, const char *file,
|
|||||||
|
|
||||||
if (c == '.')
|
if (c == '.')
|
||||||
c = file[2];
|
c = file[2];
|
||||||
if (IS_DIR_SEP(c) || c == '\0')
|
if (mksh_dirsep(c) || c == '\0')
|
||||||
use_cdpath = false;
|
use_cdpath = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1660,7 +1660,7 @@ make_path(const char *cwd, const char *file,
|
|||||||
XcheckN(*xsp, xp, len);
|
XcheckN(*xsp, xp, len);
|
||||||
memcpy(xp, cwd, len);
|
memcpy(xp, cwd, len);
|
||||||
xp += len;
|
xp += len;
|
||||||
if (!IS_DIR_SEP(cwd[len - 1]))
|
if (!mksh_dirsep(cwd[len - 1]))
|
||||||
Xput(*xsp, xp, '/');
|
Xput(*xsp, xp, '/');
|
||||||
}
|
}
|
||||||
*phys_pathp = Xlength(*xsp, xp);
|
*phys_pathp = Xlength(*xsp, xp);
|
||||||
@ -1668,7 +1668,7 @@ make_path(const char *cwd, const char *file,
|
|||||||
XcheckN(*xsp, xp, plen);
|
XcheckN(*xsp, xp, plen);
|
||||||
memcpy(xp, plist, plen);
|
memcpy(xp, plist, plen);
|
||||||
xp += plen;
|
xp += plen;
|
||||||
if (!IS_DIR_SEP(plist[plen - 1]))
|
if (!mksh_dirsep(plist[plen - 1]))
|
||||||
Xput(*xsp, xp, '/');
|
Xput(*xsp, xp, '/');
|
||||||
rval = 1;
|
rval = 1;
|
||||||
}
|
}
|
||||||
@ -1713,7 +1713,7 @@ simplify_path(char *p)
|
|||||||
case '\\':
|
case '\\':
|
||||||
#endif
|
#endif
|
||||||
/* exactly two leading slashes? (SUSv4 3.266) */
|
/* exactly two leading slashes? (SUSv4 3.266) */
|
||||||
if (IS_DIR_SEP(p[1]) && !IS_DIR_SEP(p[2]))
|
if (mksh_dirsep(p[1]) && !mksh_dirsep(p[2]))
|
||||||
/* keep them, e.g. for UNC pathnames */
|
/* keep them, e.g. for UNC pathnames */
|
||||||
++p;
|
++p;
|
||||||
needslash = true;
|
needslash = true;
|
||||||
@ -1725,14 +1725,14 @@ simplify_path(char *p)
|
|||||||
|
|
||||||
while (*ip) {
|
while (*ip) {
|
||||||
/* skip slashes in input */
|
/* skip slashes in input */
|
||||||
while (IS_DIR_SEP(*ip))
|
while (mksh_dirsep(*ip))
|
||||||
++ip;
|
++ip;
|
||||||
if (!*ip)
|
if (!*ip)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* get next pathname component from input */
|
/* get next pathname component from input */
|
||||||
tp = ip;
|
tp = ip;
|
||||||
while (*ip && !IS_DIR_SEP(*ip))
|
while (*ip && !mksh_dirsep(*ip))
|
||||||
++ip;
|
++ip;
|
||||||
len = ip - tp;
|
len = ip - tp;
|
||||||
|
|
||||||
@ -1752,7 +1752,7 @@ simplify_path(char *p)
|
|||||||
strip_last_component:
|
strip_last_component:
|
||||||
/* strip off last pathname component */
|
/* strip off last pathname component */
|
||||||
while (dp > sp)
|
while (dp > sp)
|
||||||
if (IS_DIR_SEP(*--dp))
|
if (mksh_dirsep(*--dp))
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
/* relative path, at its beginning */
|
/* relative path, at its beginning */
|
||||||
|
68
sh.h
68
sh.h
@ -302,42 +302,6 @@ struct rusage {
|
|||||||
} while (/* CONSTCOND */ 0)
|
} while (/* CONSTCOND */ 0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __OS2__
|
|
||||||
#define UNIXROOT "/@unixroot"
|
|
||||||
#define PATH_SEP ';'
|
|
||||||
#define PATH_SEP_STR ";"
|
|
||||||
#define IS_DIR_SEP(c) ({ \
|
|
||||||
char _ch_ = (c); \
|
|
||||||
(_ch_ == '/' || _ch_ == '\\'); \
|
|
||||||
})
|
|
||||||
#define IS_ABS_PATH(x) ({ \
|
|
||||||
const char *_p_ = (x); \
|
|
||||||
((ksh_isalphx(_p_[0]) && _p_[1] == ':') || IS_DIR_SEP(_p_[0])); \
|
|
||||||
})
|
|
||||||
#define ksh_strchr_dirsep(s) ({ \
|
|
||||||
const char *_p_ = (s); \
|
|
||||||
const char *_p1_ = strchr(_p_, '/'); \
|
|
||||||
const char *_p2_ = strchr(_p_, '\\'); \
|
|
||||||
const char *_p3_ = ((ksh_isalphx(_p_[0]) && _p_[1] == ':') \
|
|
||||||
? (_p_ + 1) : NULL ); \
|
|
||||||
_p1_ = _p1_ > _p2_ ? _p1_ : _p2_; \
|
|
||||||
((char *)(_p1_ > _p3_ ? _p1_ : _p3_)); \
|
|
||||||
})
|
|
||||||
#define ksh_vstrchr_dirsep(s) ({ \
|
|
||||||
const char *_p_ = (s); \
|
|
||||||
(vstrchr((_p_), '/') || vstrchr((_p_), '\\') || \
|
|
||||||
(ksh_isalphx(_p_[0]) && _p_[1] == ':')); \
|
|
||||||
})
|
|
||||||
#else
|
|
||||||
#define UNIXROOT ""
|
|
||||||
#define PATH_SEP ':'
|
|
||||||
#define PATH_SEP_STR ":"
|
|
||||||
#define IS_DIR_SEP(c) ((c) == '/')
|
|
||||||
#define IS_ABS_PATH(x) (IS_DIR_SEP((x)[0]))
|
|
||||||
#define ksh_strchr_dirsep(s) (strchr((s), '/'))
|
|
||||||
#define ksh_vstrchr_dirsep(s) (vstrchr((s), '/'))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef MKSH__NO_PATH_MAX
|
#ifdef MKSH__NO_PATH_MAX
|
||||||
#undef PATH_MAX
|
#undef PATH_MAX
|
||||||
#else
|
#else
|
||||||
@ -1109,7 +1073,7 @@ EXTERN mksh_ari_t x_lins E_INIT(24); /* tty lines */
|
|||||||
#if defined(ANDROID)
|
#if defined(ANDROID)
|
||||||
#define MKSH_DEFAULT_PROFILEDIR "/system/etc"
|
#define MKSH_DEFAULT_PROFILEDIR "/system/etc"
|
||||||
#else
|
#else
|
||||||
#define MKSH_DEFAULT_PROFILEDIR UNIXROOT "/etc"
|
#define MKSH_DEFAULT_PROFILEDIR MKSH_UNIXROOT "/etc"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -2156,13 +2120,41 @@ extern int tty_init_fd(void); /* initialise tty_fd, tty_devtty */
|
|||||||
})
|
})
|
||||||
#define mksh_abspath(s) __extension__({ \
|
#define mksh_abspath(s) __extension__({ \
|
||||||
const char *mksh_abspath_s = (s); \
|
const char *mksh_abspath_s = (s); \
|
||||||
(mksh_abspath_s[0] == '/' || (ksh_isalphx(mksh_abspath_s[0]) && \
|
(mksh_dirsep(mksh_abspath_s[0]) || (ksh_isalphx(mksh_abspath_s[0]) && \
|
||||||
mksh_abspath_s[1] == ':')); \
|
mksh_abspath_s[1] == ':')); \
|
||||||
})
|
})
|
||||||
|
#define mksh_dirsep(c) __extension__({ \
|
||||||
|
char mksh_dirsep_c = (c); \
|
||||||
|
(mksh_dirsep_c == '/' || mksh_dirsep_c == '\\'); \
|
||||||
|
})
|
||||||
|
#define mksh_strchr_dirsep(s) __extension__({ \
|
||||||
|
const char *mksh_strchr_dirsep_p = (s); \
|
||||||
|
const char *mksh_strchr_dirsep_p1 = strchr(mksh_strchr_dirsep_p, '/'); \
|
||||||
|
const char *mksh_strchr_dirsep_p2 = strchr(mksh_strchr_dirsep_p, '\\'); \
|
||||||
|
const char *mksh_strchr_dirsep_p3 = \
|
||||||
|
((ksh_isalphx(mksh_strchr_dirsep_p[0]) && \
|
||||||
|
mksh_strchr_dirsep_p[1] == ':') \
|
||||||
|
? (mksh_strchr_dirsep_p + 1) : NULL ); \
|
||||||
|
mksh_strchr_dirsep_p1 = mksh_strchr_dirsep_p1 > mksh_strchr_dirsep_p2 ? \
|
||||||
|
mksh_strchr_dirsep_p1 : mksh_strchr_dirsep_p2; \
|
||||||
|
((char *)(mksh_strchr_dirsep_p1 > mksh_strchr_dirsep_p3 ? \
|
||||||
|
mksh_strchr_dirsep_p1 : mksh_strchr_dirsep_p3)); \
|
||||||
|
})
|
||||||
|
#define mksh_vstrchr_dirsep(s) __extension__({ \
|
||||||
|
const char *mksh_vstrchr_dirsep_p = (s); \
|
||||||
|
(vstrchr((mksh_vstrchr_dirsep_p), '/') || \
|
||||||
|
vstrchr((mksh_vstrchr_dirsep_p), '\\') || \
|
||||||
|
(ksh_isalphx(mksh_vstrchr_dirsep_p[0]) && \
|
||||||
|
mksh_vstrchr_dirsep_p[1] == ':')); \
|
||||||
|
})
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define binopen2(path,flags) open((path), (flags) | O_BINARY)
|
#define binopen2(path,flags) open((path), (flags) | O_BINARY)
|
||||||
#define binopen3(path,flags,mode) open((path), (flags) | O_BINARY, (mode))
|
#define binopen3(path,flags,mode) open((path), (flags) | O_BINARY, (mode))
|
||||||
#define mksh_abspath(s) ((s)[0] == '/')
|
#define mksh_abspath(s) ((s)[0] == '/')
|
||||||
|
#define mksh_dirsep(c) ((c) == '/')
|
||||||
|
#define mksh_strchr_dirsep(s) (strchr((s), '/'))
|
||||||
|
#define mksh_vstrchr_dirsep(s) (vstrchr((s), '/'))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* be sure not to interfere with anyone else's idea about EXTERN */
|
/* be sure not to interfere with anyone else's idea about EXTERN */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user