aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2002-07-06 06:11:54 +0000
committerChristopher Faylor <me@cgf.cx>2002-07-06 06:11:54 +0000
commit3bfb3884d41b17ac8255af8925a1c2ec93a36af1 (patch)
tree715cdb4908970f4ef2bbf5395828dbf1b1d8dda6
parent615e0dd96e47d721b012831b8f3abedd83647ddc (diff)
downloadnewlib-unlabeled-1.226.2.zip
newlib-unlabeled-1.226.2.tar.gz
newlib-unlabeled-1.226.2.tar.bz2
* path.cc (suffix_scan::has): Reorganize to eliminate double scanning for forgithub/unlabeled-1.226.2unlabeled-1.226.2
.exe (in the typical case). * fhandler_socket.cc (fhandler_socket::set_sun_path): Don't free memory here. Allow NULL parameter. * fhandler_socket.cc (fhandler_socket::dup): Add missing copy operation on sun_path.
-rw-r--r--winsup/cygwin/path.cc70
1 files changed, 36 insertions, 34 deletions
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index ed76f94..c09b459 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -2822,8 +2822,43 @@ suffix_scan::has (const char *in_path, const suffix_info *in_suffixes)
int
suffix_scan::next ()
{
- if (suffixes)
+ for (;;)
{
+ if (!suffixes)
+ switch (nextstate)
+ {
+ case SCAN_BEG:
+ suffixes = suffixes_start;
+ if (!suffixes)
+ {
+ nextstate = SCAN_LNK;
+ return 1;
+ }
+ if (!*suffixes->name)
+ suffixes++;
+ nextstate = SCAN_EXTRALNK;
+ /* fall through to suffix checking below */
+ break;
+ case SCAN_HASLNK:
+ nextstate = SCAN_EXTRALNK; /* Skip SCAN_BEG */
+ return 1;
+ case SCAN_LNK:
+ case SCAN_EXTRALNK:
+ strcpy (eopath, ".lnk");
+ nextstate = SCAN_DONE;
+ return 1;
+ case SCAN_JUSTCHECK:
+ nextstate = SCAN_APPENDLNK;
+ return 1;
+ case SCAN_APPENDLNK:
+ strcat (eopath, ".lnk");
+ nextstate = SCAN_DONE;
+ return 1;
+ default:
+ *eopath = '\0';
+ return 0;
+ }
+
while (suffixes && suffixes->name)
if (!suffixes->addon)
suffixes++;
@@ -2837,39 +2872,6 @@ suffix_scan::next ()
}
suffixes = NULL;
}
-
- switch (nextstate)
- {
- case SCAN_BEG:
- suffixes = suffixes_start;
- if (!suffixes)
- nextstate = SCAN_LNK;
- else
- {
- if (!*suffixes->name)
- suffixes++;
- nextstate = SCAN_EXTRALNK;
- }
- return 1;
- case SCAN_HASLNK:
- nextstate = SCAN_EXTRALNK; /* Skip SCAN_BEG */
- return 1;
- case SCAN_LNK:
- case SCAN_EXTRALNK:
- strcpy (eopath, ".lnk");
- nextstate = SCAN_DONE;
- return 1;
- case SCAN_JUSTCHECK:
- nextstate = SCAN_APPENDLNK;
- return 1;
- case SCAN_APPENDLNK:
- strcat (eopath, ".lnk");
- nextstate = SCAN_DONE;
- return 1;
- default:
- *eopath = '\0';
- return 0;
- }
}
/* Check if PATH is a symlink. PATH must be a valid Win32 path name.