aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/Pl_ASCII85Decoder.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-04-02 23:14:10 +0200
committerJay Berkenbilt <ejb@ql.org>2022-04-04 14:10:40 +0200
commit12f1eb15ca3fed6310402847559a7c99d3c77847 (patch)
tree8935675b623c6f3b4914b8b44f7fa5f2816a9241 /libqpdf/Pl_ASCII85Decoder.cc
parentf20fa61eb4c323eb1642c69c236b3d9a1f8b2cdb (diff)
downloadqpdf-12f1eb15ca3fed6310402847559a7c99d3c77847.tar.zst
Programmatically apply new formatting to code
Run this: for i in **/*.cc **/*.c **/*.h **/*.hh; do clang-format < $i >| $i.new && mv $i.new $i done
Diffstat (limited to 'libqpdf/Pl_ASCII85Decoder.cc')
-rw-r--r--libqpdf/Pl_ASCII85Decoder.cc77
1 files changed, 29 insertions, 48 deletions
diff --git a/libqpdf/Pl_ASCII85Decoder.cc b/libqpdf/Pl_ASCII85Decoder.cc
index c8e6d860..5d1bbee2 100644
--- a/libqpdf/Pl_ASCII85Decoder.cc
+++ b/libqpdf/Pl_ASCII85Decoder.cc
@@ -19,55 +19,41 @@ Pl_ASCII85Decoder::~Pl_ASCII85Decoder()
void
Pl_ASCII85Decoder::write(unsigned char* buf, size_t len)
{
- if (eod > 1)
- {
+ if (eod > 1) {
return;
}
- for (size_t i = 0; i < len; ++i)
- {
- if (eod > 1)
- {
+ for (size_t i = 0; i < len; ++i) {
+ if (eod > 1) {
break;
- }
- else if (eod == 1)
- {
- if (buf[i] == '>')
- {
+ } else if (eod == 1) {
+ if (buf[i] == '>') {
flush();
eod = 2;
- }
- else
- {
+ } else {
throw std::runtime_error(
"broken end-of-data sequence in base 85 data");
}
- }
- else
- {
- switch (buf[i])
- {
- case ' ':
- case '\f':
- case '\v':
- case '\t':
- case '\r':
- case '\n':
+ } else {
+ switch (buf[i]) {
+ case ' ':
+ case '\f':
+ case '\v':
+ case '\t':
+ case '\r':
+ case '\n':
QTC::TC("libtests", "Pl_ASCII85Decoder ignore space");
// ignore whitespace
break;
- case '~':
+ case '~':
eod = 1;
break;
- case 'z':
- if (pos != 0)
- {
+ case 'z':
+ if (pos != 0) {
throw std::runtime_error(
"unexpected z during base 85 decode");
- }
- else
- {
+ } else {
QTC::TC("libtests", "Pl_ASCII85Decoder read z");
unsigned char zeroes[4];
memset(zeroes, '\0', 4);
@@ -75,17 +61,13 @@ Pl_ASCII85Decoder::write(unsigned char* buf, size_t len)
}
break;
- default:
- if ((buf[i] < 33) || (buf[i] > 117))
- {
+ default:
+ if ((buf[i] < 33) || (buf[i] > 117)) {
throw std::runtime_error(
"character out of range during base 85 decode");
- }
- else
- {
+ } else {
this->inbuf[this->pos++] = buf[i];
- if (pos == 5)
- {
+ if (pos == 5) {
flush();
}
}
@@ -98,28 +80,27 @@ Pl_ASCII85Decoder::write(unsigned char* buf, size_t len)
void
Pl_ASCII85Decoder::flush()
{
- if (this->pos == 0)
- {
+ if (this->pos == 0) {
QTC::TC("libtests", "Pl_ASCII85Decoder no-op flush");
return;
}
unsigned long lval = 0;
- for (int i = 0; i < 5; ++i)
- {
+ for (int i = 0; i < 5; ++i) {
lval *= 85;
lval += (this->inbuf[i] - 33U);
}
unsigned char outbuf[4];
memset(outbuf, 0, 4);
- for (int i = 3; i >= 0; --i)
- {
+ for (int i = 3; i >= 0; --i) {
outbuf[i] = lval & 0xff;
lval >>= 8;
}
- QTC::TC("libtests", "Pl_ASCII85Decoder partial flush",
- (this->pos == 5) ? 0 : 1);
+ QTC::TC(
+ "libtests",
+ "Pl_ASCII85Decoder partial flush",
+ (this->pos == 5) ? 0 : 1);
// Reset before calling getNext()->write in case that throws an
// exception.
auto t = this->pos - 1;