diff --git a/runtest.c b/runtest.c
index 02fe09a..8472209 100644
--- a/runtest.c
+++ b/runtest.c
@@ -81,8 +81,10 @@
  */
 #ifdef	O_BINARY
 #define RD_FLAGS	O_RDONLY | O_BINARY
+#define WR_FLAGS	O_WRONLY | O_BINARY
 #else
 #define	RD_FLAGS	O_RDONLY
+#define	WR_FLAGS	O_WRONLY
 #endif
 
 typedef int (*functest) (const char *filename, const char *result,
@@ -100,6 +102,7 @@ struct testDesc {
     int     options;  /* parser options for the test */
 };
 
+static int update_results = 0;
 static int checkTestFile(const char *filename);
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
@@ -646,6 +649,15 @@ static int compareFileMem(const char *filename, const char *mem, int size) {
     int idx = 0;
     struct stat info;
 
+    if (update_results) {
+        fd = open(filename, WR_FLAGS);
+        if (fd < 0)
+            return(-1);
+        res = write(fd, mem, size);
+        close(fd);
+        return(res != size);
+    }
+
     if (stat(filename, &info) < 0)
 	return(-1);
     if (info.st_size != size)
@@ -4440,6 +4452,8 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
     for (a = 1; a < argc;a++) {
         if (!strcmp(argv[a], "-v"))
 	    verbose = 1;
+        else if (!strcmp(argv[a], "-u"))
+	    update_results = 1;
         else if (!strcmp(argv[a], "-quiet"))
 	    tests_quiet = 1;
 	else {
