src/lib/INIReader.cpp
branchv_0
changeset 34 7eb3dcacba7b
parent 28 596a724fbb83
child 35 930f17f16fd7
--- a/src/lib/INIReader.cpp	Sun Dec 13 17:34:26 2020 +0100
+++ b/src/lib/INIReader.cpp	Tue Sep 21 21:02:43 2021 +0200
@@ -58,6 +58,20 @@
 
 	std::vector<ConfiguredDialect> dialects;
 
+	/**
+	 * If there is a „\“ backspace at the end of a physical line, the logical line continues on the next physical line.
+	 *
+	 * Disabling this option makes sense only if we also disable the unescaping processors (unescape-basic, unescape-backspace).
+	 * Otherwise they will complain about „Missing escape sequence“ because they got „\“ at the end of the value.
+	 */
+	bool allowLineContinuationsWithEscaping = true;
+
+	/**
+	 * If a line starts with a space, it is continuation of the previous line.
+	 * This rule conflicts with default ignorance of such insignificant whitespace and is quite specific to the Java MANIFEST.MF dialect.
+	 */
+	bool allowLineContinuationsWithSpace = false;
+
 	/** 
 	 * By default, we ignore all leading whitespace on continuing lines.
 	 * If there should be some spaces or tabs, they should be placed on the previous line before the „\“.
@@ -189,7 +203,7 @@
 		std::stringstream result;
 
 		for (char ch = peek(); input.good() && !oneOf(ch, until); ch = peek()) {
-			if (ch == '\\') {
+			if (allowLineContinuationsWithEscaping && ch == '\\') {
 				get();
 				ch = get();
 				if (oneOf(ch, until) && ch == '\n') processContinuingLine(result);
@@ -309,7 +323,9 @@
 	}
 
 	void setOption(const std::string& uri, const std::string& value) override {
-		if (uri == option::TrimContinuingLines) trimLeadingSpacesOnContinuingLines = parseBoolean(value); // TODO: continuing lines modes (enum), not just boolean
+		if (uri == option::AllowLineContinuationWithEscaping) allowLineContinuationsWithEscaping = parseBoolean(value);
+		else if (uri == option::AllowLineContinuationWithSpace) allowLineContinuationsWithSpace = parseBoolean(value);
+		else if (uri == option::TrimContinuingLines) trimLeadingSpacesOnContinuingLines = parseBoolean(value);
 		else if (uri == option::AllowSections) allowSections = parseBoolean(value);
 		else if (uri == option::AllowSectionTags) allowSectionTags = parseBoolean(value);
 		else if (uri == option::AllowSubKeys) allowSubKeys = parseBoolean(value);