[Miranda-jp-cvs] commit-notify[38] add lpgen javascript version

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2012年 5月 20日 (日) 23:09:53 JST


Revision: 38
          http://sourceforge.jp/projects/miranda-jp/scm/svn/commits/38
Author:   taguchi-ch
Date:     2012-05-20 23:09:53 +0900 (Sun, 20 May 2012)
Log Message:
-----------
add lpgen javascript version

Added Paths:
-----------
    trunk/miranda-tools/lpgen/lpgen.js

-------------- next part --------------
Added: trunk/miranda-tools/lpgen/lpgen.js
===================================================================
--- trunk/miranda-tools/lpgen/lpgen.js	                        (rev 0)
+++ trunk/miranda-tools/lpgen/lpgen.js	2012-05-20 14:09:53 UTC (rev 38)
@@ -0,0 +1,201 @@
+function Error_message(Ename,Ecode,Evalue)
+{
+	var Emessage = new Array( "","","is not numeric","Unknown","File is not existed" );
+       	return ( "Error: " + Ename + " " + Emessage[ Ecode ] +" : " + Evalue );
+}
+
+function Read_allfile(filename)
+{
+	var read_only = 1; //read
+
+	var obj_file;
+	var obj_infile;
+
+	var script_path;
+	var file_path;
+	var file_alldata;
+
+//get script path
+	script_path = String(WScript.ScriptFullName).replace(WScript.ScriptName,"");
+	obj_file = new ActiveXObject("Scripting.FileSystemObject");
+
+//make file path
+	file_path = obj_file.BuildPath(script_path,filename);
+
+	try
+	{
+		obj_infile = obj_file.OpenTextFile( file_path , read_only );
+		file_alldata = obj_infile.ReadAll();
+		obj_infile.Close();
+	}
+	catch(e)
+	{
+		WScript.echo( Error_message("",4,filename));
+	}
+	objfile = null;
+	objInFile = null;
+
+	return( file_alldata );
+
+}
+
+function Get_version(version_file)
+{
+	var version_no = new Array("","","");
+	var build = "";
+	var file_alldata = "";
+
+	file_alldata = Read_allfile( version_file );
+
+	if (file_alldata.match(/\#define MIRANDA_VERSION_STRING\s*?\"(\d*?\.\d*?)\.(\d*?)\.(\d*?)\"/))
+	{
+		if( RegExp.$3 != 0 )
+		{
+			build = RegExp.$3;			
+		}
+		version_no[0] = RegExp.$1;
+		version_no[1] = RegExp.$2;
+		version_no[2] = build;
+	}
+	return( version_no );
+}
+
+function Make_versionstyle( version_no )
+{
+	var version = "";
+// 1st arg version major i.e. 07 for "0.7"
+	if (version_no[0].match(/^([0-9]*)([0-9])$/))
+	{
+		if (RegExp.$1 == "")
+		{
+			version = RegExp.$2;
+		}
+		else
+		{
+			version = RegExp.$1 + "." + RegExp.$2;
+		}
+	}
+	else
+	{
+		version = version_no[0];
+	}
+// 2nd arg version minor i.e. 1 for "0.7.1"
+	if (version_no[1].match(/^[0-9]+$/))
+	{
+		version += ( "." + version_no[1] );
+	}
+	else
+	{
+		version += version_no[1];
+	}
+
+// 3rd arg build number i.e. 36 for "0.7.1 build 36"
+	if (version_no[2].match(/^[0-9]+$/))
+	{
+		version += (" build " + version_no[2]);
+	}
+	else
+	{
+		version += version_no[2];
+	}
+	return( version );
+}
+
+function create_langfile(rootdir,outfile,lang,locale,author,email,plugins)
+{
+	var hash = new Array();
+	var common = new Array();
+	var clines = 0;
+	var time = new Date();
+	var new_langfile = "";
+
+	WScript.echo("Building language file for " + rootdir ":\n");
+
+//add HEADER
+	new_langfile += "Miranda Language Pack Version 1\n";
+	new_langfile += ("Locale: " + author + "\n");
+	new_langfile += ("Authors: " + locale + "\n");
+	new_langfile += ("Author-email: " + email + "\n");
+	new_langfile += ("Last-Modified-Using: Miranda IM " + version + "\n");
+	new_langfile += ("Plugins-included: " + plugins + "\n");
+	new_langfile += ("; Generated by lpgen on " + document.write(time.toLocaleString()) + "\n");
+	new_langfile += ("; Translations: " + clines + "\n");
+
+
+//file process
+}
+
+//main
+var version = "";
+var version_file = '../../miranda/include/m_version.h';
+
+//save param info
+var objParm = WScript.arguments;
+var error_code = 0;
+var parm_name = new Array("module","version_major","version_minor","build_number");
+var parm;
+var version_no = new Array("","","");
+
+switch ( objParm.length )
+{
+	case 4:
+		if( isNaN( objParm(3)))
+		{
+			error_code = 2;
+			WScript.echo( Error_message(parm_name[3], error_code, objParm(3)) );
+		}
+		else
+		{
+			version_no[2] = objParm(3);
+		}
+	case 3:
+		if( isNaN( objParm(2)))
+		{
+			error_code = 2;
+			WScript.echo( Error_message(parm_name[2], error_code, objParm(2)) );
+		}
+		else
+		{
+			version_no[1] = objParm(2);
+		}
+	case 2:
+		if( isNaN( objParm(1)))
+		{
+			error_code = 2;
+			WScript.echo( Error_message(parm_name[1], error_code, objParm(1)) );
+		}
+		else
+		{
+			version_no[0] = objParm(1);
+		}
+	case 1:
+		if (objParm(0).match(/^(version|core|srmm|import)$/i))
+		{
+			parm = objParm(0);
+
+		}
+		else
+		{
+			error_code = 3;
+			WScript.echo( Error_message(parm_name[0], error_code, objParm(0)) );
+		}
+		break;
+	case 0:
+//Get default version no. from m_version.h
+		parm = "no param";
+		version_no = Get_version( version_file );
+		break;
+	default:
+		error_code = 1;
+		WScript.echo( WScript.ScriptName + " <" + parm_name[0] + "> <" + parm_name[1] + "> <" + parm_name[2] + "> <" + parm_name[3] + ">");
+		break;
+
+}
+//show param for debug
+WScript.echo(" 1:" + parm + " 2:" + version_no[0] + " 3:" + version_no[1] + " 4:" + version_no[2]);
+
+version = Make_versionstyle( version_no );
+
+//show version for debug
+WScript.echo(" version:" + version );
+



Miranda-jp-cvs メーリングリストの案内
Back to archive index