diff options
| author | Joey Yakimowich-Payne <jyapayne@gmail.com> | 2018-07-13 08:17:10 +0900 |
|---|---|---|
| committer | Joey Yakimowich-Payne <jyapayne@gmail.com> | 2018-07-13 08:17:10 +0900 |
| commit | 59c64782bd1f70688d3105024bc2c9cffb8bf313 (patch) | |
| tree | f6b58bcb9e6ee13f5dc6380a8087499cfd0cf0bb /src | |
| parent | 7d60e2eea78169d7237594f6ab77ed02c968acc3 (diff) | |
| download | nimgen-59c64782bd1f70688d3105024bc2c9cffb8bf313.tar.gz nimgen-59c64782bd1f70688d3105024bc2c9cffb8bf313.zip | |
Workaround regex replace issue
Diffstat (limited to 'src')
| -rw-r--r-- | src/nimgen/fileops.nim | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/nimgen/fileops.nim b/src/nimgen/fileops.nim index 2e51d09..c4e67a0 100644 --- a/src/nimgen/fileops.nim +++ b/src/nimgen/fileops.nim @@ -76,14 +76,14 @@ proc removeStatic*(filename: string) = ## out body withFile(filename): 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 = let funcDecl = s[m.group(0)[0]] let body = s[m.group(1)[0]].strip() result = "" result.add("$#;" % [funcDecl]) - result.add(body.replace(re"(?m)^", "//")) + result.add(body.replace(re"(?m)^(.*\n?)", "//$1")) ) proc reAddStatic*(filename: string) = @@ -91,14 +91,14 @@ proc reAddStatic*(filename: string) = ## removeStatic withFile(filename): 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 = let funcDecl = s[m.group(0)[0]] let body = s[m.group(1)[0]].strip() result = "" result.add("$# " % [funcDecl]) - result.add(body.replace(re"(?m)^\/\/", "")) + result.add(body.replace(re"(?m)^\/\/(.*\n?)", "$1")) ) proc fixFuncProtos*(file: string) = |
