From: cgf Date: Sun, 6 Mar 2005 20:15:05 +0000 (+0000) Subject: * path.cc (special_name): Reorganize to always detect the use of special names X-Git-Tag: pre_wait_sig_exit~2747 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=ee7544cbb00b8eee40dd9a98580c025080d72d64;p=pf3gnuchains%2Fpf3gnuchains4x.git * path.cc (special_name): Reorganize to always detect the use of special names first, before detecting special characters. --- diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 7c5d314ffd..a36dfb898a 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2005-03-06 Christopher Faylor + + * path.cc (special_name): Reorganize to always detect the use of + special names first, before detecting special characters. + 2005-03-04 Christopher Faylor * fhandler_clipboard.cc: Use int for cygnativeformat rather than UINT diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 10a174838a..6d4228d637 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -1255,29 +1255,26 @@ special_name (const char *s, int inc = 1) return false; s += inc; - if (strpbrk (s, special_chars)) - return !strncasematch (s, "%2f", 3); - if (strcasematch (s, ".") || strcasematch (s, "..")) + if (strcmp (s, ".") == 0 || strcmp (s, "..") == 0) return false; - if (s[strlen (s)-1] == '.') - return true; - - const char *p; - if (strcasematch (s, "conin$") || strcasematch (s, "conout$")) - return -1; - if (strncasematch (s, "nul", 3) + int n; + const char *p = NULL; + if (strncasematch (s, "conin$", n = 5) + || strncasematch (s, "conout$", n = 7) + || strncasematch (s, "nul", n = 3) || strncasematch (s, "aux", 3) || strncasematch (s, "prn", 3) || strncasematch (s, "con", 3)) - p = s + 3; + p = s + n; else if (strncasematch (s, "com", 3) || strncasematch (s, "lpt", 3)) (void) strtoul (s + 3, (char **) &p, 10); - else - return false; + if (p && (*p == '\0' || *p == '.')) + return -1; - return (*p == '\0' || *p == '.') ? -1 : false; + return (strchr (s, '\0')[-1] == '.') + || (strpbrk (s, special_chars) && !strncasematch (s, "%2f", 3)); } bool