aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJan Engelhardt <[email protected]>2019-10-04 19:53:04 +0000
committerJan Engelhardt <[email protected]>2019-10-05 09:31:51 +0000
commitc9119effd784055d27b71a567c3fbd0d6e7b03b0 (patch)
treeeb266a74531ea9f00a80573521fb3bc785c4f3b4 /src
parentModernize RFC reference for boundary line characteristics (diff)
downloadvmime-c9119effd784055d27b71a567c3fbd0d6e7b03b0.tar.gz
vmime-c9119effd784055d27b71a567c3fbd0d6e7b03b0.zip
Reduce indent by 3 levels in findNextBoundary
Diffstat (limited to 'src')
-rw-r--r--src/vmime/body.cpp76
1 files changed, 39 insertions, 37 deletions
diff --git a/src/vmime/body.cpp b/src/vmime/body.cpp
index 44679390..b7f491a1 100644
--- a/src/vmime/body.cpp
+++ b/src/vmime/body.cpp
@@ -65,7 +65,7 @@ size_t body::findNextBoundaryPosition(
size_t pos = position;
- while (pos != npos && pos < end) {
+ for (; pos != npos && pos < end; ++pos) {
pos = parser->findNext(boundary, pos);
@@ -73,60 +73,62 @@ size_t body::findNextBoundaryPosition(
break; // not found
}
- if (pos != 0) {
+ if (pos == 0) {
+ // Boundary is a prefix of another, continue the search (same for the other "continue"s)
+ continue;
+ }
- // Skip transport padding bytes (SPACE or HTAB), if any
- size_t advance = 0;
+ // Skip transport padding bytes (SPACE or HTAB), if any
+ size_t advance = 0;
- while (pos != 0) {
+ while (pos != 0) {
- parser->seek(pos - advance - 1);
+ parser->seek(pos - advance - 1);
- const byte_t c = parser->peekByte();
+ const byte_t c = parser->peekByte();
- if (c == ' ' || c == '\t') {
- ++advance;
- } else {
- break;
- }
+ if (c == ' ' || c == '\t') {
+ ++advance;
+ } else {
+ break;
}
+ }
- // Ensure the bytes before boundary are "[LF]--": boundary should be
- // at the beginning of a line, and should start with "--"
- if (pos - advance >= 3) {
-
- parser->seek(pos - advance - 3);
-
- if (parser->matchBytes("\n--", 3)) {
+ // Ensure the bytes before boundary are "[LF]--": boundary should be
+ // at the beginning of a line, and should start with "--"
+ if (pos - advance < 3) {
+ continue;
+ }
- parser->seek(pos + boundary.length());
+ parser->seek(pos - advance - 3);
- const byte_t next = parser->peekByte();
+ if (!parser->matchBytes("\n--", 3)) {
+ continue;
+ }
- // Boundary should be followed by a new line or a dash
- if (next == '\r' || next == '\n' || next == '-') {
+ parser->seek(pos + boundary.length());
- // Get rid of the "[CR]" just before "[LF]--", if any
- if (pos - advance >= 4) {
+ const byte_t next = parser->peekByte();
- parser->seek(pos - advance - 4);
+ // Boundary should be followed by a new line or a dash
+ if (next != '\r' && next != '\n' && next != '-') {
+ continue;
+ }
- if (parser->peekByte() == '\r') {
- advance++;
- }
- }
+ // Get rid of the "[CR]" just before "[LF]--", if any
+ if (pos - advance >= 4) {
- *boundaryStart = pos - advance - 3;
- *boundaryEnd = pos + boundary.length();
+ parser->seek(pos - advance - 4);
- return pos;
- }
- }
+ if (parser->peekByte() == '\r') {
+ advance++;
}
}
- // Boundary is a prefix of another, continue the search
- pos++;
+ *boundaryStart = pos - advance - 3;
+ *boundaryEnd = pos + boundary.length();
+
+ return pos;
}
return pos;