Fix issue ROOT-7588.#84
Conversation
…reated to store cin.
|
Is there a way to interogate the stream to see if it is seekable or not? |
|
@pcanal In the function "GetNewlineValue(inputStream)", it is trying to call tellg() and seekg() functions to read the first line of the .csv file and make sure the stream goes back to the beginning position at the end of "GetNewlineValue(inputStream)". For stringstream and fstream, I can see the position of stream "inPos" increments as the characters read in. But cin always sets "inPos" as -1. |
|
Edit: inputStream.seekg(inPos) in GetNewlineValue() function the location error happened. Since cin always set inPos as -1, this function will set FailBit in inputStream and cause the error. |
|
The question I have is whether the detection of the case where we need to use the fallback solution can be improve (comparing to std::cin address might not be sufficient (and might sometimes but a false positive). |
|
Did you get a change to analyze my question about detecting the case where we need to use a fallback? Thanks, |
|
Philippe, I am not sure if I understand "fallback" correctly. But I tried two different experiments and get more solid analysis:
Anyway, I think we can either create a sstream to hold std::cin or find a new way to reserve a memory buffer for std::cin. Does this answer the question of fallback you mentioned? Regards, Zhe |
|
Hi, The patch contains if (&inputStream == &std::cin) {where rather than test on the address of std::cin, I wonder if there is a test we can make on the seek ability of inputStream. Cheers, |
d52a45e to
5d75d99
Compare
|
@pcanal I made a change. It checks if tellg() return -1 and also makes sure the stream is good. |
|
That looks right to me. Is there a test written for this? |
|
@pcanal I am writing roottest for this patch. where parseCin.sh is one line bash script When I run the test case, these two command always generate empty file. test.csv never been parsed in as an argument. How should I parse a argument? I tried MACRO_ARGS but that did not work. Thanks. |
|
Hi Zhe, Were you able to post the roottest branch to your github account so I could review your issue? Brian |
|
Sure. I was compiling the roottest directly within root. I will try to reproduce my issue with standalone roottest and upload repo to my github. Zhe
|
|
To do that - simply checkout roottest into the |
|
@pcanal - any chance to get an official mirror of roottest? It's somewhat a PITA to review contributions otherwise... |
|
@bbockelm I accidentally deleted my previous work last night. But good news is I figured out the issue I was facing when I try to reproduce my work today. |
|
Sounds good! If we're happy with the approach now and have a corresponding test ... are we ready to get this merged? @pcanal - any unaddressed issues in the ticket history? |
|
it looks good. Can you remind where to pick the roottest changes? |
|
merged into the master. Thank you very much. |
|
Could you look into this (somewhat related issues): |
|
Sure I am looking at it. |
cin is not seekable. Temporary stringstream is created to store cin.
This patch fixes the error. But I am afraid using intermediate stringstream is not an efficient way, especially it costs a lot of memory if the input file is large. Any suggestion? @bbockelm