File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed
Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -2442,11 +2442,19 @@ namespace simplecpp {
24422442 bool isAbsolutePath (const std::string &path)
24432443 {
24442444#ifdef SIMPLECPP_WINDOWS
2445- if (path.length () >= 3 && path[0 ] > 0 && std::isalpha (path[0 ]) && path[1 ] == ' :' && (path[2 ] == ' \\ ' || path[2 ] == ' /' ))
2445+ // C:\\path\\file
2446+ // C:/path/file
2447+ if (path.length () >= 3 && std::isalpha (path[0 ]) && path[1 ] == ' :' && (path[2 ] == ' \\ ' || path[2 ] == ' /' ))
24462448 return true ;
2447- return path.length () > 1U && (path[0 ] == ' /' || path[0 ] == ' \\ ' );
2449+
2450+ // \\host\path\file
2451+ // //host/path/file
2452+ if (path.length () >= 2 && (path[0 ] == ' \\ ' || path[0 ] == ' /' ) && (path[1 ] == ' \\ ' || path[1 ] == ' /' ))
2453+ return true ;
2454+
2455+ return false ;
24482456#else
2449- return path.length () > 1U && path[0 ] == ' /' ;
2457+ return ! path.empty () && path[0 ] == ' /' ;
24502458#endif
24512459 }
24522460}
Original file line number Diff line number Diff line change @@ -3261,14 +3261,14 @@ static void isAbsolutePath() {
32613261 // ASSERT_EQUALS(true, simplecpp::isAbsolutePath("\\")); // TODO
32623262 ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" 0:\\ foo\\ bar" ));
32633263 ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" 0:/foo/bar" ));
3264- // ASSERT_EQUALS(false, simplecpp::isAbsolutePath("\\foo\\bar")); // TODO
3264+ ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" \\ foo\\ bar" ));
32653265 // ASSERT_EQUALS(false, simplecpp::isAbsolutePath("\\\\")); // TODO
32663266 // ASSERT_EQUALS(false, simplecpp::isAbsolutePath("//")); // TODO
3267- // ASSERT_EQUALS(false, simplecpp::isAbsolutePath("/foo/bar")); // TODO
3267+ ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" /foo/bar" ));
32683268 ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" /" ));
32693269#else
32703270 ASSERT_EQUALS (true , simplecpp::isAbsolutePath (" /foo/bar" ));
3271- // ASSERT_EQUALS(true, simplecpp::isAbsolutePath("/")); // TODO
3271+ ASSERT_EQUALS (true , simplecpp::isAbsolutePath (" /" ));
32723272 ASSERT_EQUALS (true , simplecpp::isAbsolutePath (" //host/foo/bar" ));
32733273
32743274 ASSERT_EQUALS (false , simplecpp::isAbsolutePath (" foo/bar" ));
You can’t perform that action at this time.
0 commit comments