*** empty log message ***
[h316.git] / pc-tools / ldc2 / src / tool.cpp
index cc04868ac8e7b663ac9f6308e0c7f54a143c5ae5..b33e0279c82cfc811dcebe710f2c8535b7277103 100644 (file)
@@ -7,22 +7,6 @@
 
 using namespace std;
 
-/*!
- *\brief Output a vector of strings to out_fd.
- *\arg strings A vector containing text.
- *\retval 0 The vector was empty.
- *\retval 1 The vector contained text.
- */
-int dump_vector(vector<string> strings){
-  int res=0;
-  for (vector<string>::iterator iter=strings.begin();iter<strings.end();iter++){
-    char buffer[50000];
-    snprintf(buffer,50000,"%s\n",(*iter).c_str());
-    write (out_fd,buffer,strlen(buffer));
-    res=1;
-  }
-  return res;
-}
 
 /*!
  *\brief Output a vector of strings.
@@ -34,27 +18,20 @@ int dump_vector(vector<string> strings){
 int dump_vector_fp(vector<string> strings, FILE * fp){
   int res=0;
   for (vector<string>::iterator iter=strings.begin();iter<strings.end();iter++){
-    fprintf(fp,"%s\n",(*iter).c_str());
+    fprintf(fp,"%s\n",
+           iter->substr(0,iter->find_last_not_of(" ")+1).c_str());
     res=1;
   }
   return res;
 }
 
 /*!
- *\brief add contents of one vector to another vector uniquely.
- *\param target Reference to the target vector.
- *\param source Reference to the vector whose contents are to be added
- *       to target.
+ *\brief Output a vector of strings to out_fd.
+ *\arg strings A vector containing text.
+ *\retval 0 The vector was empty.
+ *\retval 1 The vector contained text.
  */
-template<typename T>
-void merge_vector_unique(vector<T> &target, const vector<T> & source){
-  for (unsigned int isource=0; isource<source.size();isource++){
-    bool already_present=false;
-    for (int itarget=0;itarget<target.size();itarget++)
-      if (target[itarget]==source[isource]){
-       already_present=true;
-       break;
-      }
-    if (!already_present) target.insert(target.end().source[isource]);
-  }
+int dump_vector(vector<string> strings){
+  FILE * fp=fdopen(out_fd,"w");
+  return dump_vector_fp(strings,fp);
 }