* fixed GCC 4.4.0 mingw compilation:
[fw/sdcc] / support / regression / HTMLgen.py
index 055a204705fa7a028de527b4c7cc8eaa2a122fcd..3f44e2540ea35a30292f336c1138da5a37fa41e2 100644 (file)
@@ -185,3 +185,23 @@ class TemplateDocument(StringTemplate):
         f = open(template)
         self.source = f.read()
         f.close()
+
+def compare_s2f(s, f2):
+    """Helper to compare a string to a file, return 0 if they are equal."""
+
+    BUFSIZE = 8192
+    i = 0
+    fp2 = open(f2)
+    try:
+        while 1:
+            try:
+                b1 = s[i: i + BUFSIZE]
+                i = i + BUFSIZE
+            except IndexError:
+                b1 = ''
+            b2 = fp2.read(BUFSIZE)
+            if not b1 and not b2: return 0
+            c = cmp(b1, b2)
+            if c: return c
+    finally:
+        fp2.close()