octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #55648] [MXE-Octave] cannot print with gnuplot


From: Dan Sebald
Subject: [Octave-bug-tracker] [bug #55648] [MXE-Octave] cannot print with gnuplot graphics toolkit
Date: Tue, 12 Feb 2019 02:01:06 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0

Follow-up Comment #16, bug #55648 (project octave):

To me, the code hunk in Comment #10 looks poorly constructed, almost bound to
be an infinite loop depending on one's system speed, CPU load, etc.  Calling
fclear(istream) could easily clear out the next string of characters that
would represent a gnuplot output or partial gnuplot output (depending on how
fread() waits/returns).  If that stream gets cleared after the next valid 
character string is available then str will be empty from then on:


      while (isempty (str))
        str = fread (istream, "*char")';  % NOT AVAILABLE FROM GNUPLOT
IMMEDIATELY
        if (isempty (str))
          pause (0.05);                   % ARRIVES FROM GNUPLOT WITHIN THIS
TIME FRAME
        else
          str = regexp (str, 'OCTAVE:.*', "match");
          str = str{end}(8:end);
        endif
        fclear (istream);                 % GETS CLEARED AND ISTREAM IS EMPTY
FROM HERE OUT
      endwhile


I think the hunk of code at line 95 of ___gnuplot_get_var___ is a slightly
better approach in that it reads until adequate characters are present (like a
small buffer) and then treats that small buffer of characters as the return
result.  Markus, can you devise a changeset more along those lines?  (I don't
know MXE very well.)  Also, there really should be some kind of timer/timeout
tied to this loop so that there is no hang if gnuplot can't interpret the
command or crashes when executing the command.  E.g.,


      str = [];
      time0 = time();
      while (time() - time0 < 10)
        cval = fread (istream, 1, "*char")';
        if (! isempty (cval))
          str = strcat(str, cval);
        elseif (cval == SOME_END_OF_STRING_SYMBOL)
          str = regexp (str, 'OCTAVE:.*', "match");
          str = str{end}(8:end);
          break;
        else
          pause (0.05);
        endif
      endwhile



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?55648>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]