diff options
author | Goraf <goraf@miranda-ng.org> | 2015-01-10 18:55:31 +0000 |
---|---|---|
committer | Goraf <goraf@miranda-ng.org> | 2015-01-10 18:55:31 +0000 |
commit | 970ed9790ed27a5933f66e7e760a932bfc97e94c (patch) | |
tree | 7910edda0a3cd7c25809fe5fc970396cfad542ca | |
parent | 2cd05c2649104e8690defdcf0122d8c3e827c1d2 (diff) |
lpgen: fix for multi-line parsing
git-svn-id: http://svn.miranda-ng.org/main/trunk@11822 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | tools/lpgen/lpgen.js | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/tools/lpgen/lpgen.js b/tools/lpgen/lpgen.js index f3972af588..234dd15269 100644 --- a/tools/lpgen/lpgen.js +++ b/tools/lpgen/lpgen.js @@ -449,15 +449,17 @@ function ParseSourceFile (FileTextVar,array) { //not store ?: functions LPGEN or LPGENT? or Translate(T or W) or _T, than any unnecessary space \s, than not stored ?: "(" followed by ' or " (stored and used as \1) than \S\s - magic with multiline capture, ending with not stored ?= \1 (we get " or ' after "("), than none or few spaces \x20 followed by )/m=multiline g=global
//var find= /(?:LPGENT?|Translate[TW]?|_T)(?:\s*?\(\s*?L?\s*)(['"])([\S\s]*?)(?=\1,?\x20*?(?:tmp)?\))/mg;
//comment previous line and uncomment following line to output templates without _T() function in source files. Too many garbage from _T()..
- var find= /(?:LPGEN[TW]?|Translate[TW]?)(?:\s*?\(\s*?L?\s*)("[^"\\]*(?:\\[\S\s][^"\\]*)*")(?:\s*?,?\s*?(?:tmp)?\))/mg;
+ var find= /(?:LPGEN[TW]?|Translate[TW]?)(?:\s*?\(\s*?L?\s*)((?:(?:"[^"\\]*(?:\\[\S\s][^"\\]*)*")\s*)*)(?:\s*?,?\s*?(?:tmp)?\))/gm;
//now make a job, till end of matching regexp
while ((string = find.exec(FileTextVar)) != null) {
//first, init empty var
var string;
//replace newlines with "" in second [1] subregexp ([\S\s]*?), and Delphi newlines "'#13#10+" replace
- onestring=string[1].replace(/'?(\#13\#10)*?\\?\r\n(\x20*?\')?/g,"");
+ onestring=string[1].replace(/["']?(?:\#13\#10)*?\\?\r*\n(?:(?:\x20|\t)*['"])?/g,"");
+ //trim single-line whitespaces
+ trimedstring=onestring.replace(/[\s]*$/g,"");
//remove trailing slash from the string. This is a tree item, slesh is a crap :)
- noslashstring=onestring.replace(/\/(?=$)/g,"");
+ noslashstring=trimedstring.replace(/\/(?=$)/g,"");
//remove first and last "
nofirstlaststring=noslashstring.slice(1, -1)
//remove escape slashes before ' and "
|