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 [7a2c37063a] - merge trunk into creole branch by bob on 2009-09-22 07:49:39. Also file src/diffcmd.c part of check-in [0eb08b860c] - Change more system() calls into portable_system() in an effort to fix path quoting problems on windows. by drh on 2009-09-16 21:29:18. [view]

@@ -101,9 +101,9 @@
       );
       shell_escape(&cmd, zFullName);
       printf("%s\n", blob_str(&cmd));
       fflush(stdout);
-      system(blob_str(&cmd));
+      portable_system(blob_str(&cmd));
     }
     free(zFullName);
   }
   db_finalize(&q);
@@ -170,11 +170,13 @@
       zExternalCommand = db_get("gdiff-command", 0);
     }
     if( zExternalCommand==0 ){
       internalDiff=1;
-    }
-    blob_zero(&cmd);
-    blob_appendf(&cmd, "%s ", zExternalCommand);
+    }else{
+      blob_zero(&cmd);
+      shell_escape(&cmd, zExternalCommand);
+      blob_append(&cmd, " ", 1);
+    }
   }
   zFile = g.argv[g.argc-1];
   file_tree_name(zFile, &fname, 1);
 
@@ -209,11 +211,31 @@
     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.
+*/
+int portable_system(char *zOrigCmd){
+  int rc;
+#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);
+  rc = system(zNewCmd);
+  free(zNewCmd);
+#else
+  /* On unix, evaluate the command directly.
+  */
+  rc = system(zOrigCmd);
+#endif
+  return rc;
 }