summaryrefslogtreecommitdiff
path: root/mail/evolution/patches/patch-ad
blob: be7cb4b5d933d77b81337ca4b0aeaedc9238e8cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
$NetBSD: patch-ad,v 1.10 2008/06/05 11:08:08 drochner Exp $

--- calendar/gui/itip-utils.c.orig	2008-04-04 11:18:00.000000000 +0200
+++ calendar/gui/itip-utils.c
@@ -174,50 +174,16 @@ get_attendee_if_attendee_sentby_is_user 
 }
 
 static char *
-html_new_lines_for (char *string)
+html_new_lines_for (const char *string)
 {
-	char *html_string = (char *) malloc (sizeof (char)* (3500));
-	int length = strlen (string);
-	int index = 0;
-	char *index_ptr = string;
-	char *temp = string;
+	gchar **lines;
+	gchar *joined;
 
-	/*Find the first occurence*/
-	index_ptr = strstr ((const char *)temp, "\n");
+	lines = g_strsplit_set (string, "\n", -1);
+	joined = g_strjoinv ("<br>", lines);
+	g_strfreev (lines);
 
-	/*Doesn't occur*/
-	if (index_ptr == NULL) {
-		strcpy (html_string, (const char *)string);
-		html_string[length] = '\0';
-		return html_string;
-	}
-
-	/*Split into chunks inserting <br> for \n */
-	do{
-		while (temp != index_ptr){
-			html_string[index++] = *temp;
-			temp++;
-		}
-		temp++;
-
-		html_string[index++] = '<';
-		html_string[index++] = 'b';
-		html_string[index++] = 'r';
-		html_string[index++] = '>';
-
-		index_ptr = strstr ((const char *)temp, "\n");
-
-	} while (index_ptr);
-
-	/*Don't leave out the last chunk*/
-	while (*temp != '\0'){
-		html_string[index++] = *temp;
-		temp++;
-	}
-
-	html_string[index] = '\0';
-
-	return html_string;
+	return joined;
 }
 
 char *