From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:60019) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SRlmN-00005K-TC for qemu-devel@nongnu.org; Tue, 08 May 2012 10:52:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SRlmK-0007YF-H1 for qemu-devel@nongnu.org; Tue, 08 May 2012 10:52:43 -0400 Received: from mail-pz0-f47.google.com ([209.85.210.47]:52083) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SRlmK-0007Sn-8K for qemu-devel@nongnu.org; Tue, 08 May 2012 10:52:40 -0400 Received: by mail-pz0-f47.google.com with SMTP id h21so8313251dal.34 for ; Tue, 08 May 2012 07:52:39 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Tue, 8 May 2012 16:51:47 +0200 Message-Id: <1336488722-13120-8-git-send-email-pbonzini@redhat.com> In-Reply-To: <1336488722-13120-1-git-send-email-pbonzini@redhat.com> References: <1336488722-13120-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 1.1 07/22] block: simplify path_is_absolute List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, stefanha@linux.vnet.ibm.com On Windows, all the logic is already in is_windows_drive and is_windows_drive_prefix. On POSIX, there is no need to look out for colons. The win32 code changes the behaviour in some cases, we could have something like "d:foo.img". The old code would treat it as relative path, the new one as absolute. Now the path is absolute, because to go from c:/program files/blah to d:foo.img you cannot say c:/program files/blah/d:foo.img. You have to say d:foo.img. But you could also say it's relative because (I think, at least it was like that in DOS 15 years ago) d:foo.img is relative to the current path of drive D. Considering how path_is_absolute is used by path_combine, I think it's better to treat it as absolute. Signed-off-by: Paolo Bonzini --- block.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/block.c b/block.c index 2978135..0fb188f 100644 --- a/block.c +++ b/block.c @@ -210,21 +210,14 @@ static int path_has_protocol(const char *path) int path_is_absolute(const char *path) { - const char *p; #ifdef _WIN32 /* specific case for names like: "\\.\d:" */ - if (*path == '/' || *path == '\\') + if (is_windows_drive(path) || is_windows_drive_prefix(path)) { return 1; -#endif - p = strchr(path, ':'); - if (p) - p++; - else - p = path; -#ifdef _WIN32 - return (*p == '/' || *p == '\\'); + } + return (*path == '/' || *path == '\\'); #else - return (*p == '/'); + return (*path == '/'); #endif } -- 1.7.10.1