mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Fixed folding bug (detecting indentation, example 8.2), and clipping/stripping empty strings (example 8.6)
This commit is contained in:
@@ -143,7 +143,7 @@ namespace YAML
|
|||||||
|
|
||||||
if(!nextEmptyLine && foldedNewlineCount > 0) {
|
if(!nextEmptyLine && foldedNewlineCount > 0) {
|
||||||
scalar += std::string(foldedNewlineCount - 1, '\n');
|
scalar += std::string(foldedNewlineCount - 1, '\n');
|
||||||
if(foldedNewlineStartedMoreIndented || nextMoreIndented)
|
if(foldedNewlineStartedMoreIndented || nextMoreIndented | !foundNonEmptyLine)
|
||||||
scalar += "\n";
|
scalar += "\n";
|
||||||
foldedNewlineCount = 0;
|
foldedNewlineCount = 0;
|
||||||
}
|
}
|
||||||
@@ -175,12 +175,23 @@ namespace YAML
|
|||||||
scalar.erase(pos + 1);
|
scalar.erase(pos + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(params.chomp == STRIP || params.chomp == CLIP) {
|
switch(params.chomp) {
|
||||||
std::size_t pos = scalar.find_last_not_of('\n');
|
case CLIP: {
|
||||||
if(params.chomp == CLIP && pos + 1 < scalar.size())
|
const std::size_t pos = scalar.find_last_not_of('\n');
|
||||||
scalar.erase(pos + 2);
|
if(pos == std::string::npos)
|
||||||
else if(params.chomp == STRIP && pos < scalar.size())
|
scalar.erase();
|
||||||
scalar.erase(pos + 1);
|
else if(pos + 1 < scalar.size())
|
||||||
|
scalar.erase(pos + 2);
|
||||||
|
} break;
|
||||||
|
case STRIP: {
|
||||||
|
const std::size_t pos = scalar.find_last_not_of('\n');
|
||||||
|
if(pos == std::string::npos)
|
||||||
|
scalar.erase();
|
||||||
|
else if(pos < scalar.size())
|
||||||
|
scalar.erase(pos + 1);
|
||||||
|
} break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return scalar;
|
return scalar;
|
||||||
|
Reference in New Issue
Block a user