summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0203-2011-04-30-Jerry-DeLisle-jvdelisle-gcc.gnu.org.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0203-2011-04-30-Jerry-DeLisle-jvdelisle-gcc.gnu.org.patch')
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0203-2011-04-30-Jerry-DeLisle-jvdelisle-gcc.gnu.org.patch108
1 files changed, 108 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0203-2011-04-30-Jerry-DeLisle-jvdelisle-gcc.gnu.org.patch b/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0203-2011-04-30-Jerry-DeLisle-jvdelisle-gcc.gnu.org.patch
new file mode 100644
index 0000000000..64b882f0c8
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0203-2011-04-30-Jerry-DeLisle-jvdelisle-gcc.gnu.org.patch
@@ -0,0 +1,108 @@
1From fe8fe654371824f9121e248a30204bfad7433aba Mon Sep 17 00:00:00 2001
2From: jvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>
3Date: Sat, 30 Apr 2011 15:24:57 +0000
4Subject: [PATCH] 2011-04-30 Jerry DeLisle <jvdelisle@gcc.gnu.org>
5
6 Backport from mainline:
7 PR libgfortran/48030
8 * io/read.c (read_x): Re-implement using fbuf_getc.
9
10
11git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@173218 138bc75d-0d04-0410-961f-82ee72b054a4
12
13index 50b1b40..4eda4a2 100644
14--- a/libgfortran/io/read.c
15+++ b/libgfortran/io/read.c
16@@ -1117,8 +1117,7 @@ bad_float:
17 void
18 read_x (st_parameter_dt *dtp, int n)
19 {
20- int length;
21- char *p, q;
22+ int length, q, q2;
23
24 if ((dtp->u.p.current_unit->pad_status == PAD_NO || is_internal_unit (dtp))
25 && dtp->u.p.current_unit->bytes_left < n)
26@@ -1131,7 +1130,7 @@ read_x (st_parameter_dt *dtp, int n)
27
28 if (is_internal_unit (dtp))
29 {
30- p = mem_alloc_r (dtp->u.p.current_unit->s, &length);
31+ mem_alloc_r (dtp->u.p.current_unit->s, &length);
32 if (unlikely (length < n))
33 n = length;
34 goto done;
35@@ -1140,55 +1139,37 @@ read_x (st_parameter_dt *dtp, int n)
36 if (dtp->u.p.sf_seen_eor)
37 return;
38
39- p = fbuf_read (dtp->u.p.current_unit, &length);
40- if (p == NULL)
41- {
42- hit_eof (dtp);
43- return;
44- }
45-
46- if (length == 0 && dtp->u.p.item_count == 1)
47- {
48- if (dtp->u.p.current_unit->pad_status == PAD_NO)
49- {
50- hit_eof (dtp);
51- return;
52- }
53- else
54- return;
55- }
56-
57 n = 0;
58 while (n < length)
59 {
60- q = *p;
61- if (q == '\n' || q == '\r')
62+ q = fbuf_getc (dtp->u.p.current_unit);
63+ if (q == EOF)
64+ break;
65+ else if (q == '\n' || q == '\r')
66 {
67 /* Unexpected end of line. Set the position. */
68- fbuf_seek (dtp->u.p.current_unit, n + 1 ,SEEK_CUR);
69 dtp->u.p.sf_seen_eor = 1;
70
71+ /* If we see an EOR during non-advancing I/O, we need to skip
72+ the rest of the I/O statement. Set the corresponding flag. */
73+ if (dtp->u.p.advance_status == ADVANCE_NO || dtp->u.p.seen_dollar)
74+ dtp->u.p.eor_condition = 1;
75+
76 /* If we encounter a CR, it might be a CRLF. */
77 if (q == '\r') /* Probably a CRLF */
78 {
79- /* See if there is an LF. Use fbuf_read rather then fbuf_getc so
80- the position is not advanced unless it really is an LF. */
81- int readlen = 1;
82- p = fbuf_read (dtp->u.p.current_unit, &readlen);
83- if (*p == '\n' && readlen == 1)
84- {
85- dtp->u.p.sf_seen_eor = 2;
86- fbuf_seek (dtp->u.p.current_unit, 1 ,SEEK_CUR);
87- }
88+ /* See if there is an LF. */
89+ q2 = fbuf_getc (dtp->u.p.current_unit);
90+ if (q2 == '\n')
91+ dtp->u.p.sf_seen_eor = 2;
92+ else if (q2 != EOF) /* Oops, seek back. */
93+ fbuf_seek (dtp->u.p.current_unit, -1, SEEK_CUR);
94 }
95 goto done;
96 }
97 n++;
98- p++;
99 }
100
101- fbuf_seek (dtp->u.p.current_unit, n, SEEK_CUR);
102-
103 done:
104 if ((dtp->common.flags & IOPARM_DT_HAS_SIZE) != 0)
105 dtp->u.p.size_used += (GFC_IO_INT) n;
106--
1071.7.0.4
108