OLD | NEW |
1 /* | 1 /* |
2 This file is part of LilyPond, the GNU music typesetter. | 2 This file is part of LilyPond, the GNU music typesetter. |
3 | 3 |
4 Copyright (C) 1998--2019 Jan Nieuwenhuizen <janneke@gnu.org> | 4 Copyright (C) 1998--2019 Jan Nieuwenhuizen <janneke@gnu.org> |
5 Han-Wen Nienhuys <hanwen@xs4all.nl> | 5 Han-Wen Nienhuys <hanwen@xs4all.nl> |
6 | 6 |
7 LilyPond is free software: you can redistribute it and/or modify | 7 LilyPond is free software: you can redistribute it and/or modify |
8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
9 the Free Software Foundation, either version 3 of the License, or | 9 the Free Software Foundation, either version 3 of the License, or |
10 (at your option) any later version. | 10 (at your option) any later version. |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 | 633 |
634 LY_DEFINE (ly_spawn, "ly:spawn", | 634 LY_DEFINE (ly_spawn, "ly:spawn", |
635 1, 0, 1, (SCM command, SCM rest), | 635 1, 0, 1, (SCM command, SCM rest), |
636 "Simple interface to g_spawn_sync" | 636 "Simple interface to g_spawn_sync" |
637 " @var{str}." | 637 " @var{str}." |
638 " The error is formatted with @code{format} and @var{rest}.") | 638 " The error is formatted with @code{format} and @var{rest}.") |
639 | 639 |
640 { | 640 { |
641 LY_ASSERT_TYPE (scm_is_string, command, 1); | 641 LY_ASSERT_TYPE (scm_is_string, command, 1); |
642 | 642 |
643 int argc = scm_is_pair (rest) ? scm_ilength (rest) : 0; | 643 long argc = scm_is_pair (rest) ? scm_ilength (rest) : 0; |
644 char **argv = new char*[argc + 2]; | 644 char **argv = new char*[argc + 2]; |
645 | 645 |
646 int n = 0; | 646 int n = 0; |
647 argv[n++] = ly_scm2utf8 (command); | 647 argv[n++] = ly_scm2utf8 (command); |
648 for (SCM s = rest; scm_is_pair (s); s = scm_cdr (s)) | 648 for (SCM s = rest; scm_is_pair (s); s = scm_cdr (s)) |
649 argv[n++] = ly_scm2utf8 (scm_car (s)); | 649 argv[n++] = ly_scm2utf8 (scm_car (s)); |
650 argv[n] = 0; | 650 argv[n] = 0; |
651 | 651 |
652 char *standard_output = 0; | 652 char *standard_output = 0; |
653 char *standard_error = 0; | 653 char *standard_error = 0; |
654 // Always get the pointer to the stdout/stderr messages | 654 // Always get the pointer to the stdout/stderr messages |
655 int exit_status = ly_run_command (argv, &standard_output, &standard_error); | 655 int exit_status = ly_run_command (argv, &standard_output, &standard_error); |
656 | 656 |
657 if (standard_output && standard_error) | 657 if (standard_output && standard_error) |
658 { | 658 { |
659 // Print out stdout and stderr only in debug mode | 659 // Print out stdout and stderr only in debug mode |
660 debug_output (string ("\n") + standard_output + standard_error, true); | 660 debug_output (string ("\n") + standard_output + standard_error, true); |
661 } | 661 } |
662 | 662 |
663 g_free (standard_error); | 663 g_free (standard_error); |
664 g_free (standard_output); | 664 g_free (standard_output); |
665 | 665 |
666 for (int i = 0; i < n; i++) | 666 for (int i = 0; i < n; i++) |
667 free (argv[i]); | 667 free (argv[i]); |
668 delete[] argv; | 668 delete[] argv; |
669 | 669 |
670 return scm_from_int (exit_status); | 670 return scm_from_int (exit_status); |
671 } | 671 } |
OLD | NEW |