static char *replace(char *text, const char *rep, const char *with, int count) { if (!text || !rep || !with || !rep[0]) return text; const int len_with = strlen(with); const int gap = len_with - strlen(rep); char *pos = strstr(text, rep); while (pos) { if(--count == -1) return text; // replace all if count < 0 if(gap > 0) memmove(pos + gap, pos, strlen(pos) + 1); if(gap >= 0)
| 167 | } |
| 168 | */ |
| 169 | static void replace_char(char *text, char c, char r) |
| 170 | { |
| 171 | if(!text) return; |
| 172 | |
| 173 | for( ; *text; text++) if(*text == c) *text = r; |
| 174 | } |
| 175 | |
| 176 | static char *trim(char *title) |
| 177 | { |
no outgoing calls
no test coverage detected