Browse Source

Removed string cast

Thomas Buck 10 years ago
parent
commit
0339d5382b
1 changed files with 5 additions and 9 deletions
  1. 5
    9
      src/utils/strings.cpp

+ 5
- 9
src/utils/strings.cpp View File

@@ -31,9 +31,9 @@ char *stringRemoveQuotes(const char *s) {
31 31
 }
32 32
 
33 33
 char *stringReplace(const char *s, const char *search, const char *replace) {
34
-    char *tmp = strstr((char *)s, search);
34
+    const char *tmp = strstr(s, search);
35 35
     if (tmp == NULL)
36
-        return NULL;
36
+        return bufferString("%s", s);
37 37
     size_t offset = tmp - s;
38 38
 
39 39
     size_t length = strlen(s) - strlen(search) + strlen(replace);
@@ -49,13 +49,9 @@ char *stringReplace(const char *s, const char *search, const char *replace) {
49 49
     for (size_t i = (offset + strlen(search)); i < strlen(s); i++)
50 50
         buf[i + strlen(replace) - strlen(search)] = s[i];
51 51
 
52
-    tmp = stringReplace(buf, search, replace);
53
-    if (tmp == NULL)
54
-        return buf;
55
-    else {
56
-        delete [] buf;
57
-        return tmp;
58
-    }
52
+    char *ret = stringReplace(buf, search, replace);
53
+    delete [] buf;
54
+    return ret;
59 55
 }
60 56
 
61 57
 int readBool(const char *value, bool *var) {

Loading…
Cancel
Save