head 1.1; branch 1.1.1; access ; symbols start:1.1.1.1 vendor:1.1.1; locks ; strict; comment @# @; 1.1 date 2004.04.10.16.02.48; author tarookumichi; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2004.04.10.16.02.48; author tarookumichi; state Exp; branches ; next ; desc @@ 1.1 log @Initial revision @ text @@@d5_cuts; $d5_dumphtml = ""; $d5_dumphtml_types = ""; %d5_dumphtml_types_alloc = (); $d5_divstart = "\n
\n
\"close\""; $d5_divend = "
\n
"; sub d5_addcut { my ($posbeg,$posend,$cmd,$arg) = @@_; my (%cut,$filename); if ($dbgon == 1) { print ("\n+Addcut($posbeg,$posend,$cmd,$arg)\n");} %cut = ( posbeg => $posbeg, posend => $posend, cmd => $cmd, arg => $arg ); push (@@d5_cuts,[%cut]); } sub d5_dumpcut { my $filename; my ($posbeg,$posend,$cmd,$arg,$i); my %tmp; if ($dbgon == 1) { for($i = 0;$i < $#d5_cuts;$i++) { %tmp = @@{$d5_cuts[$i]}; $posbeg = $tmp{posbeg}; $posend = $tmp{posend}; $cmd = $tmp{cmd}; $arg = $tmp{arg}; $filename = d3_filename ($posbeg); print("$filename"."[$posbeg-$posend]: $cmd($arg)\n"); } } } sub d5_gethtml { my ($beg,$end,$ommit) = @@_; my ($filename,$posbeg,$posend,$ok,$id); my $cmd,my $arg,my $i=0,my $off,my $html="",my $part; my %tmp = (); my @@cuts =(); if ($dbgon == 1) { print ("Dump[$beg,$end]\n"); } for($i = 0;$i <= $#d5_cuts;$i++) { %tmp = @@{$d5_cuts[$i]}; $posbeg = $tmp{posbeg}; $posend = $tmp{posend}; if (($posbeg >= $beg && $posbeg < $end) || ($posend > $beg && $posend <= $end)) { if ($posbeg < $beg) { $posbeg = $beg; } if ($posend > $end) { $posend = $end; } $tmp{posbeg} = $posbeg; $tmp{posend} = $posend; push(@@cuts,[%tmp]); } } $off = $beg; if ($dbgon == 1) { print ("Start Cutting from $off\n"); } $html = "
";
    for($i = 0;$i <= $#cuts;$i++) {
	%tmp = @@{$cuts[$i]};
	$posbeg = $tmp{posbeg};
	$posend = $tmp{posend};
	$part = substr($body_all,$posbeg,$posend-$posbeg);
	$cmd = $tmp{cmd};
	$arg = $tmp{arg};
	if ($dbgon == 1) {
	    print ("Cut [$posbeg,$posend]: $cmd,$arg\n");
	}
	if ($off < $posbeg) {
	    $html .= substr($body_all,$off,$posbeg-$off);
	}
	if (($cmd eq "vartyp") || ($cmd eq "record")) {
	    ($ok,$id) = d5_addtype_dumphtml($arg);
	    if ($ok == 1 && (not ($arg eq $ommit))) {
		$html .= "".$part."";
	    } else {
		$html .= $part;
	    }
	} elsif ($cmd eq "const") {
	    ($ok,$id) = d5_addconst_dumphtml($arg);
	    if ($ok == 1 && (not ($arg eq $ommit))) {
		$html .= "".$part."";
	    } else {
		$html .= $part;
	    }
	} elsif ($cmd eq "proc") {
	    ($ok,$id) = d5_addproc_dumphtml($arg);
	    if ($ok == 1 && (not ($arg eq $ommit))) {
		$html .= "".$part."";
	    } else {
		$html .= $part;
	    }
	} elsif ($cmd eq "func") {
	    ($ok,$id) = d5_addfunc_dumphtml($arg);
	    if ($ok == 1 && (not ($arg eq $ommit))) {
		$html .= "".$part."";
	    } else {
		$html .= $part;
	    }
	} elsif ($cmd eq "enum") {
	    ($ok,$id) = d5_addenum_dumphtml($arg);
	    if ($ok == 1 && (not ($arg eq $ommit))) {
		$html .= "".$part."";
	    } else {
		$html .= $part;
	    }
	} elsif ($cmd eq "file") {
	    
	    ($ok,$id) = d5_addfile_dumphtml($arg);
	    if ($ok == 1 && (not ($arg eq $ommit))) {
		$html .= "".$part."";
	    } else {
		$html .= $part;
	    }
	} elsif ($cmd eq "style") {
	    
	    $html .= "$part";
	    
	} else {
	    $html .= $part;
	}
	$off = $posend;
    }
    if ($off < $end) {
	$html .= substr($body_all,$off,$end-$off);
    }
    $html .= "
"; } sub d5_addfile_dumphtml() { my ($type) = @@_; my ($posbeg,$posend,$fname); my %tmp = (); my ($id,$html,$title); if (exists($d3_usedby_set{$type})) { %tmp = @@{$d3_usedby_set{$type}}; $html = $tmp{html}; $id = $tmp{id}; if (not (exists($d5_dumphtml_types_alloc{$id}))) { if ($dbgon == 1) { print ("Output file usage div [$id:$type]\n"); } $d5_dumphtml_types_alloc{$id} = 1; $d5_dumphtml_types .= $html; } return (1,$id); } return (0,-1); } sub d5_addenum_dumphtml() { my ($type) = @@_; my ($posbeg,$posend,$fname); my %tmp = (); my ($id,$html,$title); if (exists($d2_enums{$type})) { %tmp = @@{$d2_enums{$type}}; $posbeg = $tmp{posbeg}; $posend = $tmp{posend}; $id = $tmp{id}; if (not (exists($d5_dumphtml_types_alloc{$id}))) { if ($dbgon == 1) { print ("Output const div [$id:$type]\n"); } $d5_dumphtml_types_alloc{$id} = 1; $fname = d3_filename($posbeg); $d3_pathreplace{"%$d3_pathreplaceid%"} = d3_gethtmlname($fname); $title = "   Enum $type defined in $fname"; $title = $d5_divstart."$title
"; $title =~ s/%id%/$id/g; $d3_pathreplaceid++; $html = d5_gethtml($posbeg,$posend,$type); $d5_dumphtml_types .= $title.$html.$d5_divend; } return (1,$id); } return (0,-1); } sub d5_addfunc_dumphtml() { my ($type) = @@_; my ($posbeg,$posend,$fname); my %tmp = (); my ($id,$html,$title); if (exists($d2_funcs{$type})) { %tmp = @@{$d2_funcs{$type}}; $posbeg = $tmp{posbeg}; $posend = $tmp{posend}; $id = $tmp{id}; if (not (exists($d5_dumphtml_types_alloc{$id}))) { if ($dbgon == 1) { print ("Output const div [$id:$type]\n"); } $d5_dumphtml_types_alloc{$id} = 1; $fname = d3_filename($posbeg); $d3_pathreplace{"%$d3_pathreplaceid%"} = d3_gethtmlname($fname); $title = "   Function $type defined in $fname"; $title = $d5_divstart."$title
"; $title =~ s/%id%/$id/g; $d3_pathreplaceid++; $html = d5_gethtml($posbeg,$posend,$type); $d5_dumphtml_types .= $title.$html.$d5_divend; } return (1,$id); } return (0,-1); } sub d5_addproc_dumphtml() { my ($type) = @@_; my ($posbeg,$posend,$fname); my %tmp = (); my ($id,$html,$title); if (exists($d2_procs{$type})) { %tmp = @@{$d2_procs{$type}}; $posbeg = $tmp{posbeg}; $posend = $tmp{posend}; $id = $tmp{id}; if (not (exists($d5_dumphtml_types_alloc{$id}))) { if ($dbgon == 1) { print ("Output const div [$id:$type]\n"); } $d5_dumphtml_types_alloc{$id} = 1; $fname = d3_filename($posbeg); $d3_pathreplace{"%$d3_pathreplaceid%"} = d3_gethtmlname($fname); $title = "   Procedure $type defined in $fname"; $title = $d5_divstart."$title
"; $title =~ s/%id%/$id/g; $d3_pathreplaceid++; $html = d5_gethtml($posbeg,$posend,$type); $d5_dumphtml_types .= $title.$html.$d5_divend; } return (1,$id); } return (0,-1); } sub d5_addconst_dumphtml() { my ($type) = @@_; my ($posbeg,$posend,$fname); my %tmp = (); my ($id,$html,$title); if (exists($d2_consts{$type})) { %tmp = @@{$d2_consts{$type}}; $posbeg = $tmp{posbeg}; $posend = $tmp{posend}; $id = $tmp{id}; if (not (exists($d5_dumphtml_types_alloc{$id}))) { if ($dbgon == 1) { print ("Output const div [$id:$type]\n"); } $d5_dumphtml_types_alloc{$id} = 1; $fname = d3_filename($posbeg); $d3_pathreplace{"%$d3_pathreplaceid%"} = d3_gethtmlname($fname); $title = "   Constant $type defined in $fname"; $title = $d5_divstart."$title
"; $title =~ s/%id%/$id/g; $d3_pathreplaceid++; $html = d5_gethtml($posbeg,$posend,$type); $d5_dumphtml_types .= $title.$html.$d5_divend; } return (1,$id); } return (0,-1); } sub d5_addtype_dumphtml { my ($type) = @@_; my ($posbeg,$posend,$fname); my %tmp = (); my ($id,$html,$title); if (exists($d2_records{$type})) { %tmp = @@{$d2_records{$type}}; $posbeg = $tmp{posbeg}; $posend = $tmp{posend}; $id = $tmp{id}; if (not (exists($d5_dumphtml_types_alloc{$id}))) { if ($dbgon == 1) { print ("Output record div [$id:$type]\n"); } $d5_dumphtml_types_alloc{$id} = 1; $fname = d3_filename($posbeg); $d3_pathreplace{"%$d3_pathreplaceid%"} = d3_gethtmlname($fname); $title = "   Type $type defined in $fname"; $title = $d5_divstart."$title
"; $title =~ s/%id%/$id/g; $d3_pathreplaceid++; $html = d5_gethtml($posbeg,$posend,$type); $d5_dumphtml_types .= $title.$html.$d5_divend; } return (1,$id); } return (0,-1); } sub d5_assemblehtml { my ($filename,$html,$dhtml,$template,$header) = @@_; my $body = d3_readfile($template,0); $body =~ s/%replace%/$html$dhtml/g; $body =~ s/%header%/$header/g; $body =~ s/%filename%/$filename/g; return $body; } 1; @ 1.1.1.1 log @Core library @ text @@