C-Analyzer

 view release on metacpan or  search on metacpan

lib/C/Analyzer.pm  view on Meta::CPAN

				|| ( $t_fun eq "bit" )
				|| ( $t_fun eq "unsigned" )
				|| ( $t_fun eq "return" ) )
			{
				next;
			}
			if ($opt_s) {
				my $filelength = length($FolderName);
				$fragment = substr $filename, $filelength;
				$fragment = "." . "$fragment";
				if ( $t_fun eq "" ) {
					;
				}
				else {
					$fun = "$t_fun" . "($lno, $fragment)";
				}
			}
			else {
				if ( $t_fun eq "" ) {
					print;
				}
				else {
					$fun = "$t_fun" . "($lno, $filename)";
				}
			}
			push( @t_funs_calls, $fun );
			$fragment = "";
		}
		while ( $ppfile =~ /(;)/g ) {
			push( @t_funs_calls, $1 );
		}
		while ( $ppfile =~ /({)/g ) {
			$OpenCount++;
			push( @t_funs_calls, $1 );
		}
		while ( $ppfile =~ /(})/g ) {
			$CloseCount++;
			push( @t_funs_calls, $1 );
		}
	}
	return ( \@t_funs_calls );
}

#################### subroutine header begin ####################

=head2 updateHashTable

 Usage     : updateHashTable()
 Purpose   : updates function wise calls hash table
 Returns   : reference to hash table containing functions and calls
 Argument  : None
 Throws    : None
 Comment   : None
See Also   : 
None

=cut

#################### subroutine header end ####################

sub updateHashTable() {
	my $fun_calls  = shift;
	my $OpenCount  = 0;
	my $CloseCount = 0;
	my $function;
	my $FUNCTIONFOUND = 0;
	my $item          = -1;
	my $titem;
	my $cnt1 = 0;
	my $call;
	my $fun_remain;

	foreach my $x (@$$fun_calls) {
		$item++;

		if ( $x eq "{" ) {
			$OpenCount++;
		}
		if ( $x eq "}" ) {
			$CloseCount++;
		}
		if (   !defined( @$$fun_calls[$item] )
			|| !defined( @$$fun_calls[ $item + 1 ] ) )
		{
			next;
		}
		$titem = $item + 1;
		if (   ( @$$fun_calls[$item] =~ /(\w+.*)/ )
			&& ( @$$fun_calls[ $item + 1 ] eq "{" )
			&& ( $OpenCount == $CloseCount ) )
		{
			$function = $1;
			$function =~ /(\w+)\s*\(/;
			$function   = $1;
			$function   = trim($function);
			$fun_remain = $';
			$fun_remain = "(" . $fun_remain;
			push( @{ $calls{$function} }, $fun_remain );
			$FUNCTIONFOUND = 1;
		}
		if ( ( $FUNCTIONFOUND == 1 ) && ( $OpenCount != $CloseCount ) ) {
			if ( ( $x eq "{" ) || ( $x eq "}" ) || ( $x eq ";" ) ) {
				next;
			}
			else {
				$call = $x;
				push( @calls_table, $call );
				$call = trim($call);
				if ( defined($call) ) {
					push( @{ $calls{$function} }, $call );
				}
			}
		}
	}

	return;
}

#################### subroutine header begin ####################

=head2 trim



( run in 0.725 second using v1.01-cache-2.11-cpan-9581c071862 )