comparison libinterp/corefcn/graphics.cc @ 21214:7be1f58f9dd7

don't strip pipe character from command in drawnow function * graphics.cc (Fdrawnow): Don't strip pipe character in command before passing to toolkit print function. Only check first character in command string for pipe character.
author John W. Eaton <jwe@octave.org>
date Sun, 07 Feb 2016 02:03:58 -0500
parents 67d2965af0b5
children cf2eae837cc8
comparison
equal deleted inserted replaced
21213:f7d1050b9b53 21214:7be1f58f9dd7
10761 10761
10762 term = args(0).xstring_value ("drawnow: TERM must be a string"); 10762 term = args(0).xstring_value ("drawnow: TERM must be a string");
10763 10763
10764 file = args(1).xstring_value ("drawnow: FILE must be a string"); 10764 file = args(1).xstring_value ("drawnow: FILE must be a string");
10765 10765
10766 size_t pos_p = file.find_first_of ("|"); 10766 if (file.empty ())
10767 size_t pos_c = file.find_first_not_of ("| ");
10768
10769 if (pos_p == std::string::npos &&
10770 pos_c == std::string::npos)
10771 error ("drawnow: empty output ''"); 10767 error ("drawnow: empty output ''");
10772 else if (pos_c == std::string::npos) 10768 else if (file.length () == 1 && file[0] == '|')
10773 error ("drawnow: empty pipe '|'"); 10769 error ("drawnow: empty pipe '|'");
10774 else if (pos_p != std::string::npos && pos_p < pos_c) 10770 else if (file[0] != '|')
10775 {
10776 // Strip leading pipe character
10777 file = file.substr (pos_c);
10778 }
10779 else
10780 { 10771 {
10781 size_t pos = file.find_last_of (file_ops::dir_sep_chars ()); 10772 size_t pos = file.find_last_of (file_ops::dir_sep_chars ());
10782 10773
10783 if (pos != std::string::npos) 10774 if (pos != std::string::npos)
10784 { 10775 {
10785 std::string dirname = file.substr (pos_c, pos+1); 10776 std::string dirname = file.substr (0, pos+1);
10786 10777
10787 file_stat fs (dirname); 10778 file_stat fs (dirname);
10788 10779
10789 if (! fs || ! fs.is_dir ()) 10780 if (! fs || ! fs.is_dir ())
10790 error ("drawnow: nonexistent directory '%s'", 10781 error ("drawnow: nonexistent directory '%s'",