summaryrefslogtreecommitdiff
path: root/dviware/dvisvgm/src/StreamReader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dviware/dvisvgm/src/StreamReader.cpp')
-rw-r--r--dviware/dvisvgm/src/StreamReader.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/dviware/dvisvgm/src/StreamReader.cpp b/dviware/dvisvgm/src/StreamReader.cpp
index 196ce7affa..1513ae97db 100644
--- a/dviware/dvisvgm/src/StreamReader.cpp
+++ b/dviware/dvisvgm/src/StreamReader.cpp
@@ -40,7 +40,7 @@ istream& StreamReader::replaceStream (istream &in) {
uint32_t StreamReader::readUnsigned (int bytes) {
uint32_t ret = 0;
for (bytes--; bytes >= 0 && !_is->eof(); bytes--) {
- uint32_t b = uint32_t(_is->get());
+ auto b = uint32_t(_is->get());
ret |= b << (8*bytes);
}
return ret;
@@ -62,7 +62,7 @@ uint32_t StreamReader::readUnsigned (int n, HashFunction &hashfunc) {
* @param[in] bytes number of bytes to read (max. 4)
* @return read integer */
int32_t StreamReader::readSigned (int bytes) {
- uint32_t ret = uint32_t(_is->get());
+ auto ret = uint32_t(_is->get());
if (ret & 128) // negative value?
ret |= 0xffffff00;
for (bytes-=2; bytes >= 0 && !_is->eof(); bytes--)
@@ -84,12 +84,12 @@ int32_t StreamReader::readSigned (int n, HashFunction &hashfunc) {
/** Reads a string terminated by a 0-byte. */
string StreamReader::readString () {
- if (!_is)
- throw StreamReaderException("no stream assigned");
string ret;
- while (!_is->eof() && _is->peek() > 0)
- ret += char(_is->get());
- _is->get(); // skip 0-byte
+ if (_is) {
+ while (!_is->eof() && _is->peek() > 0)
+ ret += char(_is->get());
+ _is->get(); // skip 0-byte
+ }
return ret;
}
@@ -102,7 +102,7 @@ string StreamReader::readString (HashFunction &hashfunc, bool finalZero) {
string ret = readString();
hashfunc.update(ret.data(), ret.length());
if (finalZero)
- hashfunc.update(0, 1);
+ hashfunc.update(nullptr, 1);
return ret;
}
@@ -111,11 +111,11 @@ string StreamReader::readString (HashFunction &hashfunc, bool finalZero) {
* @param[in] length number of characters to read
* @return the string read */
string StreamReader::readString (int length) {
- if (!_is)
- throw StreamReaderException("no stream assigned");
- length = max(0, length);
- string str(length, '\0');
- _is->read(&str[0], length); // read 'length' bytes and append '\0'
+ string str;
+ if (_is) {
+ str.resize(max(0, length));
+ _is->read(&str[0], streamsize(str.length())); // read 'length' bytes and append '\0'
+ }
return str;
}
@@ -149,7 +149,7 @@ vector<uint8_t> StreamReader::readBytes (int n, HashFunction &hashfunc) {
int StreamReader::readByte (HashFunction &hashfunc) {
int ret = readByte();
if (ret >= 0) {
- char c = ret & 0xff;
+ char c = char(ret & 0xff);
hashfunc.update(&c, 1);
}
return ret;