diff options
author | Jeff Davidson <jpd@google.com> | 2014-09-15 16:29:06 -0700 |
---|---|---|
committer | Jeff Davidson <jpd@google.com> | 2015-01-15 14:10:53 -0800 |
commit | a3b2a6da25a76f17c73d31def3952feb0fd2296e (patch) | |
tree | 586f7d5e9a7e05af45d0e821188097c0faa96219 /src/google/protobuf/compiler/importer.cc | |
parent | c7c25812eb19d080087b71e08bfe35aff9f21433 (diff) | |
download | external_protobuf-a3b2a6da25a76f17c73d31def3952feb0fd2296e.zip external_protobuf-a3b2a6da25a76f17c73d31def3952feb0fd2296e.tar.gz external_protobuf-a3b2a6da25a76f17c73d31def3952feb0fd2296e.tar.bz2 |
Update protobuf library from 2.3 to 2.6.
Copied in all files from the open source protobuf project at commit
edc5994525c79cd1919859a370837a6ff7c8e308, removing files which have
been renamed (COPYING.txt -> LICENSE, README.txt -> README.md).
Removed 2.3 prebuilts, which is an approach that will not work due to
incompatibility with the 2.6 runtime.
Merged in micro/nano-specific changes in the following files:
-Android.mk - updated list of C++/Java sources, bumped versions
-java/README.txt - merged in micro/nano instructions, bumped versions
-java/pom.xml - merged in micro/nano build rules, set packaging to jar
-src/Makefile.am - merged in references to micro/nano generators
-src/google/protobuf/compiler/javamicro/javamicro_file.h - imported
google/protobuf/compiler/code_generator.h and removed redundant
OutputDirectory class.
-src/google/protobuf/compiler/javanano/javanano_file.h - same
-Replaced instances of vector with std::vector as needed to get
libprotobuf-cpp-full to compile. Plan to upstream this fix per
discussion with protobuf maintainers.
Reran autogen.sh to update ./configure and associated scripts.
Change-Id: I949d32fb5126f1c05e2a6ed48f6636a4a9b15a48
Diffstat (limited to 'src/google/protobuf/compiler/importer.cc')
-rw-r--r-- | src/google/protobuf/compiler/importer.cc | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/src/google/protobuf/compiler/importer.cc b/src/google/protobuf/compiler/importer.cc index 7689ce9..701ac48 100644 --- a/src/google/protobuf/compiler/importer.cc +++ b/src/google/protobuf/compiler/importer.cc @@ -43,6 +43,7 @@ #include <errno.h> #include <algorithm> +#include <memory> #include <google/protobuf/compiler/importer.h> @@ -124,7 +125,8 @@ bool SourceTreeDescriptorDatabase::FindFileByName( scoped_ptr<io::ZeroCopyInputStream> input(source_tree_->Open(filename)); if (input == NULL) { if (error_collector_ != NULL) { - error_collector_->AddError(filename, -1, 0, "File not found."); + error_collector_->AddError(filename, -1, 0, + source_tree_->GetLastErrorMessage()); } return false; } @@ -186,6 +188,7 @@ Importer::Importer(SourceTree* source_tree, MultiFileErrorCollector* error_collector) : database_(source_tree), pool_(&database_, database_.GetValidationErrorCollector()) { + pool_.EnforceWeakDependencies(true); database_.RecordErrorsTo(error_collector); } @@ -195,10 +198,22 @@ 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() {} @@ -231,12 +246,17 @@ static string CanonicalizePath(string path) { // The Win32 API accepts forward slashes as a path delimiter even though // backslashes are standard. Let's avoid confusion and use only forward // slashes. - path = StringReplace(path, "\\", "/", true); + if (HasPrefixString(path, "\\\\")) { + // Avoid converting two leading backslashes. + path = "\\\\" + StringReplace(path.substr(2), "\\", "/", true); + } else { + path = StringReplace(path, "\\", "/", true); + } #endif - vector<string> parts; vector<string> canonical_parts; - SplitStringUsing(path, "/", &parts); // Note: Removes empty parts. + vector<string> parts = Split( + path, "/", true); // Note: Removes empty parts. for (int i = 0; i < parts.size(); i++) { if (parts[i] == ".") { // Ignore. @@ -244,7 +264,7 @@ static string CanonicalizePath(string path) { canonical_parts.push_back(parts[i]); } } - string result = JoinStrings(canonical_parts, "/"); + string result = Join(canonical_parts, "/"); if (!path.empty() && path[0] == '/') { // Restore leading slash. result = '/' + result; @@ -390,8 +410,8 @@ DiskSourceTree::DiskFileToVirtualFile( bool DiskSourceTree::VirtualFileToDiskFile(const string& virtual_file, string* disk_file) { - scoped_ptr<io::ZeroCopyInputStream> stream(OpenVirtualFile(virtual_file, - disk_file)); + scoped_ptr<io::ZeroCopyInputStream> stream( + OpenVirtualFile(virtual_file, disk_file)); return stream != NULL; } @@ -399,6 +419,10 @@ 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) { @@ -407,6 +431,8 @@ 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; } @@ -424,13 +450,13 @@ io::ZeroCopyInputStream* DiskSourceTree::OpenVirtualFile( if (errno == EACCES) { // The file exists but is not readable. - // TODO(kenton): Find a way to report this more nicely. - GOOGLE_LOG(WARNING) << "Read access is denied for file: " << temp_disk_file; + last_error_message_ = "Read access is denied for file: " + + temp_disk_file; return NULL; } } } - + last_error_message_ = "File not found."; return NULL; } |