Standardise line endings to LF

The codebase was inconsistent in its line endings, with some CRLF and some LF-only. This commit standardises the line endings with the replacement of all CRLF line endings with LF, and also cleans up all trailing whitespace. No functionality is affected.

Note that this is a big change because so much of the codebase is affected, and may increase the difficulty of merging work made before this commit.

These changes are automatic: the result of running the sed scripts:

```bash
sed -i -z 's/\r\n/\n/g'
sed -i 's/\s\+$//'
```

The trailing whitespace is less important than the line-endings, but as both are big changes it seems sensible to attempt both at once, and only have one 'big-change' point.