[devhelp] Replace newlines in book titles by spaces (GNOME bug 566117)



commit 84b6bd44f2f40b7f30c1a49165e5ad4c8616adc4
Author: Frédéric Péters <fpeters 0d be>
Date:   Thu Aug 27 21:50:41 2009 +0200

    Replace newlines in book titles by spaces (GNOME bug 566117)

 src/dh-parser.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/src/dh-parser.c b/src/dh-parser.c
index 0833077..9cb3b76 100644
--- a/src/dh-parser.c
+++ b/src/dh-parser.c
@@ -64,9 +64,9 @@ parser_start_node_book (DhParser             *parser,
                         const gchar         **attribute_values,
                         GError              **error)
 {
-        gint         i;
+        gint         i, j;
         gint         line, col;
-        const gchar *title = NULL;
+        gchar       *title = NULL;
         const gchar *base = NULL;
         const gchar *name = NULL;
         const gchar *uri = NULL;
@@ -104,7 +104,10 @@ parser_start_node_book (DhParser             *parser,
                         name = attribute_values[i];
                 }
                 else if (g_ascii_strcasecmp (attribute_names[i], "title") == 0) {
-                        title = attribute_values[i];
+                        title = g_strdup(attribute_values[i]);
+                        for (j = 0; title[j]; j++) {
+                                if (title[j] == '\n') title[j] = ' ';
+                        }
                 }
                 else if (g_ascii_strcasecmp (attribute_names[i], "base") == 0) {
                         base = attribute_values[i];
@@ -122,6 +125,7 @@ parser_start_node_book (DhParser             *parser,
                              _("\"title\", \"name\", and \"link\" elements are "
                                "required at line %d, column %d"),
                              line, col);
+                g_free (title);
                 return;
         }
 
@@ -144,6 +148,7 @@ parser_start_node_book (DhParser             *parser,
         parser->book_node = g_node_new (link);
         g_node_prepend (parser->book_tree, parser->book_node);
         parser->parent = parser->book_node;
+        g_free (title);
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]