This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[UTIL] Perl system does not default to $_
[metaconfig.git] / dist / U / d_nolnbuf.U
1 ?RCS: $Id: d_nolnbuf.U 1 2006-08-24 12:32:52Z rmanfredi $
2 ?RCS:
3 ?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
4 ?RCS: 
5 ?RCS: You may redistribute only under the terms of the Artistic Licence,
6 ?RCS: as specified in the README file that comes with the distribution.
7 ?RCS: You may reuse parts of this distribution only within the terms of
8 ?RCS: that same Artistic Licence; a copy of which may be found at the root
9 ?RCS: of the source tree for dist 4.0.
10 ?RCS:
11 ?RCS: $Log: d_nolnbuf.U,v $
12 ?RCS: Revision 3.0.1.1  1994/05/06  14:46:07  ram
13 ?RCS: patch23: avoid looping in the "see that again?" prompt (WED)
14 ?RCS:
15 ?RCS: Revision 3.0  1993/08/18  12:06:43  ram
16 ?RCS: Baseline for dist 3.0 netwide release.
17 ?RCS:
18 ?MAKE:d_nolnbuf: test +cc cat rm Setvar Myread
19 ?MAKE:  -pick add $@ %<
20 ?S:d_nolnbuf:
21 ?S:     This variable conditionally defines the NOLINEBUF symbol, which
22 ?S:     indicates to the C program that stdout is not buffered, so that
23 ?S:     the program can call setbuf() or setlinebuf() for efficiency.
24 ?S:.
25 ?C:NOLINEBUF:
26 ?C:     This symbol, if defined, indicates that stdout is not buffered, so that
27 ?C:     the program can call setbuf() or setlinebuf() for efficiency.
28 ?C:.
29 ?H:#$d_nolnbuf  NOLINEBUF       /**/
30 ?H:.
31 ?T:xxx
32 ?F:!blurfl
33 ?LINT:set d_nolnbuf
34 : check for buffering of stdout
35 echo " "
36 case "$d_nolnbuf" in
37 '')
38         $cat <<'EOT' >blurfl.c
39 #include <stdio.h>
40 int main()
41 {
42         int i;
43
44         for (i = 0; i < 5; i++) {
45                 putchar(i+'a');
46                 sleep(1);
47         }
48         putchar('\n');
49 }
50 EOT
51         $cc -o blurfl blurfl.c >/dev/null 2>&1;
52         $rm -f blurfl.c
53         $cat >&4 <<'EOM'
54 Checking for buffering of stdout to terminal.
55
56 Observe the following characters as they are printed out, to see whether they
57 print out all at once, or with a 1 second pause between each of them.  If they
58 print out one by one, you don't have buffering.  If they print together (after
59 about a 5 second pause), you do have buffering.
60
61 EOM
62         dflt='Type return to start printing the test characters'
63         rp=''
64         . ./myread
65         xxx=y
66         while $test "$xxx" = 'y'; do
67                 ./blurfl 1>&4
68                 dflt=n
69                 rp='Would you like to see that again?'
70                 . ./myread
71                 case "$ans" in
72                 [yY]*) xxx="y";;
73                 *) xxx="n";;
74                 esac
75         done
76         dflt=y
77         rp="Do you have buffering (printed all at once)?"
78         . ./myread
79         case "$ans" in
80         n*) val="$define";;
81         *)  val="$undef";;
82         esac
83         ;;
84 *)
85         case "$d_nolnbuf" in
86         "$define") dflt=n;;
87         *) dflt=y;;
88         esac
89         rp="Do you have buffering on stdout to terminals?"
90         . ./myread
91         case "$ans" in
92         n*) val="$define";;
93         *)  val="$undef";;
94         esac
95         ;;
96 esac
97 set d_nolnbuf
98 eval $setvar
99