1 /* Test of yesno module.
2 Copyright (C) 2007-2008 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
28 #include "binary-io.h"
32 /* Test yesno. Without arguments, read one line. If first argument
33 is zero, close stdin before attempting to read one line.
34 Otherwise, read the number of lines specified by first
37 main (int argc, char **argv)
40 program_name = argv[0];
42 /* yesno recommends that all clients use close_stdin in main. */
44 /* But on mingw, close_stdin leaves stdin's file descriptor at the expected
45 position (i.e. where this program left off reading) only if its mode has
46 been set to O_BINARY. If it has been set to O_TEXT, and the file
47 descriptor is seekable, and stdin is buffered, the MSVCRT runtime ends up
48 setting the file descriptor's position to the expected position _minus_
49 the number of LFs not preceded by CR that were read between the expected
50 position and the last filled buffer end position. (I.e. the repositioning
51 from the end-of-buffer to the expected position does not work if the input
52 file contains end-of-line markers in Unix convention.) */
63 puts (yesno () ? "Y" : "N");