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

Alan Schmitt alan.schmitt at polytechnique.org
Thu May 6 06:33:13 EDT 2010


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


More information about the Unison-hackers mailing list