3566 lines · 95.2 KB · Perl
RawDownload
 	return $res;} my $av_preprocessor = 0;my $av_pending;my @av_paren_type;my $av_pend_colon; sub annotate_reset {	$av_preprocessor = 0;	$av_pending = '_';	@av_paren_type = ('E');	$av_pend_colon = 'O';} sub annotate_values {	my ($stream, $type) = @_; 	my $res;	my $var = '_' x length($stream);	my $cur = $stream; 	print "$stream\n" if ($dbg_values > 1); 	while (length($cur)) {		@av_paren_type = ('E') if ($#av_paren_type < 0);		print " <" . join('', @av_paren_type) .				"> <$type> <$av_pending>" if ($dbg_values > 1);		if ($cur =~ /^(\s+)/o) {			print "WS($1)\n" if ($dbg_values > 1);			if ($1 =~ /\n/ && $av_preprocessor) {				$type = pop(@av_paren_type);				$av_preprocessor = 0;			} 		} elsif ($cur =~ /^(\(\s*$Type\s*)\)/ && $av_pending eq '_') {			print "CAST($1)\n" if ($dbg_values > 1);			push(@av_paren_type, $type);			$type = 'c'; 		} elsif ($cur =~ /^($Type)\s*(?:$Ident|,|\)|\(|\s*$)/) {			print "DECLARE($1)\n" if ($dbg_values > 1);			$type = 'T'; 		} elsif ($cur =~ /^($Modifier)\s*/) {			print "MODIFIER($1)\n" if ($dbg_values > 1);			$type = 'T'; 		} elsif ($cur =~ /^(\#\s*define\s*$Ident)(\(?)/o) {			print "DEFINE($1,$2)\n" if ($dbg_values > 1);			$av_preprocessor = 1;			push(@av_paren_type, $type);			if ($2 ne '') {				$av_pending = 'N';			}			$type = 'E'; 		} elsif ($cur =~ /^(\#\s*(?:undef\s*$Ident|include\b))/o) {			print "UNDEF($1)\n" if ($dbg_values > 1);			$av_preprocessor = 1;			push(@av_paren_type, $type); 		} elsif ($cur =~ /^(\#\s*(?:ifdef|ifndef|if))/o) {			print "PRE_START($1)\n" if ($dbg_values > 1);			$av_preprocessor = 1; 			push(@av_paren_type, $type);			push(@av_paren_type, $type);			$type = 'E'; 		} elsif ($cur =~ /^(\#\s*(?:else|elif))/o) {			print "PRE_RESTART($1)\n" if ($dbg_values > 1);			$av_preprocessor = 1; 			push(@av_paren_type, $av_paren_type[$#av_paren_type]); 			$type = 'E'; 		} elsif ($cur =~ /^(\#\s*(?:endif))/o) {			print "PRE_END($1)\n" if ($dbg_values > 1); 			$av_preprocessor = 1; 			# Assume all arms of the conditional end as this			# one does, and continue as if the #endif was not here.			pop(@av_paren_type);			push(@av_paren_type, $type);			$type = 'E'; 		} elsif ($cur =~ /^(\\\n)/o) {			print "PRECONT($1)\n" if ($dbg_values > 1); 		} elsif ($cur =~ /^(__attribute__)\s*\(?/o) {			print "ATTR($1)\n" if ($dbg_values > 1);			$av_pending = $type;			$type = 'N'; 		} elsif ($cur =~ /^(sizeof)\s*(\()?/o) {			print "SIZEOF($1)\n" if ($dbg_values > 1);			if (defined $2) {				$av_pending = 'V';			}			$type = 'N'; 		} elsif ($cur =~ /^(if|while|for)\b/o) {			print "COND($1)\n" if ($dbg_values > 1);			$av_pending = 'E';			$type = 'N'; 		} elsif ($cur =~/^(case)/o) {			print "CASE($1)\n" if ($dbg_values > 1);			$av_pend_colon = 'C';			$type = 'N'; 		} elsif ($cur =~/^(return|else|goto|typeof|__typeof__)\b/o) {			print "KEYWORD($1)\n" if ($dbg_values > 1);			$type = 'N'; 		} elsif ($cur =~ /^(\()/o) {			print "PAREN('$1')\n" if ($dbg_values > 1);			push(@av_paren_type, $av_pending);			$av_pending = '_';			$type = 'N'; 		} elsif ($cur =~ /^(\))/o) {			my $new_type = pop(@av_paren_type);			if ($new_type ne '_') {				$type = $new_type;				print "PAREN('$1') -> $type\n"							if ($dbg_values > 1);			} else {				print "PAREN('$1')\n" if ($dbg_values > 1);			} 		} elsif ($cur =~ /^($Ident)\s*\(/o) {			print "FUNC($1)\n" if ($dbg_values > 1);			$type = 'V';			$av_pending = 'V'; 		} elsif ($cur =~ /^($Ident\s*):(?:\s*\d+\s*(,|=|;))?/) {			if (defined $2 && $type eq 'C' || $type eq 'T') {				$av_pend_colon = 'B';			} elsif ($type eq 'E') {				$av_pend_colon = 'L';			}			print "IDENT_COLON($1,$type>$av_pend_colon)\n" if ($dbg_values > 1);			$type = 'V'; 		} elsif ($cur =~ /^($Ident|$Constant)/o) {			print "IDENT($1)\n" if ($dbg_values > 1);			$type = 'V'; 		} elsif ($cur =~ /^($Assignment)/o) {			print "ASSIGN($1)\n" if ($dbg_values > 1);			$type = 'N'; 		} elsif ($cur =~/^(;|{|})/) {			print "END($1)\n" if ($dbg_values > 1);			$type = 'E';			$av_pend_colon = 'O'; 		} elsif ($cur =~/^(,)/) {			print "COMMA($1)\n" if ($dbg_values > 1);			$type = 'C'; 		} elsif ($cur =~ /^(\?)/o) {			print "QUESTION($1)\n" if ($dbg_values > 1);			$type = 'N'; 		} elsif ($cur =~ /^(:)/o) {			print "COLON($1,$av_pend_colon)\n" if ($dbg_values > 1); 			substr($var, length($res), 1, $av_pend_colon);			if ($av_pend_colon eq 'C' || $av_pend_colon eq 'L') {				$type = 'E';			} else {				$type = 'N';			}			$av_pend_colon = 'O'; 		} elsif ($cur =~ /^(\[)/o) {			print "CLOSE($1)\n" if ($dbg_values > 1);			$type = 'N'; 		} elsif ($cur =~ /^(-(?![->])|\+(?!\+)|\*|\&\&|\&)/o) {			my $variant; 			print "OPV($1)\n" if ($dbg_values > 1);			if ($type eq 'V') {				$variant = 'B';			} else {				$variant = 'U';			} 			substr($var, length($res), 1, $variant);			$type = 'N'; 		} elsif ($cur =~ /^($Operators)/o) {			print "OP($1)\n" if ($dbg_values > 1);			if ($1 ne '++' && $1 ne '--') {				$type = 'N';			} 		} elsif ($cur =~ /(^.)/o) {			print "C($1)\n" if ($dbg_values > 1);		}		if (defined $1) {			$cur = substr($cur, length($1));			$res .= $type x length($1);		}	} 	return ($res, $var);} sub possible {	my ($possible, $line) = @_;	my $notPermitted = qr{(?:		^(?:			$Modifier|			$Storage|			$Type|			DEFINE_\S+		)$|		^(?:			goto|			return|			case|			else|			asm|__asm__|			do|			\#|			\#\#|		)(?:\s|$)|		^(?:typedef|struct|enum)\b	    )}x;	warn "CHECK<$possible> ($line)\n" if ($dbg_possible > 2);	if ($possible !~ $notPermitted) {		# Check for modifiers.		$possible =~ s/\s*$Storage\s*//g;		$possible =~ s/\s*$Sparse\s*//g;		if ($possible =~ /^\s*$/) { 		} elsif ($possible =~ /\s/) {			$possible =~ s/\s*$Type\s*//g;			for my $modifier (split(' ', $possible)) {				if ($modifier !~ $notPermitted) {					warn "MODIFIER: $modifier ($possible) ($line)\n" if ($dbg_possible);					push(@modifierList, $modifier);				}			} 		} else {			warn "POSSIBLE: $possible ($line)\n" if ($dbg_possible);			push(@typeList, $possible);		}		build_types();	} else {		warn "NOTPOSS: $possible ($line)\n" if ($dbg_possible > 1);	}} my $prefix = ''; sub show_type {       return !defined $ignore_type{$_[0]};} sub report {	if (!show_type($_[1]) ||	    (defined $tst_only && $_[2] !~ /\Q$tst_only\E/)) {		return 0;	}	my $line;	if ($show_types) {		$line = "$prefix$_[0]:$_[1]: $_[2]\n";	} else {		$line = "$prefix$_[0]: $_[2]\n";	}	$line = (split('\n', $line))[0] . "\n" if ($terse); 	push(our @report, $line); 	return 1;}sub report_dump {	our @report;} sub ERROR {	if (report("ERROR", $_[0], $_[1])) {		our $clean = 0;		our $cnt_error++;	}}sub WARN {	if (report("WARNING", $_[0], $_[1])) {		our $clean = 0;		our $cnt_warn++;	}}sub CHK {	if ($check && report("CHECK", $_[0], $_[1])) {		our $clean = 0;		our $cnt_chk++;	}} sub check_absolute_file {	my ($absolute, $herecurr) = @_;	my $file = $absolute; 	##print "absolute<$absolute>\n"; 	# See if any suffix of this path is a path within the tree.	while ($file =~ s@^[^/]*/@@) {		if (-f "$root/$file") {			##print "file<$file>\n";			last;		}	}	if (! -f _)  {		return 0;	} 	# It is, so see if the prefix is acceptable.	my $prefix = $absolute;	substr($prefix, -length($file)) = ''; 	##print "prefix<$prefix>\n";	if ($prefix ne ".../") {		WARN("USE_RELATIVE_PATH",		     "use relative pathname instead of absolute in changelog text\n" . $herecurr);	}} sub pos_last_openparen {	my ($line) = @_; 	my $pos = 0; 	my $opens = $line =~ tr/\(/\(/;	my $closes = $line =~ tr/\)/\)/; 	my $last_openparen = 0; 	if (($opens == 0) || ($closes >= $opens)) {		return -1;	} 	my $len = length($line); 	for ($pos = 0; $pos < $len; $pos++) {		my $string = substr($line, $pos);		if ($string =~ /^($FuncArg|$balanced_parens)/) {			$pos += length($1) - 1;		} elsif (substr($line, $pos, 1) eq '(') {			$last_openparen = $pos;		} elsif (index($string, '(') == -1) {			last;		}	} 	return $last_openparen + 1;} sub process {	my $filename = shift; 	my $linenr=0;	my $prevline="";	my $prevrawline="";	my $stashline="";	my $stashrawline=""; 	my $length;	my $indent;	my $previndent=0;	my $stashindent=0; 	our $clean = 1;	my $signoff = 0;	my $is_patch = 0; 	my $in_header_lines = 1;	my $in_commit_log = 0;		#Scanning lines before patch 	our @report = ();	our $cnt_lines = 0;	our $cnt_error = 0;	our $cnt_warn = 0;	our $cnt_chk = 0; 	# Trace the real file/line as we go.	my $realfile = '';	my $realline = 0;	my $realcnt = 0;	my $here = '';	my $in_comment = 0;	my $comment_edge = 0;	my $first_line = 0;	my $p1_prefix = ''; 	my $prev_values = 'E'; 	# suppression flags	my %suppress_ifbraces;	my %suppress_whiletrailers;	my %suppress_export;	my $suppress_statement = 0; 	# Pre-scan the patch sanitizing the lines.	# Pre-scan the patch looking for any __setup documentation.	#	my @setup_docs = ();	my $setup_docs = 0; 	sanitise_line_reset();	my $line;	foreach my $rawline (@rawlines) {		$linenr++;		$line = $rawline; 		if ($rawline=~/^\+\+\+\s+(\S+)/) {			$setup_docs = 0;			if ($1 =~ m@Documentation/kernel-parameters.txt$@) {				$setup_docs = 1;			}			#next;		}		if ($rawline=~/^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) {			$realline=$1-1;			if (defined $2) {				$realcnt=$3+1;			} else {				$realcnt=1+1;			}			$in_comment = 0; 			# Guestimate if this is a continuing comment.  Run			# the context looking for a comment "edge".  If this			# edge is a close comment then we must be in a comment			# at context start.			my $edge;			my $cnt = $realcnt;			for (my $ln = $linenr + 1; $cnt > 0; $ln++) {				next if (defined $rawlines[$ln - 1] &&					 $rawlines[$ln - 1] =~ /^-/);				$cnt--;				#print "RAW<$rawlines[$ln - 1]>\n";				last if (!defined $rawlines[$ln - 1]);				if ($rawlines[$ln - 1] =~ m@(/\*|\*/)@ &&				    $rawlines[$ln - 1] !~ m@"[^"]*(?:/\*|\*/)[^"]*"@) {					($edge) = $1;					last;				}			}			if (defined $edge && $edge eq '*/') {				$in_comment = 1;			} 			# Guestimate if this is a continuing comment.  If this			# is the start of a diff block and this line starts			# ' *' then it is very likely a comment.			if (!defined $edge &&			    $rawlines[$linenr] =~ m@^.\s*(?:\*\*+| \*)(?:\s|$)@)			{				$in_comment = 1;			} 			##print "COMMENT:$in_comment edge<$edge> $rawline\n";			sanitise_line_reset($in_comment); 		} elsif ($realcnt && $rawline =~ /^(?:\+| |$)/) {			# Standardise the strings and chars within the input to			# simplify matching -- only bother with positive lines.			$line = sanitise_line($rawline);		}		push(@lines, $line); 		if ($realcnt > 1) {			$realcnt-- if ($line =~ /^(?:\+| |$)/);		} else {			$realcnt = 0;		} 		#print "==>$rawline\n";		#print "-->$line\n"; 		if ($setup_docs && $line =~ /^\+/) {			push(@setup_docs, $line);		}	} 	$prefix = ''; 	$realcnt = 0;	$linenr = 0;	foreach my $line (@lines) {

Lines 1001–1500 of 3566. Previous lines