# HG changeset patch # User František Kučera # Date 1632250963 -7200 # Node ID 7eb3dcacba7b7be5aadb5145e517bd8a6339d84a # Parent 3b81fbeb5f3baffac86d5e44114be2bf5168cfb4 implement --parser-option allow-line-continuation-with-escaping + add skeleton for allow-line-continuation-with-space diff -r 3b81fbeb5f3b -r 7eb3dcacba7b bash-completion.sh --- a/bash-completion.sh Sun Dec 13 17:34:26 2020 +0100 +++ b/bash-completion.sh Tue Sep 21 21:02:43 2021 +0200 @@ -30,6 +30,8 @@ # TODO: introspection: after moving to alt2xml the available options and their values should be provided by the parser PARSER_OPTIONS=( + "allow-line-continuation-with-escaping" + "allow-line-continuation-with-space" "trim-continuing-lines" "allow-sections" "allow-section-tags" @@ -56,6 +58,8 @@ elif [[ "$w1" == "--enable-line-numbers" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0")) elif [[ "$w1" == "--enable-event-numbers" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0")) elif [[ "$w1" == "--parser-option" ]]; then COMPREPLY=($(compgen -W "${PARSER_OPTIONS[*]}" -- "$w0")) + elif [[ "$w2" == "--parser-option" && "$w1" == "allow-line-continuation-with-escaping" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0")) + elif [[ "$w2" == "--parser-option" && "$w1" == "allow-line-continuation-with-space" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0")) elif [[ "$w2" == "--parser-option" && "$w1" == "trim-continuing-lines" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0")) elif [[ "$w2" == "--parser-option" && "$w1" == "allow-sections" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0")) elif [[ "$w2" == "--parser-option" && "$w1" == "allow-section-tags" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0")) diff -r 3b81fbeb5f3b -r 7eb3dcacba7b src/lib/INIReader.cpp --- 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 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); diff -r 3b81fbeb5f3b -r 7eb3dcacba7b src/lib/uri.h --- a/src/lib/uri.h Sun Dec 13 17:34:26 2020 +0100 +++ b/src/lib/uri.h Tue Sep 21 21:02:43 2021 +0200 @@ -25,6 +25,8 @@ /** general options of the INI parser */ namespace option { +static const char* AllowLineContinuationWithEscaping = "allow-line-continuation-with-escaping"; +static const char* AllowLineContinuationWithSpace = "allow-line-continuation-with-space"; static const char* TrimContinuingLines = "trim-continuing-lines"; static const char* AllowSections = "allow-sections"; static const char* AllowSectionTags = "allow-section-tags";