Remove trailing spaces (no other change). Bikeshed #2

llvm-svn: 201584
This commit is contained in:
Sylvestre Ledru 2014-02-18 17:21:45 +00:00
parent 97d2c9cae7
commit 82e547e1a9
4 changed files with 70 additions and 73 deletions

View File

@ -31,7 +31,7 @@ my $DefaultCCompiler;
my $DefaultCXXCompiler; my $DefaultCXXCompiler;
my $IsCXX; my $IsCXX;
if (`uname -a` =~ m/Darwin/) { if (`uname -a` =~ m/Darwin/) {
$DefaultCCompiler = 'clang'; $DefaultCCompiler = 'clang';
$DefaultCXXCompiler = 'clang++'; $DefaultCXXCompiler = 'clang++';
} else { } else {
@ -42,7 +42,7 @@ if (`uname -a` =~ m/Darwin/) {
if ($FindBin::Script =~ /c\+\+-analyzer/) { if ($FindBin::Script =~ /c\+\+-analyzer/) {
$Compiler = $ENV{'CCC_CXX'}; $Compiler = $ENV{'CCC_CXX'};
if (!defined $Compiler) { $Compiler = $DefaultCXXCompiler; } if (!defined $Compiler) { $Compiler = $DefaultCXXCompiler; }
$Clang = $ENV{'CLANG_CXX'}; $Clang = $ENV{'CLANG_CXX'};
if (!defined $Clang) { $Clang = 'clang++'; } if (!defined $Clang) { $Clang = 'clang++'; }
@ -69,7 +69,7 @@ my $CleanupFile;
my $ResultFile; my $ResultFile;
# Remove any stale files at exit. # Remove any stale files at exit.
END { END {
if (defined $ResultFile && -z $ResultFile) { if (defined $ResultFile && -z $ResultFile) {
`rm -f $ResultFile`; `rm -f $ResultFile`;
} }
@ -100,7 +100,7 @@ sub ProcessClangFailure {
my ($Clang, $Lang, $file, $Args, $HtmlDir, $ErrorType, $ofile) = @_; my ($Clang, $Lang, $file, $Args, $HtmlDir, $ErrorType, $ofile) = @_;
my $Dir = "$HtmlDir/failures"; my $Dir = "$HtmlDir/failures";
mkpath $Dir; mkpath $Dir;
my $prefix = "clang_crash"; my $prefix = "clang_crash";
if ($ErrorType eq $ParserRejects) { if ($ErrorType eq $ParserRejects) {
$prefix = "clang_parser_rejects"; $prefix = "clang_parser_rejects";
@ -118,7 +118,7 @@ sub ProcessClangFailure {
DIR => $Dir); DIR => $Dir);
system $Clang, @$Args, "-E", "-o", $PPFile; system $Clang, @$Args, "-E", "-o", $PPFile;
close ($PPH); close ($PPH);
# Create the info file. # Create the info file.
open (OUT, ">", "$PPFile.info.txt") or die "Cannot open $PPFile.info.txt\n"; open (OUT, ">", "$PPFile.info.txt") or die "Cannot open $PPFile.info.txt\n";
print OUT abs_path($file), "\n"; print OUT abs_path($file), "\n";
@ -138,7 +138,7 @@ sub ProcessClangFailure {
sub GetCCArgs { sub GetCCArgs {
my $mode = shift; my $mode = shift;
my $Args = shift; my $Args = shift;
pipe (FROM_CHILD, TO_PARENT); pipe (FROM_CHILD, TO_PARENT);
my $pid = fork(); my $pid = fork();
if ($pid == 0) { if ($pid == 0) {
@ -146,7 +146,7 @@ sub GetCCArgs {
open(STDOUT,">&", \*TO_PARENT); open(STDOUT,">&", \*TO_PARENT);
open(STDERR,">&", \*TO_PARENT); open(STDERR,">&", \*TO_PARENT);
exec $Clang, "-###", $mode, @$Args; exec $Clang, "-###", $mode, @$Args;
} }
close(TO_PARENT); close(TO_PARENT);
my $line; my $line;
while (<FROM_CHILD>) { while (<FROM_CHILD>) {
@ -156,7 +156,7 @@ sub GetCCArgs {
waitpid($pid,0); waitpid($pid,0);
close(FROM_CHILD); close(FROM_CHILD);
die "could not find clang line\n" if (!defined $line); die "could not find clang line\n" if (!defined $line);
# Strip leading and trailing whitespace characters. # Strip leading and trailing whitespace characters.
$line =~ s/^\s+|\s+$//g; $line =~ s/^\s+|\s+$//g;
@ -207,7 +207,7 @@ sub Analyze {
} }
# Display Ubiviz graph? # Display Ubiviz graph?
if (defined $ENV{'CCC_UBI'}) { if (defined $ENV{'CCC_UBI'}) {
push @Args, "-Xclang", "-analyzer-viz-egraph-ubigraph"; push @Args, "-Xclang", "-analyzer-viz-egraph-ubigraph";
} }
@ -228,7 +228,7 @@ sub Analyze {
} }
if ($Verbose == 1) { if ($Verbose == 1) {
# We MUST print to stderr. Some clients use the stdout output of # 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 join(' ', @PrintArgs);
print STDERR "\n"; print STDERR "\n";
} }
@ -239,7 +239,7 @@ sub Analyze {
# Capture the STDERR of clang and send it to a temporary file. # 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. # 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 # 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); pipe (FROM_CHILD, TO_PARENT);
my $pid = fork(); my $pid = fork();
if ($pid == 0) { if ($pid == 0) {
@ -251,7 +251,7 @@ sub Analyze {
close TO_PARENT; close TO_PARENT;
my ($ofh, $ofile) = tempfile("clang_output_XXXXXX", DIR => $HtmlDir); my ($ofh, $ofile) = tempfile("clang_output_XXXXXX", DIR => $HtmlDir);
while (<FROM_CHILD>) { while (<FROM_CHILD>) {
print $ofh $_; print $ofh $_;
print STDERR $_; print STDERR $_;
@ -293,15 +293,15 @@ sub Analyze {
# Have we already spotted this unhandled attribute? # Have we already spotted this unhandled attribute?
next if (defined $attributes_not_handled{$1}); next if (defined $attributes_not_handled{$1});
$attributes_not_handled{$1} = 1; $attributes_not_handled{$1} = 1;
# Get the name of the attribute file. # Get the name of the attribute file.
my $dir = "$HtmlDir/failures"; my $dir = "$HtmlDir/failures";
my $afile = "$dir/attribute_ignored_$1.txt"; my $afile = "$dir/attribute_ignored_$1.txt";
# Only create another preprocessed file if the attribute file # Only create another preprocessed file if the attribute file
# doesn't exist yet. # doesn't exist yet.
next if (-e $afile); next if (-e $afile);
# Add this file to the list of files that contained this attribute. # Add this file to the list of files that contained this attribute.
# Generate a preprocessed file if we haven't already. # Generate a preprocessed file if we haven't already.
if (!(defined $ppfile)) { if (!(defined $ppfile)) {
@ -319,7 +319,7 @@ sub Analyze {
} }
} }
} }
unlink($ofile); unlink($ofile);
} }
@ -397,7 +397,7 @@ my %LangMap = (
); );
my %UniqueOptions = ( my %UniqueOptions = (
'-isysroot' => 0 '-isysroot' => 0
); );
##----------------------------------------------------------------------------## ##----------------------------------------------------------------------------##
@ -466,7 +466,7 @@ my $HadArch = 0;
# Process the arguments. # Process the arguments.
foreach (my $i = 0; $i < scalar(@ARGV); ++$i) { foreach (my $i = 0; $i < scalar(@ARGV); ++$i) {
my $Arg = $ARGV[$i]; my $Arg = $ARGV[$i];
my ($ArgKey) = split /=/,$Arg,2; my ($ArgKey) = split /=/,$Arg,2;
# Modes ccc-analyzer supports # Modes ccc-analyzer supports
@ -510,7 +510,7 @@ foreach (my $i = 0; $i < scalar(@ARGV); ++$i) {
# and the linker. # and the linker.
if (defined $CompilerLinkerOptionMap{$ArgKey}) { if (defined $CompilerLinkerOptionMap{$ArgKey}) {
my $Cnt = $CompilerLinkerOptionMap{$ArgKey}; my $Cnt = $CompilerLinkerOptionMap{$ArgKey};
# Check if this is an option that should have a unique value, and if so # Check if this is an option that should have a unique value, and if so
# determine if the value was checked before. # determine if the value was checked before.
if ($UniqueOptions{$Arg}) { if ($UniqueOptions{$Arg}) {
@ -520,8 +520,8 @@ foreach (my $i = 0; $i < scalar(@ARGV); ++$i) {
} }
$Uniqued{$Arg} = 1; $Uniqued{$Arg} = 1;
} }
push @CompileOpts,$Arg; push @CompileOpts,$Arg;
push @LinkOpts,$Arg; push @LinkOpts,$Arg;
while ($Cnt > 0) { while ($Cnt > 0) {
@ -531,7 +531,7 @@ foreach (my $i = 0; $i < scalar(@ARGV); ++$i) {
} }
next; next;
} }
# Ignored options. # Ignored options.
if (defined $IgnoredOptionMap{$ArgKey}) { if (defined $IgnoredOptionMap{$ArgKey}) {
my $Cnt = $IgnoredOptionMap{$ArgKey}; my $Cnt = $IgnoredOptionMap{$ArgKey};
@ -540,10 +540,10 @@ foreach (my $i = 0; $i < scalar(@ARGV); ++$i) {
} }
next; next;
} }
# Compile mode flags. # Compile mode flags.
if ($Arg =~ /^-[D,I,U](.*)$/) { if ($Arg =~ /^-[D,I,U](.*)$/) {
my $Tmp = $Arg; my $Tmp = $Arg;
if ($1 eq '') { if ($1 eq '') {
# FIXME: Check if we are going off the end. # FIXME: Check if we are going off the end.
++$i; ++$i;
@ -552,12 +552,12 @@ foreach (my $i = 0; $i < scalar(@ARGV); ++$i) {
push @CompileOpts,$Tmp; push @CompileOpts,$Tmp;
next; next;
} }
if ($Arg =~ /-m.*/) { if ($Arg =~ /-m.*/) {
push @CompileOpts,$Arg; push @CompileOpts,$Arg;
next; next;
} }
# Language. # Language.
if ($Arg eq '-x') { if ($Arg eq '-x') {
$Lang = $ARGV[$i+1]; $Lang = $ARGV[$i+1];
@ -570,7 +570,7 @@ foreach (my $i = 0; $i < scalar(@ARGV); ++$i) {
$Output = $ARGV[$i]; $Output = $ARGV[$i];
next; next;
} }
# Get the link mode. # Get the link mode.
if ($Arg =~ /^-[l,L,O]/) { if ($Arg =~ /^-[l,L,O]/) {
if ($Arg eq '-O') { push @LinkOpts,'-O1'; } if ($Arg eq '-O') { push @LinkOpts,'-O1'; }
@ -581,12 +581,12 @@ foreach (my $i = 0; $i < scalar(@ARGV); ++$i) {
if ($Arg =~ /^-O/) { push @CompileOpts,$Arg; } if ($Arg =~ /^-O/) { push @CompileOpts,$Arg; }
next; next;
} }
if ($Arg =~ /^-std=/) { if ($Arg =~ /^-std=/) {
push @CompileOpts,$Arg; push @CompileOpts,$Arg;
next; next;
} }
# Get the compiler/link mode. # Get the compiler/link mode.
if ($Arg =~ /^-F(.+)$/) { if ($Arg =~ /^-F(.+)$/) {
my $Tmp = $Arg; my $Tmp = $Arg;
@ -609,13 +609,13 @@ foreach (my $i = 0; $i < scalar(@ARGV); ++$i) {
++$i; ++$i;
next; next;
} }
if ($Arg =~ /^-f/) { if ($Arg =~ /^-f/) {
push @CompileOpts,$Arg; push @CompileOpts,$Arg;
push @LinkOpts,$Arg; push @LinkOpts,$Arg;
next; next;
} }
# Handle -Wno-. We don't care about extra warnings, but # Handle -Wno-. We don't care about extra warnings, but
# we should suppress ones that we don't want to see. # we should suppress ones that we don't want to see.
if ($Arg =~ /^-Wno-/) { if ($Arg =~ /^-Wno-/) {
@ -644,7 +644,7 @@ if ($Action eq 'compile' or $Action eq 'link') {
$FileLang = $LangMap{$1}; $FileLang = $LangMap{$1};
} }
} }
# FileLang still not defined? Skip the file. # FileLang still not defined? Skip the file.
next if (!defined $FileLang); next if (!defined $FileLang);
@ -652,8 +652,8 @@ if ($Action eq 'compile' or $Action eq 'link') {
next if (!defined $LangsAccepted{$FileLang}); next if (!defined $LangsAccepted{$FileLang});
my @CmdArgs; my @CmdArgs;
my @AnalyzeArgs; my @AnalyzeArgs;
if ($FileLang ne 'unknown') { if ($FileLang ne 'unknown') {
push @CmdArgs, '-x', $FileLang; push @CmdArgs, '-x', $FileLang;
} }
@ -669,7 +669,7 @@ if ($Action eq 'compile' or $Action eq 'link') {
if (defined $InternalStats) { if (defined $InternalStats) {
push @AnalyzeArgs, "-analyzer-stats"; push @AnalyzeArgs, "-analyzer-stats";
} }
if (defined $Analyses) { if (defined $Analyses) {
push @AnalyzeArgs, split '\s+', $Analyses; push @AnalyzeArgs, split '\s+', $Analyses;
} }
@ -715,4 +715,3 @@ if ($Action eq 'compile' or $Action eq 'link') {
} }
exit($Status >> 8); exit($Status >> 8);

View File

@ -10,7 +10,7 @@ th, table thead {
text-align:center; text-align:center;
font-weight: bold; font-family: Verdana; font-weight: bold; font-family: Verdana;
white-space:nowrap; white-space:nowrap;
} }
.W { font-size:0px } .W { font-size:0px }
th, td { padding:5px; padding-left:8px; text-align:left } th, td { padding:5px; padding-left:8px; text-align:left }
td.SUMM_DESC { padding-left:12px } td.SUMM_DESC { padding-left:12px }
@ -21,7 +21,7 @@ tbody.scrollContent { overflow:auto }
table.form_group { table.form_group {
background-color: #ccc; background-color: #ccc;
border: 1px solid #333; border: 1px solid #333;
padding: 2px; padding: 2px;
} }
@ -33,7 +33,7 @@ table.form_inner_group {
table.form { table.form {
background-color: #999; background-color: #999;
border: 1px solid #333; border: 1px solid #333;
padding: 2px; padding: 2px;
} }

View File

@ -8,7 +8,7 @@ import sys
if sys.version_info < (2, 7): if sys.version_info < (2, 7):
print "set-xcode-analyzer requires Python 2.7 or later" print "set-xcode-analyzer requires Python 2.7 or later"
sys.exit(1) sys.exit(1)
import os import os
import subprocess import subprocess
import re import re
@ -65,7 +65,7 @@ def main():
parser.set_description(__doc__) parser.set_description(__doc__)
parser.add_option("--use-checker-build", dest="path", parser.add_option("--use-checker-build", dest="path",
help="Use the Clang located at the provided absolute path, e.g. /Users/foo/checker-1") 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", const="$(CLANG)", dest="default",
help="Use the Clang bundled with Xcode") help="Use the Clang bundled with Xcode")
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
@ -91,7 +91,7 @@ def main():
print "(+) Using the Clang bundled with Xcode" print "(+) Using the Clang bundled with Xcode"
path = options.default path = options.default
isBuiltinAnalyzer = True isBuiltinAnalyzer = True
try: try:
xcode_path = subprocess.check_output(["xcode-select", "-print-path"]) xcode_path = subprocess.check_output(["xcode-select", "-print-path"])
except AttributeError: except AttributeError:
@ -101,15 +101,14 @@ def main():
# Cut off the 'Developer' dir, as the xcspec lies in another part # Cut off the 'Developer' dir, as the xcspec lies in another part
# of the Xcode.app subtree. # of the Xcode.app subtree.
xcode_path = os.path.dirname(xcode_path) xcode_path = os.path.dirname(xcode_path)
foundSpec = False foundSpec = False
for x in FindClangSpecs(xcode_path): for x in FindClangSpecs(xcode_path):
foundSpec = True foundSpec = True
ModifySpec(x, isBuiltinAnalyzer, path) ModifySpec(x, isBuiltinAnalyzer, path)
if foundSpec == False: if foundSpec == False:
print "(-) No compiler configuration file was found. Xcode's analyzer has not been updated." print "(-) No compiler configuration file was found. Xcode's analyzer has not been updated."
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View File

@ -3,19 +3,19 @@
version 2 version 2
7th April 2007 7th April 2007
Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/ Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/
Instructions: Instructions:
Download this file Download this file
Add <script src="sorttable.js"></script> to your HTML Add <script src="sorttable.js"></script> to your HTML
Add class="sortable" to any table you'd like to make sortable Add class="sortable" to any table you'd like to make sortable
Click on the headers to sort Click on the headers to sort
Thanks to many, many people for contributions and suggestions. Thanks to many, many people for contributions and suggestions.
Licenced as X11: http://www.kryogenix.org/code/browser/licence.html Licenced as X11: http://www.kryogenix.org/code/browser/licence.html
This basically means: do what you want with it. This basically means: do what you want with it.
*/ */
var stIsIE = /*@cc_on!@*/false; var stIsIE = /*@cc_on!@*/false;
sorttable = { sorttable = {
@ -26,19 +26,19 @@ sorttable = {
arguments.callee.done = true; arguments.callee.done = true;
// kill the timer // kill the timer
if (_timer) clearInterval(_timer); if (_timer) clearInterval(_timer);
if (!document.createElement || !document.getElementsByTagName) return; if (!document.createElement || !document.getElementsByTagName) return;
sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/; sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/;
forEach(document.getElementsByTagName('table'), function(table) { forEach(document.getElementsByTagName('table'), function(table) {
if (table.className.search(/\bsortable\b/) != -1) { if (table.className.search(/\bsortable\b/) != -1) {
sorttable.makeSortable(table); sorttable.makeSortable(table);
} }
}); });
}, },
makeSortable: function(table) { makeSortable: function(table) {
if (table.getElementsByTagName('thead').length == 0) { if (table.getElementsByTagName('thead').length == 0) {
// table doesn't have a tHead. Since it should have, create one and // 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 // Safari doesn't support table.tHead, sigh
if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0]; if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0];
if (table.tHead.rows.length != 1) return; // can't cope with two header rows 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 // 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 // "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, // to do is put them in a tfoot. So, if there are sortbottom rows,
@ -73,7 +73,7 @@ sorttable = {
} }
delete sortbottomrows; delete sortbottomrows;
} }
// work through each column and calculate its type // work through each column and calculate its type
headrow = table.tHead.rows[0].cells; headrow = table.tHead.rows[0].cells;
for (var i=0; i<headrow.length; i++) { for (var i=0; i<headrow.length; i++) {
@ -92,7 +92,7 @@ sorttable = {
dean_addEvent(headrow[i],"click", function(e) { dean_addEvent(headrow[i],"click", function(e) {
if (this.className.search(/\bsorttable_sorted\b/) != -1) { 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 // reverse the table, which is quicker
sorttable.reverse(this.sorttable_tbody); sorttable.reverse(this.sorttable_tbody);
this.className = this.className.replace('sorttable_sorted', this.className = this.className.replace('sorttable_sorted',
@ -105,7 +105,7 @@ sorttable = {
return; return;
} }
if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) { 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 // re-reverse the table, which is quicker
sorttable.reverse(this.sorttable_tbody); sorttable.reverse(this.sorttable_tbody);
this.className = this.className.replace('sorttable_sorted_reverse', this.className = this.className.replace('sorttable_sorted_reverse',
@ -117,7 +117,7 @@ sorttable = {
this.appendChild(sortfwdind); this.appendChild(sortfwdind);
return; return;
} }
// remove sorttable_sorted classes // remove sorttable_sorted classes
theadrow = this.parentNode; theadrow = this.parentNode;
forEach(theadrow.childNodes, function(cell) { forEach(theadrow.childNodes, function(cell) {
@ -130,7 +130,7 @@ sorttable = {
if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); } if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); }
sortrevind = document.getElementById('sorttable_sortrevind'); sortrevind = document.getElementById('sorttable_sortrevind');
if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); } if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); }
this.className += ' sorttable_sorted'; this.className += ' sorttable_sorted';
sortfwdind = document.createElement('span'); sortfwdind = document.createElement('span');
sortfwdind.id = "sorttable_sortfwdind"; sortfwdind.id = "sorttable_sortfwdind";
@ -151,18 +151,18 @@ sorttable = {
sorttable.shaker_sort(row_array, this.sorttable_sortfunction); sorttable.shaker_sort(row_array, this.sorttable_sortfunction);
/* and comment out this one */ /* and comment out this one */
//row_array.sort(this.sorttable_sortfunction); //row_array.sort(this.sorttable_sortfunction);
tb = this.sorttable_tbody; tb = this.sorttable_tbody;
for (var j=0; j<row_array.length; j++) { for (var j=0; j<row_array.length; j++) {
tb.appendChild(row_array[j][1]); tb.appendChild(row_array[j][1]);
} }
delete row_array; delete row_array;
}); });
} }
} }
}, },
guessType: function(table, column) { guessType: function(table, column) {
// guess the type of a column based on its first non-blank row // guess the type of a column based on its first non-blank row
sortfn = sorttable.sort_alpha; sortfn = sorttable.sort_alpha;
@ -172,7 +172,7 @@ sorttable = {
if (text.match(/^-?[£$¤]?[\d,.]+%?$/)) { if (text.match(/^-?[£$¤]?[\d,.]+%?$/)) {
return sorttable.sort_numeric; 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 have / or . or - as separator
// can be mm/dd as well // can be mm/dd as well
possdate = text.match(sorttable.DATE_RE) possdate = text.match(sorttable.DATE_RE)
@ -195,17 +195,17 @@ sorttable = {
} }
return sortfn; return sortfn;
}, },
getInnerText: function(node) { getInnerText: function(node) {
// gets the text we want to use for sorting for a cell. // gets the text we want to use for sorting for a cell.
// strips leading and trailing whitespace. // strips leading and trailing whitespace.
// this is *not* a generic getInnerText function; it's special to sorttable. // this is *not* a generic getInnerText function; it's special to sorttable.
// for example, you can override the cell text with a customkey attribute. // for example, you can override the cell text with a customkey attribute.
// it also gets .value for <input> fields. // it also gets .value for <input> fields.
hasInputs = (typeof node.getElementsByTagName == 'function') && hasInputs = (typeof node.getElementsByTagName == 'function') &&
node.getElementsByTagName('input').length; node.getElementsByTagName('input').length;
if (node.getAttribute("sorttable_customkey") != null) { if (node.getAttribute("sorttable_customkey") != null) {
return node.getAttribute("sorttable_customkey"); return node.getAttribute("sorttable_customkey");
} }
@ -240,7 +240,7 @@ sorttable = {
} }
} }
}, },
reverse: function(tbody) { reverse: function(tbody) {
// reverse the rows in a tbody // reverse the rows in a tbody
newrows = []; newrows = [];
@ -252,14 +252,14 @@ sorttable = {
} }
delete newrows; delete newrows;
}, },
/* sort functions /* sort functions
each sort function takes two parameters, a and b each sort function takes two parameters, a and b
you are comparing a[0] and b[0] */ you are comparing a[0] and b[0] */
sort_numeric: function(a,b) { sort_numeric: function(a,b) {
aa = parseFloat(a[0].replace(/[^0-9.-]/g,'')); aa = parseFloat(a[0].replace(/[^0-9.-]/g,''));
if (isNaN(aa)) aa = 0; 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; if (isNaN(bb)) bb = 0;
return aa-bb; return aa-bb;
}, },
@ -298,7 +298,7 @@ sorttable = {
if (dt1<dt2) return -1; if (dt1<dt2) return -1;
return 1; return 1;
}, },
shaker_sort: function(list, comp_func) { shaker_sort: function(list, comp_func) {
// A stable sort function to allow multi-level sorting of data // A stable sort function to allow multi-level sorting of data
// see: http://en.wikipedia.org/wiki/Cocktail_sort // see: http://en.wikipedia.org/wiki/Cocktail_sort
@ -328,7 +328,7 @@ sorttable = {
b++; b++;
} // while(swap) } // while(swap)
} }
} }
/* ****************************************************************** /* ******************************************************************
@ -490,4 +490,3 @@ var forEach = function(object, block, context) {
resolve.forEach(object, block, context); resolve.forEach(object, block, context);
} }
}; };