From a50b6b2dcd76cfb494617c37f93ebed175d60560 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sun, 6 Mar 2005 20:15:07 +0000 Subject: [PATCH] * path.cc (special_name): Reorganize to always detect the use of special names first, before detecting special characters. --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/path.cc | 25 +++++++++++-------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 7c5d314ff..a36dfb898 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 10a174838..6d4228d63 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 -- 2.43.5