|
From: <pl...@pi...> - 2012-05-18 21:38:11
|
On 05/18/12 22:49, Ethan A Merritt wrote: > On Friday, May 18, 2012 02:25:15 am pl...@pi... wrote: >> If you are suggesting that associating a file descriptor with a file; >> opening; reading; closing; reopening (with implies a seek(0) ) ; and >> rereading is the same as opening ; reading upto 'e' marker *in the >> data* then continuing to read the same opened device, I have to say >> your reasoning is getting a bit contrived. >> >> I find it hard to see that as being the same behaviour. > > Nevertheless, from the point of view of the program itself, or of the > programmers working on it, these cases are handled exactly the same way. > You can find the code near the top of the routine df_open() in datafile.c > > In pseudocode: > > if (*filename == '-') > data_fp = stdin; > else if (*filename == '<') > data_fp = fpopen( some piped command stored in filename ); > else > data_fp = fopen( filename ); > > Other routines then read line by line from data_fp as needed. > In two of the three cases, pipe and stdin, backing up to the beginning > in order to re-read is not possible. The code never uses fseek(). > > Ethan > stdin is already open, the other two cases call an open function. Calling fopen implicitly calls seek(0) as I pointed out earlier. How are these "the same" ? regards. |