[Insight-developers] TransformFileReader endless loop
kent williams
norman-k-williams at uiowa.edu
Mon Feb 18 10:46:51 EST 2008
I think you may be right; the only reason no one else noticed this problem
is that in general, no one else tried to load a file other than one written
by itkTranformFileWriter.
I'll test it and check it in if there are no regressions.
On 2/18/08 7:54 AM, "Tomáš Kazmar" <Tomash.Kazmar at seznam.cz> wrote:
> Hi all,
>
> I think there is a bug in itkTransformFileReader which causes an endless
> loop when the input file does not end with an empty new line. A value returned
> from a call to std::string::find() should be checked properly for
> std::string::npos,
> there should be something like the following:
>
> while ( position < data.size() )
> {
> // Find the next string
> std::string::size_type end = data.find ( "\n", position );
> if (end == std::string::npos) {
> end = data.size()-1;
> }
> std::string line = trim ( data.substr ( position, end - position ) );
> position = end+1;
>
> patch:
> 114a115,117
>> if (end == std::string::npos) {
>> end = data.size()-1;
>> }
>
> Another option is to add newline at the end of the buffer before the loop
> starts.
>
> Regards,
> Tomas
> _______________________________________________
> Insight-developers mailing list
> Insight-developers at itk.org
> http://www.itk.org/mailman/listinfo/insight-developers
More information about the Insight-developers
mailing list