svn commit: samba r7891 - in branches/SAMBA_4_0/source/script: .

jelmer at samba.org jelmer at samba.org
Fri Jun 24 22:49:15 GMT 2005


Author: jelmer
Date: 2005-06-24 22:49:14 +0000 (Fri, 24 Jun 2005)
New Revision: 7891

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=7891

Log:
Improve output of unused macro find script
Remove duplicate find-missing-doc script (already in samba-docs repository)

Removed:
   branches/SAMBA_4_0/source/script/find_missing_doc.pl
Modified:
   branches/SAMBA_4_0/source/script/find_unused_macros.pl


Changeset:
Deleted: branches/SAMBA_4_0/source/script/find_missing_doc.pl
===================================================================
--- branches/SAMBA_4_0/source/script/find_missing_doc.pl	2005-06-24 22:34:40 UTC (rev 7890)
+++ branches/SAMBA_4_0/source/script/find_missing_doc.pl	2005-06-24 22:49:14 UTC (rev 7891)
@@ -1,90 +0,0 @@
-#!/usr/bin/perl
-
-my $doc_file = "/docs/docbook/manpages/smb.conf.5.sgml";
-my $source_file = "/source/param/loadparm.c";
-
-my %link,%doc,%param;
-
-# This one shouldn't be documented at all
-$doc{-valid} = "FOUND";
-
-$topdir = (shift @ARGV) or $topdir = ".";
-
-##################################################
-# Reading links from manpage
-
-open(IN,$topdir.$doc_file);
-
-while(<IN>) {
-	if( /<listitem><para><link linkend="([^"]*)"><parameter>([^<]*)<\/parameter><\/link><\/para><\/listitem>/g ){
-		$link{$2} = $1;
-		$ref{$1} = $2;
-	}
-}
-
-close(IN);
-
-##################################################
-# Reading documentation from manpage
-
-open(IN,$topdir.$doc_file) || die("Can't open $topdir$doc_file");
-
-while(<IN>) {
-	if( /<term><anchor id="([^"]*)"\/>([^<]*?)([ ]*)\(.\)([ ]*)<\/term>/g ) {
-		$key = $1;
-		$value = $2;
-		$doc{$value} = $key;
-
-		# There is a reference to this entry
-		if($ref{$key} eq $value){
-			$ref{$key} = "FOUND";
-		} else {
-			if($ref{$key}) {
-				print "$key should refer to $value, but refers to " . $ref{$key} . "\n";
-			} else {
-				print "$key should refer to $value, but has no reference!\n";
-			}
-			$ref{$key} = $value;
-		}
-	}
-}
-
-close(IN);
-
-#################################################
-# Reading entries from source code
-
-open(SOURCE,$topdir.$source_file) || die("Can't open $topdir$source_file");
-
-while ($ln = <SOURCE>) {
-  last if $ln =~ m/^static\ struct\ parm_struct\ parm_table.*/;
-} #burn through the preceding lines
-
-while ($ln = <SOURCE>) {
-  last if $ln =~ m/^\s*\}\;\s*$/;
-  #pull in the param names only
-  next if $ln =~ m/.*P_SEPARATOR.*/;
-  next unless $ln =~ /.*\"(.*)\".*/;
-  
-  if($doc{lc($1)}) {
-	$doc{lc($1)} = "FOUND";
-  } else {
-	print "$1 is not documented!\n";
-  }
-}
-close SOURCE;
-
-##################################################
-# Trying to find missing references
-
-foreach (keys %ref) {
-	if($ref{$_} cmp "FOUND") {
-		print "$_ references to " . $ref{$_} . ", but " . $ref{$_} . " isn't an anchor!\n";
-	}
-}
-
-foreach (keys %doc) {
-	if($doc{$_} cmp "FOUND") {
-		print "$_ is documented but is not a configuration option!\n";
-	}
-}

Modified: branches/SAMBA_4_0/source/script/find_unused_macros.pl
===================================================================
--- branches/SAMBA_4_0/source/script/find_unused_macros.pl	2005-06-24 22:34:40 UTC (rev 7890)
+++ branches/SAMBA_4_0/source/script/find_unused_macros.pl	2005-06-24 22:49:14 UTC (rev 7891)
@@ -3,30 +3,36 @@
 # it defines that are used nowhere in the code
 
 # Arguments: C and H files
+# Copyright Jelmer Vernooij <jelmer at samba.org>, GPL
 
-my %defined,%used,%files;
+use strict;
 
-$in = shift;
+my %defined;
+my %used;
+my %files;
 
+my $tmp;
 while($tmp = shift) { 
 	$files{$tmp} = $tmp;
 	open(FI, $tmp);
+	my $ln = 0;
 	while(<FI>) { 
-		$line = $_;
-		$cur = "";
+		$ln++;
+		my $line = $_;
+		my $cur = "";
 		if(/^#define ([A-Za-z0-9_]+)/) {
-			$defined{$1} = $tmp;
+			$defined{$1} = "$tmp:$ln";
 			$cur = $1;
 		}
 
 		$_ = $line;
 		while(/([A-Za-z0-9_]+)/sgm) { 
-			if($cur cmp $1) { $used{$1} = $tmp; }
+			if($cur ne $1) { $used{$1} = "$tmp:$ln"; }
 		}
 	}
 	close FI;
 }
 
 foreach(keys %defined) {
-	if(!$used{$_}) { print "$_\n"; }
+	if(!$used{$_}) { print "$defined{$_}: Macro `$_' is unused\n"; }
 }



More information about the samba-cvs mailing list