Fix the read/write auto-transition bugs.  Note that if we can't auto-transition, we fail the operation.  This is different than glibc's apparent behavior for writing of clearing the read buffer and still failing the write without setting the stream's error flag.
Fix the read/write auto-transition bugs.  Note that if we can't
auto-transition, we fail the operation.  This is different than glibc's
apparent behavior for writing of clearing the read buffer and still
failing the write without setting the stream's error flag.

Also, change a number of "errno = xxx" assignments to use __set_errno().

Also, change setvbuf(file, NULL, _IO{LF}BF, 0) behavior to more closely
match glibc's by keeping the current buffer and only changing the buffering
mode.  Update setlinebuf() in the process to match the man page behavior.

kraj/uclibc-ng,ysat0/uClibc,foss-xtensa/uClibc,ndmsystems/uClibc,majek/uclibc-vx32,klee/klee-uclibc,OpenInkpot-archive/iplinux-uclibc,m-labs/uclibc-lm32,brgl/uclibc-ng,mephi42/uClibc,ffainelli/uClibc,mephi42/uClibc,hjl-tools/uClibc,OpenInkpot-archive/iplinux-uclibc,ChickenRunjyd/klee-uclibc,hwoarang/uClibc,waweber/uclibc-clang,kraj/uClibc,foss-for-synopsys-dwc-arc-processors/uClibc,groundwater/uClibc,ysat0/uClibc,kraj/uclibc-ng,ChickenRunjyd/klee-uclibc,majek/uclibc-vx32,brgl/uclibc-ng,majek/uclibc-vx32,waweber/uclibc-clang,atgreen/uClibc-moxie,brgl/uclibc-ng,ysat0/uClibc,wbx-github/uclibc-ng,foss-xtensa/uClibc,ddcc/klee-uclibc-0.9.33.2,ChickenRunjyd/klee-uclibc,brgl/uclibc-ng,ffainelli/uClibc,groundwater/uClibc,groundwater/uClibc,klee/klee-uclibc,m-labs/uclibc-lm32,hjl-tools/uClibc,ffainelli/uClibc,gittup/uClibc,waweber/uclibc-clang,gittup/uClibc,czankel/xtensa-uclibc,hjl-tools/uClibc,kraj/uclibc-ng,gittup/uClibc,ndmsystems/uClibc,foss-for-synopsys-dwc-arc-processors/uClibc,m-labs/uclibc-lm32,wbx-github/uclibc-ng,waweber/uclibc-clang,ddcc/klee-uclibc-0.9.33.2,kraj/uclibc-ng,kraj/uClibc,skristiansson/uClibc-or1k,foss-for-synopsys-dwc-arc-processors/uClibc,hwoarang/uClibc,ddcc/klee-uclibc-0.9.33.2,ndmsystems/uClibc,ffainelli/uClibc,skristiansson/uClibc-or1k,ChickenRunjyd/klee-uclibc,wbx-github/uclibc-ng,ddcc/klee-uclibc-0.9.33.2,OpenInkpot-archive/iplinux-uclibc,hwoarang/uClibc,czankel/xtensa-uclibc,mephi42/uClibc,ndmsystems/uClibc,ffainelli/uClibc,kraj/uClibc,hwoarang/uClibc,ysat0/uClibc,atgreen/uClibc-moxie,hjl-tools/uClibc,OpenInkpot-archive/iplinux-uclibc,hjl-tools/uClibc,kraj/uClibc,atgreen/uClibc-moxie,skristiansson/uClibc-or1k,klee/klee-uclibc,gittup/uClibc,foss-for-synopsys-dwc-arc-processors/uClibc,wbx-github/uclibc-ng,groundwater/uClibc,groundwater/uClibc,atgreen/uClibc-moxie,mephi42/uClibc,czankel/xtensa-uclibc,foss-xtensa/uClibc,klee/klee-uclibc,m-labs/uclibc-lm32,czankel/xtensa-uclibc,skristiansson/uClibc-or1k,foss-xtensa/uClibc,majek/uclibc-vx32