From ba25cad6e2d218c40e33bc1165362378f84471ab Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
Date: Thu, 9 Jan 2003 11:26:57 +0000
Subject: [PATCH] pass a file name to memanalyze to read from instead of using
 stdin

---
 tests/memanalyze.pl | 22 +++++++++++++++++++---
 tests/runtests.pl   |  2 +-
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/tests/memanalyze.pl b/tests/memanalyze.pl
index 71fc1fde11..c354a5687a 100755
--- a/tests/memanalyze.pl
+++ b/tests/memanalyze.pl
@@ -6,14 +6,17 @@
 # MEM mprintf.c:1103 realloc(e5718, 64) = e6118
 # MEM sendf.c:232 free(f6520)
 
-do {
+while(1) {
     if($ARGV[0] eq "-v") {
         $verbose=1;
+        shift @ARGV;
     }
     elsif($ARGV[0] eq "-t") {
         $trace=1;
+        shift @ARGV;
     }
-} while (shift @ARGV);
+    last;
+}
 
 my $maxmem;
 
@@ -26,7 +29,19 @@ sub newtotal {
     }
 }
 
-while(<STDIN>) {
+my $file = $ARGV[0];
+
+if(! -f $file) {
+    print "Usage: memanalyze.pl [options] <dump file>\n",
+    "Options:\n",
+    " -v  Verbose\n",
+    " -t  Trace\n";
+    exit;
+}
+
+open(FILE, "<$file");
+
+while(<FILE>) {
     chomp $_;
     $line = $_;
 
@@ -219,6 +234,7 @@ while(<STDIN>) {
         print "Not recognized prefix line: $line\n";
     }
 }
+close(FILE);
 
 if($totalmem) {
     print "Leak detected: memory still allocated: $totalmem bytes\n";
diff --git a/tests/runtests.pl b/tests/runtests.pl
index 921cd28bfb..0690d4f094 100755
--- a/tests/runtests.pl
+++ b/tests/runtests.pl
@@ -777,7 +777,7 @@ sub singletest {
             print "\n** ALERT! memory debuggin without any output file?\n";
         }
         else {
-            my @memdata=`$memanalyze < $memdump`;
+            my @memdata=`$memanalyze $memdump`;
             my $leak=0;
             for(@memdata) {
                 if($_ ne "") {
-- 
GitLab