summaryrefslogtreecommitdiff
path: root/Build/source/texk/dvisvgm/dvisvgm-src/src/StreamReader.cpp
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2024-01-16 18:32:08 +0000
committerKarl Berry <karl@freefriends.org>2024-01-16 18:32:08 +0000
commit84b532c711d3e644d6ba05e8118356310fd68fbf (patch)
tree33d34c031bb6342b29a3801d2cc1f9208f637920 /Build/source/texk/dvisvgm/dvisvgm-src/src/StreamReader.cpp
parent32d816973b284f3e5a0bd28a7ad5ef73e3102b34 (diff)
dvisvgm 3.2
git-svn-id: svn://tug.org/texlive/trunk@69453 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/dvisvgm/dvisvgm-src/src/StreamReader.cpp')
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-src/src/StreamReader.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/StreamReader.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/StreamReader.cpp
index 196ce7affaa..93d4045248a 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-src/src/StreamReader.cpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/StreamReader.cpp
@@ -2,7 +2,7 @@
** StreamReader.cpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2023 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2024 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -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;