From df5adc29c40c2ae0f8024a23e321971c0dbd709a Mon Sep 17 00:00:00 2001 From: nandan Date: Mon, 30 Jan 2023 15:48:35 +0530 Subject: [PATCH 1/4] FOGL-7375 : Modified to return default value as blank for type:script Signed-off-by: nandan --- C/common/config_category.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/C/common/config_category.cpp b/C/common/config_category.cpp index a3dffe5e10..5a84d93ef3 100644 --- a/C/common/config_category.cpp +++ b/C/common/config_category.cpp @@ -1566,11 +1566,21 @@ ostringstream convert; else if (m_itemType == JsonItem || m_itemType == NumberItem || m_itemType == DoubleItem || - m_itemType == ScriptItem || m_itemType == CodeItem) { convert << ", \"default\" : \"" << JSONescape(m_default) << "\" }"; } + else if ( m_itemType == ScriptItem ) + { + if (m_default == "\"\"" ) + { + convert << ", \"default\" : \"\" }"; + } + else + { + convert << ", \"default\" : \"" << JSONescape(m_default) << "\" }"; + } + } return convert.str(); } From 7615dc0e930a8bf66b1222dc31dd0b7e4572e5ea Mon Sep 17 00:00:00 2001 From: nandan Date: Tue, 31 Jan 2023 11:29:51 +0530 Subject: [PATCH 2/4] FOGL-7375 : Modfied CategoryItem constructor to not pass quotes for blank value or default config item Signed-off-by: nandan --- C/common/config_category.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/C/common/config_category.cpp b/C/common/config_category.cpp index 5a84d93ef3..703943fb9c 100644 --- a/C/common/config_category.cpp +++ b/C/common/config_category.cpp @@ -1264,7 +1264,8 @@ ConfigCategory::CategoryItem::CategoryItem(const string& name, item["default"].Accept(writer); if (m_default.empty()) { - m_default = "\"\""; + m_default = ""; + } } else @@ -1566,21 +1567,12 @@ ostringstream convert; else if (m_itemType == JsonItem || m_itemType == NumberItem || m_itemType == DoubleItem || + m_itemType == ScriptItem || m_itemType == CodeItem) { convert << ", \"default\" : \"" << JSONescape(m_default) << "\" }"; } - else if ( m_itemType == ScriptItem ) - { - if (m_default == "\"\"" ) - { - convert << ", \"default\" : \"\" }"; - } - else - { - convert << ", \"default\" : \"" << JSONescape(m_default) << "\" }"; - } - } + return convert.str(); } From aa7f365da1b1eaa48c55b23301bb78212fa0a408 Mon Sep 17 00:00:00 2001 From: nandan Date: Tue, 31 Jan 2023 12:29:19 +0530 Subject: [PATCH 3/4] Revert "FOGL-7375 : Modfied CategoryItem constructor to not pass quotes for blank value or default config item" This reverts commit 7615dc0e930a8bf66b1222dc31dd0b7e4572e5ea. --- C/common/config_category.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/C/common/config_category.cpp b/C/common/config_category.cpp index 703943fb9c..5a84d93ef3 100644 --- a/C/common/config_category.cpp +++ b/C/common/config_category.cpp @@ -1264,8 +1264,7 @@ ConfigCategory::CategoryItem::CategoryItem(const string& name, item["default"].Accept(writer); if (m_default.empty()) { - m_default = ""; - + m_default = "\"\""; } } else @@ -1567,12 +1566,21 @@ ostringstream convert; else if (m_itemType == JsonItem || m_itemType == NumberItem || m_itemType == DoubleItem || - m_itemType == ScriptItem || m_itemType == CodeItem) { convert << ", \"default\" : \"" << JSONescape(m_default) << "\" }"; } - + else if ( m_itemType == ScriptItem ) + { + if (m_default == "\"\"" ) + { + convert << ", \"default\" : \"\" }"; + } + else + { + convert << ", \"default\" : \"" << JSONescape(m_default) << "\" }"; + } + } return convert.str(); } From 02a72ee2b04294a93a85f5c6b469dd7cad2f28ff Mon Sep 17 00:00:00 2001 From: nandan Date: Tue, 31 Jan 2023 12:53:34 +0530 Subject: [PATCH 4/4] FOGL-7375 : Removed hard coding for default Signed-off-by: nandan --- C/common/config_category.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/C/common/config_category.cpp b/C/common/config_category.cpp index 5a84d93ef3..1984bac2f4 100644 --- a/C/common/config_category.cpp +++ b/C/common/config_category.cpp @@ -1572,9 +1572,9 @@ ostringstream convert; } else if ( m_itemType == ScriptItem ) { - if (m_default == "\"\"" ) + if (m_default == "\"\"" ) // Already escaped blank value, No need to escape twice { - convert << ", \"default\" : \"\" }"; + convert << ", \"default\" : " << m_default << " }"; } else {