Document as 2.4 additions. (unescape_text): Implement newline and
authorMatthias Clasen <maclas@gmx.de>
Wed, 8 Oct 2003 21:44:04 +0000 (21:44 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Wed, 8 Oct 2003 21:44:04 +0000 (21:44 +0000)
Wed Oct  8 23:40:26 2003  Matthias Clasen  <maclas@gmx.de>

* 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.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
glib/gmarkup.c

index 612015a14987ef360a93d1962e10da5a11a26c5a..d7d2302dde25328eac940f679db2be06db730d9d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Wed Oct  8 23:40:26 2003  Matthias Clasen  <maclas@gmx.de>
+
+       * 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  <maclas@gmx.de>
 
        * configure.in: Make the various printf feature test macros
index 612015a14987ef360a93d1962e10da5a11a26c5a..d7d2302dde25328eac940f679db2be06db730d9d 100644 (file)
@@ -1,3 +1,11 @@
+Wed Oct  8 23:40:26 2003  Matthias Clasen  <maclas@gmx.de>
+
+       * 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  <maclas@gmx.de>
 
        * configure.in: Make the various printf feature test macros
index 612015a14987ef360a93d1962e10da5a11a26c5a..d7d2302dde25328eac940f679db2be06db730d9d 100644 (file)
@@ -1,3 +1,11 @@
+Wed Oct  8 23:40:26 2003  Matthias Clasen  <maclas@gmx.de>
+
+       * 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  <maclas@gmx.de>
 
        * configure.in: Make the various printf feature test macros
index 612015a14987ef360a93d1962e10da5a11a26c5a..d7d2302dde25328eac940f679db2be06db730d9d 100644 (file)
@@ -1,3 +1,11 @@
+Wed Oct  8 23:40:26 2003  Matthias Clasen  <maclas@gmx.de>
+
+       * 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  <maclas@gmx.de>
 
        * configure.in: Make the various printf feature test macros
index 612015a14987ef360a93d1962e10da5a11a26c5a..d7d2302dde25328eac940f679db2be06db730d9d 100644 (file)
@@ -1,3 +1,11 @@
+Wed Oct  8 23:40:26 2003  Matthias Clasen  <maclas@gmx.de>
+
+       * 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  <maclas@gmx.de>
 
        * configure.in: Make the various printf feature test macros
index 612015a14987ef360a93d1962e10da5a11a26c5a..d7d2302dde25328eac940f679db2be06db730d9d 100644 (file)
@@ -1,3 +1,11 @@
+Wed Oct  8 23:40:26 2003  Matthias Clasen  <maclas@gmx.de>
+
+       * 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  <maclas@gmx.de>
 
        * configure.in: Make the various printf feature test macros
index 0dd265fbea78a3b157e0b85a1a739efaa05f7638..f5090305870dbb7763d81a68575f73182f140394 100644 (file)
@@ -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.
  *
  * <informalexample><programlisting>
- * const char *store = "Fortnum & Mason";
+ * const char *store = "Fortnum &amp; Mason";
  * const char *item = "Tea";
  * char *output;
  * &nbsp;
@@ -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, ...)