<commit_before>
our $debug = 0;
our $version = 'v0.0.0';

&main();
exit(0);

sub main{
	&input_flags();
	&output();
}

sub input_flags{
	print "リリース用のファイルを出力しますか？[y] ";
	$_ = <STDIN>; tr/\r\n//d;
	if(/n/i){ $debug=1;}

	print "バージョンを入力してください[$version] ";
	$_ = <STDIN>; tr/\r\n//d;
	if($_){
		$version = $_;
		$version =~ s/\[a\]/α/g;
		$version =~ s/\[b\]/β/g;
	}
}

sub output{
	&output_file('candle.js', ['source/candle.js']);
}
sub output_file{
	my $filename = $_[0];
	my @files = @{$_[1]};

	if(!$debug){
		open OUT, ">$filename.txt";
		&printfiles(\@files);
		close OUT;

		&output_doc("notices.txt", $filename);

		system("copy /Y /B .\\notices.txt + .\\$filename.txt .\\$filename");

		unlink("notices.txt");
		unlink("$filename.txt");
	}
	else{
		open OUT, ">$filename.txt";
		print OUT "// テスト用\n";
		&printfiles_debug(\@files);
		close OUT;

		system("copy /Y $filename.txt .\\$filename");
		unlink("$filename.txt");
	}
}

sub output_doc{
	my($file, $filename) = @_;
	my @dates = localtime(time);
	my $datestr = sprintf("%04d-%02d-%02d",1900+$dates[5],1+$dates[4],$dates[3]);

	open DOC, ">$file";

	print DOC <<"EOR";
/* 
 * $filename
 * 
 * $filename is a graphic library for JavaScript.
 * 
 * \@author  D.Kobayashi
 * \@version $version
 * \@date    $datestr
 * 
 * This script is referencing following library.
 *  uuCanvas.js (version 1.0)
 *  http://code.google.com/p/uupaa-js-spinoff/	uupaa.js SpinOff Project Home(Google Code)
 * 
 * This script is under the MIT license. Please see below.
 * http://www.opensource.org/licenses/mit-license.php
 * 
 */
EOR
	close DOC;
}

# ファイル出力関数
sub printfiles{
	my @files = @{$_[0]};
	foreach(@files){
		my $filename = $_;

		print STDERR $filename;

		# 実際の出力部
		open SRC, $filename;
		# 変換をかけたい場合は、、この中に変換処理を入れるべし
		while(<SRC>){
			my $sline = $_;
			$sline =~ tr/\r\n//d;
			$sline =~ s/\t//g;
			$sline =~ s/^\/\/.*//g;
			$sline =~ s/\/\*.*\*\///g;
			$sline =~ s/([^\\\:])\/\/.*/$1/g;<commit_msg>make.pl: ファイル結合時のファイル名指定を修正しました<commit_after>
our $debug = 0;
our $version = 'v0.0.0';

&main();
exit(0);

sub main{
	&input_flags();
	&output();
}

sub input_flags{
	print "リリース用のファイルを出力しますか？[y] ";
	$_ = <STDIN>; tr/\r\n//d;
	if(/n/i){ $debug=1;}

	print "バージョンを入力してください[$version] ";
	$_ = <STDIN>; tr/\r\n//d;
	if($_){
		$version = $_;
		$version =~ s/\[a\]/α/g;
		$version =~ s/\[b\]/β/g;
	}
}

sub output{
	&output_file('candle.js', ['core','base','svg','canvas','sl','vml']);
}
sub output_file{
	my $filename = $_[0];
	my @files = @{$_[1]};

	if(!$debug){
		open OUT, ">$filename.txt";
		&printfiles(\@files);
		close OUT;

		&output_doc("notices.txt", $filename);

		system("copy /Y /B .\\notices.txt + .\\$filename.txt .\\$filename");

		unlink("notices.txt");
		unlink("$filename.txt");
	}
	else{
		open OUT, ">$filename.txt";
		print OUT "// テスト用\n";
		&printfiles_debug(\@files);
		close OUT;

		system("copy /Y $filename.txt .\\$filename");
		unlink("$filename.txt");
	}
}

sub output_doc{
	my($file, $filename) = @_;
	my @dates = localtime(time);
	my $datestr = sprintf("%04d-%02d-%02d",1900+$dates[5],1+$dates[4],$dates[3]);

	open DOC, ">$file";

	print DOC <<"EOR";
/* 
 * $filename
 * 
 * $filename is a graphic library for JavaScript.
 * 
 * \@author  D.Kobayashi
 * \@version $version
 * \@date    $datestr
 * 
 * This script is referencing following library.
 *  uuCanvas.js (version 1.0)
 *  http://code.google.com/p/uupaa-js-spinoff/	uupaa.js SpinOff Project Home(Google Code)
 * 
 * This script is under the MIT license. Please see below.
 * http://www.opensource.org/licenses/mit-license.php
 * 
 */
EOR
	close DOC;
}

# ファイル出力関数
sub printfiles{
	my @files = @{$_[0]};
	foreach(@files){
		my $filename = "source/candle.$_.js";

		print STDERR $filename;

		# 実際の出力部
		open SRC, $filename;
		# 変換をかけたい場合は、、この中に変換処理を入れるべし
		while(<SRC>){
			my $sline = $_;
			$sline =~ tr/\r\n//d;
			$sline =~ s/\t//g;
			$sline =~ s/^\/\/.*//g;
			$sline =~ s/\/\*.*\*\///g;
			$sline =~ s/([^\\\:])\/\/.*/$1/g;
{'fraction_non_alphanumeric': 0.2383107088989442, 'fraction_numerical': 0.013071895424836602, 'mean_word_length': 3.153444676409186, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '838449', 'n_tokens_mistral': 1942, 'n_tokens_neox': 1800, 'n_words': 329}