mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-11 19:49:15 +08:00
* path.cc: Translate scan states from defines to enums.
(suffix_scan): Rename state to nextstate for clarity. (lnk_match): Change to allow multiple states to indicate that a .lnk has been matched. (suffix_scan::has): Eliminate a goto. Handle .lnk as a special case, since a .lnk may also need to be tacked on the end of a .lnk. (suffix_scan::next): Don't increment next state. Set it specifically. Recognize new .lnk states.
This commit is contained in:
parent
5ccbf4b699
commit
b65c6896c8
@ -1,3 +1,14 @@
|
|||||||
|
Fri Mar 16 20:25:40 2001 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
|
* path.cc: Translate scan states from defines to enums.
|
||||||
|
(suffix_scan): Rename state to nextstate for clarity.
|
||||||
|
(lnk_match): Change to allow multiple states to indicate that a .lnk
|
||||||
|
has been matched.
|
||||||
|
(suffix_scan::has): Eliminate a goto. Handle .lnk as a special case,
|
||||||
|
since a .lnk may also need to be tacked on the end of a .lnk.
|
||||||
|
(suffix_scan::next): Don't increment next state. Set it specifically.
|
||||||
|
Recognize new .lnk states.
|
||||||
|
|
||||||
aturday Mar 17 01:19 2001 Robert Collins rbtcollins@hotmail.com
|
aturday Mar 17 01:19 2001 Robert Collins rbtcollins@hotmail.com
|
||||||
|
|
||||||
* cygwin.din: Export the new functions.
|
* cygwin.din: Export the new functions.
|
||||||
|
@ -2394,23 +2394,28 @@ check_sysfile (const char *path, DWORD fileattr, HANDLE h,
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SCAN_BEG 0
|
enum
|
||||||
#define SCAN_LNK 1
|
{
|
||||||
#define SCAN_TERM1 2
|
SCAN_BEG,
|
||||||
#define SCAN_JUSTCHECK 3
|
SCAN_LNK,
|
||||||
|
SCAN_HASLNK,
|
||||||
|
SCAN_JUSTCHECK,
|
||||||
|
SCAN_DONE,
|
||||||
|
SCAN_CHECKEDLNK,
|
||||||
|
SCAN_APPENDLNK,
|
||||||
|
};
|
||||||
|
|
||||||
class suffix_scan
|
class suffix_scan
|
||||||
{
|
{
|
||||||
char *ext_here;
|
char *ext_here;
|
||||||
const suffix_info *suffixes;
|
const suffix_info *suffixes;
|
||||||
int state;
|
int nextstate;
|
||||||
int lnk_state;
|
|
||||||
int nullterm;
|
int nullterm;
|
||||||
public:
|
public:
|
||||||
const char *path;
|
const char *path;
|
||||||
char *has (const char *, const suffix_info *, char **);
|
char *has (const char *, const suffix_info *, char **);
|
||||||
int next ();
|
int next ();
|
||||||
int lnk_match () {return lnk_state;}
|
int lnk_match () {return nextstate >= SCAN_CHECKEDLNK;}
|
||||||
};
|
};
|
||||||
|
|
||||||
char *
|
char *
|
||||||
@ -2419,8 +2424,7 @@ suffix_scan::has (const char *in_path, const suffix_info *in_suffixes, char **ex
|
|||||||
path = in_path;
|
path = in_path;
|
||||||
suffixes = in_suffixes;
|
suffixes = in_suffixes;
|
||||||
nullterm = 0;
|
nullterm = 0;
|
||||||
state = SCAN_BEG;
|
nextstate = SCAN_BEG;
|
||||||
lnk_state = 0;
|
|
||||||
ext_here = *ext_where = strrchr (in_path, '.');
|
ext_here = *ext_where = strrchr (in_path, '.');
|
||||||
if (ext_here)
|
if (ext_here)
|
||||||
{
|
{
|
||||||
@ -2430,7 +2434,7 @@ suffix_scan::has (const char *in_path, const suffix_info *in_suffixes, char **ex
|
|||||||
for (const suffix_info *ex = in_suffixes; ex->name != NULL; ex++)
|
for (const suffix_info *ex = in_suffixes; ex->name != NULL; ex++)
|
||||||
if (strcasematch (ext_here, ex->name))
|
if (strcasematch (ext_here, ex->name))
|
||||||
{
|
{
|
||||||
state = SCAN_JUSTCHECK;
|
nextstate = SCAN_JUSTCHECK;
|
||||||
suffixes = NULL; /* Has an extension so don't scan for one. */
|
suffixes = NULL; /* Has an extension so don't scan for one. */
|
||||||
return ext_here;
|
return ext_here;
|
||||||
}
|
}
|
||||||
@ -2438,7 +2442,7 @@ suffix_scan::has (const char *in_path, const suffix_info *in_suffixes, char **ex
|
|||||||
/* Didn't match. Use last resort -- .lnk. */
|
/* Didn't match. Use last resort -- .lnk. */
|
||||||
if (strcasematch (ext_here, ".lnk"))
|
if (strcasematch (ext_here, ".lnk"))
|
||||||
{
|
{
|
||||||
lnk_state = 1;
|
nextstate = SCAN_HASLNK;
|
||||||
suffixes = NULL;
|
suffixes = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2464,17 +2468,23 @@ suffix_scan::next ()
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
suffixes = NULL;
|
suffixes = NULL;
|
||||||
state++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (state++)
|
switch (nextstate)
|
||||||
{
|
{
|
||||||
case SCAN_LNK:
|
|
||||||
lnk_state = 1;
|
|
||||||
strcpy (ext_here, ".lnk");
|
|
||||||
/* fall through */
|
|
||||||
case SCAN_BEG:
|
case SCAN_BEG:
|
||||||
|
nextstate = SCAN_LNK;
|
||||||
|
return 1;
|
||||||
|
case SCAN_HASLNK:
|
||||||
|
nextstate = SCAN_APPENDLNK; /* Skip SCAN_BEG */
|
||||||
|
return 1;
|
||||||
|
case SCAN_LNK:
|
||||||
|
case SCAN_APPENDLNK:
|
||||||
|
strcpy (ext_here, ".lnk");
|
||||||
|
nextstate = SCAN_CHECKEDLNK;
|
||||||
|
return 1;
|
||||||
case SCAN_JUSTCHECK:
|
case SCAN_JUSTCHECK:
|
||||||
|
nextstate = SCAN_DONE;
|
||||||
return 1;
|
return 1;
|
||||||
default:
|
default:
|
||||||
if (nullterm && ext_here)
|
if (nullterm && ext_here)
|
||||||
@ -2559,7 +2569,7 @@ symlink_info::check (const char *path, const suffix_info *suffixes)
|
|||||||
if (suffix.lnk_match ())
|
if (suffix.lnk_match ())
|
||||||
{
|
{
|
||||||
fileattr = (DWORD)-1;
|
fileattr = (DWORD)-1;
|
||||||
continue;
|
continue; /* in case we're going to tack *another* .lnk on this filename. */
|
||||||
}
|
}
|
||||||
goto file_not_symlink;
|
goto file_not_symlink;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user