X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fextension%2Finternal%2Fsvg.cpp;h=ab9c59830f99df36bf2cf958884af4ec25c25e5d;hb=3027d46e220d40848a2a56135aa0cbe2384c2ae4;hp=e6d02b62dbf5db759328d644dcaa2135267f4398;hpb=6b15695578f07a3f72c4c9475c1a261a3021472a;p=inkscape.git diff --git a/src/extension/internal/svg.cpp b/src/extension/internal/svg.cpp index e6d02b62d..ab9c59830 100644 --- a/src/extension/internal/svg.cpp +++ b/src/extension/internal/svg.cpp @@ -20,6 +20,7 @@ #include "file.h" #include "extension/system.h" #include "extension/output.h" +#include #ifdef WITH_GNOME_VFS # include @@ -29,6 +30,8 @@ namespace Inkscape { namespace Extension { namespace Internal { +#include "clear-n_.h" + /** \return None \brief What would an SVG editor be without loading/saving SVG @@ -49,13 +52,13 @@ Svg::init(void) /* SVG in */ ext = Inkscape::Extension::build_from_mem( "\n" - "SVG Input\n" + "" N_("SVG Input") "\n" "" SP_MODULE_KEY_INPUT_SVG "\n" "\n" ".svg\n" "image/x-svg\n" - "Scalable Vector Graphic (*.svg)\n" - "Inkscape native file format and W3C standard\n" + "" N_("Scalable Vector Graphic (*.svg)") "\n" + "" N_("Inkscape native file format and W3C standard") "\n" "" SP_MODULE_KEY_OUTPUT_SVG_INKSCAPE "\n" "\n" "", new Svg()); @@ -63,13 +66,13 @@ Svg::init(void) /* SVG out Inkscape */ ext = Inkscape::Extension::build_from_mem( "\n" - "SVG Output Inkscape\n" + "" N_("SVG Output Inkscape") "\n" "" SP_MODULE_KEY_OUTPUT_SVG_INKSCAPE "\n" "\n" ".svg\n" "image/x-svg\n" - "Inkscape SVG (*.svg)\n" - "SVG format with Inkscape extensions\n" + "" N_("Inkscape SVG (*.svg)") "\n" + "" N_("SVG format with Inkscape extensions") "\n" "FALSE\n" "\n" "", new Svg()); @@ -77,13 +80,13 @@ Svg::init(void) /* SVG out */ ext = Inkscape::Extension::build_from_mem( "\n" - "SVG Output\n" + "" N_("SVG Output") "\n" "" SP_MODULE_KEY_OUTPUT_SVG "\n" "\n" ".svg\n" "image/x-svg\n" - "Plain SVG (*.svg)\n" - "Scalable Vector Graphics format as defined by the W3C\n" + "" N_("Plain SVG (*.svg)") "\n" + "" N_("Scalable Vector Graphics format as defined by the W3C") "\n" "\n" "", new Svg()); @@ -104,9 +107,6 @@ _load_uri (const gchar *uri) { GnomeVFSHandle *handle = NULL; GnomeVFSFileSize bytes_read; - gchar buffer[BUF_SIZE] = ""; - gchar *doc = NULL; - gchar *new_doc = NULL; gsize bytesRead = 0; gsize bytesWritten = 0; @@ -123,20 +123,14 @@ _load_uri (const gchar *uri) g_warning(gnome_vfs_result_to_string(result)); } + std::vector doc; while (result == GNOME_VFS_OK) { + gchar buffer[BUF_SIZE]; result = gnome_vfs_read (handle, buffer, BUF_SIZE, &bytes_read); - buffer[bytes_read] = '\0'; - - if (doc == NULL) { - doc = g_strndup(buffer, bytes_read); - } else { - new_doc = g_strconcat(doc, buffer, NULL); - g_free(doc); - doc = new_doc; - } + doc.insert(doc.end(), buffer, buffer+bytes_read); } - return doc; + return g_strndup(&doc[0], doc.size()); } #endif