[ttssh2-commit] [10357] "#" を含んだファイル名が存在するとエラーを出すようにした

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2022年 11月 11日 (金) 23:13:00 JST


Revision: 10357
          https://osdn.net/projects/ttssh2/scm/svn/commits/10357
Author:   zmatsuo
Date:     2022-11-11 23:13:00 +0900 (Fri, 11 Nov 2022)
Log Message:
-----------
"#" を含んだファイル名が存在するとエラーを出すようにした

- editorの一時ファイル名に "#" が含まれていることがある
- タイトルの取得を関数に分離した

Modified Paths:
--------------
    trunk/doc/htmlhelp_index_make.pl

-------------- next part --------------
Modified: trunk/doc/htmlhelp_index_make.pl
===================================================================
--- trunk/doc/htmlhelp_index_make.pl	2022-11-11 14:12:51 UTC (rev 10356)
+++ trunk/doc/htmlhelp_index_make.pl	2022-11-11 14:13:00 UTC (rev 10357)
@@ -85,18 +85,13 @@
 	}
 }
 
-sub check_html_file {
-	my($filename) = shift;
-	local(*FP);
+sub get_title {
+	my $filename = $_[0];
+	my $title = "";
 	my($line, $no, $val);
 
-	if ($filename !~ /.html$/) {
-		return;
-	}
-
 	open(FP, "<:crlf:encoding(sjis)", "$filename") || return;
 	$no = 1;
-	my $find_title = 0;
 	while ($line = <FP>) {
 #		$line = chomp($line);
 #		print "$line\n";
@@ -105,20 +100,35 @@
 #			print "$line\n";
 			$val = $1;
 			$val =~ s/"/"/g;  # 二重引用符をエスケープする
-			write_add_index($filename, $val);
-			$find_title = 1;
+			$title = $val;
 			last;
 		}
 
 		$no++;
 	}
-	if ($find_title == 0) {
+	close(FP);
+
+	return $title;
+}
+
+sub check_html_file {
+	my($filename) = shift;
+
+	if ($filename !~ /.html$/) {
+		return;
+	}
+	if ($filename =~ /#/) {
+		die "bad filename '$filename'";
+	}
+
+	my $title = &get_title($filename);
+	if ($title eq "") {
 		# タイトルがないhtmlのときファイル名をタイトルとする
 		$filename =~ /\/([^\/]+)\.html$/;
-		my $title = $1;
-		write_add_index($filename, $title);
+		$title = $1;
 	}
-	close(FP);
+
+	write_add_index($filename, $title);
 }
 
 sub write_add_index {


ttssh2-commit メーリングリストの案内
Back to archive index