diff options
author | mp <mp@FreeBSD.org> | 2004-07-11 02:17:56 +0000 |
---|---|---|
committer | mp <mp@FreeBSD.org> | 2004-07-11 02:17:56 +0000 |
commit | bbd1addf8f9452690ad13ce5b875ee4cc9633958 (patch) | |
tree | 730792f0cc19f3bb4fb663fe727589381f5901be /contrib/tcsh/tw.parse.c | |
parent | f2c2aa29b7d05c53575ab7ce4dc5870fd33a1310 (diff) | |
download | FreeBSD-src-bbd1addf8f9452690ad13ce5b875ee4cc9633958.zip FreeBSD-src-bbd1addf8f9452690ad13ce5b875ee4cc9633958.tar.gz |
Import of tcsh-6.13.00
Diffstat (limited to 'contrib/tcsh/tw.parse.c')
-rw-r--r-- | contrib/tcsh/tw.parse.c | 62 |
1 files changed, 38 insertions, 24 deletions
diff --git a/contrib/tcsh/tw.parse.c b/contrib/tcsh/tw.parse.c index 7bec5be..dd6dedc 100644 --- a/contrib/tcsh/tw.parse.c +++ b/contrib/tcsh/tw.parse.c @@ -1,4 +1,4 @@ -/* $Header: /src/pub/tcsh/tw.parse.c,v 3.92 2002/06/25 19:02:12 christos Exp $ */ +/* $Header: /src/pub/tcsh/tw.parse.c,v 3.96 2004/01/23 16:21:33 christos Exp $ */ /* * tw.parse.c: Everyone has taken a shot in this futile effort to * lexically analyze a csh line... Well we cannot good @@ -35,7 +35,7 @@ */ #include "sh.h" -RCSID("$Id: tw.parse.c,v 3.92 2002/06/25 19:02:12 christos Exp $") +RCSID("$Id: tw.parse.c,v 3.96 2004/01/23 16:21:33 christos Exp $") #include "tw.h" #include "ed.h" @@ -115,7 +115,8 @@ static int c_glob __P((Char ***)); static int is_prefix __P((Char *, Char *)); static int is_prefixmatch __P((Char *, Char *, int)); static int is_suffix __P((Char *, Char *)); -static int recognize __P((Char *, Char *, int, int, int)); +static int recognize __P((Char *, Char *, int, int, int, + int)); static int ignored __P((Char *)); static int isadirectory __P((Char *, Char *)); #ifndef __MVS__ @@ -813,29 +814,19 @@ starting_a_command(wordstart, inputline) * If we shorten it back to the prefix length, stop searching. */ static int -recognize(exp_name, item, name_length, numitems, enhanced) +recognize(exp_name, item, name_length, numitems, enhanced, igncase) Char *exp_name, *item; - int name_length, numitems, enhanced; + int name_length, numitems, enhanced, igncase; { Char MCH1, MCH2; register Char *x, *ent; register int len = 0; -#ifdef WINNT_NATIVE - struct varent *vp; - int igncase; - igncase = (vp = adrof(STRcomplete)) != NULL && vp->vec != NULL && - Strcmp(*(vp->vec), STRigncase) == 0; -#endif /* WINNT_NATIVE */ if (numitems == 1) { /* 1st match */ copyn(exp_name, item, MAXNAMLEN); return (0); } - if (!enhanced -#ifdef WINNT_NATIVE - && !igncase -#endif /* WINNT_NATIVE */ - ) { + if (!enhanced && !igncase) { for (x = exp_name, ent = item; *x && (*x & TRIM) == (*ent & TRIM); x++, ent++) len++; } else { @@ -890,7 +881,7 @@ tw_collect_items(command, looking, exp_dir, exp_name, target, pat, flags) Char *item, *ptr; Char buf[MAXPATHLEN+1]; struct varent *vp; - int len, enhanced; + int len, enhanced = 0; int cnt = 0; int igncase = 0; @@ -929,6 +920,23 @@ tw_collect_items(command, looking, exp_dir, exp_name, target, pat, flags) break; case TW_COMMAND: +#if defined(_UWIN) || defined(__CYGWIN__) + /* Turn foo.{exe,com,bat} into foo since UWIN's readdir returns + * the file with the .exe, .com, .bat extension + */ + { + size_t ext = strlen((char *)item) - 4; + if ((ext > 0) && (strcasecmp((char *)&item[ext], ".exe") == 0 || + strcasecmp((char *)&item[ext], ".bat") == 0 || + strcasecmp((char *)&item[ext], ".com") == 0)) + { + item[ext] = '\0'; +#if defined(__CYGWIN__) + strlwr((char *)item); +#endif /* __CYGWIN__ */ + } + } +#endif /* _UWIN || __CYGWIN__ */ exec_check = flags & TW_EXEC_CHK; dir_ok = flags & TW_DIR_OK; break; @@ -988,11 +996,16 @@ tw_collect_items(command, looking, exp_dir, exp_name, target, pat, flags) case RECOGNIZE_ALL: case RECOGNIZE_SCROLL: -#ifdef WINNT_NATIVE - igncase = (vp = adrof(STRcomplete)) != NULL && vp->vec != NULL && - Strcmp(*(vp->vec), STRigncase) == 0; -#endif /* WINNT_NATIVE */ - enhanced = (vp = adrof(STRcomplete)) != NULL && !Strcmp(*(vp->vec),STRenhance); + if ((vp = adrof(STRcomplete)) != NULL && vp->vec != NULL) { + Char **cp; + for (cp = vp->vec; *cp; cp++) { + if (Strcmp(*cp, STRigncase) == 0) + igncase = 1; + if (Strcmp(*cp, STRenhance) == 0) + enhanced = 1; + } + } + if (enhanced || igncase) { if (!is_prefixmatch(target, item, igncase)) break; @@ -1077,7 +1090,8 @@ tw_collect_items(command, looking, exp_dir, exp_name, target, pat, flags) break; } } - if (recognize(exp_name, item, name_length, ++numitems, enhanced)) + if (recognize(exp_name, item, name_length, ++numitems, + enhanced, igncase)) if (command != RECOGNIZE_SCROLL) done = TRUE; if (enhanced && (int)Strlen(exp_name) < name_length) @@ -2092,7 +2106,7 @@ print_by_column(dir, items, count, no_file_suffix) } else { /* Print filename followed by '/' or '*' or ' ' */ - xprintf("%S%c", items[i], + xprintf("\045S%c", items[i], filetype(dir, items[i])); w++; } |