From 30027481f7f9e9191f7c8deea51850b7a76b1b1f Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sat, 23 Feb 2013 21:46:21 -0500 Subject: Remove all old-style casts from C++ code --- libqpdf/QPDF.cc | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'libqpdf/QPDF.cc') diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index 5860fb11..7cd3509b 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -159,9 +159,10 @@ QPDF::processMemoryFile(char const* description, char const* password) { processInputSource( - new BufferInputSource(description, - new Buffer((unsigned char*)buf, length), - true), + new BufferInputSource( + description, + new Buffer(QUtil::unsigned_char_pointer(buf), length), + true), password); } @@ -280,7 +281,7 @@ QPDF::parse(char const* password) // where the regexp matches. char* p = buf; char const* candidate = ""; - while ((p = (char*)memchr(p, 's', tbuf_size - (p - buf))) != 0) + while ((p = static_cast(memchr(p, 's', tbuf_size - (p - buf)))) != 0) { if (eof_re.match(p)) { @@ -796,7 +797,7 @@ QPDF::processXRefStream(qpdf_offset_t xref_offset, QPDFObjectHandle& xref_obj) for (int k = 0; k < W[j]; ++k) { fields[j] <<= 8; - fields[j] += (int)(*p++); + fields[j] += static_cast(*p++); } } @@ -828,7 +829,8 @@ QPDF::processXRefStream(qpdf_offset_t xref_offset, QPDFObjectHandle& xref_obj) // This is needed by checkLinearization() this->first_xref_item_offset = xref_offset; } - insertXrefEntry(obj, (int)fields[0], fields[1], (int)fields[2]); + insertXrefEntry(obj, static_cast(fields[0]), + fields[1], static_cast(fields[2])); } if (! this->trailer.isInitialized()) @@ -1096,8 +1098,7 @@ QPDF::readObject(PointerHolder input, } length = length_obj.getIntValue(); - input->seek( - stream_offset + (qpdf_offset_t)length, SEEK_SET); + input->seek(stream_offset + length, SEEK_SET); if (! (readToken(input) == QPDFTokenizer::Token( QPDFTokenizer::tt_word, "endstream"))) @@ -1395,7 +1396,7 @@ QPDF::readObjectAtOffset(bool try_recovery, char ch; if (this->file->read(&ch, 1)) { - if (! isspace((unsigned char)ch)) + if (! isspace(static_cast(ch))) { this->file->seek(-1, SEEK_CUR); break; @@ -2064,7 +2065,7 @@ QPDF::pipeStreamData(int objid, int generation, "unexpected EOF reading stream data"); } length -= len; - pipeline->write((unsigned char*)buf, len); + pipeline->write(QUtil::unsigned_char_pointer(buf), len); } } catch (QPDFExc& e) -- cgit v1.2.3-54-g00ecf