Merge branch 'b_fix_markup-only_one_replace' of git://github.com/matcatc/dunst into fix_markup

This commit is contained in:
Sascha Kruse 2013-01-19 04:09:30 +01:00
commit 97bf419028
3 changed files with 31 additions and 15 deletions

30
dunst.c
View File

@ -874,23 +874,23 @@ char
return NULL; return NULL;
} }
str = string_replace(""", "\"", str); str = string_replace_all(""", "\"", str);
str = string_replace("'", "'", str); str = string_replace_all("'", "'", str);
str = string_replace("&", "&", str); str = string_replace_all("&", "&", str);
str = string_replace("&lt;", "<", str); str = string_replace_all("&lt;", "<", str);
str = string_replace("&gt;", ">", str); str = string_replace_all("&gt;", ">", str);
/* remove tags */ /* remove tags */
str = string_replace("<b>", "", str); str = string_replace_all("<b>", "", str);
str = string_replace("</b>", "", str); str = string_replace_all("</b>", "", str);
str = string_replace("<br>", " ", str); str = string_replace_all("<br>", " ", str);
str = string_replace("<br/>", " ", str); str = string_replace_all("<br/>", " ", str);
str = string_replace("<br />", " ", str); str = string_replace_all("<br />", " ", str);
str = string_replace("<i>", "", str); str = string_replace_all("<i>", "", str);
str = string_replace("</i>", "", str); str = string_replace_all("</i>", "", str);
str = string_replace("<u>", "", str); str = string_replace_all("<u>", "", str);
str = string_replace("</u>", "", str); str = string_replace_all("</u>", "", str);
str = string_replace("</a>", "", str); str = string_replace_all("</a>", "", str);
start = strstr(str, "<a href"); start = strstr(str, "<a href");
if (start != NULL) { if (start != NULL) {

12
utils.c
View File

@ -25,6 +25,18 @@ char *lskip(char *s)
return s; return s;
} }
char *string_replace_all(const char *needle, const char *replacement,
char *haystack)
{
char *start;
start = strstr(haystack, needle);
while(start != NULL) {
haystack = string_replace(needle, replacement, haystack);
start = strstr(haystack, needle);
}
return haystack;
}
char *string_replace(const char *needle, const char *replacement, char *string_replace(const char *needle, const char *replacement,
char *haystack) char *haystack)
{ {

View File

@ -4,6 +4,10 @@
char *rstrip(char *str); char *rstrip(char *str);
char *lskip(char *str); char *lskip(char *str);
/* replace all occurrences of needle with replacement in haystack */
char *string_replace_all(const char *needle, const char *replacement,
char *haystack);
/* replace needle with replacement in haystack */ /* replace needle with replacement in haystack */
char *string_replace(const char *needle, const char *replacement, char *string_replace(const char *needle, const char *replacement,
char *haystack); char *haystack);