From: Matthias Clasen Date: Wed, 8 Oct 2003 21:44:04 +0000 (+0000) Subject: Document as 2.4 additions. (unescape_text): Implement newline and X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=fce9dce6b3e689c910ec9badfedafbd58b680c8a;p=dana%2Fcg-glib.git Document as 2.4 additions. (unescape_text): Implement newline and Wed Oct 8 23:40:26 2003 Matthias Clasen * glib/gmarkup.c (g_markup_printf_escaped): (g_markup_vprintf_escaped): Document as 2.4 additions. (unescape_text): Implement newline and whitespace normalization according to the XML specification. (#123919) (g_markup_escape_text): Document whitespace (non)handling. --- diff --git a/ChangeLog b/ChangeLog index 612015a1..d7d2302d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Wed Oct 8 23:40:26 2003 Matthias Clasen + + * glib/gmarkup.c (g_markup_printf_escaped): + (g_markup_vprintf_escaped): Document as 2.4 additions. + (unescape_text): Implement newline and whitespace normalization + according to the XML specification. (#123919) + (g_markup_escape_text): Document whitespace (non)handling. + 2003-10-05 Matthias Clasen * configure.in: Make the various printf feature test macros diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 612015a1..d7d2302d 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,11 @@ +Wed Oct 8 23:40:26 2003 Matthias Clasen + + * glib/gmarkup.c (g_markup_printf_escaped): + (g_markup_vprintf_escaped): Document as 2.4 additions. + (unescape_text): Implement newline and whitespace normalization + according to the XML specification. (#123919) + (g_markup_escape_text): Document whitespace (non)handling. + 2003-10-05 Matthias Clasen * configure.in: Make the various printf feature test macros diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 612015a1..d7d2302d 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,11 @@ +Wed Oct 8 23:40:26 2003 Matthias Clasen + + * glib/gmarkup.c (g_markup_printf_escaped): + (g_markup_vprintf_escaped): Document as 2.4 additions. + (unescape_text): Implement newline and whitespace normalization + according to the XML specification. (#123919) + (g_markup_escape_text): Document whitespace (non)handling. + 2003-10-05 Matthias Clasen * configure.in: Make the various printf feature test macros diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 612015a1..d7d2302d 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,11 @@ +Wed Oct 8 23:40:26 2003 Matthias Clasen + + * glib/gmarkup.c (g_markup_printf_escaped): + (g_markup_vprintf_escaped): Document as 2.4 additions. + (unescape_text): Implement newline and whitespace normalization + according to the XML specification. (#123919) + (g_markup_escape_text): Document whitespace (non)handling. + 2003-10-05 Matthias Clasen * configure.in: Make the various printf feature test macros diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 612015a1..d7d2302d 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,11 @@ +Wed Oct 8 23:40:26 2003 Matthias Clasen + + * glib/gmarkup.c (g_markup_printf_escaped): + (g_markup_vprintf_escaped): Document as 2.4 additions. + (unescape_text): Implement newline and whitespace normalization + according to the XML specification. (#123919) + (g_markup_escape_text): Document whitespace (non)handling. + 2003-10-05 Matthias Clasen * configure.in: Make the various printf feature test macros diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 612015a1..d7d2302d 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,11 @@ +Wed Oct 8 23:40:26 2003 Matthias Clasen + + * glib/gmarkup.c (g_markup_printf_escaped): + (g_markup_vprintf_escaped): Document as 2.4 additions. + (unescape_text): Implement newline and whitespace normalization + according to the XML specification. (#123919) + (g_markup_escape_text): Document whitespace (non)handling. + 2003-10-05 Matthias Clasen * configure.in: Make the various printf feature test macros diff --git a/glib/gmarkup.c b/glib/gmarkup.c index 0dd265fb..f5090305 100644 --- a/glib/gmarkup.c +++ b/glib/gmarkup.c @@ -335,9 +335,16 @@ unescape_text (GMarkupParseContext *context, const gchar *p; UnescapeState state; const gchar *start; + gboolean normalize_attribute; str = g_string_new (NULL); + if (context->state == STATE_INSIDE_ATTRIBUTE_VALUE_SQ || + context->state == STATE_INSIDE_ATTRIBUTE_VALUE_DQ) + normalize_attribute = TRUE; + else + normalize_attribute = FALSE; + state = USTATE_INSIDE_TEXT; p = text; start = p; @@ -350,7 +357,26 @@ unescape_text (GMarkupParseContext *context, case USTATE_INSIDE_TEXT: { while (p != text_end && *p != '&') - p = g_utf8_next_char (p); + { + if ((*p == '\t' || *p == '\n') && normalize_attribute) + { + g_string_append_len (str, start, p - start); + g_string_append_c (str, ' '); + p = g_utf8_next_char (p); + start = p; + } + else if (*p == '\r') + { + g_string_append_len (str, start, p - start); + g_string_append_c (str, normalize_attribute ? ' ' : '\n'); + p = g_utf8_next_char (p); + if (*p == '\n') + p = g_utf8_next_char (p); + start = p; + } + else + p = g_utf8_next_char (p); + } if (p != start) { @@ -752,6 +778,7 @@ find_current_text_end (GMarkupParseContext *context) } } + static void add_attribute (GMarkupParseContext *context, char *name) { @@ -1809,6 +1836,10 @@ append_escaped_text (GString *str, * corresponding entities. This function would typically be used * when writing out a file to be parsed with the markup parser. * + * Note that this function doesn't protect whitespace and line endings + * from being processed according to the XML rules for normalization + * of line endings and attribute values. + * * Return value: escaped text **/ gchar* @@ -1965,6 +1996,8 @@ find_conversion (const char *format, * * Return value: newly allocated result from formatting * operation. Free with g_free(). + * + * Since: 2.4 **/ char * g_markup_vprintf_escaped (const char *format, @@ -2103,7 +2136,7 @@ g_markup_vprintf_escaped (const char *format, * might themselves contain markup. * * - * const char *store = "Fortnum & Mason"; + * const char *store = "Fortnum & Mason"; * const char *item = "Tea"; * char *output; *   @@ -2116,6 +2149,8 @@ g_markup_vprintf_escaped (const char *format, * * Return value: newly allocated result from formatting * operation. Free with g_free(). + * + * Since: 2.4 **/ char * g_markup_printf_escaped (const char *format, ...)