util: Add a README file for the m5 utility.
[gem5.git] / util / rundiff
index cd2527e5437aa424988927b9a3b1210adb57c007..b988d5db2b95fdac494634ef432e5b3464877f10 100755 (executable)
@@ -25,9 +25,6 @@
 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-# Authors: Nathan Binkert
-#          Steve Reinhardt
 
 # Diff two streams.
 #
@@ -166,7 +163,11 @@ sub printdiff
     # Set $postcontext to print the next $postcontext_lines matching lines.
     $postcontext = $postcontext_lines;
 
-    STDOUT->flush();
+    # Normally we flush after the postcontext lines are printed, but if
+    # the user has decreed that there aren't any we need to flush now
+    if ($postcontext == 0) {
+        STDOUT->flush();
+    }
 }
 
 
@@ -291,10 +292,12 @@ while (1) {
        # figure out what to do with this line
        if ($postcontext > 0) {
            # we're in the post-context of a diff: print it
-           $postcontext--;
            print ' ', $l1;
            $lineno1++;
            $lineno2++;
+            if (--$postcontext == 0) {
+                STDOUT->flush();
+            }
        }
        else {
            # we're in the middle of a matching region... save this