Diff
Not logged in

Differences From:

File src/diffcmd.c part of check-in [85670cfcc8] - Improvements to the output of the "diff" command so that it is closer to standards. by drh on 2008-10-24 10:56:19. [view]

To:

File src/diffcmd.c part of check-in [aeaee1f385] - Add extra quoted to system() calls on windows. Ticket 8d073be8808b. Also update to the latest SQLite. by drh on 2009-09-10 23:00:22. [view]

@@ -172,9 +172,10 @@
     if( zExternalCommand==0 ){
       internalDiff=1;
     }
     blob_zero(&cmd);
-    blob_appendf(&cmd, "%s ", zExternalCommand);
+    shell_escape(&cmd, zExternalCommand);
+    blob_append(&cmd, " ", 1);
   }
   zFile = g.argv[g.argc-1];
   file_tree_name(zFile, &fname, 1);
 
@@ -209,11 +210,29 @@
     blob_reset(&record);
     shell_escape(&cmd, blob_str(&vname));
     blob_appendf(&cmd, " ");
     shell_escape(&cmd, zFile);
-    system(blob_str(&cmd));
+    portable_system(blob_str(&cmd));
     unlink(blob_str(&vname));
     blob_reset(&vname);
     blob_reset(&cmd);
   }
   blob_reset(&fname);
+}
+
+/*
+** This function implements a cross-platform "system()" interface.
+*/
+void portable_system(char *zOrigCmd){
+#ifdef __MINGW32__
+  /* On windows, we have to put double-quotes around the entire command.
+  ** Who knows why - this is just the way windows works.
+  */
+  char *zNewCmd = mprintf("\"%s\"", zOrigCmd);
+  system(zNewCmd);
+  free(zNewCmd);
+#else
+  /* On unix, evaluate the command directly.
+  */
+  system(zOrigCmd);
+#endif
 }