diff options
-rwxr-xr-x | configure.py | 5 | ||||
-rw-r--r-- | misc/ninja-mode.el | 16 | ||||
-rw-r--r-- | src/disk_interface.cc | 13 | ||||
-rw-r--r-- | src/disk_interface_test.cc | 13 | ||||
-rw-r--r-- | src/util.cc | 1 | ||||
-rw-r--r-- | src/util_test.cc | 8 |
6 files changed, 45 insertions, 11 deletions
diff --git a/configure.py b/configure.py index cceb0f7..da2f6ef 100755 --- a/configure.py +++ b/configure.py @@ -328,7 +328,10 @@ if options.with_gtest: gtest_all_incs = '-I%s -I%s' % (path, os.path.join(path, 'include')) if platform.is_msvc(): - gtest_cflags = '/nologo /EHsc /Zi /D_VARIADIC_MAX=10 ' + gtest_all_incs + gtest_cflags = '/nologo /EHsc /Zi /D_VARIADIC_MAX=10 ' + if platform.msvc_needs_fs(): + gtest_cflags += '/FS ' + gtest_cflags += gtest_all_incs else: gtest_cflags = '-fvisibility=hidden ' + gtest_all_incs objs += n.build(built('gtest-all' + objext), 'cxx', diff --git a/misc/ninja-mode.el b/misc/ninja-mode.el index d939206..9fe6fc8 100644 --- a/misc/ninja-mode.el +++ b/misc/ninja-mode.el @@ -1,3 +1,5 @@ +;;; ninja-mode.el --- Major mode for editing .ninja files + ;; Copyright 2011 Google Inc. All Rights Reserved. ;; ;; Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,10 +14,14 @@ ;; See the License for the specific language governing permissions and ;; limitations under the License. +;;; Commentary: + ;; Simple emacs mode for editing .ninja files. ;; Just some syntax highlighting for now. -(setq ninja-keywords +;;; Code: + +(defvar ninja-keywords (list '("^#.*" . font-lock-comment-face) (cons (concat "^" (regexp-opt '("rule" "build" "subninja" "include" @@ -28,6 +34,8 @@ ;; Rule names '("rule \\([[:alnum:]_]+\\)" . (1 font-lock-function-name-face)) )) + +;;;###autoload (define-derived-mode ninja-mode fundamental-mode "ninja" (setq comment-start "#") ; Pass extra "t" to turn off syntax-based fontification -- we don't want @@ -35,8 +43,10 @@ (setq font-lock-defaults '(ninja-keywords t)) ) -(provide 'ninja-mode) - ;; Run ninja-mode for files ending in .ninja. ;;;###autoload (add-to-list 'auto-mode-alist '("\\.ninja$" . ninja-mode)) + +(provide 'ninja-mode) + +;;; ninja-mode.el ends here diff --git a/src/disk_interface.cc b/src/disk_interface.cc index 090e94e..4dfae1a 100644 --- a/src/disk_interface.cc +++ b/src/disk_interface.cc @@ -14,6 +14,8 @@ #include "disk_interface.h" +#include <algorithm> + #include <errno.h> #include <stdio.h> #include <string.h> @@ -31,15 +33,16 @@ namespace { string DirName(const string& path) { #ifdef _WIN32 - const char kPathSeparator = '\\'; + const char kPathSeparators[] = "\\/"; #else - const char kPathSeparator = '/'; + const char kPathSeparators[] = "/"; #endif - - string::size_type slash_pos = path.rfind(kPathSeparator); + string::size_type slash_pos = path.find_last_of(kPathSeparators); if (slash_pos == string::npos) return string(); // Nothing to do. - while (slash_pos > 0 && path[slash_pos - 1] == kPathSeparator) + const char* const kEnd = kPathSeparators + strlen(kPathSeparators); + while (slash_pos > 0 && + std::find(kPathSeparators, kEnd, path[slash_pos - 1]) != kEnd) --slash_pos; return path.substr(0, slash_pos); } diff --git a/src/disk_interface_test.cc b/src/disk_interface_test.cc index 55822a6..51a1d14 100644 --- a/src/disk_interface_test.cc +++ b/src/disk_interface_test.cc @@ -93,7 +93,18 @@ TEST_F(DiskInterfaceTest, ReadFile) { } TEST_F(DiskInterfaceTest, MakeDirs) { - EXPECT_TRUE(disk_.MakeDirs("path/with/double//slash/")); + string path = "path/with/double//slash/"; + EXPECT_TRUE(disk_.MakeDirs(path.c_str())); + FILE* f = fopen((path + "a_file").c_str(), "w"); + EXPECT_TRUE(f); + EXPECT_EQ(0, fclose(f)); +#ifdef _WIN32 + string path2 = "another\\with\\back\\\\slashes\\"; + EXPECT_TRUE(disk_.MakeDirs(path2.c_str())); + FILE* f2 = fopen((path2 + "a_file").c_str(), "w"); + EXPECT_TRUE(f2); + EXPECT_EQ(0, fclose(f2)); +#endif } TEST_F(DiskInterfaceTest, RemoveFile) { diff --git a/src/util.cc b/src/util.cc index 0e4dc59..24d231f 100644 --- a/src/util.cc +++ b/src/util.cc @@ -194,7 +194,6 @@ static inline bool IsKnownShellSafeCharacter(char ch) { static inline bool IsKnownWin32SafeCharacter(char ch) { switch (ch) { - case '\\': case ' ': case '"': return false; diff --git a/src/util_test.cc b/src/util_test.cc index f6728fb..f827e5a 100644 --- a/src/util_test.cc +++ b/src/util_test.cc @@ -159,6 +159,14 @@ TEST(PathEscaping, SensiblePathsAreNotNeedlesslyEscaped) { EXPECT_EQ(path, result); } +TEST(PathEscaping, SensibleWin32PathsAreNotNeedlesslyEscaped) { + const char* path = "some\\sensible\\path\\without\\crazy\\characters.cc"; + string result; + + GetWin32EscapedString(path, &result); + EXPECT_EQ(path, result); +} + TEST(StripAnsiEscapeCodes, EscapeAtEnd) { string stripped = StripAnsiEscapeCodes("foo\33"); EXPECT_EQ("foo", stripped); |