From 1b3b68fb314d302d3dfed68613b4276a1ab1369c Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Wed, 4 Feb 2015 14:15:14 +0100 Subject: [PATCH] browser: safari version usage from wikimedia engines table Browser versions do not distinguish Safari numbers, but an additional table "Browser engines" does report (combined) counts (without percentages for some reason). Obviously a terrible hack, as Webkit numbers to not map exactly, and platform distribution differences are lost. --- tools/mkusage-wikimedia | 85 ++++++++++++++++++++++++++++------------- 1 file changed, 59 insertions(+), 26 deletions(-) diff --git a/tools/mkusage-wikimedia b/tools/mkusage-wikimedia index 41ed977..63cded2 100755 --- a/tools/mkusage-wikimedia +++ b/tools/mkusage-wikimedia @@ -17,6 +17,30 @@ if (m{} .. m{}) { />In alphabetical order/ .. eof or next; # second table my ($id, $count2, $count) = map { s/<[^>]*>//gr } split /<\/td>/; +if (/>Browser engines/ ... m{}) { + my $apple = $id =~ s/^AppleWebKit ?//; + $apple .. 1 or next; + my ($abs) = m/>showCount\((\d+),/; + + state %version; + if (defined $count2) { + $version{$id} = $abs; + next; + } + + # replace safari total percentage by individual version counts + # have to use combined distribution for multiple platforms :( + for my $browser (qw/ safari ios_saf /) { + my $multiplier = delete $count{$browser}{'0.0'} or next; + $multiplier /= $abs; # total number + while (my ($verwebkit, $count) = each %version) { + my $ver = safariver($verwebkit, $browser eq 'ios_saf'); + $count{$browser}{$ver} += $count * $multiplier; + } + } + last; +} + # select version data />Browser versions(.*)/ ... !defined $count2 or next; unless (defined $count2) { @@ -53,32 +77,6 @@ given ($browser) { } when ('Safari') { $browser = $mobile ? 'ios_saf' : 'safari'; - my $numversion = join('.', map { sprintf '%03d', $_ } split /\./, $version); - $numversion =~ s/6(?=\d{3})//; # incomparable 6532.22 → 523 - for ( - # http://en.wikipedia.org/wiki/Safari_version_history - $mobile ? ( - [ '413' => '1' ], - [ '419' => '1.1' ], - [ '525' => '2' ], - [ '528' => '3' ], - [ '531' => '3.2' ], - [ '531.022' => '4' ], - [ '533' => '4.2' ], - [ '534' => '4x' ], - ) : ( - [ '413' => '2' ], - [ '522' => '3' ], - [ '525.013' => '3.1' ], - [ '525.026' => '3.2' ], - [ '526' => '4' ], - [ '533' => '5' ], - [ '534' => '5x' ], - ) - ) { - last if $numversion lt $_->[0]; - $version = $_->[1]; - } } when ('Chrome') { $browser = $mobile ? 'and_chr' : 'chrome'; @@ -103,6 +101,41 @@ END { print pp(\%count); } +sub safariver { + my ($webkitnum, $ios) = @_; + my $safarinum = ''; + for ( + $ios ? ( + [ 413 => '1' ], + [ 419 => '1.1' ], + [ 525 => '2' ], + [ 528 => '3' ], + [ 531 => '3.2' ], # or 4 from 531.022 + [ 532 => '4' ], + [ 533 => '4.2' ], + [ 534 => '5' ], + [ 536 => '7' ], + [ 537 => '8' ], + [ 600 => '8.1' ], + ) : ( + # http://en.wikipedia.org/wiki/Safari_version_history + [ 412 => '2' ], + [ 522 => '3' ], + [ 525 => '3.1' ], # 3.2 from 525.026 + [ 526 => '4' ], + [ 533 => '5' ], # or 4.1 + [ 534 => '5.1' ], + [ 536 => '6' ], + [ 537 => '7.1' ], # or 6.1 or 7.0 + [ 538 => '8' ], + ) + ) { + last if $webkitnum lt $_->[0]; + $safarinum = $_->[1]; + } + return $safarinum; +} + __END__ =head1 USAGE -- 2.30.0