netsurf: branch master updated. release/3.0-23-g4c4dff3

NetSurf Browser Project (Commit Mailer) no-reply at netsurf-browser.org
Thu May 2 23:08:40 BST 2013


Gitweb links:

...log http://git.netsurf-browser.org/netsurf.git/shortlog/4c4dff3384ef87a537cb57dd893c9b7a1d3a441d
...commit http://git.netsurf-browser.org/netsurf.git/commit/4c4dff3384ef87a537cb57dd893c9b7a1d3a441d
...tree http://git.netsurf-browser.org/netsurf.git/tree/4c4dff3384ef87a537cb57dd893c9b7a1d3a441d

The branch, master has been updated
       via  4c4dff3384ef87a537cb57dd893c9b7a1d3a441d (commit)
      from  98369b74e21fb5cf769fcfdf0e717cf6592736c1 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=4c4dff3384ef87a537cb57dd893c9b7a1d3a441d
commit 4c4dff3384ef87a537cb57dd893c9b7a1d3a441d
Author: Vivek Dasmohapatra <vivek at collabora.co.uk>
Commit: Vincent Sanders <vince at netsurf-browser.org>

    Improvements to generated output

diff --git a/utils/split-messages.pl b/utils/split-messages.pl
index 08d8822..45e5539 100644
--- a/utils/split-messages.pl
+++ b/utils/split-messages.pl
@@ -49,7 +49,7 @@ my %opt = qw( plat any format messages );
 sub input_stream  ();
 sub output_stream ();
 sub formatter     ();
-sub header        ();
+sub static_section($);
 sub usage         ();
 
 sub main ()
@@ -58,6 +58,7 @@ sub main ()
     my $output;
     my $format;
     my $header;
+    my $footer;
     my $opt_ok;
 
     # option parsing:
@@ -74,7 +75,8 @@ sub main ()
         $input  = input_stream();
         $output = output_stream();
         $format = formatter();
-        $header = header();
+        $header = static_section('header');
+        $footer = static_section('footer');
     }
 
     # double check the options are sane (and we weren't asked for the help)
@@ -100,7 +102,7 @@ sub main ()
                 $opt{plat} eq $plat ||
                 'all'      eq $plat )
             {
-                print( $output $format->( $key, $val ), "\n" );
+                print( $output $format->( $key, $val ) );
             }
         }
         else
@@ -108,6 +110,8 @@ sub main ()
             warn( "Malformed entry: $_" );
         }
     }
+
+    print( $output $footer );
 }
 
 main();
@@ -169,10 +173,11 @@ sub formatter ()
     return $func || die( "No handler found for format '$name'\n" );
 }
 
-sub header ()
+sub static_section ($)
 {
     my $name = $opt{format};
-    my $func = "msgfmt::$name"->UNIVERSAL::can("header");
+    my $sect = shift();
+    my $func = "msgfmt::$name"->UNIVERSAL::can( $sect );
 
     return $func ? $func->() : "";
 }
@@ -181,17 +186,15 @@ sub header ()
 {
     package msgfmt::java;
 
-    # escape characters spec says ' should be escaped here but
-    # transifex does not recognise it. hence [\\:] and not [\\:']
-    sub escape { $_[0] =~ s/([\\:])/\\$1/g; $_[0] }
-    sub format { return join(' = ', $_[0], escape( $_[1] ) ) }
+    sub escape { $_[0] =~ s/([:'\\])/\\$1/g; $_[0] }
+    sub format { return join(' = ', $_[0], escape( $_[1] ) ) . "\n" }
     sub header { "# autogenerated from " . ($opt{input} || '-stdin-') . "\n" }
 }
 
 {
-    package msgfmt::messages;
+    package msgfmt::messages; # native netsurf format
 
-    sub format { return join( ":", @_ ) }
+    sub format { return join( ":", @_ ) . "\n" }
     sub header
     {
         my $in = $opt{input} || '-stdin-';
@@ -202,6 +205,19 @@ TXT
     }
 }
 
+{
+    package msgfmt::transifex;
+    use base 'msgfmt::java';
+
+    # transifex has the following quirks:
+    # \ processing is buggy - they re-process every \\ as a \
+    # so \\n, instead or producing literal '\n', is interpreted as \ ^J
+    # Additionally, although the java properties format specifies
+    # that ' should be \ escaped, transifex does not allow/support this:
+    sub escape { $_[0] =~ s/(:|\\(?![abfnrtv]))/\\$1/g; $_[0] }
+    sub format { return join(' = ', $_[0], escape( $_[1] ) ) . "\n" }
+}
+
 ########### YAML ###########
 #{
 #    package msgfmt::yaml;
@@ -209,18 +225,15 @@ TXT
 #    print Dump %data;
 #}
 
-######## android properties ########
-#{
-#    package msgfmt::android;
-#    use HTML::Entities;
-#    print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n";
-#    foreach my $lang (sort keys %data) {
-#	foreach my $plat (sort keys %{$data{$lang}}) {
-#	    foreach my $key (sort keys %{$data{$lang}{$plat}}) {
-#		my $val = $data{$lang}{$plat}{$key};
-#		print "<string name=\"$key\">" . encode_entities($val, '<>&"') . "</string>\n";
-#	    }		
-#	}
-#   }
-#  print "</resources>";
-#}
+{
+    package msgfmt::android;
+
+    sub header { qq|<?xml version="1.0" encoding="utf-8"?>\n<resources>\n| }
+    sub footer { qq|</resources>| }
+    sub format
+    {
+        use HTML::Entities qw(encode_entities);
+        my $escaped = encode_entities( $_[1], '<>&"' );
+        qq|  <string name="$_[0]">$escaped</string>\n|;
+    }
+}


-----------------------------------------------------------------------

Summary of changes:
 utils/split-messages.pl |   65 ++++++++++++++++++++++++++++------------------
 1 files changed, 39 insertions(+), 26 deletions(-)

diff --git a/utils/split-messages.pl b/utils/split-messages.pl
index 08d8822..45e5539 100644
--- a/utils/split-messages.pl
+++ b/utils/split-messages.pl
@@ -49,7 +49,7 @@ my %opt = qw( plat any format messages );
 sub input_stream  ();
 sub output_stream ();
 sub formatter     ();
-sub header        ();
+sub static_section($);
 sub usage         ();
 
 sub main ()
@@ -58,6 +58,7 @@ sub main ()
     my $output;
     my $format;
     my $header;
+    my $footer;
     my $opt_ok;
 
     # option parsing:
@@ -74,7 +75,8 @@ sub main ()
         $input  = input_stream();
         $output = output_stream();
         $format = formatter();
-        $header = header();
+        $header = static_section('header');
+        $footer = static_section('footer');
     }
 
     # double check the options are sane (and we weren't asked for the help)
@@ -100,7 +102,7 @@ sub main ()
                 $opt{plat} eq $plat ||
                 'all'      eq $plat )
             {
-                print( $output $format->( $key, $val ), "\n" );
+                print( $output $format->( $key, $val ) );
             }
         }
         else
@@ -108,6 +110,8 @@ sub main ()
             warn( "Malformed entry: $_" );
         }
     }
+
+    print( $output $footer );
 }
 
 main();
@@ -169,10 +173,11 @@ sub formatter ()
     return $func || die( "No handler found for format '$name'\n" );
 }
 
-sub header ()
+sub static_section ($)
 {
     my $name = $opt{format};
-    my $func = "msgfmt::$name"->UNIVERSAL::can("header");
+    my $sect = shift();
+    my $func = "msgfmt::$name"->UNIVERSAL::can( $sect );
 
     return $func ? $func->() : "";
 }
@@ -181,17 +186,15 @@ sub header ()
 {
     package msgfmt::java;
 
-    # escape characters spec says ' should be escaped here but
-    # transifex does not recognise it. hence [\\:] and not [\\:']
-    sub escape { $_[0] =~ s/([\\:])/\\$1/g; $_[0] }
-    sub format { return join(' = ', $_[0], escape( $_[1] ) ) }
+    sub escape { $_[0] =~ s/([:'\\])/\\$1/g; $_[0] }
+    sub format { return join(' = ', $_[0], escape( $_[1] ) ) . "\n" }
     sub header { "# autogenerated from " . ($opt{input} || '-stdin-') . "\n" }
 }
 
 {
-    package msgfmt::messages;
+    package msgfmt::messages; # native netsurf format
 
-    sub format { return join( ":", @_ ) }
+    sub format { return join( ":", @_ ) . "\n" }
     sub header
     {
         my $in = $opt{input} || '-stdin-';
@@ -202,6 +205,19 @@ TXT
     }
 }
 
+{
+    package msgfmt::transifex;
+    use base 'msgfmt::java';
+
+    # transifex has the following quirks:
+    # \ processing is buggy - they re-process every \\ as a \
+    # so \\n, instead or producing literal '\n', is interpreted as \ ^J
+    # Additionally, although the java properties format specifies
+    # that ' should be \ escaped, transifex does not allow/support this:
+    sub escape { $_[0] =~ s/(:|\\(?![abfnrtv]))/\\$1/g; $_[0] }
+    sub format { return join(' = ', $_[0], escape( $_[1] ) ) . "\n" }
+}
+
 ########### YAML ###########
 #{
 #    package msgfmt::yaml;
@@ -209,18 +225,15 @@ TXT
 #    print Dump %data;
 #}
 
-######## android properties ########
-#{
-#    package msgfmt::android;
-#    use HTML::Entities;
-#    print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n";
-#    foreach my $lang (sort keys %data) {
-#	foreach my $plat (sort keys %{$data{$lang}}) {
-#	    foreach my $key (sort keys %{$data{$lang}{$plat}}) {
-#		my $val = $data{$lang}{$plat}{$key};
-#		print "<string name=\"$key\">" . encode_entities($val, '<>&"') . "</string>\n";
-#	    }		
-#	}
-#   }
-#  print "</resources>";
-#}
+{
+    package msgfmt::android;
+
+    sub header { qq|<?xml version="1.0" encoding="utf-8"?>\n<resources>\n| }
+    sub footer { qq|</resources>| }
+    sub format
+    {
+        use HTML::Entities qw(encode_entities);
+        my $escaped = encode_entities( $_[1], '<>&"' );
+        qq|  <string name="$_[0]">$escaped</string>\n|;
+    }
+}


-- 
NetSurf Browser



More information about the netsurf-commits mailing list