1 c { dg-do run { target fd_truncate } }
2 c { dg-options "-std=legacy" }
4 c This program tests the fixes to PR22570.
6 c Provided by Paul Thomas - pault@gcc.gnu.org
12 open
(10, status
= "scratch")
14 c Check that lines with only x-editing followed by a slash generate
15 c spaces and that subsequent lines have spaces where they should.
17 c Line 2 has nothing but x editing, followed by a slash.
18 c Line 3 has x editing finished off by a 1h*
21 100 format (1h1
,58x
,1h
!,/,60x
,/,59x
,1h*
,/)
27 if (ichar
(a
(i
:i
)).ne
.32) call abort
()
32 if (ichar
(a
(i
:i
)).ne
.32) call abort
()
34 if (a
(60:60).ne
."*") call abort
()
37 c Check that sequences of t- and x-editing generate the correct
40 c Line 2 has tabs to the right of present position.
41 c Line 3 has tabs to the left of present position.
44 101 format (1h1
,58x
,1h#
,/,t38
,2x
,1h
,tr10
,9x
,1h$
,/,
45 > 6habcdef
,tl4
,2x
,6hghijkl
,t1
,59x
,1h*
)
51 if (ichar
(a
(i
:i
)).ne
.32) call abort
()
53 if (a
(60:60).ne
."$") call abort
()
55 if (a
(1:10).ne
."abcdghijkl") call abort
()
57 if (ichar
(a
(i
:i
)).ne
.32) call abort
()
59 if (a
(60:60).ne
."*") call abort
()
62 c Now repeat the first test, with the write broken up into three
63 c separate statements. This checks that the position counters are
64 c correctly reset for each statement.
76 if (ichar
(a
(i
:i
)).ne
.32) call abort
()
78 if (a
(60:60).ne
."$") call abort
()
81 c Next we check multiple read x- and t-editing.
82 c First, tab to the right.
85 201 format (tr10
,49x
,a1
,/,/,2x
,t60
,a1
)
86 if ((b
.ne
."#").or
.(c
.ne
."$")) call abort
()
89 c Now break it up into three reads and use left tabs.
92 202 format (10x
,tl10
,59x
,a1
)
96 204 format (10x
,t5
,55x
,a1
)
97 if ((b
.ne
."#").or
.(c
.ne
."$")) call abort
()
100 c Now, check that trailing spaces are not transmitted when we have
101 c run out of data (Thanks to Jack Howarth for finding this one:
102 c http://gcc.gnu.org/ml/fortran/2005-07/msg00395.html).
104 open
(10, pad
= "no", status
= "scratch")
107 105 format (i10
,1x
,i10
)
109 106 format ("============================")
111 read (10, 205, iostat
= ier
) i
, b
113 if ((ier
.eq
.0).or
.(ichar
(b
).ne
.0)) call abort
()
115 c That's all for now, folks!