From 21ecba88cd7891cdf28968ad5dfd70b589f12b34 Mon Sep 17 00:00:00 2001 From: "epoger@google.com" Date: Wed, 8 Aug 2012 13:47:39 +0000 Subject: skdiff: clean up isPathAbsolute check for Windows This is a followup to https://codereview.appspot.com/6458046/ ('Fix skdiff when using windows path that begins with a drive letter') Review URL: https://codereview.appspot.com/6450106 git-svn-id: http://skia.googlecode.com/svn/trunk@5004 2bbb7eff-a529-9590-31e7-b0007b416f81 --- tools/skdiff_main.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tools/skdiff_main.cpp b/tools/skdiff_main.cpp index d10ebfc28d..3fc18e7ad8 100644 --- a/tools/skdiff_main.cpp +++ b/tools/skdiff_main.cpp @@ -1048,14 +1048,21 @@ static void print_diff_page (const int matchCount, // Need to convert paths from relative-to-cwd to relative-to-outputDir // FIXME this doesn't work if there are '..' inside the outputDir - bool pathFromRoot; + bool isPathAbsolute = false; + // On Windows or Linux, a path starting with PATH_DIV_CHAR is absolute. + if (outputDir.size() > 0 && PATH_DIV_CHAR == outputDir[0]) { + isPathAbsolute = true; + } #ifdef SK_BUILD_FOR_WIN32 - pathFromRoot = outputDir.size() > 1 && ':' == outputDir[1]; -#else - pathFromRoot = outputDir.size() > 0 && PATH_DIV_CHAR == outputDir[0]; + // On Windows, absolute paths can also start with "x:", where x is any + // drive letter. + if (outputDir.size() > 1 && ':' == outputDir[1]) { + isPathAbsolute = true; + } #endif + SkString relativePath; - if (!pathFromRoot) { + if (!isPathAbsolute) { unsigned int ui; for (ui = 0; ui < outputDir.size(); ui++) { if (outputDir[ui] == PATH_DIV_CHAR) { -- cgit v1.2.3