Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
delete all the files to add the new integrated files version
[simgrid.git] / tools / tesh2 / src / str_replace.c
diff --git a/tools/tesh2/src/str_replace.c b/tools/tesh2/src/str_replace.c
deleted file mode 100644 (file)
index f4c275a..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-#include <str_replace.h>
-#include <string.h>
-#include <errno.h>
-#include <stdlib.h>
-
-#include <stdio.h>
-
-int
-str_replace(char** str, const char* what, const char* with)
-{
-       int pos, i;
-       char* begin;
-       char* buf;
-        
-       if(!(begin = strstr(*str, what)))
-       {
-               errno = ESRCH;
-               return -1;
-       }
-       
-       pos = begin - *str;
-       
-       i = 0;
-       
-       /*while(begin[i] != ' ' && begin[i] != '\n' && begin[i] != '\r' && begin[i] != '\0')
-               i++;
-       
-       pos += i;
-       */
-       
-       pos += strlen(what);
-       
-       if(begin == *str)
-       {
-               if(!(buf = (char*) calloc(strlen(with) + ((pos < strlen(*str)) ? strlen(*str + pos) : 0) + 1, sizeof(char))))
-                       return -1;
-                       
-               strcpy(buf, with);
-               
-               if(pos < strlen(*str))
-                       strcpy(buf + strlen(with), *str + pos);
-       }
-       else
-       {
-               if(!(buf = (char*) calloc((begin - *str) + strlen(with) + ((pos < strlen(*str)) ? strlen(*str + pos) : 0) + 1, sizeof(char))))
-                       return -1;
-               
-               strncpy(buf, *str,  (begin - *str));
-               strcpy(buf + (begin - *str) , with);
-               
-
-               if(pos < strlen(*str))
-                       strcpy(buf + (begin - *str) + strlen(with), *str + pos);
-       }       
-       
-       free(*str);;
-       *str = buf;
-       
-       return 0;
-} 
-
-int
-str_replace_all(char** str, const char* what, const char* with)
-{
-       int rv;
-       
-       while(!(rv = str_replace(str, what, with)));
-       
-       return (errno == ESRCH) ? 0 : -1;
-}
-
-