Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lib_base
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sikang
lib_base
Commits
9091be33
Commit
9091be33
authored
Mar 29, 2019
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update script
parent
18778624
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
20 deletions
+21
-20
script/garble/insert.py
+21
-20
No files found.
script/garble/insert.py
View file @
9091be33
...
...
@@ -40,12 +40,12 @@ def get_rand_code(isInFunc):
elif
num
==
4
:
code
+=
indentasiStr
+
"long "
+
filedName
+
"="
+
str
(
random
.
randint
(
0
,
100000
))
+
";
\n
"
#
if isInFunc:
#
if num == 0:
#
code += "if(\"" + filedName + "\".equals(\"" + gen_rand_str() + "\")){}//interference code\n"
#
else:
#
index = gen_rand_str()
#
code += "for(int " + index + "="+str(random.randint(0,10))+";"+index+"<"+filedName+";"+index+"++){}//interference code\n"
if
isInFunc
:
if
num
==
0
:
code
+=
"if(
\"
"
+
filedName
+
"
\"
.equals(
\"
"
+
gen_rand_str
()
+
"
\"
)){}//interference code
\n
"
else
:
index
=
gen_rand_str
()
code
+=
"for(int "
+
index
+
"="
+
str
(
random
.
randint
(
0
,
10
))
+
";"
+
index
+
"<"
+
filedName
+
";"
+
index
+
"++){}//interference code
\n
"
return
code
...
...
@@ -60,32 +60,33 @@ def process_file_content(path, file_name):
with
open
(
path
,
"w"
,
encoding
=
"utf-8"
)
as
f_w
:
isReturn
=
False
isErrorIf
=
False
=
0
func_level
=
0
for
line
in
lines
:
#没加{}的if else
if
(
"if("
in
line
or
"if ("
in
line
)
and
"{"
not
in
line
:
isErrorIf
=
True
#return后有多行代码
if
"return"
in
line
or
"throw"
in
line
:
if
"return"
in
line
or
"throw"
in
line
and
not
isReturn
:
isReturn
=
True
func_level
=
0
=
0
if
isReturn
:
if
"{"
in
line
:
func_level
+=
1
+=
1
elif
"}"
in
line
:
func_level
-=
1
if
func_level
<
0
:
func_level
=
0
-=
1
if
<
0
:
=
0
# if "//interference code" not in line and ")" in line and "{\n" in line
and func_level == 0:
#
func_level = 1
# elif "//interference code" not in line and "{\n" in line
:
# func_level +=1
#
#
if "//interference code" not in line and "}\n" in line:
#
func_level -=1
if
"//interference code"
not
in
line
and
(
"){
\n
"
in
line
or
") {
\n
"
in
line
)
and
func_level
==
0
:
func_level
=
1
if
func_level
>
0
:
if
"//interference code"
not
in
line
and
"{
\n
"
in
line
:
func_level
+=
1
if
"//interference code"
not
in
line
and
"}
\n
"
in
line
:
func_level
-=
1
#需要忽略的行
if
not
isReturn
and
not
isErrorIf
and
\
...
...
@@ -106,7 +107,7 @@ def process_file_content(path, file_name):
if
";"
in
line
:
isErrorIf
=
False
if
";
\n
"
in
line
and
func
_level
==
0
:
if
";
\n
"
in
line
and
return
_level
==
0
:
isReturn
=
False
f_w
.
write
(
line
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment