summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorBasil <basil@miranda-ng.org>2013-02-15 13:05:36 +0000
committerBasil <basil@miranda-ng.org>2013-02-15 13:05:36 +0000
commitf49630a24072cb13f6ea28c35b6ba0735fc20eb9 (patch)
treebb7c7ea33fd3d75f718d6a44911b31deb8b869c5 /tools
parent839c390eef0b5485538077449881370fa54b8167 (diff)
temporary version of lpgen, which support find a define inside of translation function.
For example, there is a TranslateT(someMSG), first, try to find #define someMSG "sometext", than, if not found define in same file, search ALL SOURCE FILES of current plugin (or CORE) for this #define. Currently, seldom additional strings founded, but processing speed few times slower, than before. Sorce code refactoring needed... git-svn-id: http://svn.miranda-ng.org/main/trunk@3611 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'tools')
-rw-r--r--tools/lpgen/lpgen.js52
1 files changed, 47 insertions, 5 deletions
diff --git a/tools/lpgen/lpgen.js b/tools/lpgen/lpgen.js
index b4bfd7f415..9a0c2f0d18 100644
--- a/tools/lpgen/lpgen.js
+++ b/tools/lpgen/lpgen.js
@@ -152,7 +152,7 @@ if (log) WScript.Echo("Finish getting strings from source files.");
function GenerateCore() {
//init arrays
corestrings=new Array();
- core_src=new Array();
+ sourcefiles=new Array();
core_rc=new Array();
//if log parameter specified, output a log.
if (log) WScript.Echo("Processing CORE...");
@@ -163,11 +163,11 @@ function GenerateCore() {
//find all *.rc files and list files in array
FindFiles(core,"\\.rc$",core_rc);
//find all source files and list files in array
- FindFiles(core,"\\.h$|\\.cpp$|\\.c$",core_src);
+ FindFiles(core,"\\.h$|\\.cpp$|\\.c$",sourcefiles);
//Parse files "core_rc", put result into "corestrings" using "ParseRCFile" function
ParseFiles(core_rc,corestrings,ParseRCFile);
- //Parse files "core_src", put result into "corestrings" using "ParseSourceFile" function
- ParseFiles(core_src,corestrings,ParseSourceFile);
+ //Parse files "sourcefiles", put result into "corestrings" using "ParseSourceFile" function
+ ParseFiles(sourcefiles,corestrings,ParseSourceFile);
//Now we have all strings in "corestrings", next we remove duplicate strings from array and put results into "nodupes"
nodupes=eliminateDuplicates(corestrings);
//if dupes requred, make nodupes with dupes :)
@@ -460,7 +460,7 @@ function ParseSourceFile (SourceFile,array) {
//var find= /(?:LPGENT?|Translate[TW]?|_T)(?:\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= /(?:LPGENT?|Translate[TW]?)(?:\s*?\(\s*?L?\s*)(['"])([\S\s]*?)(?=\1,?\x20*?(?:tmp)?\))/mg;
-
+ var find_defines=/(?:LPGENT?|Translate[TW]?)(?:\s*?\()(\w+?)(?=\))/mg;
//read file fully into var
allstrings=sourcefile_stream.ReadAll();
//now make a job, till end of matching regexp
@@ -479,10 +479,52 @@ function ParseSourceFile (SourceFile,array) {
if (clearstring) {array.push("["+clearstring+"]")}
};
}
+ while ((define_name_regexp_check = find_defines.exec(allstrings)) != null) {
+ define_name=define_name_regexp_check[1]
+ //WScript.Echo(define);
+ define_regexp_str="#define\\s+"+define_name+"\\s+\"([\\S\\s]*?)(?=\")";
+ //WScript.Echo(define_regexp_str);
+ var define_name_regexp=new RegExp(define_regexp_str,"mg");
+ define_string=define_name_regexp.exec(allstrings);
+ //WScript.Echo(string1[1]);
+ if (define_string) {
+ onestring=define_string[1].replace(/'?(\#13\#10)*?\\?\r\n(\x20*?\')?/g,"");
+ stringtolangpack=onestring.replace(/\\(['"])/g,"$1");
+ //WScript.Echo(stringtolangpack);
+ array.push("["+stringtolangpack+"]");
+ } else {WScript.Echo("can't find define "+define_name);
+ FindDefineText(define_name,sourcefiles,array);
+ }
+ }
//close file, we've finish.
sourcefile_stream.Close();
};
+function FindDefineText(define_name1,filelist1,array1) {
+define_regexp_str1="#define\\s+"+define_name1+"\\s+\"([\\S\\s]*?)(?=\")";
+filesenum1=new Enumerator(filelist1);
+ //cycle through file list
+ while (!filesenum1.atEnd()) {
+ curfile1=filesenum1.item();
+ //WScript.Echo(curfile1);
+ if (FSO.GetFile(curfile1).Size==0) return;
+ //open file
+ sourcefile_stream1=FSO.GetFile(curfile1).OpenAsTextStream(ForReading, TristateUseDefault);
+ allstrings1=sourcefile_stream1.ReadAll();
+ var define_name_regexp1=new RegExp(define_regexp_str,"mg");
+ define_string1=define_name_regexp1.exec(allstrings1);
+ if (define_string1) {
+ //WScript.Echo(define_string1);
+ onestring1=define_string1[1].replace(/'?(\#13\#10)*?\\?\r\n(\x20*?\')?/g,"");
+ stringtolangpack1=onestring1.replace(/\\(['"])/g,"$1");
+ //WScript.Echo(stringtolangpack);
+ array1.push("["+stringtolangpack1+"]");
+ }
+ sourcefile_stream1.Close();
+ filesenum1.moveNext();
+ }
+}
+
//filter _T() function results
function filter_T(string) {
//filter not begin with symbols :.]?;#~{!/_+$