BNFC/bnfc — pull request #86 by robstewart57 (2014-04-05 13:25:58+00:00)
Title: Strict version of 'readFile' in BNFC.Utils for Windows compatibility

The way `writeFileRep2` is implemented is incompatible with the IO handling behaviour on Windows. Specifically, the `readFile` calls on `path` and `tmp` are lazy. Later the two `renameFile` calls are unable to move files whose handles have not been closed. This only affects Windows, not Linux. Here's the error:

```
Reading grammar from XXX.cf

167 rules accepted

no change to file AbsXXX.hs
no change to file LexXXX.x
(Use Alex 3.0 to compile.)
no change to file ParXXX.y
(Tested with Happy 1.15)
no change to file DocXXX.tex
no change to file DocXXX.txt
no change to file SkelXXX.hs
no change to file PrintXXX.hs
no change to file TestXXX.hs
no change to file ErrM.hs
writing file Makefile (saving old file as Makefile.bak)

bnfc: Makefile: MoveFileEx "Makefile" "Makefile.bak": permission denied (The pro
cess cannot access the file because it is being used by another process.)
make: *** [frontend] Error 1
```

The fix is to use a `readFile` that forces the consumption of files, close the handlers, and then `renameFile` calls do not complain. The corresponding code is in the pull request.