java-manifest-mf + improve unescaping v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 13 Dec 2020 17:34:26 +0100
branchv_0
changeset 33 3b81fbeb5f3b
parent 32 193c643f4ffe
child 34 7eb3dcacba7b
java-manifest-mf + improve unescaping
bash-completion.sh
src/INICommand.cpp
src/lib/BasicUnescapingProcessor.h
src/lib/Dialect.h
src/lib/UnescapingProcessor.h
src/lib/uri.h
--- a/bash-completion.sh	Sun Nov 29 10:50:16 2020 +0100
+++ b/bash-completion.sh	Sun Dec 13 17:34:26 2020 +0100
@@ -45,6 +45,7 @@
 
 	DIALECTS=(
 		"java-properties"
+		"java-manifest-mf"
 	);
 
 	if   [[ "$w1" == "--relation"                      && "x$w0" == "x" ]];    then COMPREPLY=("''")
--- a/src/INICommand.cpp	Sun Nov 29 10:50:16 2020 +0100
+++ b/src/INICommand.cpp	Sun Dec 13 17:34:26 2020 +0100
@@ -177,6 +177,7 @@
 	reader->addUnescapingProcessor(std::make_shared<JavaPropertiesUnescapingProcessor>(), unescaping::JavaProperties, false);
 	reader->addUnescapingProcessor(std::make_shared<BackspaceUnescapingProcessor>(), unescaping::Backspace, true);
 	reader->addDialect(std::make_shared<JavaPropertiesDialect>(), dialect::JavaProperties, false);
+	reader->addDialect(std::make_shared<JavaPropertiesDialect>(), dialect::JavaManifestMF, false);
 	reader->addHandler(&handler);
 	// TODO: smart pointers vs. references: are we going to call addUnescapingProcessor() dynamically/conditionally or share instances? Then pointers will be better.
 	for (ParserOptionRecipe option : configuration.parserOptions) reader->setOption(convertor.to_bytes(option.uri), convertor.to_bytes(option.value));
--- a/src/lib/BasicUnescapingProcessor.h	Sun Nov 29 10:50:16 2020 +0100
+++ b/src/lib/BasicUnescapingProcessor.h	Sun Dec 13 17:34:26 2020 +0100
@@ -43,6 +43,7 @@
 				else if (ch == 's') put(result, ' ', i); // TODO: Reconsider what is „basic“ escaping and should be supported.
 				else if (ch == '"') put(result, ch, i); //        The delimiters (\n,]",') are already unescaped during the first stage in the INIReader while parsing (the delimiter relevant to given environment is unescaped, e.g. \" in "quoted" value).
 				else if (ch == '\'') put(result, ch, i); //       So it does not necessary to do it here. But someone might write a="xxx\'zzz" however it is superfluous because a="xxx'zzz" will also work.
+				else if (ch == '[') put(result, ch, i);
 				else if (ch == ']') put(result, ch, i);
 				else if (ch == ':') put(result, ch, i);
 				else if (ch == ';') put(result, ch, i);
--- a/src/lib/Dialect.h	Sun Nov 29 10:50:16 2020 +0100
+++ b/src/lib/Dialect.h	Sun Dec 13 17:34:26 2020 +0100
@@ -18,8 +18,6 @@
 
 #include "INIReader.h"
 
-using namespace std;
-
 namespace relpipe {
 namespace in {
 namespace ini {
@@ -37,6 +35,9 @@
 	 */
 	virtual void apply(INIReader& reader) = 0;
 
+	virtual ~Dialect() {
+	}
+
 };
 
 }
--- a/src/lib/UnescapingProcessor.h	Sun Nov 29 10:50:16 2020 +0100
+++ b/src/lib/UnescapingProcessor.h	Sun Dec 13 17:34:26 2020 +0100
@@ -20,8 +20,6 @@
 
 #include "INIReader.h"
 
-using namespace std;
-
 namespace relpipe {
 namespace in {
 namespace ini {
@@ -52,6 +50,8 @@
 
 	virtual std::string unescape(const std::string& s, const TextType type) = 0;
 
+	virtual ~UnescapingProcessor() {
+	}
 };
 
 }
--- a/src/lib/uri.h	Sun Nov 29 10:50:16 2020 +0100
+++ b/src/lib/uri.h	Sun Dec 13 17:34:26 2020 +0100
@@ -45,6 +45,7 @@
 /** not options but a values of the dialect option */
 namespace dialect {
 static const char* JavaProperties = "java-properties";
+static const char* JavaManifestMF = "java-manifest-mf";
 }
 
 /** options for configuring the stage where events from the INI parser are converted to SAX events or DOM building */