Skip to content

Commit ea9145f

Browse files
committed
Fix parse script
1 parent e2ff504 commit ea9145f

File tree

1 file changed

+28
-24
lines changed

1 file changed

+28
-24
lines changed

parse_config.py

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def build_c_code(self, varname: str, argnum: str) -> str:
9292
elif self.content != "" and not self.isChar:
9393
c_code = c_code+structbuild_template["set_arg_long"].format(varname=varname, argname="arg"+argnum, arg=self.content)
9494
if self.isFdesc:
95-
c_code = c_code+structbuild_template["set_arg_isfdesc"].format(varname=varname, argname="arg"+argnum, isfdesc=self.isFdesc)
95+
c_code = c_code+structbuild_template["set_arg_isfdesc"].format(varname=varname, argname="arg"+argnum, isfdesc=str(self.isFdesc).lower())
9696
return c_code
9797

9898
@staticmethod
@@ -205,29 +205,33 @@ def build_c_code(self) -> str:
205205
i = i - 1
206206
c_structs = c_structs + "\n"
207207

208-
linked_list_setup = ""
209-
for i in range(1, len(self.syscalls) + 1):
210-
if i == 1:
211-
linked_list_setup = linked_list_setup + structbuild_template[
212-
"set_next"
213-
].format(varname="call" + str(i), nextcall="call" + str(i + 1))
214-
linked_list_setup = linked_list_setup + structbuild_template[
215-
"set_prev"
216-
].format(varname="call" + str(i), prevcall="NULL")
217-
elif i == len(self.syscalls):
218-
linked_list_setup = linked_list_setup + structbuild_template[
219-
"set_prev"
220-
].format(varname="call" + str(i), prevcall="call" + str(i - 1))
221-
linked_list_setup = linked_list_setup + structbuild_template[
222-
"set_next"
223-
].format(varname="call" + str(i), nextcall="NULL")
224-
else:
225-
linked_list_setup = linked_list_setup + structbuild_template[
226-
"set_prev"
227-
].format(varname="call" + str(i), prevcall="call" + str(i - 1))
228-
linked_list_setup = linked_list_setup + structbuild_template[
229-
"set_next"
230-
].format(varname="call" + str(i), nextcall="call" + str(i + 1))
208+
linked_list_setup: str = ""
209+
if len(self.syscalls) == 1:
210+
linked_list_setup = linked_list_setup + structbuild_template["set_next"].format(varname="call1", nextcall="NULL")
211+
linked_list_setup = linked_list_setup + structbuild_template["set_prev"].format(varname="call1", prevcall="NULL")
212+
else:
213+
for i in range(1, len(self.syscalls) + 1):
214+
if i == 1:
215+
linked_list_setup = linked_list_setup + structbuild_template[
216+
"set_next"
217+
].format(varname="call" + str(i), nextcall="call" + str(i + 1))
218+
linked_list_setup = linked_list_setup + structbuild_template[
219+
"set_prev"
220+
].format(varname="call" + str(i), prevcall="NULL")
221+
elif i == len(self.syscalls):
222+
linked_list_setup = linked_list_setup + structbuild_template[
223+
"set_prev"
224+
].format(varname="call" + str(i), prevcall="call" + str(i - 1))
225+
linked_list_setup = linked_list_setup + structbuild_template[
226+
"set_next"
227+
].format(varname="call" + str(i), nextcall="NULL")
228+
else:
229+
linked_list_setup = linked_list_setup + structbuild_template[
230+
"set_prev"
231+
].format(varname="call" + str(i), prevcall="call" + str(i - 1))
232+
linked_list_setup = linked_list_setup + structbuild_template[
233+
"set_next"
234+
].format(varname="call" + str(i), nextcall="call" + str(i + 1))
231235

232236
c_structs = c_structs + linked_list_setup
233237
c_code = header_template.format(

0 commit comments

Comments
 (0)