From 0218d1ba16d5c3952c3dbd273f9aa6a2f0d60e28 Mon Sep 17 00:00:00 2001 From: mquinson Date: Wed, 10 Sep 2008 01:12:35 +0000 Subject: [PATCH] Kill dead commented code git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@5908 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- tools/tesh2/src/str_replace.c | 139 ---------------------------------- 1 file changed, 139 deletions(-) diff --git a/tools/tesh2/src/str_replace.c b/tools/tesh2/src/str_replace.c index efb916bd07..df147e456e 100644 --- a/tools/tesh2/src/str_replace.c +++ b/tools/tesh2/src/str_replace.c @@ -5,136 +5,6 @@ #include -/*int -str_replace(char** str, const char* what, const char* with) -{ - size_t pos, i; - char* begin; - char* buf; - - if(!(begin = strstr(*str, what))) - { - errno = ESRCH; - return -1; - } - - pos = begin - *str; - - i = 0; - - 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; - -} -*/ - -/* last version int -str_replace(char** str, const char* what, const char* with, const char* delimiters) -{ - size_t pos, i, len; - char* begin; - char* buf; - char* delimited; - int size; - - if(!*str || !what || !with || !delimiters) - { - errno = EINVAL; - return -1; - } - - - if(!(delimited = (char*) calloc((strlen(what) + 2) , sizeof(char)))) - return -1; - - len = strlen(delimiters); - - for(i = 0; i < len; i++) - { - memset(delimited, 0, (strlen(what) + 2)); - - sprintf(delimited,"%s%c", what, delimiters[i]); - - if((begin = strstr(*str, delimited))) - break; - } - - free(delimited); - - - if(!begin && (size = (int)strlen(*str) - (int)strlen(what)) >= 0 && !strcmp(*str + size, what)) - begin = strstr(*str, what); - - if(!begin) - { - errno = ESRCH; - return -1; - } - - pos = begin - *str; - - i = 0; - - 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(char** str, const char* what, const char* with, const char* delimiters) { @@ -233,15 +103,6 @@ str_replace_all(char** str, const char* what, const char* with, const char* deli } -/*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; -}*/ -- 2.20.1