Changeset 0d2ef60


Ignore:
Timestamp:
07/31/2023 04:27:35 PM (11 months ago)
Author:
Xi Ruoyao <xry111@…>
Branches:
12.0, 12.1, ken/TL2024, ken/tuningfonts, lazarus, plabs/newcss, python3.11, rahul/power-profiles-daemon, renodr/vulkan-addition, trunk, xry111/llvm18
Children:
bd141376
Parents:
cceadef
git-author:
Xi Ruoyao <xry111@…> (07/31/2023 03:57:30 PM)
git-committer:
Xi Ruoyao <xry111@…> (07/31/2023 04:27:35 PM)
Message:

kernel-config: Reuse parse_config for parsing choice

The special parse_choice function is just duplicating code unnecessary
and it has some flaws. Remove it and handle choice's with parse_config
too.

All kernel.xml files regenerated and there is no change.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel-config/kernel-config.py

    rcceadef r0d2ef60  
    6262def parse_config(buf):
    6363    global ind0, ind1, stack, menu_id
    64     is_menu = buf[0].startswith('menu')
    65     is_nonconfig_menu = buf[0].startswith('menu ')
     64    is_choice = buf[0].strip() == 'choice'
     65    is_menu = buf[0].startswith('menu') or is_choice
     66    is_nonconfig_menu = buf[0].startswith('menu ') or is_choice
    6667    key = None if is_nonconfig_menu else buf[0].split()[1].strip()
    6768    title = buf[0][len('menu '):] if is_nonconfig_menu else None
     
    146147
    147148    key = key or 'menu'
    148     stack_ent = (key, 2, 0, menu_id) if is_menu else (key, 0, x, cur_menu())
     149    menu = (menu_id if is_menu else cur_menu())
     150    menu |= choice_bit if is_choice else 0
     151    stack_ent = (key, 2, 0, menu) if is_menu else (key, 0, x, menu)
    149152    ind0 += stack_ent[1]
    150153    ind1 += stack_ent[2]
    151154    stack += [stack_ent]
    152155
    153     return r
    154 
    155 def parse_choice(buf):
    156     global ind0, ind1, stack, menu_id
    157     assert(buf[0] == 'choice\n')
    158     title = ''
    159     for line in buf:
    160         line = line.strip()
    161         if line.startswith('prompt '):
    162             title = line[len('prompt '):].strip().strip('"')
    163 
    164     menu_id += 1
    165 
    166     if stack:
    167         fa = stack[-1][0]
    168         if fa == 'menu':
    169             fa = cur_menu() & ~choice_bit
    170         main_dep[menu_id] = fa
    171 
    172     r = [ind0, None, ind1, title, ' --->', menu_id, cur_menu(), None]
    173     stack += [('menu', 2, 0, menu_id | choice_bit)]
    174     ind0 += 2
    175156    return r
    176157
     
    183164            if config_buf:
    184165                if not (line.startswith('\t') or line.startswith('    ')):
    185                     if config_buf[0] == 'choice\n':
    186                         r += [parse_choice(config_buf)]
    187                     else:
    188                         r += [parse_config(config_buf)]
     166                    r += [parse_config(config_buf)]
    189167                    config_buf = []
    190168                else:
Note: See TracChangeset for help on using the changeset viewer.