mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-23 00:08:50 -05:00
libalpm/util.c : remove _alpm_strreplace
This function is unused since commit
358cc5804a
.
Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
[Dan: also kill from util.h]
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
0845b2f13c
commit
845f21207c
@ -196,51 +196,6 @@ char *_alpm_strtrim(char *str)
|
||||
return(str);
|
||||
}
|
||||
|
||||
/* Helper function for _alpm_strreplace */
|
||||
static void _strnadd(char **str, const char *append, unsigned int count)
|
||||
{
|
||||
if(*str) {
|
||||
*str = realloc(*str, strlen(*str) + count + 1);
|
||||
} else {
|
||||
*str = calloc(count + 1, sizeof(char));
|
||||
}
|
||||
|
||||
strncat(*str, append, count);
|
||||
}
|
||||
|
||||
/* Replace all occurances of 'needle' with 'replace' in 'str', returning
|
||||
* a new string (must be free'd) */
|
||||
char *_alpm_strreplace(const char *str, const char *needle, const char *replace)
|
||||
{
|
||||
const char *p, *q;
|
||||
p = q = str;
|
||||
|
||||
char *newstr = NULL;
|
||||
unsigned int needlesz = strlen(needle),
|
||||
replacesz = strlen(replace);
|
||||
|
||||
while (1) {
|
||||
q = strstr(p, needle);
|
||||
if(!q) { /* not found */
|
||||
if(*p) {
|
||||
/* add the rest of 'p' */
|
||||
_strnadd(&newstr, p, strlen(p));
|
||||
}
|
||||
break;
|
||||
} else { /* found match */
|
||||
if(q > p){
|
||||
/* add chars between this occurance and last occurance, if any */
|
||||
_strnadd(&newstr, p, q - p);
|
||||
}
|
||||
_strnadd(&newstr, replace, replacesz);
|
||||
p = q + needlesz;
|
||||
}
|
||||
}
|
||||
|
||||
return newstr;
|
||||
}
|
||||
|
||||
|
||||
/* Create a lock file */
|
||||
int _alpm_lckmk()
|
||||
{
|
||||
|
@ -60,7 +60,6 @@ int _alpm_makepath(const char *path);
|
||||
int _alpm_makepath_mode(const char *path, mode_t mode);
|
||||
int _alpm_copyfile(const char *src, const char *dest);
|
||||
char *_alpm_strtrim(char *str);
|
||||
char *_alpm_strreplace(const char *str, const char *needle, const char *replace);
|
||||
int _alpm_lckmk();
|
||||
int _alpm_lckrm();
|
||||
int _alpm_unpack(const char *archive, const char *prefix, const char *fn);
|
||||
|
Loading…
Reference in New Issue
Block a user