diff options
| author | Eduard Braun <eduard.braun2@gmx.de> | 2018-09-24 22:14:20 +0000 |
|---|---|---|
| committer | Patrick Storz <eduard.braun2@gmx.de> | 2018-09-29 21:04:56 +0000 |
| commit | ca9d69e7e53354800b57421d7b0e90191c604d2c (patch) | |
| tree | 4576f8f26925c9d3a3a8b0b8a4ff7f4b51782c8f /src | |
| parent | Clean up stream output in repr-io.cpp (diff) | |
| download | inkscape-ca9d69e7e53354800b57421d7b0e90191c604d2c.tar.gz inkscape-ca9d69e7e53354800b57421d7b0e90191c604d2c.zip | |
Purge gunichar from Inkscapestream
None of these functions seems to expect an actual gunichar (which is
a 32-bit type and can hold any UTF-32 or UCS-4 character code, also
known as a Unicode code point).
Instead we want UTF-8 encoded character data (i.e. gchar, which is
equivalent to char) that can be output byte-wise to form a valid
UTF-8 encoded string.
Diffstat (limited to 'src')
| -rw-r--r-- | src/extension/internal/filter/filter-file.cpp | 4 | ||||
| -rw-r--r-- | src/io/base64stream.cpp | 2 | ||||
| -rw-r--r-- | src/io/base64stream.h | 2 | ||||
| -rw-r--r-- | src/io/bufferstream.cpp | 2 | ||||
| -rw-r--r-- | src/io/bufferstream.h | 2 | ||||
| -rw-r--r-- | src/io/gzipstream.cpp | 6 | ||||
| -rw-r--r-- | src/io/gzipstream.h | 2 | ||||
| -rw-r--r-- | src/io/inkscapestream.cpp | 31 | ||||
| -rw-r--r-- | src/io/inkscapestream.h | 22 | ||||
| -rw-r--r-- | src/io/stringstream.cpp | 2 | ||||
| -rw-r--r-- | src/io/stringstream.h | 2 | ||||
| -rw-r--r-- | src/io/uristream.cpp | 8 | ||||
| -rw-r--r-- | src/io/uristream.h | 6 | ||||
| -rw-r--r-- | src/io/xsltstream.cpp | 2 | ||||
| -rw-r--r-- | src/io/xsltstream.h | 2 |
15 files changed, 46 insertions, 49 deletions
diff --git a/src/extension/internal/filter/filter-file.cpp b/src/extension/internal/filter/filter-file.cpp index 023643deb..d95bbf184 100644 --- a/src/extension/internal/filter/filter-file.cpp +++ b/src/extension/internal/filter/filter-file.cpp @@ -80,13 +80,13 @@ class mywriter : public Inkscape::IO::BasicWriter { public: void close() override; void flush() override; - void put (gunichar ch) override; + void put (char ch) override; gchar const * c_str () { return _str.c_str(); } }; void mywriter::close () { return; } void mywriter::flush () { return; } -void mywriter::put (gunichar ch) { _str += ch; } +void mywriter::put (char ch) { _str += ch; } void diff --git a/src/io/base64stream.cpp b/src/io/base64stream.cpp index c0c5e1a02..c08584e33 100644 --- a/src/io/base64stream.cpp +++ b/src/io/base64stream.cpp @@ -290,7 +290,7 @@ void Base64OutputStream::putCh(int ch) /** * Writes the specified byte to this output stream. */ -int Base64OutputStream::put(gunichar ch) +int Base64OutputStream::put(char ch) { if (closed) { diff --git a/src/io/base64stream.h b/src/io/base64stream.h index 697f64678..2db5a19e5 100644 --- a/src/io/base64stream.h +++ b/src/io/base64stream.h @@ -88,7 +88,7 @@ public: void flush() override; - int put(gunichar ch) override; + int put(char ch) override; /** * Sets the maximum line length for base64 output. If diff --git a/src/io/bufferstream.cpp b/src/io/bufferstream.cpp index 9a79f4e1b..235c0de77 100644 --- a/src/io/bufferstream.cpp +++ b/src/io/bufferstream.cpp @@ -135,7 +135,7 @@ void BufferOutputStream::flush() /** * Writes the specified byte to this output stream. */ -int BufferOutputStream::put(gunichar ch) +int BufferOutputStream::put(char ch) { if (closed) return -1; diff --git a/src/io/bufferstream.h b/src/io/bufferstream.h index e1b57252d..81b278a51 100644 --- a/src/io/bufferstream.h +++ b/src/io/bufferstream.h @@ -86,7 +86,7 @@ public: ~BufferOutputStream() override; void close() override; void flush() override; - int put(gunichar ch) override; + int put(char ch) override; virtual std::vector<unsigned char> &getBuffer() { return buffer; } diff --git a/src/io/gzipstream.cpp b/src/io/gzipstream.cpp index dfb605f14..82e20a08f 100644 --- a/src/io/gzipstream.cpp +++ b/src/io/gzipstream.cpp @@ -359,14 +359,14 @@ void GzipOutputStream::close() uLong outlong = crc; for (int n = 0; n < 4; n++) { - destination.put(static_cast<gunichar>(outlong & 0xff)); + destination.put(static_cast<char>(outlong & 0xff)); outlong >>= 8; } //# send the file length outlong = totalIn & 0xffffffffL; for (int n = 0; n < 4; n++) { - destination.put(static_cast<gunichar>(outlong & 0xff)); + destination.put(static_cast<char>(outlong & 0xff)); outlong >>= 8; } @@ -432,7 +432,7 @@ void GzipOutputStream::flush() /** * Writes the specified byte to this output stream. */ -int GzipOutputStream::put(gunichar ch) +int GzipOutputStream::put(char ch) { if (closed) { diff --git a/src/io/gzipstream.h b/src/io/gzipstream.h index 1fc137b41..26eee2af4 100644 --- a/src/io/gzipstream.h +++ b/src/io/gzipstream.h @@ -98,7 +98,7 @@ public: void flush() override; - int put(gunichar ch) override; + int put(char ch) override; private: diff --git a/src/io/inkscapestream.cpp b/src/io/inkscapestream.cpp index be69e4139..7afc3a175 100644 --- a/src/io/inkscapestream.cpp +++ b/src/io/inkscapestream.cpp @@ -125,7 +125,7 @@ void BasicOutputStream::flush() /** * Writes the specified byte to this output stream. */ -int BasicOutputStream::put(gunichar ch) +int BasicOutputStream::put(char ch) { if (closed) return -1; @@ -173,12 +173,12 @@ void BasicReader::close() /** * Reads the next byte of data from the reader. */ -gunichar BasicReader::get() +char BasicReader::get() { if (source) return source->get(); else - return (gunichar)-1; + return (char)-1; } @@ -190,7 +190,7 @@ Glib::ustring BasicReader::readLine() Glib::ustring str; while (available() > 0) { - gunichar ch = get(); + char ch = get(); if (ch == '\n') break; str.push_back(ch); @@ -206,8 +206,8 @@ Glib::ustring BasicReader::readWord() Glib::ustring str; while (available() > 0) { - gunichar ch = get(); - if (!g_unichar_isprint(ch)) + char ch = get(); + if (!std::isprint(ch)) break; str.push_back(ch); } @@ -366,10 +366,9 @@ int InputStreamReader::available() * Overloaded to receive its bytes from an InputStream * rather than a Reader */ -gunichar InputStreamReader::get() +char InputStreamReader::get() { - //Do we need conversions here? - gunichar ch = (gunichar)inputStream.get(); + char ch = inputStream.get(); return ch; } @@ -418,10 +417,9 @@ int StdReader::available() * Overloaded to receive its bytes from an InputStream * rather than a Reader */ -gunichar StdReader::get() +char StdReader::get() { - //Do we need conversions here? - gunichar ch = (gunichar)inputStream->get(); + char ch = inputStream->get(); return ch; } @@ -464,7 +462,7 @@ void BasicWriter::flush() /** * Writes the specified byte to this output writer. */ -void BasicWriter::put(gunichar ch) +void BasicWriter::put(char ch) { if (destination) destination->put(ch); @@ -490,8 +488,7 @@ Writer &BasicWriter::printf(char const *fmt, ...) */ Writer &BasicWriter::writeChar(char ch) { - gunichar uch = ch; - put(uch); + put(ch); return *this; } @@ -738,7 +735,7 @@ void OutputStreamWriter::flush() * Overloaded to redirect the output chars from the next Writer * in the chain to an OutputStream instead. */ -void OutputStreamWriter::put(gunichar ch) +void OutputStreamWriter::put(char ch) { outputStream.put(ch); } @@ -788,7 +785,7 @@ void StdWriter::flush() * Overloaded to redirect the output chars from the next Writer * in the chain to an OutputStream instead. */ -void StdWriter::put(gunichar ch) +void StdWriter::put(char ch) { outputStream->put(ch); } diff --git a/src/io/inkscapestream.h b/src/io/inkscapestream.h index 2e0a7aa20..d1b27e902 100644 --- a/src/io/inkscapestream.h +++ b/src/io/inkscapestream.h @@ -189,7 +189,7 @@ public: /** * Send one byte to the destination stream. */ - virtual int put(gunichar ch) = 0; + virtual int put(char ch) = 0; }; // class OutputStream @@ -212,7 +212,7 @@ public: void flush() override; - int put(gunichar ch) override; + int put(char ch) override; protected: @@ -238,7 +238,7 @@ public: void flush() override { } - int put(gunichar ch) override + int put(char ch) override {return putchar(ch); } }; @@ -275,7 +275,7 @@ public: virtual void close() = 0; - virtual gunichar get() = 0; + virtual char get() = 0; virtual Glib::ustring readLine() = 0; @@ -330,7 +330,7 @@ public: void close() override; - gunichar get() override; + char get() override; Glib::ustring readLine() override; @@ -402,7 +402,7 @@ public: void close() override; - gunichar get() override; + char get() override; private: @@ -429,7 +429,7 @@ public: void close() override; - gunichar get() override; + char get() override; private: @@ -470,7 +470,7 @@ public: virtual void flush() = 0; - virtual void put(gunichar ch) = 0; + virtual void put(char ch) = 0; /* Formatted output */ virtual Writer& printf(char const *fmt, ...) G_GNUC_PRINTF(2,3) = 0; @@ -524,7 +524,7 @@ public: void flush() override; - void put(gunichar ch) override; + void put(char ch) override; @@ -615,7 +615,7 @@ public: void flush() override; - void put(gunichar ch) override; + void put(char ch) override; private: @@ -643,7 +643,7 @@ public: void flush() override; - void put(gunichar ch) override; + void put(char ch) override; private: diff --git a/src/io/stringstream.cpp b/src/io/stringstream.cpp index 62918ffa5..360cc7fc9 100644 --- a/src/io/stringstream.cpp +++ b/src/io/stringstream.cpp @@ -108,7 +108,7 @@ void StringOutputStream::flush() /** * Writes the specified byte to this output stream. */ -int StringOutputStream::put(gunichar ch) +int StringOutputStream::put(char ch) { buffer.push_back(ch); return 1; diff --git a/src/io/stringstream.h b/src/io/stringstream.h index 91285f850..215e9b6a0 100644 --- a/src/io/stringstream.h +++ b/src/io/stringstream.h @@ -67,7 +67,7 @@ public: void flush() override; - int put(gunichar ch) override; + int put(char ch) override; virtual Glib::ustring &getString() { return buffer; } diff --git a/src/io/uristream.cpp b/src/io/uristream.cpp index 6dfb38e1f..0b38dbc84 100644 --- a/src/io/uristream.cpp +++ b/src/io/uristream.cpp @@ -268,9 +268,9 @@ void UriReader::close() /** * */ -gunichar UriReader::get() +char UriReader::get() { - gunichar ch = (gunichar)inputStream->get(); + char ch = inputStream->get(); return ch; } @@ -402,7 +402,7 @@ void UriOutputStream::flush() /** * Writes the specified byte to this output stream. */ -int UriOutputStream::put(gunichar ch) +int UriOutputStream::put(char ch) { if (closed) return -1; @@ -468,7 +468,7 @@ void UriWriter::flush() /** * */ -void UriWriter::put(gunichar ch) +void UriWriter::put(char ch) { outputStream->put(ch); } diff --git a/src/io/uristream.h b/src/io/uristream.h index 531f5f484..4c6f0607c 100644 --- a/src/io/uristream.h +++ b/src/io/uristream.h @@ -84,7 +84,7 @@ public: void close() override; - gunichar get() override; + char get() override; private: @@ -118,7 +118,7 @@ public: void flush() override; - int put(gunichar ch) override; + int put(char ch) override; private: @@ -155,7 +155,7 @@ public: void flush() override; - void put(gunichar ch) override; + void put(char ch) override; private: diff --git a/src/io/xsltstream.cpp b/src/io/xsltstream.cpp index 2e3c954da..916cb0ed0 100644 --- a/src/io/xsltstream.cpp +++ b/src/io/xsltstream.cpp @@ -228,7 +228,7 @@ void XsltOutputStream::flush() /** * Writes the specified byte to this output stream. */ -int XsltOutputStream::put(gunichar ch) +int XsltOutputStream::put(char ch) { outbuf.push_back(ch); return 1; diff --git a/src/io/xsltstream.h b/src/io/xsltstream.h index b1ad57faa..da5068ce2 100644 --- a/src/io/xsltstream.h +++ b/src/io/xsltstream.h @@ -118,7 +118,7 @@ public: void flush() override; - int put(gunichar ch) override; + int put(char ch) override; private: |
