Reply to post: (((buf[idx] == '\n') && ((idx == 0) || (buf[idx-1] != '\r'))) || (buf[idx] == '\r'))

Windows Notepad fixed after 33 years: Now it finally handles Unix, Mac OS line endings

Kevin McMurtrie Silver badge
Trollface

(((buf[idx] == '\n') && ((idx == 0) || (buf[idx-1] != '\r'))) || (buf[idx] == '\r'))

Handling three types of line endings requires one character of look-back. And with one character of look-back, you have to make sure you don't look at index -1 if the first character is a LF. That's complicated stuff for the poor new hire that has to work on the default text editor. Look at all those parenthesis! I don't even know if I got it right. Now, 33 years later, there's Stack Overflow.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon