[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH] kconfigeditor2: Fix processing of 'source' inside 'choice'



Currently kconfigeditor.kconfig.menu.all.All assumes the parser will put
all MenuEntrySource elements directly under the parse root.  However,
they may also be placed under a MenuEntryChoice.  There is one instance
where this occurs in current linux sources, in
drivers/usb/gadget/Kconfig.

There are two options to fix this; either push the MenuEntrySource
elements up or handle MenuEntryChoice elements specially.

Please apply one of the following:

Index: kconfigeditor/kconfig/menu/all.py
===================================================================
--- kconfigeditor/kconfig/menu/all.py	(revision 22704)
+++ kconfigeditor/kconfig/menu/all.py	(working copy)
@@ -2,7 +2,7 @@
 
 import os
 
-from . import MenuEntrySource
+from . import MenuEntrySource, MenuEntryChoice
 from .file import Parser
 
 
@@ -28,9 +28,13 @@
                 if not f:
                     f = cache[filename] = self.read(filename)
 
-                for i in f:
-                    if isinstance(i, MenuEntrySource):
-                        work.append(i.filename)
+                def add_files(f):
+                    for i in f:
+                        if isinstance(i, MenuEntrySource):
+                            work.append(i.filename)
+                        elif isinstance(i, MenuEntryChoice):
+                            add_files(i)
+                add_files(f)
 
                 files_arch.append(f)
 
--- END ---

Index: kconfigeditor/kconfig/menu/file.py
===================================================================
--- kconfigeditor/kconfig/menu/file.py	(revision 22704)
+++ kconfigeditor/kconfig/menu/file.py	(working copy)
@@ -182,6 +182,7 @@
         super(_BlockChoice, self).__init__(parent)
         self.entry = MenuEntryChoice()
         parent.entry.append(self.entry)
+        self._parent = parent
         _BlockConfigData(self, self.entry)
 
     def process_default(self, text, ind):
@@ -190,6 +191,10 @@
     def process_endchoice(self, text, ind):
         self.pop()
 
+    def process_source(self, text, ind):
+        # Push source statements up to the parent
+        self._parent.process_source(text, ind)
+
 class _BlockComment(_BlockObject, _BlockContainerDepends):
     pass
 
--- END ---

-- 
Ben Hutchings
Unix is many things to many people,
but it's never been everything to anybody.

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: