Index: third_party/protobuf/src/google/protobuf/compiler/importer.cc |
diff --git a/third_party/protobuf/src/google/protobuf/compiler/importer.cc b/third_party/protobuf/src/google/protobuf/compiler/importer.cc |
index 8333684e1ba56a9d4e3fe52d485632f0b9b6ac32..422f759f2be75b21881f3591cef5cbd525b07a5b 100644 |
--- a/third_party/protobuf/src/google/protobuf/compiler/importer.cc |
+++ b/third_party/protobuf/src/google/protobuf/compiler/importer.cc |
@@ -1,6 +1,6 @@ |
// Protocol Buffers - Google's data interchange format |
// Copyright 2008 Google Inc. All rights reserved. |
-// https://developers.google.com/protocol-buffers/ |
+// http://code.google.com/p/protobuf/ |
// |
// Redistribution and use in source and binary forms, with or without |
// modification, are permitted provided that the following conditions are |
@@ -43,10 +43,6 @@ |
#include <errno.h> |
#include <algorithm> |
-#include <memory> |
-#ifndef _SHARED_PTR_H |
-#include <google/protobuf/stubs/shared_ptr.h> |
-#endif |
#include <google/protobuf/compiler/importer.h> |
@@ -125,11 +121,10 @@ SourceTreeDescriptorDatabase::~SourceTreeDescriptorDatabase() {} |
bool SourceTreeDescriptorDatabase::FindFileByName( |
const string& filename, FileDescriptorProto* output) { |
- google::protobuf::scoped_ptr<io::ZeroCopyInputStream> input(source_tree_->Open(filename)); |
+ scoped_ptr<io::ZeroCopyInputStream> input(source_tree_->Open(filename)); |
if (input == NULL) { |
if (error_collector_ != NULL) { |
- error_collector_->AddError(filename, -1, 0, |
- source_tree_->GetLastErrorMessage()); |
+ error_collector_->AddError(filename, -1, 0, "File not found."); |
} |
return false; |
} |
@@ -191,7 +186,6 @@ Importer::Importer(SourceTree* source_tree, |
MultiFileErrorCollector* error_collector) |
: database_(source_tree), |
pool_(&database_, database_.GetValidationErrorCollector()) { |
- pool_.EnforceWeakDependencies(true); |
database_.RecordErrorsTo(error_collector); |
} |
@@ -201,22 +195,10 @@ const FileDescriptor* Importer::Import(const string& filename) { |
return pool_.FindFileByName(filename); |
} |
-void Importer::AddUnusedImportTrackFile(const string& file_name) { |
- pool_.AddUnusedImportTrackFile(file_name); |
-} |
- |
-void Importer::ClearUnusedImportTrackFiles() { |
- pool_.ClearUnusedImportTrackFiles(); |
-} |
- |
// =================================================================== |
SourceTree::~SourceTree() {} |
-string SourceTree::GetLastErrorMessage() { |
- return "File not found."; |
-} |
- |
DiskSourceTree::DiskSourceTree() {} |
DiskSourceTree::~DiskSourceTree() {} |
@@ -257,9 +239,9 @@ static string CanonicalizePath(string path) { |
} |
#endif |
+ vector<string> parts; |
vector<string> canonical_parts; |
- vector<string> parts = Split( |
- path, "/", true); // Note: Removes empty parts. |
+ SplitStringUsing(path, "/", &parts); // Note: Removes empty parts. |
for (int i = 0; i < parts.size(); i++) { |
if (parts[i] == ".") { |
// Ignore. |
@@ -267,7 +249,7 @@ static string CanonicalizePath(string path) { |
canonical_parts.push_back(parts[i]); |
} |
} |
- string result = Join(canonical_parts, "/"); |
+ string result = JoinStrings(canonical_parts, "/"); |
if (!path.empty() && path[0] == '/') { |
// Restore leading slash. |
result = '/' + result; |
@@ -403,7 +385,7 @@ DiskSourceTree::DiskFileToVirtualFile( |
// Verify that we can open the file. Note that this also has the side-effect |
// of verifying that we are not canonicalizing away any non-existent |
// directories. |
- google::protobuf::scoped_ptr<io::ZeroCopyInputStream> stream(OpenDiskFile(disk_file)); |
+ scoped_ptr<io::ZeroCopyInputStream> stream(OpenDiskFile(disk_file)); |
if (stream == NULL) { |
return CANNOT_OPEN; |
} |
@@ -413,8 +395,8 @@ DiskSourceTree::DiskFileToVirtualFile( |
bool DiskSourceTree::VirtualFileToDiskFile(const string& virtual_file, |
string* disk_file) { |
- google::protobuf::scoped_ptr<io::ZeroCopyInputStream> stream( |
- OpenVirtualFile(virtual_file, disk_file)); |
+ scoped_ptr<io::ZeroCopyInputStream> stream(OpenVirtualFile(virtual_file, |
+ disk_file)); |
return stream != NULL; |
} |
@@ -422,10 +404,6 @@ io::ZeroCopyInputStream* DiskSourceTree::Open(const string& filename) { |
return OpenVirtualFile(filename, NULL); |
} |
-string DiskSourceTree::GetLastErrorMessage() { |
- return last_error_message_; |
-} |
- |
io::ZeroCopyInputStream* DiskSourceTree::OpenVirtualFile( |
const string& virtual_file, |
string* disk_file) { |
@@ -434,8 +412,6 @@ io::ZeroCopyInputStream* DiskSourceTree::OpenVirtualFile( |
// We do not allow importing of paths containing things like ".." or |
// consecutive slashes since the compiler expects files to be uniquely |
// identified by file name. |
- last_error_message_ = "Backslashes, consecutive slashes, \".\", or \"..\" " |
- "are not allowed in the virtual path"; |
return NULL; |
} |
@@ -453,13 +429,13 @@ io::ZeroCopyInputStream* DiskSourceTree::OpenVirtualFile( |
if (errno == EACCES) { |
// The file exists but is not readable. |
- last_error_message_ = "Read access is denied for file: " + |
- temp_disk_file; |
+ // TODO(kenton): Find a way to report this more nicely. |
+ GOOGLE_LOG(WARNING) << "Read access is denied for file: " << temp_disk_file; |
return NULL; |
} |
} |
} |
- last_error_message_ = "File not found."; |
+ |
return NULL; |
} |