aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/ContentNormalizer.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/ContentNormalizer.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/ContentNormalizer.cc')
-rw-r--r--libqpdf/ContentNormalizer.cc48
1 files changed, 18 insertions, 30 deletions
diff --git a/libqpdf/ContentNormalizer.cc b/libqpdf/ContentNormalizer.cc
index 1793c6f3..d7f3cbd7 100644
--- a/libqpdf/ContentNormalizer.cc
+++ b/libqpdf/ContentNormalizer.cc
@@ -18,57 +18,46 @@ ContentNormalizer::handleToken(QPDFTokenizer::Token const& token)
std::string value = token.getRawValue();
QPDFTokenizer::token_type_e token_type = token.getType();
- if (token_type == QPDFTokenizer::tt_bad)
- {
+ if (token_type == QPDFTokenizer::tt_bad) {
this->any_bad_tokens = true;
this->last_token_was_bad = true;
- }
- else if (token_type != QPDFTokenizer::tt_eof)
- {
+ } else if (token_type != QPDFTokenizer::tt_eof) {
this->last_token_was_bad = false;
}
- switch (token_type)
- {
- case QPDFTokenizer::tt_space:
+ switch (token_type) {
+ case QPDFTokenizer::tt_space:
{
size_t len = value.length();
- for (size_t i = 0; i < len; ++i)
- {
+ for (size_t i = 0; i < len; ++i) {
char ch = value.at(i);
- if (ch == '\r')
- {
- if ((i + 1 < len) && (value.at(i + 1) == '\n'))
- {
+ if (ch == '\r') {
+ if ((i + 1 < len) && (value.at(i + 1) == '\n')) {
// ignore
- }
- else
- {
+ } else {
write("\n");
}
- }
- else
- {
+ } else {
write(&ch, 1);
}
}
}
break;
- case QPDFTokenizer::tt_string:
+ case QPDFTokenizer::tt_string:
// Replacing string and name tokens in this way normalizes
// their representation as this will automatically handle
// quoting of unprintable characters, etc.
- writeToken(QPDFTokenizer::Token(
- QPDFTokenizer::tt_string, token.getValue()));
+ writeToken(
+ QPDFTokenizer::Token(QPDFTokenizer::tt_string, token.getValue()));
break;
- case QPDFTokenizer::tt_name:
- writeToken(QPDFTokenizer::Token(
- QPDFTokenizer::tt_name, token.getValue()));
+ case QPDFTokenizer::tt_name:
+ writeToken(
+ QPDFTokenizer::Token(QPDFTokenizer::tt_name, token.getValue()));
break;
- default:
+ default:
writeToken(token);
break;
}
@@ -77,8 +66,7 @@ ContentNormalizer::handleToken(QPDFTokenizer::Token const& token)
if (((token_type == QPDFTokenizer::tt_string) ||
(token_type == QPDFTokenizer::tt_name)) &&
((value.find('\r') != std::string::npos) ||
- (value.find('\n') != std::string::npos)))
- {
+ (value.find('\n') != std::string::npos))) {
write("\n");
}
}
@@ -90,7 +78,7 @@ ContentNormalizer::anyBadTokens() const
}
bool
-ContentNormalizer::lastTokenWasBad()const
+ContentNormalizer::lastTokenWasBad() const
{
return this->last_token_was_bad;
}