Fix a subtle bug in cpp_use_include_path.
authorDavid Reiss <dreiss@apache.org>
Wed, 27 Feb 2008 22:28:12 +0000 (22:28 +0000)
committerDavid Reiss <dreiss@apache.org>
Wed, 27 Feb 2008 22:28:12 +0000 (22:28 +0000)
Summary:
I thought I had eliminated all the places where work was only done
if cpp_use_include_path was set.  I guess I missed one.

Reviewed By: mcslee, mrabkin, kholst

Test Plan:
Built BigGrep and looked at the generated code.

Revert Plan: ok

DiffCamp Revision: 8375

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665530 13f79535-47bb-0310-9956-ffa450edef68

compiler/cpp/src/main.cc

index 75d23e2..80da53a 100644 (file)
@@ -1160,19 +1160,19 @@ int main(int argc, char** argv) {
   if (out_path.size()) {
     program->set_out_path(out_path);
   }
-  if (g_cpp_use_include_prefix) {
-    // infer this from the filename passed in
-    string input_filename = argv[i];
-    string include_prefix;
-
-    string::size_type last_slash = string::npos;
-    if ((last_slash = input_filename.rfind("/")) != string::npos) {
-      include_prefix = input_filename.substr(0, last_slash);
-    }
 
-    program->set_include_prefix(include_prefix);
+  // Compute the cpp include prefix.
+  // infer this from the filename passed in
+  string input_filename = argv[i];
+  string include_prefix;
+
+  string::size_type last_slash = string::npos;
+  if ((last_slash = input_filename.rfind("/")) != string::npos) {
+    include_prefix = input_filename.substr(0, last_slash);
   }
 
+  program->set_include_prefix(include_prefix);
+
   // Initialize global types
   g_type_void   = new t_base_type("void",   t_base_type::TYPE_VOID);
   g_type_string = new t_base_type("string", t_base_type::TYPE_STRING);