⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 isip_check_code.pl

📁 这是一个从音频信号里提取特征参量的程序
💻 PL
📖 第 1 页 / 共 2 页
字号:
#! /usr/local/bin/perl# file: $isip/util/devel/check_code/isip_check_code.pl## load the command line package#require "$ENV{ISIP}/lib/scripts/perl/command_line.pm";# split list of files into .cc and other#($arg, $ret, $retfull, $debug, $method_com, @files) = command_line(-1, "-methods", 0, 				     "-ret", 0,				     "-retfull", 0,				     "-debug", 0,				     "-comment", 0);@other_files = grep(!/\.(cc|h)$/, @files);@files = grep(/\.(cc|h)$/,@files);# print error message for anything other than .cc files#foreach $file (@other_files) {    print "$file:1: cannot check anything but .cc files\n";}# loop through the list of filenames#NEXT: foreach $file (@files) {    # open the file    #    open(FP,$file) or isip_die("cannot open file $file: $!");        if ($file =~ /.h$/) {	$header_file = 1;    } else {	$header_file = 0;    }    # initialize the state machine    #    $state = 0;	    $_ = `pwd`;    chop;    $file_real = "$_\/$file";    $filename = "";    $classdir="";    $method="";    $multi_method = -1;    $template_mode = 0;    $start = 0;    undef @args;    $line = 0;        while (<FP>) {		$line ++;		if ($debug) {	    print "$state: $line: $_";	}	# look for the filename comment	#	if (($state == 0) &&	    (/^\/\/ file: \$isip\/class\/[\w\/]+?\/(\w+)\/(\w+(_\w+\d+\.cc|.h))$/)) {	    $classdir = $1;	    $filename = $2;	    if ($file_real =~ /$classdir\/$filename/) {		$state = 1;	    } else {		print "$file:$line: invalid filename comment\n";	    }	    	    if ($line != 1) {		print "$file:$line: the filename should be on line 1\n";	    }	}		# look for the version comment	#	elsif (($state == 1) && (/^\/\/ version: /)) {	    $state = 1.1;	    if ($line != 2) {		print "$file:$line: the version should be on line 2\n";	    }	}		elsif (($state == 1.1) && (/^\/\/\s*$/)) {	    $state = 1.2;	    if ($line != 3) {		print "$file:$line: the blank comment should be on line 3\n";	    }	}	elsif (($state == 1.2) && (/^\s*$/)) {	    	    if ($header_file == 1) {		$state = 3;	    } else {		$state = 2;	    }	    if ($line != 4) {		print "$file:$line: the blankline should be on line 4\n";	    }	}	# look for isip include files	#	elsif (($state == 2) && (/isip include files/)) {	    $state = 3;	}	elsif ((($state == 2) || ($state == 3))	       && (/there is no source code in this file/)) {	    $state = 8;	}		# look for the method name	#	elsif ($state == 3) {	    	    $header_args = 0;	    if (/^\s*\/\/ method: ([\w ]+)/) {		$method = $1;		$method =~ s/\s*$//;				if ($debug) {		    print "method found: $method\n";		}		if ($header_file == 1) {		    $state = 6;		} else {		    $state = 4;		}	    }	    elsif ((/system include files/) && ($header_file == 0)) {		print "$file:$line: list system include before isip include\n";	    }	}	# look for the argument list	#	elsif (($state == 4) && (/arguments:/)) {	    $state = 5;	    $pre_ret_blank = 0;	    undef @args;	}		elsif ($state == 5) {	    $return = "";	    $comment = "";	    $pre_blank = 0;	    $post_blank = 0;	    	    # read in the argument list from the comments. 	    #	    if (/\/\/\s+((?:const |).*?):(\s+)\((input|output|input\/output)\)(\s*)\S+/) {		push @args, $1;		if ($pre_ret_blank == 1) {		    print "$file:", $line-1, ": blank line found\n";		    $pre_ret_blank = 0;		}		if ($2 ne " ") {		    print "$file:$line: spacing error between : and (\n";		}		if ($4 ne " ") {		    print "$file:$line: spacing error after )\n";		}				if (/^\/\/  \w/ == 0) {		    print "$file:$line: spacing error before arg definition\n";		}	    }	    # blank comment line, only should have one	    #	    elsif (/^\/\/\s*$/) {		if ($pre_ret_blank == 1) {		    print "$file:$line: too many blank lines\n";		} else {		    $pre_ret_blank = 1;		}	    }	    # the argument list ends with the return value statement	    #	    elsif (/return: (.*)\s*$/) {		$return = $1;		if ($debug) {		    print ("args = ", join(',', @args), "\n");		}		if ($retfull) {		    print "$file:$line: return value = $return\n";		}		$ret_line = $line;		$func_def = "";		$state = 6;	    }	    elsif (/:/) {		print "$file:$line: invalid argument definition\n";	    }	    else {		print "$file:$line: ERROR: couldn't parse line\n";	    }	}	elsif ($state == 6) {	    # see if arguments were defined for the header file (such	    # as dstr classes	    #	    if (($header_file == 1) && (/arguments:/)) {		$state = 5;		$header_args = 1;		$pre_ret_blank = 0;		undef @args;	    }	    # grab the comment until the method is defined	    #	    if (/^\s*\/\/(.*)$/) {		$func_def = "";				$comm_line = $1;				if ($comm_line =~ /^\s*$/) {		    if ($comment eq "") {			if ($pre_blank == 0) {			    $pre_blank = 1;			}			elsif ($header_file == 0) {			    print "$file:$line: too many blank lines 6.1\n";			}		    }		    else {			if ($post_blank == 0) {			    $post_blank = 1;			}			elsif ($header_file == 0) {			    print "$file:$line: too many blank lines 6.2\n";			}		    }		}		else {		    $post_blank = 0;		    if (($comment eq "") && ($method_com)) {			print "$file:$line: method comment\n";			$comment = $comm_line;		    }		    else {			$comment = join(' ', $comment,$comm_line);		    }		}	    }	    # look and see if this is a template 	    #  clears multi-line function definition	    #	    elsif (/^template/) {		$template_mode = 1;		$multi_method = -1;		$func_def = "";	    }	    # handle multi-line function definitions	    #	    else {				chop;		if ($func_def ne "") {		    if (/\)\{/) {			print "$file:$line: spacing error before {\n";		    }		    $func_def = join(' ',$func_def, $_);		    $func_def =~ s/\s+/ /g;		    $_ = $func_def;		} else {		    if (/\)\{/) {			print "$file:$line: spacing error before {\n";		    }		    $func_def = $_;		    $func_def =~ s/\s+/ /g;		}		if ($debug) {		    print "func_def = >$_<\n";		}	    }	    	    # this should accept all formats of function definitions	    #	    if ((/^[\w\ :\*\&]+ (\w+)::(\w+)\((.*?)\) (?:const \{|\{|\{\}|const \{\})$/) ||		(/^(\w+)::~*(\w+)\((.*?)\) (?:const \{|\{|\{\}|const \{\})$/) ||		(/^[\w\*\&]+ (\w+)::(operator .+?)\((.*?)\) (?:const \{|\{|\{\}|const \{\})$/) ||		(/^(\w+)::(operator .+?)\((.*?)\) (?:const \{|\{|\{\}|const \{\})$/)		|| (($header_file == 1) &&		    (/^[\w\ :\*\&]+? ()(\w+)\((.*?)\) (?:const \{|\{|\{\}|const \{\})$/) ||		    (/^()\s*(\w+)\((.*?)\) (?:const \{|\{|\{\}|const \{\})$/) ||		    (/^()\s*[\w\*\&]+ (operator ?.+?)\((.*?)\) (?:const \{|\{|\{\}|const \{\})$/) ||		    (/^()\s*(operator ?.+?)\((.*?)\) (?:const \{|\{|\{\}|const \{\})$/))		|| (($template_mode == 1) &&		    ((/^[\w\ \>\<:\*\&]+ (\w+)<[\w\ \,]+>::(\w+)\((.*?)\) (?:const \{|\{|\{\}|const \{\})$/) ||		     (/^(\w+)<[\w\ \,]+>::~*(\w+)\((.*?)\) (?:const \{|\{|\{\}|const \{\})$/) ||		     (/^[\w\*\&]+ (\w+)<[\w\ \,]+>::(operator .+?)\((.*?)\) (?:const \{|\{|\{\}|const \{\})$/) ||		     (/^(\w+)<[\w\ \,]+>::(operator .+?)\((.*?)\) (?:const \{|\{|\{\}|const \{\})$/)))) {				if ($debug) {		    print "$state: $line: found target >$_<\n";		}				if ($header_file == 1) {		    $def_method = $2;		    $arg_defs = $3;#		    print "arg_defs: 1=>$1<, 2=>$2<, 3=>$3<\n";		    while ($arg_defs =~ s/(\<[^\>\,]*?),([^\>]*?\>)/$1__ISIP_COMMA_HOLDER__$2/) { }		    		    @def_args = grep(s/^\s*(.*?)\s*$/$1/, 				     split(/,/,$arg_defs));		    foreach $arg (@def_args) {			$arg =~ s/__ISIP_COMMA_HOLDER__/,/g;			if (($#args == -1) 			     && (($arg =~ /_a$/) || ($arg =~ /_a\s*\=/))) {			    			    print "$file:$line: argument \"$arg\" should not have a _a suffix\n";			}		    }		} else {		    $def_class = $1;		    $def_method = $2;		    $arg_defs = $3;		    while ($arg_defs =~ s/(\<[^\>\,]*?),([^\>]*?\>)/$1__ISIP_COMMA_HOLDER__$2/) { }		    @def_args = grep(s/^\s*(.*?)\s*$/$1/, 				     split(/,/,$arg_defs));		    foreach $arg (@def_args) {			$arg =~ s/__ISIP_COMMA_HOLDER__/,/g;		    }		}		if (($ret) && ($header_file == 0)) {		    if (/^(\w+)::~*(\w+)\((.*?)\) \{$/) {			if ($return =~ !/none/) {			    print "$file:$ret_line: invalid return comment\n";			}		    }		    elsif ((/^([\w\ \*\&]+) (\w+)::(\w+)\((.*?)\) \{$/) ||			   (/^([\w\*\&]+) (\w+)::(operator .+?)\((.*?)\) \{$/)) {			$return_type = $1;			if (($return_type =~ /boolean/) && 			    (($return =~ /logical error status/) ||			     ($return =~ /boolean .*value/) ||			     ($return =~ /boolean .*result/))) {			} 			elsif (($return_type =~ /long/) && 			       (($return =~ /long index.*/) ||				($return =~ /long .*value/) ||				($return =~ /long .*result/))) {			}			elsif (($return_type =~ /double/) && 			       (($return =~ /double .*value/) ||

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -