> On Oct 28, 2013, at 2:20 PM, Manav Bhatia <[email protected]> wrote:
> 
> 
> 
>> On Mon, Oct 28, 2013 at 2:53 PM, John Peterson <[email protected]> wrote:
>> 
>> 
>> One possible problem I can see with the getpot code: is it legal C++ to call 
>> unget() immediately after a call to seekg or is it possibly invoking 
>> undefined behavior?
>  
>  
> The purpose of unget() seems to be to decrease position of istream by one 
> character (http://www.cplusplus.com/reference/istream/istream/unget/), so I 
> don't see why this would be illegal, unless you are already at the beginning 
> of the stream (?).

I'm not sure what actually happens under the hood when you call stream.unget(). 
 Presumably something different than merely stream.seekg(-1, cur) as you seem 
to imply.


>> Second: I'm not sure I even understand the logic of what's going on here.  
>> You save "Pos", then if the current character is _not_ a comment character, 
>> seekg(Pos) and immediately call istr.unget().  I don't see the point of 
>> tellg()/seekg() here because you could not have moved the cursor in the 
>> interim.  I commented out these lines and it fixed my test code and 
>> adjoints_ex3.  I'm running the rest of the libmesh examples now and will 
>> commit if they all pass.
> Are you sure it is reading the parameters from the input file and not just 
> assigning the default values?
>  
> Pos is the position of the first character of the parameter. So, if it 
> intends to go the beginning of the parameter, then it has to decrease its 
> position by one character. For example, if the input parameter is "val", then 
> the output of { istr.seekg(Pos);  std::cout << "istr" <<std::endl; }   would 
> be "al", and the output of {  istr.seekg(Pos); istr.unget();  std::cout << 
> "istr" <<std::endl; } would be "val".

Note that we are still calling unget().  The only thing I removed was an 
(apparently) redundant tellg/seekg pairing...


>> Would you and Subramanya mind testing apple clang again after I patch getpot 
>> and let me know if it works for you? 
>  
>  
> I will be glad to test.
>  
> -Manav
>  
> 
------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
_______________________________________________
Libmesh-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmesh-users

Reply via email to