changeset 19909:6b7aee95c54c

Test directly for '|' character at front of drawnow "file". * graphics.cc (drawnow): Test directly for '|' character at front of drawnow "file". * __osmesa_print__.c: Test directly for '|' character at front of drawnow "file".
author Rik <rik@octave.org>
date Fri, 27 Feb 2015 16:29:14 -0800
parents 5261186f1b00
children 2f2220bfd379
files libinterp/corefcn/graphics.cc libinterp/dldfcn/__osmesa_print__.cc
diffstat 2 files changed, 5 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/graphics.cc	Fri Feb 27 15:53:42 2015 -0800
+++ b/libinterp/corefcn/graphics.cc	Fri Feb 27 16:29:14 2015 -0800
@@ -11069,12 +11069,11 @@
 
               if (! error_state)
                 {
-                  size_t pos = file.find_first_not_of ("|");
-                  if (pos != std::string::npos)
-                    file = file.substr (pos);
+                  if (! file.empty () && file[0] == '|')
+                    file = file.substr (1);  // Strip leading pipe character
                   else
                     {
-                      pos = file.find_last_of (file_ops::dir_sep_chars ());
+                      size_t pos = file.find_last_of (file_ops::dir_sep_chars ());
 
                       if (pos != std::string::npos)
                         {
--- a/libinterp/dldfcn/__osmesa_print__.cc	Fri Feb 27 15:53:42 2015 -0800
+++ b/libinterp/dldfcn/__osmesa_print__.cc	Fri Feb 27 16:29:14 2015 -0800
@@ -182,11 +182,10 @@
 
       if (! error_state)
         {
-          size_t pos = file.find_first_not_of ("|");
-          if (pos != std::string::npos)
+          if (! file.empty () && file[0] == '|')
             {
               // create process and pipe gl2ps output to it
-              std::string cmd = file.substr (pos);
+              std::string cmd = file.substr (1);
               gl2ps_print (fobj, cmd, term);
             }
           else