Unexpected CR/LF in source file due to editor lazarus / 9-Editor ---------------------------------------------------------------------- 440bx · 2020-03-17 22:50 Hello, This is a very minor thing that doesn't usually affect anything.  Whenever a source file is edited in the Lazarus editor, the editor automatically adds an unnecessary "CR/LF" at the end of file (in Windows, I don't know what it does in other O/Ss.) Ideally, there shouldn't be anything after the "end." not even a line ending. ---------------------------------------------------------------------- winni · 2020-03-17 23:08 @440bx NO, no, no. What you want is a file where the last readln fails. It is a good standard that the last line ends with a lineEnding. Because I now know that a missing LineEnding after the last line there is always an empty line after the last end in my units. Better take care .... Btw.: There are so many failing config files in Linux that fail because of the last missing LF. Winni ---------------------------------------------------------------------- 440bx · 2020-03-17 23:21 Quote from: winni on March 18, 2020, 12:08:10 amWhat you want is a file where the last readln fails. I fully expect readln to be smart enough to realize that the end of file implies end of line. ---------------------------------------------------------------------- Thaddy · 2020-03-18 06:45 https://www.freepascal.org/docs- html/rtl/classes/tstrings.skiplastlinebreak.html As the editor's content is a Tstrings descendant this should be configurable or easy to fix. ---------------------------------------------------------------------- 440bx · 2020-03-18 07:00 Quote from: Thaddy on March 18, 2020, 07:45:30 amhttps://www.freepascal.org/docs- html/rtl/classes/tstrings.skiplastlinebreak.html As the editor's content is a Tstrings descendant this should be configurable or easy to fix. That sounds like the perfect solution.  It's a very minor thing but, in some rare cases, that extra line ending can be a nuisance. ---------------------------------------------------------------------- af0815 · 2020-03-18 07:59 Quote from: 440bx on March 18, 2020, 12:21:58 amQuote from: winni on March 18, 2020, 12:08:10 amWhat you want is a file where the last readln fails. I fully expect readln to be smart enough to realize that the end of file implies end of line. Why should readln be smart and do unwanted things? It should only read until end of line not guess. If it is configurable, it will be ok. ---------------------------------------------------------------------- PascalDragon · 2020-03-18 08:29 Quote from: af0815 on March 18, 2020, 08:59:47 amQuote from: 440bx on March 18, 2020, 12:21:58 amQuote from: winni on March 18, 2020, 12:08:10 amWhat you want is a file where the last readln fails. I fully expect readln to be smart enough to realize that the end of file implies end of line. Why should readln be smart and do unwanted things? It should only read until end of line not guess. If it is configurable, it will be ok. Because if it wouldn't detect the end of the file then the ReadLn would hang forever (like it does with StdIn if no line ending is read). And you can just as easily test it: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program tread; var  t: Text;  s: AnsiString;begin  Assign(t, ParamStr(1));  Reset(t);  while not Eof(t) do begin    Readln(t, s);    Writeln(s);  end;end. The test file: Code: [Select]test another end. (no line ending after end.) Output: Code: [Select]PS E:\fpc\git> .\testoutput\tread.exe .\fpctests\test.txt test another end.