Workaround regex replace issue
This commit is contained in:
parent
7d60e2eea7
commit
59c64782bd
1 changed files with 4 additions and 4 deletions
|
|
@ -76,14 +76,14 @@ proc removeStatic*(filename: string) =
|
||||||
## out body
|
## out body
|
||||||
withFile(filename):
|
withFile(filename):
|
||||||
content = content.replace(
|
content = content.replace(
|
||||||
re"(?m)(static inline.*?\))(\s*\{(\s*?.*?$)*[\n\r]\})",
|
re"(?m)(static inline.*?\))(\s*\{(\s*?.*?$)*?[\n\r]\})",
|
||||||
proc (m: RegexMatch, s: string): string =
|
proc (m: RegexMatch, s: string): string =
|
||||||
let funcDecl = s[m.group(0)[0]]
|
let funcDecl = s[m.group(0)[0]]
|
||||||
let body = s[m.group(1)[0]].strip()
|
let body = s[m.group(1)[0]].strip()
|
||||||
result = ""
|
result = ""
|
||||||
|
|
||||||
result.add("$#;" % [funcDecl])
|
result.add("$#;" % [funcDecl])
|
||||||
result.add(body.replace(re"(?m)^", "//"))
|
result.add(body.replace(re"(?m)^(.*\n?)", "//$1"))
|
||||||
)
|
)
|
||||||
|
|
||||||
proc reAddStatic*(filename: string) =
|
proc reAddStatic*(filename: string) =
|
||||||
|
|
@ -91,14 +91,14 @@ proc reAddStatic*(filename: string) =
|
||||||
## removeStatic
|
## removeStatic
|
||||||
withFile(filename):
|
withFile(filename):
|
||||||
content = content.replace(
|
content = content.replace(
|
||||||
re"(?m)(static inline.*?\));(\/\/\s*\{(\s*?.*?$)*[\n\r]\/\/\})",
|
re"(?m)(static inline.*?\));(\/\/\s*\{(\s*?.*?$)*?[\n\r]\/\/\})",
|
||||||
proc (m: RegexMatch, s: string): string =
|
proc (m: RegexMatch, s: string): string =
|
||||||
let funcDecl = s[m.group(0)[0]]
|
let funcDecl = s[m.group(0)[0]]
|
||||||
let body = s[m.group(1)[0]].strip()
|
let body = s[m.group(1)[0]].strip()
|
||||||
result = ""
|
result = ""
|
||||||
|
|
||||||
result.add("$# " % [funcDecl])
|
result.add("$# " % [funcDecl])
|
||||||
result.add(body.replace(re"(?m)^\/\/", ""))
|
result.add(body.replace(re"(?m)^\/\/(.*\n?)", "$1"))
|
||||||
)
|
)
|
||||||
|
|
||||||
proc fixFuncProtos*(file: string) =
|
proc fixFuncProtos*(file: string) =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue