Implementation of various helper functions for replacing characters or strings in a string. More...
#include <ctype.h>#include <stdlib.h>#include <string.h>#include <stdio.h>#include "replace.h"#include "strstri.h"
Go to the source code of this file.
Functions | |
| void | replace_chr (char *s, char c1, char c2) |
Replace all occurrences of narrow character c1 with narrow character c2 in s, using case-sensitive search. If c2 is '\0' then all matches to c1 are effectively removed from the string. | |
| void | replace_chri (char *s, char c1, char c2) |
Replace all occurrences of narrow character c1 with narrow character c2 in s, using case-insensitive search. If c2 is '\0' then all matches to c1 are effectively removed from the string. | |
| static void | _append_range (char **buffer, const char *start, const char *end) |
| Helper function to append a range of characters to a string that may need to be resized to accommodate the range of characters. | |
| char * | replace_str (const char *s, const char *str1, const char *str2) |
Replace all occurrences of narrow string str1 with narrow string str2 in s, using case-sensitive search, returning a new string. | |
| char * | replace_stri (const char *s, const char *str1, const char *str2) |
Replace all occurrences of narrow string str1 with narrow string str2 in s, using case-insensitive search, returning a new string. | |
Implementation of various helper functions for replacing characters or strings in a string.
Definition in file replace.c.
|
static |
Helper function to append a range of characters to a string that may need to be resized to accommodate the range of characters.
| buffer | Pointer to a pointer to a character string. This will contain the pointer to the updated string on return. |
| start | Pointer to first character of range to copy. |
| end | Pointer to one after last character of range to copy. Must be greater than or equal to start and must point into the same string. |
Definition at line 93 of file replace.c.
Referenced by replace_str(), and replace_stri().
| void replace_chr | ( | char * | s, |
| char | c1, | ||
| char | c2 | ||
| ) |
Replace all occurrences of narrow character c1 with narrow character c2 in s, using case-sensitive search. If c2 is '\0' then all matches to c1 are effectively removed from the string.
| s | String to modify |
| c1 | Character to replace |
| c2 | Character to replace with |
Definition at line 17 of file replace.c.
Referenced by Composite_FileAccess_GetEntry().
| void replace_chri | ( | char * | s, |
| char | c1, | ||
| char | c2 | ||
| ) |
Replace all occurrences of narrow character c1 with narrow character c2 in s, using case-insensitive search. If c2 is '\0' then all matches to c1 are effectively removed from the string.
| s | String to modify |
| c1 | Character to replace |
| c2 | Character to replace with |
| char * replace_str | ( | const char * | s, |
| const char * | str1, | ||
| const char * | str2 | ||
| ) |
Replace all occurrences of narrow string str1 with narrow string str2 in s, using case-sensitive search, returning a new string.
| s | String to modify |
| str1 | String to replace |
| str2 | String to replace with (can be an empty string to remove str1). |
Definition at line 127 of file replace.c.
References _append_range().
Referenced by Command_Operation_Replace(), and Memento_Operation_Replace().
| char * replace_stri | ( | const char * | s, |
| const char * | str1, | ||
| const char * | str2 | ||
| ) |
Replace all occurrences of narrow string str1 with narrow string str2 in s, using case-insensitive search, returning a new string.
| s | String to modify |
| str1 | String to replace |
| str2 | String to replace with (can be an empty string to remove str1). |
Definition at line 163 of file replace.c.
References _append_range(), and strstri().