summaryrefslogtreecommitdiff
path: root/repo/lshw/15565229509455527de9ce7cbb9530e2b31d043b.patch
diff options
context:
space:
mode:
Diffstat (limited to 'repo/lshw/15565229509455527de9ce7cbb9530e2b31d043b.patch')
-rw-r--r--repo/lshw/15565229509455527de9ce7cbb9530e2b31d043b.patch59
1 files changed, 59 insertions, 0 deletions
diff --git a/repo/lshw/15565229509455527de9ce7cbb9530e2b31d043b.patch b/repo/lshw/15565229509455527de9ce7cbb9530e2b31d043b.patch
new file mode 100644
index 0000000..0d9c65d
--- /dev/null
+++ b/repo/lshw/15565229509455527de9ce7cbb9530e2b31d043b.patch
@@ -0,0 +1,59 @@
+From 15565229509455527de9ce7cbb9530e2b31d043b Mon Sep 17 00:00:00 2001
+From: Lyonel Vincent <lyonel@ezix.org>
+Date: Wed, 27 May 2020 01:07:16 +0200
+Subject: [PATCH] clean-up JSON output
+
+---
+ src/core/hw.cc | 29 +++++++++++++++++++++++++----
+ 1 file changed, 25 insertions(+), 4 deletions(-)
+
+diff --git a/src/core/hw.cc b/src/core/hw.cc
+index ab345fe..6aea7cf 100644
+--- a/src/core/hw.cc
++++ b/src/core/hw.cc
+@@ -1650,13 +1650,20 @@ string hwNode::asJSON(unsigned level)
+ resources.clear();
+ }
+
+- for (unsigned int i = 0; i < countChildren(); i++)
++ if(!::enabled("output:list") && countChildren()>0)
+ {
+- out << getChild(i)->asJSON(visible(getClassName()) ? level + 2 : 1);
+- if (visible(getChild(i)->getClassName()))
++ out << "," << endl;
++ out << spaces(2*level+2);
++ out << "\"children\" : [";
++ for (unsigned int i = 0; i < countChildren(); i++)
+ {
+- out << "," << endl;
++ out << getChild(i)->asJSON(visible(getClassName()) ? level + 2 : 1);
++ if (visible(getChild(i)->getClassName()) && i<countChildren()-1)
++ {
++ out << "," << endl;
++ }
+ }
++ out << "]";
+ }
+
+ if(visible(getClassName()))
+@@ -1665,6 +1672,20 @@ string hwNode::asJSON(unsigned level)
+ out << "}";
+ }
+
++ if(::enabled("output:list") && countChildren()>0)
++ {
++ bool needcomma = visible(getClassName());
++ for (unsigned int i = 0; i < countChildren(); i++)
++ {
++ string json = getChild(i)->asJSON(visible(getClassName()) ? level + 2 : 1);
++
++ if(needcomma && strip(json)!="")
++ out << "," << endl;
++ out << getChild(i)->asJSON(visible(getClassName()) ? level + 2 : 1);
++ needcomma |= strip(json)!="";
++ }
++ }
++
+ if (::enabled("output:list") && level == 0)
+ {
+ out << endl << "]" << endl;