diff options
| author | ruki <[email protected]> | 2017-01-06 21:02:59 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-01-06 21:02:59 +0800 |
| commit | 8ebf3589c0981ef078a817e246f45d549406034a (patch) | |
| tree | 4851b351291b5b710d6b0c2b6ce4640a27a1553c | |
| parent | b898bfaaa35568bf911204dde5239de9fe6e062f (diff) | |
improve to check main
| -rw-r--r-- | xmake/languages/c++/check_main.lua | 6 | ||||
| -rw-r--r-- | xmake/languages/golang/check_main.lua | 6 | ||||
| -rw-r--r-- | xmake/languages/objc++/check_main.lua | 6 |
3 files changed, 15 insertions, 3 deletions
diff --git a/xmake/languages/c++/check_main.lua b/xmake/languages/c++/check_main.lua index 462ad4c6c..87a2002ae 100644 --- a/xmake/languages/c++/check_main.lua +++ b/xmake/languages/c++/check_main.lua @@ -27,8 +27,12 @@ function main(sourcefile) -- load source code local sourcecode = io.read(sourcefile) + -- remove comment first + sourcecode = sourcecode:gsub("/%*.-%*/", "") + sourcecode = sourcecode:gsub("//.-\n", "\n") + -- find int main(int argc, char** argv) {} - if sourcecode:find("%s+main%s*%(.*%)") then + if sourcecode:find("%s+main%s*%(.-%)") then return true end diff --git a/xmake/languages/golang/check_main.lua b/xmake/languages/golang/check_main.lua index 38cb4a812..ab19e1e14 100644 --- a/xmake/languages/golang/check_main.lua +++ b/xmake/languages/golang/check_main.lua @@ -27,8 +27,12 @@ function main(sourcefile) -- load source code local sourcecode = io.read(sourcefile) + -- remove comment first + sourcecode = sourcecode:gsub("/%*.-%*/", "") + sourcecode = sourcecode:gsub("//.-\n", "\n") + -- find func main() { - if sourcecode:find("func%s+main%s*%(.*%)") then + if sourcecode:find("func%s+main%s*%(.-%)") then return true end diff --git a/xmake/languages/objc++/check_main.lua b/xmake/languages/objc++/check_main.lua index 462ad4c6c..87a2002ae 100644 --- a/xmake/languages/objc++/check_main.lua +++ b/xmake/languages/objc++/check_main.lua @@ -27,8 +27,12 @@ function main(sourcefile) -- load source code local sourcecode = io.read(sourcefile) + -- remove comment first + sourcecode = sourcecode:gsub("/%*.-%*/", "") + sourcecode = sourcecode:gsub("//.-\n", "\n") + -- find int main(int argc, char** argv) {} - if sourcecode:find("%s+main%s*%(.*%)") then + if sourcecode:find("%s+main%s*%(.-%)") then return true end |
