mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-01-12 22:51:55 +08:00
[analyzer] update to checker-276
http://clang-analyzer.llvm.org/release_notes.html
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -29,8 +29,9 @@ my $Compiler;
|
||||
my $Clang;
|
||||
my $DefaultCCompiler;
|
||||
my $DefaultCXXCompiler;
|
||||
my $IsCXX;
|
||||
|
||||
if (`uname -a` =~ m/Darwin/) {
|
||||
if (`uname -a` =~ m/Darwin/) {
|
||||
$DefaultCCompiler = 'clang';
|
||||
$DefaultCXXCompiler = 'clang++';
|
||||
} else {
|
||||
@@ -40,17 +41,21 @@ if (`uname -a` =~ m/Darwin/) {
|
||||
|
||||
if ($FindBin::Script =~ /c\+\+-analyzer/) {
|
||||
$Compiler = $ENV{'CCC_CXX'};
|
||||
if (!defined $Compiler) { $Compiler = $DefaultCXXCompiler; }
|
||||
|
||||
if (!defined $Compiler || ! -x $Compiler) { $Compiler = $DefaultCXXCompiler; }
|
||||
|
||||
$Clang = $ENV{'CLANG_CXX'};
|
||||
if (!defined $Clang) { $Clang = 'clang++'; }
|
||||
if (!defined $Clang || ! -x $Clang) { $Clang = 'clang++'; }
|
||||
|
||||
$IsCXX = 1
|
||||
}
|
||||
else {
|
||||
$Compiler = $ENV{'CCC_CC'};
|
||||
if (!defined $Compiler) { $Compiler = $DefaultCCompiler; }
|
||||
if (!defined $Compiler || ! -x $Compiler) { $Compiler = $DefaultCCompiler; }
|
||||
|
||||
$Clang = $ENV{'CLANG'};
|
||||
if (!defined $Clang) { $Clang = 'clang'; }
|
||||
if (!defined $Clang || ! -x $Clang) { $Clang = 'clang'; }
|
||||
|
||||
$IsCXX = 0
|
||||
}
|
||||
|
||||
##===----------------------------------------------------------------------===##
|
||||
@@ -64,7 +69,7 @@ my $CleanupFile;
|
||||
my $ResultFile;
|
||||
|
||||
# Remove any stale files at exit.
|
||||
END {
|
||||
END {
|
||||
if (defined $ResultFile && -z $ResultFile) {
|
||||
`rm -f $ResultFile`;
|
||||
}
|
||||
@@ -95,7 +100,7 @@ sub ProcessClangFailure {
|
||||
my ($Clang, $Lang, $file, $Args, $HtmlDir, $ErrorType, $ofile) = @_;
|
||||
my $Dir = "$HtmlDir/failures";
|
||||
mkpath $Dir;
|
||||
|
||||
|
||||
my $prefix = "clang_crash";
|
||||
if ($ErrorType eq $ParserRejects) {
|
||||
$prefix = "clang_parser_rejects";
|
||||
@@ -113,7 +118,7 @@ sub ProcessClangFailure {
|
||||
DIR => $Dir);
|
||||
system $Clang, @$Args, "-E", "-o", $PPFile;
|
||||
close ($PPH);
|
||||
|
||||
|
||||
# Create the info file.
|
||||
open (OUT, ">", "$PPFile.info.txt") or die "Cannot open $PPFile.info.txt\n";
|
||||
print OUT abs_path($file), "\n";
|
||||
@@ -133,7 +138,7 @@ sub ProcessClangFailure {
|
||||
sub GetCCArgs {
|
||||
my $mode = shift;
|
||||
my $Args = shift;
|
||||
|
||||
|
||||
pipe (FROM_CHILD, TO_PARENT);
|
||||
my $pid = fork();
|
||||
if ($pid == 0) {
|
||||
@@ -141,7 +146,7 @@ sub GetCCArgs {
|
||||
open(STDOUT,">&", \*TO_PARENT);
|
||||
open(STDERR,">&", \*TO_PARENT);
|
||||
exec $Clang, "-###", $mode, @$Args;
|
||||
}
|
||||
}
|
||||
close(TO_PARENT);
|
||||
my $line;
|
||||
while (<FROM_CHILD>) {
|
||||
@@ -151,11 +156,10 @@ sub GetCCArgs {
|
||||
|
||||
waitpid($pid,0);
|
||||
close(FROM_CHILD);
|
||||
|
||||
|
||||
die "could not find clang line\n" if (!defined $line);
|
||||
# Strip the newline and initial whitspace
|
||||
chomp $line;
|
||||
$line =~ s/^\s+//;
|
||||
# Strip leading and trailing whitespace characters.
|
||||
$line =~ s/^\s+|\s+$//g;
|
||||
my @items = quotewords('\s+', 0, $line);
|
||||
my $cmd = shift @items;
|
||||
die "cannot find 'clang' in 'clang' command\n" if (!($cmd =~ /clang/));
|
||||
@@ -203,7 +207,7 @@ sub Analyze {
|
||||
}
|
||||
|
||||
# Display Ubiviz graph?
|
||||
if (defined $ENV{'CCC_UBI'}) {
|
||||
if (defined $ENV{'CCC_UBI'}) {
|
||||
push @Args, "-Xclang", "-analyzer-viz-egraph-ubigraph";
|
||||
}
|
||||
|
||||
@@ -224,7 +228,7 @@ sub Analyze {
|
||||
}
|
||||
if ($Verbose == 1) {
|
||||
# We MUST print to stderr. Some clients use the stdout output of
|
||||
# gcc for various purposes.
|
||||
# gcc for various purposes.
|
||||
print STDERR join(' ', @PrintArgs);
|
||||
print STDERR "\n";
|
||||
}
|
||||
@@ -235,7 +239,7 @@ sub Analyze {
|
||||
# Capture the STDERR of clang and send it to a temporary file.
|
||||
# Capture the STDOUT of clang and reroute it to ccc-analyzer's STDERR.
|
||||
# We save the output file in the 'crashes' directory if clang encounters
|
||||
# any problems with the file.
|
||||
# any problems with the file.
|
||||
pipe (FROM_CHILD, TO_PARENT);
|
||||
my $pid = fork();
|
||||
if ($pid == 0) {
|
||||
@@ -247,7 +251,7 @@ sub Analyze {
|
||||
|
||||
close TO_PARENT;
|
||||
my ($ofh, $ofile) = tempfile("clang_output_XXXXXX", DIR => $HtmlDir);
|
||||
|
||||
|
||||
while (<FROM_CHILD>) {
|
||||
print $ofh $_;
|
||||
print STDERR $_;
|
||||
@@ -289,15 +293,15 @@ sub Analyze {
|
||||
# Have we already spotted this unhandled attribute?
|
||||
next if (defined $attributes_not_handled{$1});
|
||||
$attributes_not_handled{$1} = 1;
|
||||
|
||||
|
||||
# Get the name of the attribute file.
|
||||
my $dir = "$HtmlDir/failures";
|
||||
my $afile = "$dir/attribute_ignored_$1.txt";
|
||||
|
||||
|
||||
# Only create another preprocessed file if the attribute file
|
||||
# doesn't exist yet.
|
||||
next if (-e $afile);
|
||||
|
||||
|
||||
# Add this file to the list of files that contained this attribute.
|
||||
# Generate a preprocessed file if we haven't already.
|
||||
if (!(defined $ppfile)) {
|
||||
@@ -315,7 +319,7 @@ sub Analyze {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unlink($ofile);
|
||||
}
|
||||
|
||||
@@ -325,11 +329,6 @@ sub Analyze {
|
||||
|
||||
my %CompileOptionMap = (
|
||||
'-nostdinc' => 0,
|
||||
'-fblocks' => 0,
|
||||
'-fno-builtin' => 0,
|
||||
'-fobjc-gc-only' => 0,
|
||||
'-fobjc-gc' => 0,
|
||||
'-ffreestanding' => 0,
|
||||
'-include' => 1,
|
||||
'-idirafter' => 1,
|
||||
'-imacros' => 1,
|
||||
@@ -346,18 +345,16 @@ my %LinkerOptionMap = (
|
||||
);
|
||||
|
||||
my %CompilerLinkerOptionMap = (
|
||||
'-fobjc-arc' => 0,
|
||||
'-fno-objc-arc' => 0,
|
||||
'-fobjc-abi-version' => 0, # This is really a 1 argument, but always has '='
|
||||
'-fobjc-legacy-dispatch' => 0,
|
||||
'-Wwrite-strings' => 0,
|
||||
'-ftrapv-handler' => 1, # specifically call out separated -f flag
|
||||
'-mios-simulator-version-min' => 0, # This really has 1 argument, but always has '='
|
||||
'-isysroot' => 1,
|
||||
'-arch' => 1,
|
||||
'-m32' => 0,
|
||||
'-m64' => 0,
|
||||
'-stdlib' => 0, # This is really a 1 argument, but always has '='
|
||||
'-target' => 1,
|
||||
'-v' => 0,
|
||||
'-fpascal-strings' => 0,
|
||||
'-mmacosx-version-min' => 0, # This is really a 1 argument, but always has '='
|
||||
'-miphoneos-version-min' => 0 # This is really a 1 argument, but always has '='
|
||||
);
|
||||
@@ -384,22 +381,23 @@ my %IgnoredOptionMap = (
|
||||
);
|
||||
|
||||
my %LangMap = (
|
||||
'c' => 'c',
|
||||
'c' => $IsCXX ? 'c++' : 'c',
|
||||
'cp' => 'c++',
|
||||
'cpp' => 'c++',
|
||||
'cxx' => 'c++',
|
||||
'txx' => 'c++',
|
||||
'cc' => 'c++',
|
||||
'C' => 'c++',
|
||||
'ii' => 'c++',
|
||||
'i' => 'c-cpp-output',
|
||||
'ii' => 'c++-cpp-output',
|
||||
'i' => $IsCXX ? 'c++-cpp-output' : 'c-cpp-output',
|
||||
'm' => 'objective-c',
|
||||
'mi' => 'objective-c-cpp-output',
|
||||
'mm' => 'objective-c++'
|
||||
'mm' => 'objective-c++',
|
||||
'mii' => 'objective-c++-cpp-output',
|
||||
);
|
||||
|
||||
my %UniqueOptions = (
|
||||
'-isysroot' => 0
|
||||
'-isysroot' => 0
|
||||
);
|
||||
|
||||
##----------------------------------------------------------------------------##
|
||||
@@ -427,8 +425,8 @@ my %Uniqued;
|
||||
|
||||
# Forward arguments to gcc.
|
||||
my $Status = system($Compiler,@ARGV);
|
||||
if (defined $ENV{'CCC_ANALYZER_LOG'}) {
|
||||
print "$Compiler @ARGV\n";
|
||||
if (defined $ENV{'CCC_ANALYZER_LOG'}) {
|
||||
print STDERR "$Compiler @ARGV\n";
|
||||
}
|
||||
if ($Status) { exit($Status >> 8); }
|
||||
|
||||
@@ -451,10 +449,13 @@ my $InternalStats = $ENV{'CCC_ANALYZER_INTERNAL_STATS'};
|
||||
my $OutputFormat = $ENV{'CCC_ANALYZER_OUTPUT_FORMAT'};
|
||||
if (!defined $OutputFormat) { $OutputFormat = "html"; }
|
||||
|
||||
# Get the config options.
|
||||
my $ConfigOptions = $ENV{'CCC_ANALYZER_CONFIG'};
|
||||
|
||||
# Determine the level of verbosity.
|
||||
my $Verbose = 0;
|
||||
if (defined $ENV{CCC_ANALYZER_VERBOSE}) { $Verbose = 1; }
|
||||
if (defined $ENV{CCC_ANALYZER_LOG}) { $Verbose = 2; }
|
||||
if (defined $ENV{'CCC_ANALYZER_VERBOSE'}) { $Verbose = 1; }
|
||||
if (defined $ENV{'CCC_ANALYZER_LOG'}) { $Verbose = 2; }
|
||||
|
||||
# Get the HTML output directory.
|
||||
my $HtmlDir = $ENV{'CCC_ANALYZER_HTML'};
|
||||
@@ -465,7 +466,7 @@ my $HadArch = 0;
|
||||
|
||||
# Process the arguments.
|
||||
foreach (my $i = 0; $i < scalar(@ARGV); ++$i) {
|
||||
my $Arg = $ARGV[$i];
|
||||
my $Arg = $ARGV[$i];
|
||||
my ($ArgKey) = split /=/,$Arg,2;
|
||||
|
||||
# Modes ccc-analyzer supports
|
||||
@@ -491,10 +492,6 @@ foreach (my $i = 0; $i < scalar(@ARGV); ++$i) {
|
||||
while ($Cnt > 0) { ++$i; --$Cnt; push @CompileOpts, $ARGV[$i]; }
|
||||
next;
|
||||
}
|
||||
if ($Arg =~ /-m.*/) {
|
||||
push @CompileOpts,$Arg;
|
||||
next;
|
||||
}
|
||||
# Handle the case where there isn't a space after -iquote
|
||||
if ($Arg =~ /-iquote.*/) {
|
||||
push @CompileOpts,$Arg;
|
||||
@@ -513,7 +510,7 @@ foreach (my $i = 0; $i < scalar(@ARGV); ++$i) {
|
||||
# and the linker.
|
||||
if (defined $CompilerLinkerOptionMap{$ArgKey}) {
|
||||
my $Cnt = $CompilerLinkerOptionMap{$ArgKey};
|
||||
|
||||
|
||||
# Check if this is an option that should have a unique value, and if so
|
||||
# determine if the value was checked before.
|
||||
if ($UniqueOptions{$Arg}) {
|
||||
@@ -523,8 +520,8 @@ foreach (my $i = 0; $i < scalar(@ARGV); ++$i) {
|
||||
}
|
||||
$Uniqued{$Arg} = 1;
|
||||
}
|
||||
|
||||
push @CompileOpts,$Arg;
|
||||
|
||||
push @CompileOpts,$Arg;
|
||||
push @LinkOpts,$Arg;
|
||||
|
||||
while ($Cnt > 0) {
|
||||
@@ -534,7 +531,7 @@ foreach (my $i = 0; $i < scalar(@ARGV); ++$i) {
|
||||
}
|
||||
next;
|
||||
}
|
||||
|
||||
|
||||
# Ignored options.
|
||||
if (defined $IgnoredOptionMap{$ArgKey}) {
|
||||
my $Cnt = $IgnoredOptionMap{$ArgKey};
|
||||
@@ -543,10 +540,10 @@ foreach (my $i = 0; $i < scalar(@ARGV); ++$i) {
|
||||
}
|
||||
next;
|
||||
}
|
||||
|
||||
|
||||
# Compile mode flags.
|
||||
if ($Arg =~ /^-[D,I,U](.*)$/) {
|
||||
my $Tmp = $Arg;
|
||||
my $Tmp = $Arg;
|
||||
if ($1 eq '') {
|
||||
# FIXME: Check if we are going off the end.
|
||||
++$i;
|
||||
@@ -555,7 +552,12 @@ foreach (my $i = 0; $i < scalar(@ARGV); ++$i) {
|
||||
push @CompileOpts,$Tmp;
|
||||
next;
|
||||
}
|
||||
|
||||
|
||||
if ($Arg =~ /-m.*/) {
|
||||
push @CompileOpts,$Arg;
|
||||
next;
|
||||
}
|
||||
|
||||
# Language.
|
||||
if ($Arg eq '-x') {
|
||||
$Lang = $ARGV[$i+1];
|
||||
@@ -568,26 +570,23 @@ foreach (my $i = 0; $i < scalar(@ARGV); ++$i) {
|
||||
$Output = $ARGV[$i];
|
||||
next;
|
||||
}
|
||||
|
||||
|
||||
# Get the link mode.
|
||||
if ($Arg =~ /^-[l,L,O]/) {
|
||||
if ($Arg eq '-O') { push @LinkOpts,'-O1'; }
|
||||
elsif ($Arg eq '-Os') { push @LinkOpts,'-O2'; }
|
||||
else { push @LinkOpts,$Arg; }
|
||||
|
||||
# Must pass this along for the __OPTIMIZE__ macro
|
||||
if ($Arg =~ /^-O/) { push @CompileOpts,$Arg; }
|
||||
next;
|
||||
}
|
||||
|
||||
|
||||
if ($Arg =~ /^-std=/) {
|
||||
push @CompileOpts,$Arg;
|
||||
next;
|
||||
}
|
||||
|
||||
# if ($Arg =~ /^-f/) {
|
||||
# # FIXME: Not sure if the remaining -fxxxx options have no arguments.
|
||||
# push @CompileOpts,$Arg;
|
||||
# push @LinkOpts,$Arg; # FIXME: Not sure if these are link opts.
|
||||
# }
|
||||
|
||||
|
||||
# Get the compiler/link mode.
|
||||
if ($Arg =~ /^-F(.+)$/) {
|
||||
my $Tmp = $Arg;
|
||||
@@ -610,7 +609,13 @@ foreach (my $i = 0; $i < scalar(@ARGV); ++$i) {
|
||||
++$i;
|
||||
next;
|
||||
}
|
||||
|
||||
|
||||
if ($Arg =~ /^-f/) {
|
||||
push @CompileOpts,$Arg;
|
||||
push @LinkOpts,$Arg;
|
||||
next;
|
||||
}
|
||||
|
||||
# Handle -Wno-. We don't care about extra warnings, but
|
||||
# we should suppress ones that we don't want to see.
|
||||
if ($Arg =~ /^-Wno-/) {
|
||||
@@ -639,7 +644,7 @@ if ($Action eq 'compile' or $Action eq 'link') {
|
||||
$FileLang = $LangMap{$1};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# FileLang still not defined? Skip the file.
|
||||
next if (!defined $FileLang);
|
||||
|
||||
@@ -647,8 +652,8 @@ if ($Action eq 'compile' or $Action eq 'link') {
|
||||
next if (!defined $LangsAccepted{$FileLang});
|
||||
|
||||
my @CmdArgs;
|
||||
my @AnalyzeArgs;
|
||||
|
||||
my @AnalyzeArgs;
|
||||
|
||||
if ($FileLang ne 'unknown') {
|
||||
push @CmdArgs, '-x', $FileLang;
|
||||
}
|
||||
@@ -664,7 +669,7 @@ if ($Action eq 'compile' or $Action eq 'link') {
|
||||
if (defined $InternalStats) {
|
||||
push @AnalyzeArgs, "-analyzer-stats";
|
||||
}
|
||||
|
||||
|
||||
if (defined $Analyses) {
|
||||
push @AnalyzeArgs, split '\s+', $Analyses;
|
||||
}
|
||||
@@ -680,12 +685,15 @@ if ($Action eq 'compile' or $Action eq 'link') {
|
||||
my ($h, $f) = tempfile("report-XXXXXX", SUFFIX => ".plist",
|
||||
DIR => $HtmlDir);
|
||||
$ResultFile = $f;
|
||||
# If the HtmlDir is not set, we sould clean up the plist files.
|
||||
# If the HtmlDir is not set, we should clean up the plist files.
|
||||
if (!defined $HtmlDir || -z $HtmlDir) {
|
||||
$CleanupFile = $f;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (defined $ConfigOptions) {
|
||||
push @AnalyzeArgs, split '\s+', $ConfigOptions;
|
||||
}
|
||||
|
||||
push @CmdArgs, @CompileOpts;
|
||||
push @CmdArgs, $file;
|
||||
@@ -707,4 +715,3 @@ if ($Action eq 'compile' or $Action eq 'link') {
|
||||
}
|
||||
|
||||
exit($Status >> 8);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -10,7 +10,7 @@ th, table thead {
|
||||
text-align:center;
|
||||
font-weight: bold; font-family: Verdana;
|
||||
white-space:nowrap;
|
||||
}
|
||||
}
|
||||
.W { font-size:0px }
|
||||
th, td { padding:5px; padding-left:8px; text-align:left }
|
||||
td.SUMM_DESC { padding-left:12px }
|
||||
@@ -21,7 +21,7 @@ tbody.scrollContent { overflow:auto }
|
||||
|
||||
table.form_group {
|
||||
background-color: #ccc;
|
||||
border: 1px solid #333;
|
||||
border: 1px solid #333;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ table.form_inner_group {
|
||||
|
||||
table.form {
|
||||
background-color: #999;
|
||||
border: 1px solid #333;
|
||||
border: 1px solid #333;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import sys
|
||||
if sys.version_info < (2, 7):
|
||||
print "set-xcode-analyzer requires Python 2.7 or later"
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import re
|
||||
@@ -65,7 +65,7 @@ def main():
|
||||
parser.set_description(__doc__)
|
||||
parser.add_option("--use-checker-build", dest="path",
|
||||
help="Use the Clang located at the provided absolute path, e.g. /Users/foo/checker-1")
|
||||
parser.add_option("--use-xcode-clang", action="store_const",
|
||||
parser.add_option("--use-xcode-clang", action="store_const",
|
||||
const="$(CLANG)", dest="default",
|
||||
help="Use the Clang bundled with Xcode")
|
||||
(options, args) = parser.parse_args()
|
||||
@@ -91,7 +91,7 @@ def main():
|
||||
print "(+) Using the Clang bundled with Xcode"
|
||||
path = options.default
|
||||
isBuiltinAnalyzer = True
|
||||
|
||||
|
||||
try:
|
||||
xcode_path = subprocess.check_output(["xcode-select", "-print-path"])
|
||||
except AttributeError:
|
||||
@@ -101,15 +101,14 @@ def main():
|
||||
# Cut off the 'Developer' dir, as the xcspec lies in another part
|
||||
# of the Xcode.app subtree.
|
||||
xcode_path = os.path.dirname(xcode_path)
|
||||
|
||||
|
||||
foundSpec = False
|
||||
for x in FindClangSpecs(xcode_path):
|
||||
foundSpec = True
|
||||
ModifySpec(x, isBuiltinAnalyzer, path)
|
||||
|
||||
|
||||
if foundSpec == False:
|
||||
print "(-) No compiler configuration file was found. Xcode's analyzer has not been updated."
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
|
||||
@@ -3,19 +3,19 @@
|
||||
version 2
|
||||
7th April 2007
|
||||
Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/
|
||||
|
||||
|
||||
Instructions:
|
||||
Download this file
|
||||
Add <script src="sorttable.js"></script> to your HTML
|
||||
Add class="sortable" to any table you'd like to make sortable
|
||||
Click on the headers to sort
|
||||
|
||||
|
||||
Thanks to many, many people for contributions and suggestions.
|
||||
Licenced as X11: http://www.kryogenix.org/code/browser/licence.html
|
||||
This basically means: do what you want with it.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
var stIsIE = /*@cc_on!@*/false;
|
||||
|
||||
sorttable = {
|
||||
@@ -26,19 +26,19 @@ sorttable = {
|
||||
arguments.callee.done = true;
|
||||
// kill the timer
|
||||
if (_timer) clearInterval(_timer);
|
||||
|
||||
|
||||
if (!document.createElement || !document.getElementsByTagName) return;
|
||||
|
||||
|
||||
sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/;
|
||||
|
||||
|
||||
forEach(document.getElementsByTagName('table'), function(table) {
|
||||
if (table.className.search(/\bsortable\b/) != -1) {
|
||||
sorttable.makeSortable(table);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
|
||||
|
||||
makeSortable: function(table) {
|
||||
if (table.getElementsByTagName('thead').length == 0) {
|
||||
// table doesn't have a tHead. Since it should have, create one and
|
||||
@@ -49,9 +49,9 @@ sorttable = {
|
||||
}
|
||||
// Safari doesn't support table.tHead, sigh
|
||||
if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0];
|
||||
|
||||
|
||||
if (table.tHead.rows.length != 1) return; // can't cope with two header rows
|
||||
|
||||
|
||||
// Sorttable v1 put rows with a class of "sortbottom" at the bottom (as
|
||||
// "total" rows, for example). This is B&R, since what you're supposed
|
||||
// to do is put them in a tfoot. So, if there are sortbottom rows,
|
||||
@@ -73,7 +73,7 @@ sorttable = {
|
||||
}
|
||||
delete sortbottomrows;
|
||||
}
|
||||
|
||||
|
||||
// work through each column and calculate its type
|
||||
headrow = table.tHead.rows[0].cells;
|
||||
for (var i=0; i<headrow.length; i++) {
|
||||
@@ -92,7 +92,7 @@ sorttable = {
|
||||
dean_addEvent(headrow[i],"click", function(e) {
|
||||
|
||||
if (this.className.search(/\bsorttable_sorted\b/) != -1) {
|
||||
// if we're already sorted by this column, just
|
||||
// if we're already sorted by this column, just
|
||||
// reverse the table, which is quicker
|
||||
sorttable.reverse(this.sorttable_tbody);
|
||||
this.className = this.className.replace('sorttable_sorted',
|
||||
@@ -105,7 +105,7 @@ sorttable = {
|
||||
return;
|
||||
}
|
||||
if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) {
|
||||
// if we're already sorted by this column in reverse, just
|
||||
// if we're already sorted by this column in reverse, just
|
||||
// re-reverse the table, which is quicker
|
||||
sorttable.reverse(this.sorttable_tbody);
|
||||
this.className = this.className.replace('sorttable_sorted_reverse',
|
||||
@@ -117,7 +117,7 @@ sorttable = {
|
||||
this.appendChild(sortfwdind);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// remove sorttable_sorted classes
|
||||
theadrow = this.parentNode;
|
||||
forEach(theadrow.childNodes, function(cell) {
|
||||
@@ -130,7 +130,7 @@ sorttable = {
|
||||
if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); }
|
||||
sortrevind = document.getElementById('sorttable_sortrevind');
|
||||
if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); }
|
||||
|
||||
|
||||
this.className += ' sorttable_sorted';
|
||||
sortfwdind = document.createElement('span');
|
||||
sortfwdind.id = "sorttable_sortfwdind";
|
||||
@@ -151,18 +151,18 @@ sorttable = {
|
||||
sorttable.shaker_sort(row_array, this.sorttable_sortfunction);
|
||||
/* and comment out this one */
|
||||
//row_array.sort(this.sorttable_sortfunction);
|
||||
|
||||
|
||||
tb = this.sorttable_tbody;
|
||||
for (var j=0; j<row_array.length; j++) {
|
||||
tb.appendChild(row_array[j][1]);
|
||||
}
|
||||
|
||||
|
||||
delete row_array;
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
guessType: function(table, column) {
|
||||
// guess the type of a column based on its first non-blank row
|
||||
sortfn = sorttable.sort_alpha;
|
||||
@@ -172,7 +172,7 @@ sorttable = {
|
||||
if (text.match(/^-?[<5B>$<24>]?[\d,.]+%?$/)) {
|
||||
return sorttable.sort_numeric;
|
||||
}
|
||||
// check for a date: dd/mm/yyyy or dd/mm/yy
|
||||
// check for a date: dd/mm/yyyy or dd/mm/yy
|
||||
// can have / or . or - as separator
|
||||
// can be mm/dd as well
|
||||
possdate = text.match(sorttable.DATE_RE)
|
||||
@@ -195,17 +195,17 @@ sorttable = {
|
||||
}
|
||||
return sortfn;
|
||||
},
|
||||
|
||||
|
||||
getInnerText: function(node) {
|
||||
// gets the text we want to use for sorting for a cell.
|
||||
// strips leading and trailing whitespace.
|
||||
// this is *not* a generic getInnerText function; it's special to sorttable.
|
||||
// for example, you can override the cell text with a customkey attribute.
|
||||
// it also gets .value for <input> fields.
|
||||
|
||||
|
||||
hasInputs = (typeof node.getElementsByTagName == 'function') &&
|
||||
node.getElementsByTagName('input').length;
|
||||
|
||||
|
||||
if (node.getAttribute("sorttable_customkey") != null) {
|
||||
return node.getAttribute("sorttable_customkey");
|
||||
}
|
||||
@@ -240,7 +240,7 @@ sorttable = {
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
reverse: function(tbody) {
|
||||
// reverse the rows in a tbody
|
||||
newrows = [];
|
||||
@@ -252,14 +252,14 @@ sorttable = {
|
||||
}
|
||||
delete newrows;
|
||||
},
|
||||
|
||||
|
||||
/* sort functions
|
||||
each sort function takes two parameters, a and b
|
||||
you are comparing a[0] and b[0] */
|
||||
sort_numeric: function(a,b) {
|
||||
aa = parseFloat(a[0].replace(/[^0-9.-]/g,''));
|
||||
if (isNaN(aa)) aa = 0;
|
||||
bb = parseFloat(b[0].replace(/[^0-9.-]/g,''));
|
||||
bb = parseFloat(b[0].replace(/[^0-9.-]/g,''));
|
||||
if (isNaN(bb)) bb = 0;
|
||||
return aa-bb;
|
||||
},
|
||||
@@ -298,7 +298,7 @@ sorttable = {
|
||||
if (dt1<dt2) return -1;
|
||||
return 1;
|
||||
},
|
||||
|
||||
|
||||
shaker_sort: function(list, comp_func) {
|
||||
// A stable sort function to allow multi-level sorting of data
|
||||
// see: http://en.wikipedia.org/wiki/Cocktail_sort
|
||||
@@ -328,7 +328,7 @@ sorttable = {
|
||||
b++;
|
||||
|
||||
} // while(swap)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ******************************************************************
|
||||
@@ -490,4 +490,3 @@ var forEach = function(object, block, context) {
|
||||
resolve.forEach(object, block, context);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user