From 845f21207c53c36c02f14343dcf4dbbca5462ce0 Mon Sep 17 00:00:00 2001 From: Xavier Chantry Date: Mon, 7 Sep 2009 01:13:24 +0200 Subject: libalpm/util.c : remove _alpm_strreplace This function is unused since commit 358cc5804a2df873180e6d9ef2420ab3247f8437. Signed-off-by: Xavier Chantry [Dan: also kill from util.h] Signed-off-by: Dan McGee --- lib/libalpm/util.c | 45 --------------------------------------------- lib/libalpm/util.h | 1 - 2 files changed, 46 deletions(-) diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 082c095b..f78d193a 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -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() { diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h index 4bc8b92f..ccf169d3 100644 --- a/lib/libalpm/util.h +++ b/lib/libalpm/util.h @@ -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); -- cgit v1.2.3-70-g09d2