> Istniejąca funkcja gg_append() jest bardzo podobna do Twojej funkcji
> pomocniczej, tylko nie kończy ciągu \0 (zamiast strncpy() jest memcpy()).
> Jakbyś mógł przerobić na łatkę aby z niej korzystała to by było super.

Rzeczywiście, nie zauważyłem.

Te funkcje nie mają spójnych typów - gg_append korzysta z int, a moja
(i gg_message_html_to_text) z size_t. Domyślam się, że właściwym jest
tu użycie tego drugiego, więc w ten sposób poprawiłem kod. Sprawdziłem
z Pidginem - działa tak jak wcześniej.

Jedyne, co mnie martwi, to copy-paste tej funkcji do pliku libgadu.c,
oraz duże podobieństwo gg_message_text_to_html() do
gg_convert_to_html().

Pozdrawiam,
Tomek
Index: src/message.c
===================================================================
--- src/message.c	(wersja 1091)
+++ src/message.c	(kopia robocza)
@@ -361,7 +361,7 @@
  * \param src Dodawany tekst
  * \param len Długość dodawanego tekstu
  */
-static void gg_append(char *dst, int *pos, const void *src, int len)
+static void gg_append(char *dst, size_t *pos, const void *src, size_t len)
 {
 	if (dst != NULL)
 		memcpy(&dst[*pos], src, len);
@@ -394,7 +394,8 @@
 	int format_idx = 0;
 	unsigned char old_attr = 0;
 	const unsigned char *color = (const unsigned char*) "\x00\x00\x00";
-	int len, i;
+	int i;
+	size_t len;
 	const unsigned char *format_ = (const unsigned char*) format;
 
 	len = 0;
@@ -585,8 +586,11 @@
 
 	for (src = html; *src != 0; src++) {
 		if (*src == '<') {
+			if (in_entity)
+				gg_append(dst, &len, entity, src - entity);
 			tag = src;
 			in_tag = 1;
+			in_entity = 0;
 			continue;
 		}
 
@@ -603,7 +607,9 @@
 		if (in_tag)
 			continue;
 
-		if (*src == '&') {
+		if (*src == '&' && !in_tag) {
+			if (in_entity)
+				gg_append(dst, &len, entity, src - entity);
 			in_entity = 1;
 			entity = src;
 			continue;
@@ -637,8 +643,10 @@
 			continue;
 		}
 
-		if (in_entity && !(isalnum(*src) || *src == '#'))
+		if (in_entity && !(isalnum(*src) || *src == '#')) {
+			gg_append(dst, &len, entity, src - entity);
 			in_entity = 0;
+		}
 
 		if (in_entity)
 			continue;
_______________________________________________
libgadu-devel mailing list
[email protected]
http://lists.ziew.org/mailman/listinfo/libgadu-devel

Reply via email to