| 
      
      
      From: Ethan M. <merritt@u.washington.edu> - 2006-03-08 21:00:18
      
     | 
| On Tuesday 07 March 2006 02:44 pm, Petr Mikulik wrote:
> > Then it needs yet another routine pipeexist().
>
> So, now there are (patch enclosed) both
>    fileexist(s)
> which detects regular files, and
>    pipeexist(s) which returns 1 for "-" and 1/0 whether it is a pipe
> wherefrom you can read at least 1 byte; 
Huh?  But that is quite broken.  If you read from that data source,
even 1 byte, then you have poisoned it for actual plotting.
That's no good.  This is a *pipe*, not a file.  You cannot 
necessarily go back to the beginning and read that byte a
second time.
> that's because: 
> > Trimmed from lines 1240-1280 of datafile.c:
> > ===================================================================
> >====== /* filename cannot be static array! */
> >    gp_expand_tilde(&df_filename);
>
> This line makes sense only for regular files and thus it should be
> moved to just above the "stat" function.
>
> >    /*{{{  open file */
> >    if (*df_filename == '<') {
> >        if ((data_fp = popen(df_filename + 1, "r")) == (FILE *)
> > NULL) os_error(name_token, "cannot create pipe for data");
>
> This will never work.
??? 
But this is what the code does *now*.
Are you saying that the current pipe code doesn't work for you?
> The truth is that popen() "never" returns NULL 
> (contrary to specification) -- at least for OS/2, Windows, Linux.
On linux it returns NULL if the pipe open fails.
OK, that's almost never, unless you have exceeded your quota for
open files. That is different from the case where the pipe is opened
but nothing can be read.
>
> gnuplot> plot '<bla'
> sh: bla: command not found
This is the correct error message.
There is no command "bla", so you cannot pipe its output.
> gnuplot> plot '<bla'
>                      ^
>           no data point found in specified file
>
> The last message seems to be the most proper one, while "sh: bla:
> command not found" is something unwanted.
On the contrary.  The pipe failed because there is no such command,
and that is the most enlightening error message.   
"no data point..." would be correct if the pipe was successfully opened, 
but the data stream contained no valid points.  That can happen also,
but it is a separate error.
Anyhow, my main point is that an   xxx_exists()  routine should be
exactly parallel to the routine used for actual data input.  Otherwise
you cannot trust the result as an indication of whether you will or
will not be able to plot it.   Thus it should handle both files and 
pipes, because the data input routine handles both files and pipes.
-- 
Ethan A Merritt
Biomolecular Structure Center
University of Washington, Seattle WA
 |