gpastore changed gchangepass/trunk/AUTHORS, gchangepass/trunk/ChangeLog, gchangepass/trunk/configure.ac, gchangepass/trunk/intltool-extract.in, gchangepass/trunk/intltool-merge.in, gchangepass/trunk/intltool-update.in, gchangepass/trunk/src/passwd.c, gchangepass/trunk/src/ui.c

Guilherme de S. Pastore gpastore at costa.debian.org
Tue Oct 10 21:21:58 UTC 2006


Mensagem de log: 
2006-10-10  Guilherme de S. Pastore  <gpastore at gnome.org>

        * configure.ac: release 0.1.6.

2006-09-11  Guilherme de S. Pastore  <gpastore at gnome.org>

        * src/ui.c: fix Debian bug #360173 - don't say passwords
          are equal if only their first chars match.

2006-09-11  Guilherme de S. Pastore  <gpastore at gnome.org>

        * src/ui.c, src/passwd.c: added hack to (try to) warn the
          user if the password is weak. This code could use some
          rewriting, really.


-----


Modified: gchangepass/trunk/AUTHORS
===================================================================
--- gchangepass/trunk/AUTHORS	2006-10-10 03:13:30 UTC (rev 733)
+++ gchangepass/trunk/AUTHORS	2006-10-10 21:21:57 UTC (rev 734)
@@ -1 +1 @@
-Guilherme de S. Pastore <gpastore at colband.com.br>
+Guilherme de S. Pastore <gpastore at gnome.org>

Modified: gchangepass/trunk/ChangeLog
===================================================================
--- gchangepass/trunk/ChangeLog	2006-10-10 03:13:30 UTC (rev 733)
+++ gchangepass/trunk/ChangeLog	2006-10-10 21:21:57 UTC (rev 734)
@@ -1,3 +1,18 @@
+2006-10-10  Guilherme de S. Pastore  <gpastore at gnome.org>
+
+	* configure.ac: release 0.1.6.
+
+2006-09-11  Guilherme de S. Pastore  <gpastore at gnome.org>
+
+	* src/ui.c: fix Debian bug #360173 - don't say passwords
+	  are equal if only their first chars match.
+
+2006-09-11  Guilherme de S. Pastore  <gpastore at gnome.org>
+
+	* src/ui.c, src/passwd.c: added hack to (try to) warn the
+	  user if the password is weak. This code could use some
+	  rewriting, really.
+
 2006-08-15  Gustavo Noronha Silva  <kov at debian.org>
 
 	* configure.ac: added pl to ALL_LINGUAS

Modified: gchangepass/trunk/configure.ac
===================================================================
--- gchangepass/trunk/configure.ac	2006-10-10 03:13:30 UTC (rev 733)
+++ gchangepass/trunk/configure.ac	2006-10-10 21:21:57 UTC (rev 734)
@@ -2,7 +2,7 @@
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ(2.59)
-AC_INIT(gchangepass, 0.1.5, gpastore at colband.com.br)
+AC_INIT(gchangepass, 0.1.6, gpastore at gnome.org)
 AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
 AC_CONFIG_SRCDIR(src/passwd.c)
 AM_CONFIG_HEADER(config.h)

Modified: gchangepass/trunk/intltool-extract.in
===================================================================
--- gchangepass/trunk/intltool-extract.in	2006-10-10 03:13:30 UTC (rev 733)
+++ gchangepass/trunk/intltool-extract.in	2006-10-10 21:21:57 UTC (rev 734)
@@ -32,7 +32,7 @@
 ## Release information
 my $PROGRAM      = "intltool-extract";
 my $PACKAGE      = "intltool";
-my $VERSION      = "0.33";
+my $VERSION      = "0.35.0";
 
 ## Loaded modules
 use strict; 
@@ -59,6 +59,8 @@
 my %comments = ();
 my $strcount = 0;
 
+my $XMLCOMMENT = "";
+
 ## Use this instead of \w for XML files to handle more possible characters.
 my $w = "[-A-Za-z0-9._:]";
 
@@ -186,6 +188,7 @@
     &convert;
 
     open OUT, ">$OUTFILE";
+    binmode (OUT) if $^O eq 'MSWin32';
     &msg_write;
     close OUT;
 
@@ -266,24 +269,346 @@
 
 sub type_xml {
     ### For generic translatable XML files ###
-        
-    while ($input =~ /(?:<!--([^>]*?)-->[^\n]*\n?[^\n]*)?\s_$w+\s*=\s*\"([^"]*)\"/sg) { # "
-        $messages{entity_decode_minimal($2)} = [];
-        $comments{entity_decode_minimal($2)} = $1 if (defined($1));
-    }
+    my $tree = readXml($input);
+    parseTree(0, $tree);
+}
 
-    while ($input =~ /(?:<!--([^>]*?)-->\s*)?<_($w+)(?: xml:space="($w+)")?[^>]*>(.*?)<\/_\2>/sg) {
-        $_ = $4;
-        if (!defined($3) || $3 ne "preserve") {
-            s/\s+/ /g;
-            s/^ //;
-            s/ $//;
+sub print_var {
+    my $var = shift;
+    my $vartype = ref $var;
+    
+    if ($vartype =~ /ARRAY/) {
+        my @arr = @{$var};
+        print "[ ";
+        foreach my $el (@arr) {
+            print_var($el);
+            print ", ";
         }
-        $messages{$_} = [];
-        $comments{$_} = $1 if (defined($1));
+        print "] ";
+    } elsif ($vartype =~ /HASH/) {
+        my %hash = %{$var};
+        print "{ ";
+        foreach my $key (keys %hash) {
+            print "$key => ";
+            print_var($hash{$key});
+            print ", ";
+        }
+        print "} ";
+    } else {
+        print $var;
     }
 }
 
+# Same syntax as getAttributeString in intltool-merge.in.in, similar logic (look for ## differences comment)
+sub getAttributeString
+{
+    my $sub = shift;
+    my $do_translate = shift || 1;
+    my $language = shift || "";
+    my $translate = shift;
+    my $result = "";
+    foreach my $e (reverse(sort(keys %{ $sub }))) {
+	my $key    = $e;
+	my $string = $sub->{$e};
+	my $quote = '"';
+	
+	$string =~ s/^[\s]+//;
+	$string =~ s/[\s]+$//;
+	
+	if ($string =~ /^'.*'$/)
+	{
+	    $quote = "'";
+	}
+	$string =~ s/^['"]//g;
+	$string =~ s/['"]$//g;
+
+        ## differences from intltool-merge.in.in
+	if ($key =~ /^_/) {
+            $comments{entity_decode($string)} = $XMLCOMMENT if $XMLCOMMENT;
+            $messages{entity_decode($string)} = [];
+            $$translate = 2;
+	}
+        ## differences end here from intltool-merge.in.in
+	$result .= " $key=$quote$string$quote";
+    }
+    return $result;
+}
+
+# Verbatim copy from intltool-merge.in.in
+sub getXMLstring
+{
+    my $ref = shift;
+    my $spacepreserve = shift || 0;
+    my @list = @{ $ref };
+    my $result = "";
+
+    my $count = scalar(@list);
+    my $attrs = $list[0];
+    my $index = 1;
+
+    $spacepreserve = 1 if ((exists $attrs->{"xml:space"}) && ($attrs->{"xml:space"} =~ /^["']?preserve["']?$/));
+    $spacepreserve = 0 if ((exists $attrs->{"xml:space"}) && ($attrs->{"xml:space"} =~ /^["']?default["']?$/));
+
+    while ($index < $count) {
+	my $type = $list[$index];
+	my $content = $list[$index+1];
+        if (! $type ) {
+	    # We've got CDATA
+	    if ($content) {
+		# lets strip the whitespace here, and *ONLY* here
+                $content =~ s/\s+/ /gs if (!$spacepreserve);
+		$result .= $content;
+	    }
+	} elsif ( "$type" ne "1" ) {
+	    # We've got another element
+	    $result .= "<$type";
+	    $result .= getAttributeString(@{$content}[0], 0); # no nested translatable elements
+	    if ($content) {
+		my $subresult = getXMLstring($content, $spacepreserve);
+		if ($subresult) {
+		    $result .= ">".$subresult . "</$type>";
+		} else {
+		    $result .= "/>";
+		}
+	    } else {
+		$result .= "/>";
+	    }
+	}
+	$index += 2;
+    }
+    return $result;
+}
+
+# Verbatim copy from intltool-merge.in.in, except for MULTIPLE_OUTPUT handling removed
+# Translate list of nodes if necessary
+sub translate_subnodes
+{
+    my $fh = shift;
+    my $content = shift;
+    my $language = shift || "";
+    my $singlelang = shift || 0;
+    my $spacepreserve = shift || 0;
+
+    my @nodes = @{ $content };
+
+    my $count = scalar(@nodes);
+    my $index = 0;
+    while ($index < $count) {
+        my $type = $nodes[$index];
+        my $rest = $nodes[$index+1];
+        traverse($fh, $type, $rest, $language, $spacepreserve);
+        $index += 2;
+    }
+}
+
+# Based on traverse() in intltool-merge.in.in
+sub traverse
+{
+    my $fh = shift; # unused, to allow us to sync code between -merge and -extract
+    my $nodename = shift;
+    my $content = shift;
+    my $language = shift || "";
+    my $spacepreserve = shift || 0;
+
+    if ($nodename && "$nodename" eq "1") {
+        $XMLCOMMENT = $content;
+    } elsif ($nodename) {
+	# element
+	my @all = @{ $content };
+	my $attrs = shift @all;
+	my $translate = 0;
+	my $outattr = getAttributeString($attrs, 1, $language, \$translate);
+
+	if ($nodename =~ /^_/) {
+	    $translate = 1;
+	    $nodename =~ s/^_//;
+	}
+	my $lookup = '';
+
+        $spacepreserve = 0 if ((exists $attrs->{"xml:space"}) && ($attrs->{"xml:space"} =~ /^["']?default["']?$/));
+        $spacepreserve = 1 if ((exists $attrs->{"xml:space"}) && ($attrs->{"xml:space"} =~ /^["']?preserve["']?$/));
+
+	if ($translate) {
+	    $lookup = getXMLstring($content, $spacepreserve);
+            if (!$spacepreserve) {
+                $lookup =~ s/^\s+//s;
+                $lookup =~ s/\s+$//s;
+            }
+
+	    if ($lookup && $translate != 2) {
+                $comments{$lookup} = $XMLCOMMENT if $XMLCOMMENT;
+                $messages{$lookup} = [];
+            } elsif ($translate == 2) {
+                translate_subnodes($fh, \@all, $language, 1, $spacepreserve);
+	    }
+	} else {
+            $XMLCOMMENT = "";
+	    my $count = scalar(@all);
+	    if ($count > 0) {
+                my $index = 0;
+                while ($index < $count) {
+                    my $type = $all[$index];
+                    my $rest = $all[$index+1];
+                    traverse($fh, $type, $rest, $language, $spacepreserve);
+                    $index += 2;
+                }
+	    }
+	}
+        $XMLCOMMENT = "";
+    }
+}
+
+
+# Verbatim copy from intltool-merge.in.in, $fh for compatibility
+sub parseTree
+{
+    my $fh        = shift;
+    my $ref       = shift;
+    my $language  = shift || "";
+
+    my $name = shift @{ $ref };
+    my $cont = shift @{ $ref };
+
+    while (!$name || "$name" eq "1") {
+        $name = shift @{ $ref };
+        $cont = shift @{ $ref };
+    }
+
+    my $spacepreserve = 0;
+    my $attrs = @{$cont}[0];
+    $spacepreserve = 1 if ((exists $attrs->{"xml:space"}) && ($attrs->{"xml:space"} =~ /^["']?preserve["']?$/));
+
+    traverse($fh, $name, $cont, $language, $spacepreserve);
+}
+
+# Verbatim copy from intltool-merge.in.in
+sub intltool_tree_comment
+{
+    my $expat = shift;
+    my $data  = $expat->original_string();
+    my $clist = $expat->{Curlist};
+    my $pos   = $#$clist;
+
+    $data =~ s/^<!--//s;
+    $data =~ s/-->$//s;
+    push @$clist, 1 => $data;
+}
+
+# Verbatim copy from intltool-merge.in.in
+sub intltool_tree_cdatastart
+{
+    my $expat    = shift;
+    my $clist = $expat->{Curlist};
+    my $pos   = $#$clist;
+
+    push @$clist, 0 => $expat->original_string();
+}
+
+# Verbatim copy from intltool-merge.in.in
+sub intltool_tree_cdataend
+{
+    my $expat    = shift;
+    my $clist = $expat->{Curlist};
+    my $pos   = $#$clist;
+
+    $clist->[$pos] .= $expat->original_string();
+}
+
+# Verbatim copy from intltool-merge.in.in
+sub intltool_tree_char
+{
+    my $expat = shift;
+    my $text  = shift;
+    my $clist = $expat->{Curlist};
+    my $pos   = $#$clist;
+
+    # Use original_string so that we retain escaped entities
+    # in CDATA sections.
+    #
+    if ($pos > 0 and $clist->[$pos - 1] eq '0') {
+        $clist->[$pos] .= $expat->original_string();
+    } else {
+        push @$clist, 0 => $expat->original_string();
+    }
+}
+
+# Verbatim copy from intltool-merge.in.in
+sub intltool_tree_start
+{
+    my $expat    = shift;
+    my $tag      = shift;
+    my @origlist = ();
+
+    # Use original_string so that we retain escaped entities
+    # in attribute values.  We must convert the string to an
+    # @origlist array to conform to the structure of the Tree
+    # Style.
+    #
+    my @original_array = split /\x/, $expat->original_string();
+    my $source         = $expat->original_string();
+
+    # Remove leading tag.
+    #
+    $source =~ s|^\s*<\s*(\S+)||s;
+
+    # Grab attribute key/value pairs and push onto @origlist array.
+    #
+    while ($source)
+    {
+       if ($source =~ /^\s*([\w:-]+)\s*[=]\s*["]/)
+       {
+           $source =~ s|^\s*([\w:-]+)\s*[=]\s*["]([^"]*)["]||s;
+           push @origlist, $1;
+           push @origlist, '"' . $2 . '"';
+       }
+       elsif ($source =~ /^\s*([\w:-]+)\s*[=]\s*[']/)
+       {
+           $source =~ s|^\s*([\w:-]+)\s*[=]\s*[']([^']*)[']||s;
+           push @origlist, $1;
+           push @origlist, "'" . $2 . "'";
+       }
+       else
+       {
+           last;
+       }
+    }
+
+    my $ol = [ { @origlist } ];
+
+    push @{ $expat->{Lists} }, $expat->{Curlist};
+    push @{ $expat->{Curlist} }, $tag => $ol;
+    $expat->{Curlist} = $ol;
+}
+
+# Copied from intltool-merge.in.in and added comment handler.
+sub readXml
+{
+    my $xmldoc = shift || return;
+    my $ret = eval 'require XML::Parser';
+    if(!$ret) {
+        die "You must have XML::Parser installed to run $0\n\n";
+    }
+    my $xp = new XML::Parser(Style => 'Tree');
+    $xp->setHandlers(Char => \&intltool_tree_char);
+    $xp->setHandlers(Start => \&intltool_tree_start);
+    $xp->setHandlers(CdataStart => \&intltool_tree_cdatastart);
+    $xp->setHandlers(CdataEnd => \&intltool_tree_cdataend);
+
+    ## differences from intltool-merge.in.in
+    $xp->setHandlers(Comment => \&intltool_tree_comment);
+    ## differences end here from intltool-merge.in.in
+
+    my $tree = $xp->parse($xmldoc);
+    #print_var($tree);
+
+# <foo><!-- comment --><head id="a">Hello <em>there</em></head><bar>Howdy<ref/></bar>do</foo>
+# would be:
+# [foo, [{}, 1, "comment", head, [{id => "a"}, 0, "Hello ",  em, [{}, 0, "there"]], bar, 
+# [{}, 0, "Howdy",  ref, [{}]], 0, "do" ] ]
+
+    return $tree;
+}
+
 sub type_schemas {
     ### For schemas XML files ###
          

Modified: gchangepass/trunk/intltool-merge.in
===================================================================
--- gchangepass/trunk/intltool-merge.in	2006-10-10 03:13:30 UTC (rev 733)
+++ gchangepass/trunk/intltool-merge.in	2006-10-10 21:21:57 UTC (rev 734)
@@ -35,7 +35,7 @@
 ## Release information
 my $PROGRAM = "intltool-merge";
 my $PACKAGE = "intltool";
-my $VERSION = "0.33";
+my $VERSION = "0.35.0";
 
 ## Loaded modules
 use strict; 
@@ -91,7 +91,8 @@
 
 my %po_files_by_lang = ();
 my %translations = ();
-my $iconv = $ENV{"ICONV"} || $ENV{"INTLTOOL_ICONV"} || "/usr/bin/iconv";
+my $iconv = $ENV{"ICONV"} || $ENV{"INTLTOOL_ICONV"} || "@INTLTOOL_ICONV@";
+my $devnull = ($^O eq 'MSWin32' ? 'NUL:' : '/dev/null');
 
 # Use this instead of \w for XML files to handle more possible characters.
 my $w = "[-A-Za-z0-9._:]";
@@ -256,7 +257,7 @@
 sub get_local_charset
 {
     my ($encoding) = @_;
-    my $alias_file = $ENV{"G_CHARSET_ALIAS"} || "/usr/lib/charset.alias";
+    my $alias_file = $ENV{"G_CHARSET_ALIAS"} || "@INTLTOOL_LIBDIR@/charset.alias";
 
     # seek character encoding aliases in charset.alias (glib)
 
@@ -299,7 +300,7 @@
         $encoding = "ISO-8859-1";
     }
 
-    system ("$iconv -f $encoding -t UTF-8 </dev/null 2>/dev/null");
+    system ("$iconv -f $encoding -t UTF-8 <$devnull 2>$devnull");
     if ($?) {
 	$encoding = get_local_charset($encoding);
     }
@@ -394,7 +395,7 @@
             } 
             else 
             {
-		print STDERR "WARNING: $po_file is not in UTF-8 but $encoding, converting...\n" unless $QUIET_ARG;;
+		print "NOTICE: $po_file is not in UTF-8 but $encoding, converting...\n" unless $QUIET_ARG;;
 
                 open PO_FILE, "$iconv -f $encoding -t UTF-8 $po_file|";	
             }
@@ -542,6 +543,8 @@
     }
 
     open OUTPUT, ">$OUTFILE" or die "can't open $OUTFILE: $!";
+    # Binmode so that selftest works ok if using a native Win32 Perl...
+    binmode (OUTPUT) if $^O eq 'MSWin32';
 
     while ($source =~ s|^(.*?)([ \t]*<\s*$w+\s+($w+\s*=\s*"$q"\s*)+/?>)([ \t]*\n)?||s) 
     {
@@ -610,23 +613,16 @@
 	if ($do_translate && $key =~ /^_/) {
 	    $key =~ s|^_||g;
 	    if ($language) {
-		
 		# Handle translation
-		#
 		my $decode_string = entity_decode($string);
 		my $translation = $translations{$language, $decode_string};
 		if ($translation) {
 		    $translation = entity_encode($translation);
 		    $string = $translation;
-                    $$translate = 2;
-		} else {
-                    $$translate = 2; # we still want translations for deep nesting (FIXME: this will cause
-                                     # problems since we might get untranslated duplicated entries, but with xml:lang set)
-                    # Fix would be to set it here to eg. 3, and do a check in traverse() to see if any of the containing tags
-                    # really need translation, and only emit "translation" if there is (this means parsing same data twice)
                 }
+                $$translate = 2;
             } else {
-                 $$translate = 2 if ($translate && (!$$translate)); # watch not to "overwrite" if $translate == 2
+                 $$translate = 2 if ($translate && (!$$translate)); # watch not to "overwrite" $translate
             }
 	}
 	
@@ -636,13 +632,10 @@
 }
 
 # Returns a translatable string from XML node, it works on contents of every node in XML::Parser tree
-#   doesn't support nesting of translatable tags (i.e. <_blah>this <_doh>doesn't</_doh> work</_blah> -- besides
-#   can you define the correct semantics for this?)
-#
-
 sub getXMLstring
 {
     my $ref = shift;
+    my $spacepreserve = shift || 0;
     my @list = @{ $ref };
     my $result = "";
 
@@ -650,6 +643,9 @@
     my $attrs = $list[0];
     my $index = 1;
 
+    $spacepreserve = 1 if ((exists $attrs->{"xml:space"}) && ($attrs->{"xml:space"} =~ /^["']?preserve["']?$/));
+    $spacepreserve = 0 if ((exists $attrs->{"xml:space"}) && ($attrs->{"xml:space"} =~ /^["']?default["']?$/));
+
     while ($index < $count) {
 	my $type = $list[$index];
 	my $content = $list[$index+1];
@@ -657,19 +653,15 @@
 	    # We've got CDATA
 	    if ($content) {
 		# lets strip the whitespace here, and *ONLY* here
-                $content =~ s/\s+/ /gs if (!((exists $attrs->{"xml:space"}) && ($attrs->{"xml:space"} =~ /^["']?preserve["']?$/)));
-		$result .= ($content);
-	    } else {
-		#print "no cdata content when expected it\n"; # is this possible, is this ok?
-		# what to do if this happens?
-		# Did I mention that I hate XML::Parser tree style?
+                $content =~ s/\s+/ /gs if (!$spacepreserve);
+		$result .= $content;
 	    }
-	} else {
+	} elsif ( "$type" ne "1" ) {
 	    # We've got another element
 	    $result .= "<$type";
 	    $result .= getAttributeString(@{$content}[0], 0); # no nested translatable elements
 	    if ($content) {
-		my $subresult = getXMLstring($content);
+		my $subresult = getXMLstring($content, $spacepreserve);
 		if ($subresult) {
 		    $result .= ">".$subresult . "</$type>";
 		} else {
@@ -691,6 +683,7 @@
     my $content = shift;
     my $language = shift || "";
     my $singlelang = shift || 0;
+    my $spacepreserve = shift || 0;
 
     my @nodes = @{ $content };
 
@@ -702,21 +695,39 @@
         if ($singlelang) {
             my $oldMO = $MULTIPLE_OUTPUT;
             $MULTIPLE_OUTPUT = 1;
-            traverse($fh, $type, $rest, $language);
+            traverse($fh, $type, $rest, $language, $spacepreserve);
             $MULTIPLE_OUTPUT = $oldMO;
         } else {
-            traverse($fh, $type, $rest, $language);
+            traverse($fh, $type, $rest, $language, $spacepreserve);
         }
         $index += 2;
     }
 }
 
+sub isWellFormedXmlFragment
+{
+    my $ret = eval 'require XML::Parser';
+    if(!$ret) {
+        die "You must have XML::Parser installed to run $0\n\n";
+    } 
+
+    my $fragment = shift;
+    return 0 if (!$fragment);
+
+    $fragment = "<root>$fragment</root>";
+    my $xp = new XML::Parser(Style => 'Tree');
+    my $tree = 0;
+    eval { $tree = $xp->parse($fragment); };
+    return $tree;
+}
+
 sub traverse
 {
     my $fh = shift; 
     my $nodename = shift;
     my $content = shift;
     my $language = shift || "";
+    my $spacepreserve = shift || 0;
 
     if (!$nodename) {
 	if ($content =~ /^[\s]*$/) {
@@ -735,22 +746,26 @@
 	    $nodename =~ s/^_//;
 	}
 	my $lookup = '';
+
+        $spacepreserve = 0 if ((exists $attrs->{"xml:space"}) && ($attrs->{"xml:space"} =~ /^["']?default["']?$/));
+        $spacepreserve = 1 if ((exists $attrs->{"xml:space"}) && ($attrs->{"xml:space"} =~ /^["']?preserve["']?$/));
+
 	print $fh "<$nodename", $outattr;
 	if ($translate) {
-	    $lookup = getXMLstring($content);
-            if (!((exists $attrs->{"xml:space"}) && ($attrs->{"xml:space"} =~ /^["']?preserve["']?$/))) {
+	    $lookup = getXMLstring($content, $spacepreserve);
+            if (!$spacepreserve) {
                 $lookup =~ s/^\s+//s;
                 $lookup =~ s/\s+$//s;
             }
 
 	    if ($lookup || $translate == 2) {
-                my $translation = $translations{$language, $lookup};
+                my $translation = $translations{$language, $lookup} if isWellFormedXmlFragment($translations{$language, $lookup});
                 if ($MULTIPLE_OUTPUT && ($translation || $translate == 2)) {
                     $translation = $lookup if (!$translation);
                     print $fh " xml:lang=\"", $language, "\"" if $language;
                     print $fh ">";
                     if ($translate == 2) {
-                        translate_subnodes($fh, \@all, $language, 1);
+                        translate_subnodes($fh, \@all, $language, 1, $spacepreserve);
                     } else {
                         print $fh $translation;
                     }
@@ -761,7 +776,7 @@
                 } else {
                     print $fh ">";
                     if ($translate == 2) {
-                        translate_subnodes($fh, \@all, $language, 1);
+                        translate_subnodes($fh, \@all, $language, 1, $spacepreserve);
                     } else {
                         print $fh $lookup;
                     }
@@ -780,7 +795,7 @@
                         #
                         my $translate = 0;
                         my $localattrs = getAttributeString($attrs, 1, $lang, \$translate);
-                        my $translation = $translations{$lang, $lookup};
+                        my $translation = $translations{$lang, $lookup} if isWellFormedXmlFragment($translations{$lang, $lookup});
                         if ($translate && !$translation) {
                             $translation = $lookup;
                         }
@@ -791,7 +806,7 @@
 			    print $fh $leading_space;
  			    print $fh "<", $nodename, " xml:lang=\"", $lang, "\"", $localattrs, ">";
                             if ($translate == 2) {
-                               translate_subnodes($fh, \@all, $lang, 1);
+                               translate_subnodes($fh, \@all, $lang, 1, $spacepreserve);
                             } else {
                                 print $fh $translation;
                             }
@@ -808,7 +823,7 @@
                 while ($index < $count) {
                     my $type = $all[$index];
                     my $rest = $all[$index+1];
-                    traverse($fh, $type, $rest, $language);
+                    traverse($fh, $type, $rest, $language, $spacepreserve);
                     $index += 2;
                 }
 		print $fh "</$nodename>";
@@ -819,6 +834,16 @@
     }
 }
 
+sub intltool_tree_comment
+{
+    my $expat = shift;
+    my $data  = shift;
+    my $clist = $expat->{Curlist};
+    my $pos   = $#$clist;
+
+    push @$clist, 1 => $data;
+}
+
 sub intltool_tree_cdatastart
 {
     my $expat    = shift;
@@ -962,7 +987,17 @@
 
     my $name = shift @{ $ref };
     my $cont = shift @{ $ref };
-    traverse($fh, $name, $cont, $language);
+    
+    while (!$name || "$name" eq "1") {
+        $name = shift @{ $ref };
+        $cont = shift @{ $ref };
+    }
+
+    my $spacepreserve = 0;
+    my $attrs = @{$cont}[0];
+    $spacepreserve = 1 if ((exists $attrs->{"xml:space"}) && ($attrs->{"xml:space"} =~ /^["']?preserve["']?$/));
+
+    traverse($fh, $name, $cont, $language, $spacepreserve);
 }
 
 sub xml_merge_output
@@ -975,6 +1010,7 @@
 	        mkdir $lang or die "Cannot create subdirectory $lang: $!\n";
             }
             open OUTPUT, ">$lang/$OUTFILE" or die "Cannot open $lang/$OUTFILE: $!\n";
+            binmode (OUTPUT) if $^O eq 'MSWin32';
             my $tree = readXml($FILE);
             print_header($FILE, \*OUTPUT);
             parseTree(\*OUTPUT, $tree, $lang);
@@ -983,6 +1019,7 @@
         }
     } 
     open OUTPUT, ">$OUTFILE" or die "Cannot open $OUTFILE: $!\n";
+    binmode (OUTPUT) if $^O eq 'MSWin32';
     my $tree = readXml($FILE);
     print_header($FILE, \*OUTPUT);
     parseTree(\*OUTPUT, $tree);
@@ -994,6 +1031,7 @@
 {
     open INPUT, "<${FILE}" or die;
     open OUTPUT, ">${OUTFILE}" or die;
+    binmode (OUTPUT) if $^O eq 'MSWin32';
 
     while (<INPUT>) 
     {
@@ -1029,6 +1067,7 @@
 {
     open INPUT, "<${FILE}" or die;
     open OUTPUT, ">${OUTFILE}" or die;
+    binmode (OUTPUT) if $^O eq 'MSWin32';
 
     while (<INPUT>) 
     {
@@ -1072,6 +1111,7 @@
     }
 
     open OUTPUT, ">$OUTFILE" or die;
+    binmode (OUTPUT) if $^O eq 'MSWin32';
 
     # FIXME: support attribute translations
 
@@ -1173,6 +1213,7 @@
     }
 
     open OUTPUT, ">${OUTFILE}" or die;
+    binmode (OUTPUT) if $^O eq 'MSWin32';
 
     while ($source =~ /(^|\n+)(_*)([^:\s]+)(:[ \t]*)(.*?)(?=\n[\S\n]|$)/sg)
     {

Modified: gchangepass/trunk/intltool-update.in
===================================================================
--- gchangepass/trunk/intltool-update.in	2006-10-10 03:13:30 UTC (rev 733)
+++ gchangepass/trunk/intltool-update.in	2006-10-10 21:21:57 UTC (rev 734)
@@ -30,7 +30,7 @@
 
 ## Release information
 my $PROGRAM = "intltool-update";
-my $VERSION = "0.33";
+my $VERSION = "0.35.0";
 my $PACKAGE = "intltool";
 
 ## Loaded modules
@@ -80,7 +80,8 @@
 "directory(?:\\.in)+|".	# http://www.freedesktop.org/Standards/menu-spec
 "soundlist(?:\\.in)+|".	# GNOME specific
 "keys(?:\\.in)+|".	# GNOME Mime database specific
-"theme(?:\\.in)+";	# http://www.freedesktop.org/Standards/icon-theme-spec
+"theme(?:\\.in)+|".	# http://www.freedesktop.org/Standards/icon-theme-spec
+"service(?:\\.in)+";    # DBus specific
 
 my $buildin_gettext_support = 
 "c|y|cs|cc|cpp|c\\+\\+|h|hh|gob|py";
@@ -95,6 +96,8 @@
 $SRCDIR = $ENV{"srcdir"} if $ENV{"srcdir"};
 $POTFILES_in = "<$SRCDIR/POTFILES.in";
 
+my $devnull = ($^O eq 'MSWin32' ? 'NUL:' : '/dev/null');
+
 ## Handle options
 GetOptions 
 (
@@ -122,7 +125,7 @@
 &Console_Write_IntltoolHelp if $arg_count > 1;
 
 # --version and --help don't require a module name
-my $MODULE = $GETTEXT_PACKAGE || &FindPackageName;
+my $MODULE = $GETTEXT_PACKAGE || &FindPackageName || "unknown";
 
 if ($POT_ARG)
 {
@@ -442,7 +445,7 @@
 	while (<FILE>) 
 	{
 	    # FIXME: share the pattern matching code with intltool-extract
-	    if (/\s_(.*)=\"/ || /<_[^>]+>/ || /translatable=\"yes\"/)
+	    if (/\s_[-A-Za-z0-9._:]+\s*=\s*\"([^"]+)\"/ || /<_[^>]+>/ || /translatable=\"yes\"/)
 	    {
                 if (defined isNotValidMissing (unpack("x3 A*", $file))) {
                     push @buf_allfiles, unpack("x3 A*", $file) . "\n";
@@ -608,7 +611,7 @@
 #
 sub GeneratePOTemplate
 {
-    my $XGETTEXT = $ENV{"XGETTEXT"} || "/usr/bin/xgettext";
+    my $XGETTEXT = $ENV{"XGETTEXT"} || "@INTLTOOL_XGETTEXT@";
     my $XGETTEXT_ARGS = $ENV{"XGETTEXT_ARGS"} || '';
     chomp $XGETTEXT;
 
@@ -628,7 +631,7 @@
     my $gettext_support_nonascii = 0;
 
     # checks for GNU gettext >= 0.12
-    my $dummy = `$XGETTEXT --version --from-code=UTF-8 >/dev/null 2>/dev/null`;
+    my $dummy = `$XGETTEXT --version --from-code=UTF-8 >$devnull 2>$devnull`;
     if ($? == 0)
     {
 	$gettext_support_nonascii = 1;
@@ -719,6 +722,8 @@
 			   "--files-from\=\.\/POTFILES\.in\.temp");
     my $XGETTEXT_KEYWORDS = &FindPOTKeywords;
     push @xgettext_argument, $XGETTEXT_KEYWORDS;
+    my $MSGID_BUGS_ADDRESS = &FindMakevarsBugAddress;
+    push @xgettext_argument, "--msgid-bugs-address\=$MSGID_BUGS_ADDRESS" if $MSGID_BUGS_ADDRESS;
     push @xgettext_argument, "--from-code\=$encoding" if ($gettext_support_nonascii);
     push @xgettext_argument, $XGETTEXT_ARGS if $XGETTEXT_ARGS;
     my $xgettext_command = join ' ', @xgettext_argument;
@@ -779,7 +784,7 @@
 {
     -f "$MODULE.pot" or die "$PROGRAM: $MODULE.pot does not exist.\n";
 
-    my $MSGMERGE = $ENV{"MSGMERGE"} || "/usr/bin/msgmerge";
+    my $MSGMERGE = $ENV{"MSGMERGE"} || "@INTLTOOL_MSGMERGE@";
     my ($lang, $outfile) = @_;
 
     print "Merging $SRCDIR/$lang.po with $MODULE.pot..." if $VERBOSE;
@@ -822,16 +827,16 @@
 sub Console_Write_TranslationStatus
 {
     my ($lang, $output_file) = @_;
-    my $MSGFMT = $ENV{"MSGFMT"} || "/usr/bin/msgfmt";
+    my $MSGFMT = $ENV{"MSGFMT"} || "@INTLTOOL_MSGFMT@";
 
     $output_file = "$SRCDIR/$lang.po" if ($output_file eq "");
 
-    system ("$MSGFMT", "-o", "/dev/null", "--statistics", $output_file);
+    system ("$MSGFMT", "-o", "$devnull", "--verbose", $output_file);
 }
 
 sub Console_Write_CoverageReport
 {
-    my $MSGFMT = $ENV{"MSGFMT"} || "/usr/bin/msgfmt";
+    my $MSGFMT = $ENV{"MSGFMT"} || "@INTLTOOL_MSGFMT@";
 
     &GatherPOFiles;
 
@@ -846,7 +851,7 @@
     foreach my $lang (@languages)
     {
 	print "$lang: ";
-	system ("$MSGFMT", "-o", "/dev/null", "--statistics", "$SRCDIR/$lang.po");
+	system ("$MSGFMT", "-o", "$devnull", "--verbose", "$SRCDIR/$lang.po");
     }
 }
 
@@ -871,8 +876,10 @@
     {
 	my $rest = $3;
 	my $untouched = $1;
-	my $sub = $varhash{$2};
-	
+	my $sub = "";
+        # Ignore recursive definitions of variables
+        $sub = $varhash{$2} if defined $varhash{$2} and $varhash{$2} !~ /\${?$2}?/;
+
 	return SubstituteVariable ("$untouched$sub$rest");
     }
     
@@ -989,10 +996,10 @@
 	($name, $version) = ($1, $2);
 	$name    =~ s/[\[\]\s]//g;
 	$version =~ s/[\[\]\s]//g;
-	$varhash{"AC_PACKAGE_NAME"} = $name;
-	$varhash{"PACKAGE"} = $name;
-	$varhash{"AC_PACKAGE_VERSION"} = $version;
-	$varhash{"VERSION"} = $version;
+	$varhash{"PACKAGE_NAME"} = $name if (not $name =~ /\${?AC_PACKAGE_NAME}?/);
+	$varhash{"PACKAGE"} = $name if (not $name =~ /\${?PACKAGE}?/);
+	$varhash{"PACKAGE_VERSION"} = $version if (not $name =~ /\${?AC_PACKAGE_VERSION}?/);
+	$varhash{"VERSION"} = $version if (not $name =~ /\${?VERSION}?/);
     }
     
     if ($conf_source =~ /^AC_INIT\(([^,\)]+),([^,\)]+)/m) 
@@ -1000,19 +1007,18 @@
 	($name, $version) = ($1, $2);
 	$name    =~ s/[\[\]\s]//g;
 	$version =~ s/[\[\]\s]//g;
-	$varhash{"AC_PACKAGE_NAME"} = $name;
-	$varhash{"PACKAGE"} = $name;
-	$varhash{"AC_PACKAGE_VERSION"} = $version;
-	$varhash{"VERSION"} = $version;
+	$varhash{"PACKAGE_NAME"} = $name if (not $name =~ /\${?AC_PACKAGE_NAME}?/);
+	$varhash{"PACKAGE"} = $name if (not $name =~ /\${?PACKAGE}?/);
+	$varhash{"PACKAGE_VERSION"} = $version if (not $name =~ /\${?AC_PACKAGE_VERSION}?/);
+	$varhash{"VERSION"} = $version if (not $name =~ /\${?VERSION}?/);
     }
 
     # \s makes this not work, why?
     $name = $1 if $conf_source =~ /^GETTEXT_PACKAGE=\[?([^\n\]]+)/m;
     
-    # prepend '$' to auto* internal variables, usually they are
-    # used in configure.in/ac without the '$'
-    $name =~ s/AC_/\$AC_/g;
-    $name =~ s/\$\$/\$/g;
+    # m4 macros AC_PACKAGE_NAME, AC_PACKAGE_VERSION etc. have same value
+    # as corresponding $PACKAGE_NAME, $PACKAGE_VERSION etc. shell variables.
+    $name =~ s/\bAC_PACKAGE_/\$PACKAGE_/g;
 
     $name = $domain if $domain;
 
@@ -1061,3 +1067,23 @@
     
     return $domain;
 }
+
+sub FindMakevarsBugAddress
+{
+
+    my $address = "";
+    my $makevars_source; { 
+	local (*IN);
+	open (IN, "<Makevars") || return undef;
+	seek (IN, 0, 0);
+	local $/; # slurp mode
+	$makevars_source = <IN>;
+	close IN;
+    }
+
+    $address = $1 if $makevars_source =~ /^MSGID_BUGS_ADDRESS[ ]*=\[?([^\n\]\$]+)/m;
+    $address =~ s/^\s+//;
+    $address =~ s/\s+$//;
+    
+    return $address;
+}

Modified: gchangepass/trunk/src/passwd.c
===================================================================
--- gchangepass/trunk/src/passwd.c	2006-10-10 03:13:30 UTC (rev 733)
+++ gchangepass/trunk/src/passwd.c	2006-10-10 21:21:57 UTC (rev 734)
@@ -172,6 +172,9 @@
 		  if (g_strrstr (buf, "success") || g_strrstr (buf, "done"))
 		    return 0;
 
+		  if (g_str_has_prefix (buf, "Bad: "))
+		    return -1;
+
 		  if (g_strrstr (buf, "fail")
 		      || g_strrstr (buf, "incorrect")
 		      || g_strrstr (buf, "wrong"))

Modified: gchangepass/trunk/src/ui.c
===================================================================
--- gchangepass/trunk/src/ui.c	2006-10-10 03:13:30 UTC (rev 733)
+++ gchangepass/trunk/src/ui.c	2006-10-10 21:21:57 UTC (rev 734)
@@ -281,7 +281,8 @@
 	      break;
 	    }
 	  if (_userdata->current_password &&
-	      !strncmp (_userdata->current_password, 
+	      new_len == strlen (_userdata->current_password) &&
+	      !strncmp (_userdata->current_password,
 			_userdata->new_password,
 			new_len))
 	    {
@@ -297,6 +298,10 @@
 	      gchangepass_dialog (GTK_MESSAGE_INFO,
 				  _("Password changed successfully!"));
 	      break;
+	    case -1:
+	      gchangepass_dialog (GTK_MESSAGE_ERROR,
+				  _("New password is invalid. Is it strong enough?"));
+	      break;
 	    case -2:
 	      gchangepass_dialog (GTK_MESSAGE_ERROR,
 				  _("Authentication failure: password incorrect"));




More information about the gksu-commits mailing list