diff options
| author | Jon A. Cruz <jon@joncruz.org> | 2009-03-14 08:19:42 +0000 |
|---|---|---|
| committer | joncruz <joncruz@users.sourceforge.net> | 2009-03-14 08:19:42 +0000 |
| commit | 673a3f92430aa236fc8ffa9ebebfe5088338cd2d (patch) | |
| tree | e399e1b528e570ee283f7ccc4391892b0fe77abe | |
| parent | Casts and legibility cleanup (diff) | |
| download | inkscape-673a3f92430aa236fc8ffa9ebebfe5088338cd2d.tar.gz inkscape-673a3f92430aa236fc8ffa9ebebfe5088338cd2d.zip | |
Work-around output encoding issues with comments. Fixes bug #340451.
(bzr r7485)
| -rw-r--r-- | src/xml/repr-io.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp index 3bc79a98c..e503540bb 100644 --- a/src/xml/repr-io.cpp +++ b/src/xml/repr-io.cpp @@ -662,6 +662,35 @@ repr_quote_write (Writer &out, const gchar * val) } } +static void repr_write_comment( Writer &out, const gchar * val, bool addWhitespace, gint indentLevel, int indent ) +{ + if ( indentLevel > 16 ) { + indentLevel = 16; + } + if (addWhitespace && indent) { + for (gint i = 0; i < indentLevel; i++) { + for (gint j = 0; j < indent; j++) { + out.writeString(" "); + } + } + } + + out.writeString("<!--"); + // WARNING out.printf() and out.writeString() are *NOT* non-ASCII friendly. + if (val) { + for (const gchar* cur = val; *cur; cur++ ) { + out.writeChar(*cur); + } + } else { + out.writeString(" "); + } + out.writeString("-->"); + + if (addWhitespace) { + out.writeString("\n"); + } +} + namespace { typedef std::map<Glib::QueryQuark, gchar const *, Inkscape::compare_quark_ids> LocalNameMap; @@ -777,7 +806,7 @@ void sp_repr_write_stream( Node *repr, Writer &out, gint indent_level, break; } case Inkscape::XML::COMMENT_NODE: { - out.printf( "<!--%s-->", repr->content() ); + repr_write_comment( out, repr->content(), add_whitespace, indent_level, indent ); break; } case Inkscape::XML::PI_NODE: { |
