mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 03:06:37 +00:00
98_help.pm: avoid recursion error
git-svn-id: https://svn.fhem.de/fhem/trunk@8050 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
800e1d98ef
commit
9d133cf6ba
@ -4,7 +4,10 @@ package main;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my $ret;
|
||||
|
||||
sub CommandHelp;
|
||||
sub cref_search;
|
||||
|
||||
sub help_Initialize($$) {
|
||||
my %hash = ( Fn => "CommandHelp",
|
||||
@ -25,9 +28,9 @@ sub CommandHelp {
|
||||
my $internals = "attributes command commands devspec global perl";
|
||||
$mod = lc($mod);
|
||||
my $modPath = AttrVal('global','modpath','.');
|
||||
my $output = "";
|
||||
my $output = '';
|
||||
|
||||
if($internals !~ m/$mod/) {
|
||||
if($internals !~ m/$mod /) {
|
||||
my %mods;
|
||||
my @modDir = ("$modPath/FHEM");
|
||||
|
||||
@ -44,18 +47,14 @@ sub CommandHelp {
|
||||
|
||||
return "Module $mod not found" unless defined($mods{$mod});
|
||||
|
||||
my $skip = 1;
|
||||
my ($err,@text) = FileRead({FileName => $mods{$mod}, ForceType => 'file'});
|
||||
return $err if $err;
|
||||
foreach my $l (@text) {
|
||||
if($l =~ m/^=begin html$lang$/) {
|
||||
$skip = 0;
|
||||
} elsif($l =~ m/^=end html$lang$/) {
|
||||
$skip = 1;
|
||||
} elsif(!$skip) {
|
||||
$output .= $l;
|
||||
}
|
||||
}
|
||||
$output = cref_search($mods{$mod},$lang);
|
||||
Debug $output;
|
||||
unless($output) {
|
||||
$output = cref_search($mods{$mod},"");
|
||||
$output = "Keine deutsche Hilfe gefunden!<br/>$output" if $output;
|
||||
}
|
||||
|
||||
$output = "No help found for module: $mod" unless $output;
|
||||
|
||||
} else {
|
||||
|
||||
@ -78,8 +77,6 @@ sub CommandHelp {
|
||||
|
||||
}
|
||||
|
||||
$output = "Keine deutsche Hilfe gefunden!\n\n".
|
||||
CommandHelp(undef, "$mod en") unless $output;
|
||||
|
||||
if( $cl && $cl->{TYPE} eq 'telnet' ) {
|
||||
$output =~ s/<br>/\n/g;
|
||||
@ -96,9 +93,8 @@ sub CommandHelp {
|
||||
$output =~ s/>/>/g;
|
||||
$output =~ s/<[bui]>/\ /g;
|
||||
$output =~ s/<\/[bui]>/\ /g;
|
||||
$output =~ s/\ \ +/\ /g;
|
||||
$output =~ s/\t+/ /g;
|
||||
$output =~ s/\n\n/\n/g;
|
||||
$output =~ tr/ / /s;
|
||||
$output =~ s/\n\n/\n/s;
|
||||
$output =~ s/ä/ä/g;
|
||||
$output =~ s/Ä/Ä/g;
|
||||
$output =~ s/ö/ö/g;
|
||||
@ -107,7 +103,7 @@ sub CommandHelp {
|
||||
$output =~ s/Ü/Ü/g;
|
||||
$output =~ s/ß/ß/g;
|
||||
|
||||
return $output;
|
||||
$ret = $output;
|
||||
}
|
||||
|
||||
return "<html>$output</html>";
|
||||
@ -132,6 +128,24 @@ sub CommandHelp {
|
||||
}
|
||||
}
|
||||
|
||||
sub cref_search {
|
||||
my ($mod,$lang) = @_;
|
||||
my $output = "";
|
||||
my $skip = 1;
|
||||
my ($err,@text) = FileRead({FileName => $mod, ForceType => 'file'});
|
||||
return $err if $err;
|
||||
foreach my $l (@text) {
|
||||
if($l =~ m/^=begin html$lang$/) {
|
||||
$skip = 0;
|
||||
} elsif($l =~ m/^=end html$lang$/) {
|
||||
$skip = 1;
|
||||
} elsif(!$skip) {
|
||||
$output .= $l;
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=pod
|
||||
|
Loading…
x
Reference in New Issue
Block a user