diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-04-02 23:14:10 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-04-04 14:10:40 +0200 |
commit | 12f1eb15ca3fed6310402847559a7c99d3c77847 (patch) | |
tree | 8935675b623c6f3b4914b8b44f7fa5f2816a9241 /libtests/rc4.cc | |
parent | f20fa61eb4c323eb1642c69c236b3d9a1f8b2cdb (diff) | |
download | qpdf-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 'libtests/rc4.cc')
-rw-r--r-- | libtests/rc4.cc | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/libtests/rc4.cc b/libtests/rc4.cc index b7aecd4b..7245ef86 100644 --- a/libtests/rc4.cc +++ b/libtests/rc4.cc @@ -1,12 +1,12 @@ #include <qpdf/Pl_RC4.hh> #include <qpdf/Pl_StdioFile.hh> -#include <qpdf/QUtil.hh> #include <qpdf/QIntC.hh> +#include <qpdf/QUtil.hh> -#include <stdio.h> -#include <string.h> #include <iostream> +#include <stdio.h> #include <stdlib.h> +#include <string.h> #ifdef NDEBUG // We need assert even in a release build for test code. @@ -14,7 +14,8 @@ #endif #include <cassert> -static void other_tests() +static void +other_tests() { // Test cases not covered by the pipeline: string as key, convert // in place @@ -26,16 +27,15 @@ static void other_tests() std::cout << "passed" << std::endl; } -int main(int argc, char* argv[]) +int +main(int argc, char* argv[]) { - if ((argc == 2) && (strcmp(argv[1], "other") == 0)) - { + if ((argc == 2) && (strcmp(argv[1], "other") == 0)) { other_tests(); return 0; } - if (argc != 4) - { + if (argc != 4) { std::cerr << "Usage: rc4 hex-key infile outfile" << std::endl; exit(2); } @@ -49,35 +49,30 @@ int main(int argc, char* argv[]) key[keylen] = '\0'; FILE* infile = QUtil::safe_fopen(infilename, "rb"); - for (unsigned int i = 0; i < strlen(hexkey); i += 2) - { + for (unsigned int i = 0; i < strlen(hexkey); i += 2) { char t[3]; t[0] = hexkey[i]; t[1] = hexkey[i + 1]; t[2] = '\0'; long val = strtol(t, 0, 16); - key[i/2] = static_cast<unsigned char>(val); + key[i / 2] = static_cast<unsigned char>(val); } FILE* outfile = QUtil::safe_fopen(outfilename, "wb"); Pl_StdioFile* out = new Pl_StdioFile("stdout", outfile); // Use a small buffer size (64) for testing Pl_RC4* rc4 = new Pl_RC4("rc4", out, key, QIntC::to_int(keylen), 64U); - delete [] key; + delete[] key; // 64 < buffer size < 512, buffer_size is not a power of 2 for testing unsigned char buf[100]; bool done = false; - while (! done) - { + while (!done) { size_t len = fread(buf, 1, sizeof(buf), infile); - if (len <= 0) - { + if (len <= 0) { done = true; - } - else - { + } else { rc4->write(buf, len); } } |