]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/general-scheme.cc
Release: bump Welcome versions.
[lilypond.git] / lily / general-scheme.cc
index d661c177a5802837cc2f961c50d2b396363df211..1168ee947357b06d21e0099b7a7551b09a6fd9a6 100644 (file)
@@ -24,6 +24,7 @@
 #include <ctype.h>
 #include <cstring>  /* memset */
 #include <glib.h>
+using namespace std;
 
 #include "dimensions.hh"
 #include "file-name.hh"
@@ -39,9 +40,6 @@
 #include "version.hh"
 #include "warn.hh"
 
-using std::string;
-using std::vector;
-
 /* Declaration of log function(s) */
 SCM ly_progress (SCM, SCM);
 
@@ -597,7 +595,9 @@ LY_DEFINE (ly_format, "ly:format",
   char *ptr = result;
   for (vsize i = 0; i < results.size (); i++)
     {
-      strncpy (ptr, results[i].c_str (), results[i].size ());
+      // strcpy and strncpy cannot be used here
+      // because std::string may contain '\0' in its contents.
+      results[i].copy (ptr, results[i].size ());
       ptr += results[i].size ();
     }
   *ptr = '\0';
@@ -620,7 +620,8 @@ ly_run_command (char *argv[], char **standard_output, char **standard_error)
                      standard_output, standard_error,
                      &exit_status, &error))
     {
-      fprintf (stderr, "failed (%d): %s: %s\n", exit_status, argv[0], error->message);
+      warning (_f ("g_spawn_sync failed (%d): %s: %s",
+                   exit_status, argv[0], error->message));
       g_error_free (error);
       if (!exit_status)
         exit_status = -1;
@@ -661,8 +662,14 @@ LY_DEFINE (ly_spawn, "ly:spawn",
   // Always get the pointer to the stdout/stderr messages
   int exit_status = ly_run_command (argv, &standard_output, &standard_error);
 
-  // Print out stdout and stderr only in debug mode
-  debug_output (string ("\n") + standard_output + standard_error, true);
+  if (standard_output && standard_error)
+    {
+      // Print out stdout and stderr only in debug mode
+      debug_output (string ("\n") + standard_output + standard_error, true);
+    }
+
+  g_free (standard_error);
+  g_free (standard_output);
 
   for (int i = 0; i < n; i++)
     free (argv[i]);