Sisyphus repositório
Última atualização: 1 outubro 2023 | SRPMs: 18631 | Visitas: 37752705
en ru br
ALT Linux repositórios
5.0: 0.12-alt1
4.1: 0.11-alt1.1
4.0: 0.9.1-alt7
3.0: 0.9.0-alt4

Group :: Sistema/Bibliotecas
RPM: librra

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs e FR  Repocop 

Patch: rra-comma_separated_fixed.diff
Download


diff -uriwbB rra/lib/contact.c rra-comma_separated_fixed/lib/contact.c
--- rra/lib/contact.c	2005-05-13 13:35:28.000000000 +0200
+++ rra-comma_separated_fixed/lib/contact.c	2005-05-13 18:20:48.000000000 +0200
@@ -67,6 +67,52 @@
 	}
 }/*}}}*/
 
+/* 
+   More or less the same as strbuf_append_escaped(), but specialized for comma separated lists
+*/
+static void strbuf_append_comma_separated(StrBuf* result, char* source, uint32_t flags)/*{{{*/
+{
+	char* p;
+
+	if (!source)
+		return;
+
+	for (p = source; *p; p++)
+	{
+		switch (*p)
+		{
+			case '\r': 				/* CR */
+				/* ignore */
+				break;		
+
+			case '\n':				/* LF */
+				strbuf_append_c(result, '\\');
+				strbuf_append_c(result, 'n');
+				break;
+	
+			case '\\':
+				strbuf_append_c(result, '\\');
+				strbuf_append_c(result, *p);
+				break;
+
+			case ',':
+				strbuf_append_c(result, ',');
+				while (*(p+1)==' ') /* skip blanks after comma */
+				  p++;
+				break;
+
+			case ';':
+				if (flags & RRA_CONTACT_VERSION_3_0)
+					strbuf_append_c(result, '\\');
+				/* fall through */
+
+			default:
+				strbuf_append_c(result, *p);
+				break;
+		}
+	}
+}/*}}}*/
+
 void strbuf_append_escaped_wstr(StrBuf* strbuf, WCHAR* wstr, uint32_t flags)/*{{{*/
 {
 	if (wstr)
@@ -83,6 +129,22 @@
 	}
 }/*}}}*/
 
+void strbuf_append_comma_separated_wstr(StrBuf* strbuf, WCHAR* wstr, uint32_t flags)/*{{{*/
+{
+	if (wstr)
+	{
+		char* str = NULL;
+	 
+		if (flags & RRA_CONTACT_UTF8)
+			str = wstr_to_utf8(wstr);
+		else
+			str = wstr_to_ascii(wstr);
+
+		strbuf_append_comma_separated(strbuf, str, flags);
+		wstr_free_string(str);
+	}
+}/*}}}*/
+
 /*
  * value should be a comma-separated list of types
  */
@@ -313,7 +375,7 @@
 
 			case ID_CATEGORY:
 				strbuf_append(vcard, "CATEGORIES:");
-				strbuf_append_escaped_wstr(vcard, pFields[i].val.lpwstr, flags);
+				strbuf_append_comma_separated_wstr(vcard, pFields[i].val.lpwstr, flags);
 				strbuf_append_crlf(vcard);
 				break;
 
 
projeto & código: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
mantenedor atual: Michael Shigorin
mantenedor da tradução: Fernando Martini aka fmartini © 2009