Duplicate io code

Bug #1120585 reported by Kris
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
Low
Kris

Bug Description

src/dom/io and src/io contain duplicate functionality and almost identical files. For maintainability of the source code, it is better to keep a single version.

The following files could probably be dropped from src/dom/io:
- base64stream.cpp and base64stream.h
- gzipstream.cpp and gzipstream.h

The following files could probably be dropped from src/dom/io and corresponding files in src/io be modified:
- stringstream.cpp and stringstream.h
- uristream.cpp and uristream.h

Kris (kris-degussem)
Changed in inkscape:
status: New → In Progress
importance: Undecided → Low
assignee: nobody → Kris (kris-degussem)
Revision history for this message
Kris (kris-degussem) wrote :

base64stream.* and gzipstream.* removed from dom/io in trunk revision 12118.

Revision history for this message
su_v (suv-lp) wrote :

On OS X 10.7.4, compiling r12123 (compiler: llvm-gcc-4.2), I see these new warnings (except those from poppler):

  CXX extension/init.o
  CXX extension/internal/pdfinput/svg-builder.o
In file included from /Volumes/cyan/mp-quartz/with-a-long-long-long-directory-name/include/poppler/Object.h:327,
                 from ../../src/extension/internal/pdfinput/pdf-parser.h:29,
                 from ../../src/extension/internal/pdfinput/svg-builder.cpp:23:
/Volumes/cyan/mp-quartz/with-a-long-long-long-directory-name/include/poppler/Stream.h:1058: warning: unused parameter ‘psLevel’
/Volumes/cyan/mp-quartz/with-a-long-long-long-directory-name/include/poppler/Stream.h:1058: warning: unused parameter ‘indent’
In file included from ../../src/extension/internal/pdfinput/svg-builder.cpp:38:
../../src/io/inkscapestream.h:215: warning: ‘virtual void Inkscape::IO::BasicOutputStream::put(gunichar)’ was hidden
../../src/io/base64stream.h:91: warning: by ‘virtual void Inkscape::IO::Base64OutputStream::put(int)
In file included from ../../src/extension/internal/pdfinput/svg-builder.cpp:42:
/Volumes/cyan/mp-quartz/with-a-long-long-long-directory-name/include/poppler/Function.h:84: warning: unused parameter ‘func’
  CXX extension/internal/odf.o
  CXX extension/internal/filter/filter-file.o
  CXX io/base64stream.o
In file included from ../../src/io/base64stream.cpp:32:
../../src/io/inkscapestream.h:215: warning: ‘virtual void Inkscape::IO::BasicOutputStream::put(gunichar)’ was hidden
../../src/io/base64stream.h:91: warning: by ‘virtual void Inkscape::IO::Base64OutputStream::put(int)
  CXX io/gzipstream.o
In file included from ../../src/io/gzipstream.cpp:29:
../../src/io/inkscapestream.h:215: warning: ‘virtual void Inkscape::IO::BasicOutputStream::put(gunichar)’ was hidden
../../src/io/gzipstream.h:101: warning: by ‘virtual void Inkscape::IO::GzipOutputStream::put(int)
  CXX io/inkscapestream.o
  CXX io/stringstream.o
  CXX io/uristream.o
  CXX io/xsltstream.o
In file included from ../../src/io/xsltstream.cpp:13:
../../src/io/inkscapestream.h:215: warning: ‘virtual void Inkscape::IO::BasicOutputStream::put(gunichar)’ was hidden
../../src/io/xsltstream.h:123: warning: by ‘virtual void Inkscape::IO::XsltOutputStream::put(int)
  CXX xml/repr-io.o
In file included from ../../src/xml/repr-io.cpp:32:
../../src/io/inkscapestream.h:215: warning: ‘virtual void Inkscape::IO::BasicOutputStream::put(gunichar)’ was hidden
../../src/io/gzipstream.h:101: warning: by ‘virtual void Inkscape::IO::GzipOutputStream::put(int)
  CXX ui/clipboard.o

Revision history for this message
Kris (kris-degussem) wrote :

Trunk revision 12125 fixes the warnings introduced in revision 12123.

Revision history for this message
su_v (suv-lp) wrote :

One more warning left with r12125:

In file included from ../../src/io/xsltstream.h:17:0,
                 from ../../src/io/xsltstream.cpp:13:
../../src/io/inkscapestream.h:215:18: warning: ‘virtual void Inkscape::IO::BasicOutputStream::put(gunichar)’ was hidden [-Woverloaded-virtual]
In file included from ../../src/io/xsltstream.cpp:13:0:
../../src/io/xsltstream.h:123:18: warning: by ‘virtual void Inkscape::IO::XsltOutputStream::put(int)’ [-Woverloaded-virtual]

(this one is copy&pasted from Ubuntu 12.10, FSF GCC 4.7.2, rebuilding after updating from r12119 to r12125)

Revision history for this message
Kris (kris-degussem) wrote :

re comment 4: should be fixed in trunk rev 12126

Revision history for this message
su_v (suv-lp) wrote :

New -Wformat warnings when compiling r12184 with Apple llvm-gcc-4.2, Apple clang, FSF GCC 4.6.3 (below):

../../src/extension/internal/odf.cpp: In member function 'bool Inkscape::Extension::Internal::OdfOutput::writeMeta(ZipFile&)':
../../src/extension/internal/odf.cpp:1248:50: warning: '#' flag used with '%s' gnu_printf format [-Wformat]
../../src/extension/internal/odf.cpp:1249:83: warning: '#' flag used with '%s' gnu_printf format [-Wformat]
../../src/extension/internal/odf.cpp:1257:64: warning: '#' flag used with '%s' gnu_printf format [-Wformat]
../../src/extension/internal/odf.cpp:1257:64: warning: '#' flag used with '%s' gnu_printf format [-Wformat]
../../src/extension/internal/odf.cpp:1257:64: warning: '#' flag used with '%s' gnu_printf format [-Wformat]
../../src/extension/internal/odf.cpp: In member function 'bool Inkscape::Extension::Internal::OdfOutput::writeStyle(ZipFile&)':
../../src/extension/internal/odf.cpp:1362:57: warning: '#' flag used with '%s' gnu_printf format [-Wformat]
../../src/extension/internal/odf.cpp:1363:65: warning: '#' flag used with '%s' gnu_printf format [-Wformat]
../../src/extension/internal/odf.cpp:1405:57: warning: '#' flag used with '%s' gnu_printf format [-Wformat]
../../src/extension/internal/odf.cpp:1406:65: warning: '#' flag used with '%s' gnu_printf format [-Wformat]
../../src/extension/internal/odf.cpp:1435:34: warning: '#' flag used with '%s' gnu_printf format [-Wformat]
../../src/extension/internal/odf.cpp:1439:34: warning: '#' flag used with '%s' gnu_printf format [-Wformat]
../../src/extension/internal/odf.cpp: In member function 'bool Inkscape::Extension::Internal::OdfOutput::processGradient(Inkscape::Extension::Internal::Writer&, SPItem*, const Glib::ustring&, Geom::Affine&)':
../../src/extension/internal/odf.cpp:1755:53: warning: '#' flag used with '%s' gnu_printf format [-Wformat]
../../src/extension/internal/odf.cpp:1756:61: warning: '#' flag used with '%s' gnu_printf format [-Wformat]
../../src/extension/internal/odf.cpp:1798:53: warning: '#' flag used with '%s' gnu_printf format [-Wformat]
../../src/extension/internal/odf.cpp:1799:61: warning: '#' flag used with '%s' gnu_printf format [-Wformat]
../../src/extension/internal/odf.cpp:1829:30: warning: '#' flag used with '%s' gnu_printf format [-Wformat]
../../src/extension/internal/odf.cpp:1833:30: warning: '#' flag used with '%s' gnu_printf format [-Wformat]

Revision history for this message
Kris (kris-degussem) wrote :

OK. Was not sure whether these were new warnings or old ones. Thanks for confirming my doubts!
Anyhow, this is another nice example of how refactoring brings old "hidden" issues on the forefront. The # symbol in printf commands is placed incorrect in several positions since a (very) long time in this file. Easy to fix, will do that later on when I have time...

Revision history for this message
Kris (kris-degussem) wrote :

warnings fixed in trunk revision 12191

Revision history for this message
Kris (kris-degussem) wrote :

Most of the duplicate io code dropped (=all that could be dropped now) in trunk r12192.

Changed in inkscape:
status: In Progress → Fix Committed
milestone: none → 0.49
Revision history for this message
su_v (suv-lp) wrote :

New -Wdeprecated warnings when compiling r12192 on OS X 10.7 with Apple llvm-gcc-4.2, Apple clang 3.1 (below):

  CXX extension/internal/odf.o
In file included from ../../src/extension/internal/odf.cpp:91:
In file included from ../../src/io/bufferstream.h:34:
In file included from /usr/include/c++/4.2.1/backward/vector.h:59:
/usr/include/c++/4.2.1/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated. [-W#warnings]
#warning This file includes at least one deprecated or antiquated header. \
 ^
1 warning generated.

and compilation failure with FSF GCC 4.6.3 (below):

  CXX extension/internal/odf.o
In file included from ../../src/extension/internal/odf.cpp:91:0:
../../src/io/bufferstream.h:34:20: fatal error: vector.h: No such file or directory
compilation terminated.
make[3]: *** [extension/internal/odf.o] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

Revision history for this message
su_v (suv-lp) wrote :

Build succeeds with FSF GCC 4.6.3, using this diff:

Chillida:inkscape-gcc46-2 su_v$ bzr diff src/io/
=== modified file 'src/io/bufferstream.h'
--- src/io/bufferstream.h 2013-03-11 21:47:05 +0000
+++ src/io/bufferstream.h 2013-03-11 22:13:01 +0000
@@ -31,7 +31,7 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */

-#include <vector.h>
+#include <vector>
 #include "inkscapestream.h"

Revision history for this message
Kris (kris-degussem) wrote :

Could not apply patch, but should be OK now (since r12195).

Revision history for this message
su_v (suv-lp) wrote :

> Could not apply patch

Sorry for that (somehow the 3 trailing empty lines got lost - next time I'll attach it properly as diff file). Trunk r12194 didn't build for me without that change on Ubuntu 12.10 (VM, 64bit) either btw (same error about "vector.h: No such file or directory"), so it wasn't just an issue with compilers on OS X.

Bryce Harrington (bryce)
Changed in inkscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.