[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kde-common/svn/hooks
From:       Dirk Mueller <mueller () kde ! org>
Date:       2007-10-11 8:48:08
Message-ID: 1192092488.980237.20532.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 724065 by mueller:

reduce memory usage


 M  +9 -77     test-pofiles.pl  


--- trunk/KDE/kde-common/svn/hooks/test-pofiles.pl #724064:724065
@@ -62,15 +62,13 @@
 
 # Figure out what files have changed using svnlook.
 my @files_changed;
-foreach my $line (&read_from_process($svnlook, 'changed', $repos, '-t', $txn))
-  {
+open(CHANGEDIN, "-|") || exec $svnlook, 'changed', $repos, '-t', $txn;
+while(<CHANGEDIN>) {
     # Split the line up into the modification code and path, ignoring
     # property modifications.
-    if ($line =~ /^[AU].  (trunk\/l10n-kde4\/.*\.po)$/)
-      {
-        push(@files_changed, $1);
-      }
-  }
+    push(@files_changed, $1) if (/^[AU].  (trunk\/l10n-kde4\/.*\.po)$/);
+}
+close(CHANGEDIN);
 
 unless (@files_changed)
   {
@@ -79,10 +77,11 @@
 
 foreach my $pofile (@files_changed) {
   open(MSGFMT, "| msgfmt --check-header --check - -o /dev/null") or die;
-  foreach my $line (&read_from_process($svnlook, 'cat', $repos, $pofile, '-t', $txn)) {
-    print MSGFMT "$line\n";
-  }
+  open(FILEIN, "-|") || exec $svnlook, 'cat', $repos, $pofile, '-t', $txn;
+  print MSGFMT "$_" while(<FILEIN>);
+  close(FILEIN);
   close(MSGFMT);
+
   if ($? >> 8) {
     print STDERR "\n";
     print STDERR "$pofile:\n";
@@ -99,70 +98,3 @@
   warn "@_\n" if @_;
   die "usage: $0 REPOS TXN-NAME\n";
 }
-
-sub safe_read_from_pipe
-{
-  unless (@_)
-    {
-      die "$0: safe_read_from_pipe passed no arguments.\n";
-    }
-  my $pid = open(SAFE_READ, '-|');
-  unless (defined $pid)
-    {
-      die "$0: cannot fork: $!\n";
-    }
-  unless ($pid)
-    {
-      open(STDERR, ">&STDOUT")
-        or die "$0: cannot dup STDOUT: $!\n";
-      exec(@_)
-        or die "$0: cannot exec `@_': $!\n";
-    }
-  my @output;
-  while (<SAFE_READ>)
-    {
-      chomp;
-      push(@output, $_);
-    }
-  close(SAFE_READ);
-  my $result = $?;
-  my $exit   = $result >> 8;
-  my $signal = $result & 127;
-  my $cd     = $result & 128 ? "with core dump" : "";
-  if ($signal or $cd)
-    {
-      warn "$0: pipe from `@_' failed $cd: exit=$exit signal=$signal\n";
-    }
-  if (wantarray)
-    {
-      return ($result, @output);
-    }
-  else
-    {
-      return $result;
-    }
-}
-
-sub read_from_process
-  {
-  unless (@_)
-    {
-      die "$0: read_from_process passed no arguments.\n";
-    }
-  my ($status, @output) = &safe_read_from_pipe(@_);
-  if ($status)
-    {
-      if (@output)
-        {
-          die "$0: `@_' failed with this output:\n", join("\n", @output), "\n";
-        }
-      else
-        {
-          die "$0: `@_' failed with no output.\n";
-        }
-    }
-  else
-    {
-      return @output;
-    }
-}
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic