C99/POSIX cleanup

* Compile only some files with -D_XOPEN_SOURCE
* Introduce CMake functions to selectively
  provide -D_XOPEN_SOURCE if needed
* Tell flex it gets only non-interactive input
* Move SIGWINCH code to a separate file
* Reduce POSIX dependencies in some easiest cases