[Fusionforge-commits] r10827 - trunk/tests/scripts

Alain Peyrat aljeux at libremir.placard.fr.eu.org
Sun Oct 3 19:05:59 CEST 2010


Author: aljeux
Date: 2010-10-03 19:05:58 +0200 (Sun, 03 Oct 2010)
New Revision: 10827

Added:
   trunk/tests/scripts/scan_deprecated.pl
Log:
Initial code to track deprecated use in code

Added: trunk/tests/scripts/scan_deprecated.pl
===================================================================
--- trunk/tests/scripts/scan_deprecated.pl	                        (rev 0)
+++ trunk/tests/scripts/scan_deprecated.pl	2010-10-03 17:05:58 UTC (rev 10827)
@@ -0,0 +1,47 @@
+#!/bin/perl
+
+use File::Find;
+
+# Scan for old exit_error syntax (second argument is not a tab name)
+sub scan_exit_error ($) {
+	local $content = shift;
+
+	@matches = ();
+	while ($content =~ /exit_error\s*\((.*?),([^,]*?)\s*\)\s*;(.*)/s) {
+		$content = $3;
+		($match = $2) =~ s/\s+/ /;
+		$match =~ s/^'(.*)'$/\1/;
+		push(@matches, $match) if ($match !~ /^(admin|home|my|frs|tracker|docman|forums|news|mail|pm|scm|trove|surveys|summary|)$/);
+	}
+
+	$k = "exit_error>".$File::Find::name.": ";
+	print $k.join("\n$k", @matches)."\n" if (@matches);
+}
+
+# Scan for getStringFromRequest used for *_id vars, should be getIntFromRequest intead.
+sub scan_getStringFromRequest ($) {
+	local $content = shift;
+
+	@matches = ();
+	while ($content =~ /(getStringFromRequest\s*\('[^']*?_id'\))\s*;(.*)/s) {
+		$content = $3;
+		push(@matches, $1);
+	}
+
+	$k = "getString>".$File::Find::name.": ";
+	print $k.join("\n$k", @matches)."\n" if (@matches);	
+}
+
+sub wanted {
+	next unless /\.php$/;
+	open(F, $_);
+	$content = join('', <F>);
+	close(F);
+
+	scan_exit_error($content);
+	scan_getStringFromRequest($content);
+}
+
+find(\&wanted, @ARGV);
+
+




More information about the Fusionforge-commits mailing list