[ET Trac] [Einstein Toolkit] #103: Handle parameter files with DOS newline convention

Einstein Toolkit trac-noreply at einsteintoolkit.org
Thu Dec 30 09:56:47 CST 2010

#103: Handle parameter files with DOS newline convention
  Reporter:  eschnett  |       Owner:     
      Type:  defect    |      Status:  new
  Priority:  minor     |   Milestone:     
 Component:  Cactus    |     Version:     
Resolution:            |    Keywords:     

Comment (by hinder):

 I think the problem is in the function src/ParseFile.c:ParseDefines() on
 the line

       /* Look for the end of the define name */
       if (c == '}' || c == '\0' || c == '\n')

 which assumes that the end of the define will be a \n whereas for a DOS
 file it will be \r\n.  However, this code is so hairy that I don't want to
 just add in an extra conditional || c == '\r' as I'm not 100% sure that
 this is correct.

 Instead, I have added a function to convert the entire parameter file
 buffer to Unix convention when it is read in, as this seems the safest
 thing to do.  There might also be other parts of the code which assume the
 Unix convention.

 Try the attached patch - it fixes the problem for me.

 There is one possible issue with the patch which is that I use strlen to
 find the size of the buffer.  This assumes that the buffer doesn't contain
 a \0 character, but from the looks of the code this is already assumed (in
 fact a \0 is explicitly added to the end of the buffer to ensure the
 buffer can be treated as a string) so I think this is OK.

Ticket URL: <https://trac.einsteintoolkit.org/ticket/103#comment:2>
Einstein Toolkit <http://einsteintoolkit.org>
The Einstein Toolkit

More information about the Trac mailing list