[Unison-hackers] tiny bug: permanently ignoring path and profiles with no final end of line

Benjamin Pierce bcpierce at cis.upenn.edu
Thu May 6 08:58:22 EDT 2010


Would it be hard to just check whether the final character in the file is a newline?

    - B


On May 6, 2010, at 6:33 AM, Alan Schmitt wrote:

> I discovered this one recently: when "permanently ignoring" something,
> if the profile under consideration does not end with a newline, then
> the added preference is put at the end of the line and pollutes it.
> 
> I suggest modifying the code of Prefs.addline (line 472 of prefs.ml)
> to add an extra "\n" before the line is written.
> 
> Pro: we will always create a parsable profile from a parsable one
> Con: we will have empty lines (since we add one a newline after as well)
> 
> We could also only add the newline before, and not after. I don't know
> if it's bad practice to have files with no final newline.
> 
> This is where this is used (so the impact should be minimal):
> 
> $ grep Prefs.add *
> uicommon.ml:  let r = Prefs.add "ignore" theRegExp in
> uicommon.ml:  ignore (Prefs.add "root" r1);
> uicommon.ml:  ignore (Prefs.add "root" r2)
> uicommon.ml:      Prefs.addComment "Unison preferences file";
> uimacbridge.ml:     Prefs.addComment "Unison preferences file";
> uimacbridge.ml:  Prefs.addComment "Unison preferences file"; (*
> Creates the file, assumes it doesn't exist *)
> uimacbridge.ml:  ignore (Prefs.add "root" r1);
> uimacbridge.ml:  ignore (Prefs.add "root" r2);;
> uimacbridgenew.ml:     Prefs.addComment "Unison preferences file";
> uimacbridgenew.ml:  Prefs.addComment "Unison preferences file"; (*
> Creates the file, assumes it doesn't exist *)
> uimacbridgenew.ml:  ignore (Prefs.add "root" r1);
> uimacbridgenew.ml:  ignore (Prefs.add "root" r2);;
> 
> Thoughts?
> 
> Alan
> _______________________________________________
> Unison-hackers mailing list
> Unison-hackers at lists.seas.upenn.edu
> http://lists.seas.upenn.edu/mailman/listinfo/unison-hackers



More information about the Unison-hackers mailing list