changeset 1746:f2f69b73afe9 draft

remove global variable in regex_mas
author Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
date Mon, 18 Nov 2013 18:15:04 +0900
parents ef246e421c8c
children efbb42f8077a
files example/regex_mas/main.cc
diffstat 1 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/example/regex_mas/main.cc	Mon Nov 18 16:18:45 2013 +0900
+++ b/example/regex_mas/main.cc	Mon Nov 18 18:15:04 2013 +0900
@@ -29,7 +29,6 @@
 int use_compat = 0;
 int array_task_num = 8;
 int spe_num = 1;
-unsigned char *search_word;
 CPU_TYPE spe_cpu = SPE_ANY;
 const char *usr_help_str = "Usage: ./word_count [-a -c -s] [-cpu spe_num] [-file filename]\n";
 
@@ -247,7 +246,7 @@
 static int division = 16; // in Kbyte
 
 static void
-run_start(TaskManager *manager, char *filename)
+run_start(TaskManager *manager, char *filename,unsigned char *search_word)
 {
     HTaskPtr t_print;
 
@@ -320,6 +319,7 @@
 {
 
     char *filename = 0;
+    unsigned char *search_word = 0;
 
     for (int i = 1; argv[i]; ++i) {
         if (strcmp(argv[i], "-file") == 0) {
@@ -366,15 +366,26 @@
 {
 
     char *filename = 0;
+    unsigned char *search_word = 0;
     filename = init(argc, argv);
 
+    for (int i = 1; argv[i]; ++i) {
+        if (strcmp(argv[i], "-sw") == 0) {
+            search_word = (unsigned char*)argv[i+1];
+        }
+    }
+
     if (filename < 0) {
         return -1;
     }
 
+    if (search_word < 0) {
+        return -1;
+    }
+
     task_init();
     st_time = getTime();
-    run_start(manager, filename);
+    run_start(manager, filename,search_word);
     manager->set_TMend(TMend);
     return 0;
 }