2004-07-19 Stepan Kasal * src/ed.c (print_ed_hunk): If there is a need to leave insert mode to create a line with just a dot, do not re-enter the insert mode immediately--[erhaps this was the last line of the change. (pr_forward_ed_script): Add a comment explainning that the output may be ambiguous. diff -urp diffutils-2.8.7/src/ed.c diffutils-2.8.7.work/src/ed.c --- diffutils-2.8.7/src/ed.c 2004-04-12 09:44:35.000000000 +0200 +++ diffutils-2.8.7.work/src/ed.c 2004-07-19 11:03:07.000000000 +0200 @@ -61,27 +61,37 @@ print_ed_hunk (struct change *hunk) if (changes != OLD) { lin i; + bool insert_mode = true; /* In most cases, this will stay true. */ + for (i = f1; i <= l1; i++) { + if (!insert_mode) + { + fprintf (outfile, "a\n"); + insert_mode = true; + } if (files[1].linbuf[i][0] == '.' && files[1].linbuf[i][1] == '\n') { /* The file's line is just a dot, and it would exit insert mode. Precede the dot with another dot, exit - insert mode, remove the extra dot, and then resume - insert mode. */ - fprintf (outfile, "..\n.\ns/.//\na\n"); + insert mode and remove the extra dot. */ + fprintf (outfile, "..\n.\ns/.//\n"); + insert_mode = false; } else print_1_line ("", &files[1].linbuf[i]); } - fprintf (outfile, ".\n"); + if (insert_mode) + fprintf (outfile, ".\n"); } } /* Print change script in the style of ed commands, but print the changes in the order they appear in the input files, - which means that the commands are not truly useful with ed. */ + which means that the commands are not truly useful with ed. + Because of the issue with lines containing just a dot, the output + is not even parseable. */ void pr_forward_ed_script (struct change *script)