Thrift compiler to tokenize args by " " so you can use script files
authorMark Slee <mcslee@apache.org>
Wed, 27 Sep 2006 18:50:48 +0000 (18:50 +0000)
committerMark Slee <mcslee@apache.org>
Wed, 27 Sep 2006 18:50:48 +0000 (18:50 +0000)
Summary: if you do #!/usr/local/bin/thrift --php --cpp it shows up as one arg: "--php --cpp" so you need to tokenize that

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

compiler/cpp/src/main.cc

index f75bd53..5cbf53e 100644 (file)
@@ -126,23 +126,30 @@ int main(int argc, char** argv) {
   }
 
   for (i = 1; i < argc-1; i++) {
-    if (strcmp(argv[i], "--debug") == 0) {
-      g_debug = 1;
-    } else if (strcmp(argv[i], "--cpp") == 0) {
-      gen_cpp = true;
-    } else if (strcmp(argv[i], "--java") == 0) {
-      gen_java = true;
-    } else if (strcmp(argv[i], "--php") == 0) {
-      gen_php = true;
-      php_inline = false;
-    } else if (strcmp(argv[i], "--phpi") == 0) {
-      gen_php = true;
-      php_inline = true;
-    } else if (strcmp(argv[i], "--py") == 0) {
-      gen_py = true;
-    } else {
-      fprintf(stderr, "!!! Unrecognized option: %s\n", argv[i]);
-      usage();
+    char* arg;
+    arg = strtok(argv[i], " ");
+    while (arg != NULL) {
+      if (strcmp(arg, "--debug") == 0) {
+        g_debug = 1;
+      } else if (strcmp(arg, "--cpp") == 0) {
+        gen_cpp = true;
+      } else if (strcmp(arg, "--java") == 0) {
+        gen_java = true;
+      } else if (strcmp(arg, "--php") == 0) {
+        gen_php = true;
+        php_inline = false;
+      } else if (strcmp(arg, "--phpi") == 0) {
+        gen_php = true;
+        php_inline = true;
+      } else if (strcmp(arg, "--py") == 0) {
+        gen_py = true;
+      } else {
+        fprintf(stderr, "!!! Unrecognized option: %s\n", arg);
+        usage();
+      }
+
+      // Tokenize more
+      arg = strtok(NULL, " ");
     }
   }