You need to learn how to use git diff (to produce patches), and git format patch (to produce formated patches).... Yet better, learn how to submit code directly to openocd tracking system. (its not that hard and you get proper credit)
Just be sure that the code does not break anything.
BP was sending data as reply to some command, and the command finished. BP was in the middle of tap_shift function, and still is there.
For the first flushing would suffice.
For the second case, there almost no real solution. You need to finish the sending of the tap data to end this function. (up to 2kb of data that needs to be sent). There is no side channel on which you can signal BP to restart (its a serial port). Using RTS/DTR could work, but not universal for all states in which BP can be. (user could have BP that is in transparent bridge mode, RTS DTR are ignored or else). For BPv4 it would be possible to send some "control usb packet" to reset buspirate, this would also need fw support. (and would no be compatible with BPv3)
for windows you should define something like "WIN32", so it switches to Windows' serial port handling routines.
There is a project for Codeblocks and it has not been updated for the very recent versions. Also note that you need fairly new firmware in buspirate, so that pic24 writing is supported. (6.2 and newer?)
I have tested bpv4 writing and reading, but havent played with piratepicprog since (that is almost year ago). But i doubt anyone touched it :) so it should be working.