output/raop: rewrite remove_char_from_string
This commit is contained in:
parent
0ea4c970d7
commit
eea726740b
@ -182,21 +182,22 @@ kd_lookup(struct key_data *kd, const char *key)
|
|||||||
* return the number of deleted characters
|
* return the number of deleted characters
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
remove_char_from_string(char *str, char rc)
|
remove_char_from_string(char *str, char c)
|
||||||
{
|
{
|
||||||
int i = 0, j = 0, len;
|
char *src, *dst;
|
||||||
int num = 0;
|
|
||||||
len = strlen(str);
|
/* skip all characters that don't need to be copied */
|
||||||
while (i < len) {
|
src = strchr(str, c);
|
||||||
if (str[i] == rc) {
|
if (!src)
|
||||||
for (j = i; j < len; j++) str[j] = str[j + 1];
|
return 0;
|
||||||
len--;
|
|
||||||
num++;
|
for (dst = src; *src; src++)
|
||||||
} else {
|
if (*src != c)
|
||||||
i++;
|
*(dst++) = *src;
|
||||||
}
|
|
||||||
}
|
*dst = '\0';
|
||||||
return num;
|
|
||||||
|
return src - dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SLEEP_MSEC(val) usleep(val*1000)
|
#define SLEEP_MSEC(val) usleep(val*1000)
|
||||||
|
Loading…
Reference in New Issue
Block a user