Two of Eef's bugs, was: Re: gfortran
Steven Bosscher
stevenb.gcc@gmail.com
Sat Dec 23 21:48:00 GMT 2006
On Friday 22 December 2006 16:19, Tobias Schlüter wrote:
> Anyway, in the course of our off-list discussion he pointed out two
> bugs: the first is now the embarassing PR30278
I think the attached patch shows what the fix should look like. I'm not
100% sure if this is right, though. I've asked PaulT and Steve for their
opinions, but I might as well post it here in the mean time.
$ cat t.f
call wrt('\\backslash')
write (*,200)
stop
200 format ('\\backslash now results in \\backslash')
end
subroutine wrt(a)
character*(*) a
lena = len(a)
write(*,*) 'results in: ', a(1:lena)
return
end
$ g77-hammer t.f -static
$ ./a.out
results in: \backslash
\backslash now results in \backslash
$ /opt/experimental/bin/gfortran-20061223-PR30278 t.f -static
$ ./a.out
results in: \backslash
\backslash now results in \backslash
$
$
$ g77-hammer t.f -static -fno-backslash
$ ./a.out
results in: \\backslash
\\backslash now results in \\backslash
$ /opt/experimental/bin/gfortran-20061223-PR30278 t.f -static -fno-backslash
$ ./a.out
results in: \\backslash
\\backslash now results in \\backslash
$
It's a bit of copy-and-paste from a similar function in primary.c. We
should probably make the two functions share some code (into a function
maybe_escaped_character or something...).
Gr.
Steven
* io.c (next_char): Handle escaped characters if flag_backslash.
Index: io.c
===================================================================
--- io.c (revision 120167)
+++ io.c (working copy)
@@ -137,11 +137,49 @@ next_char (int in_string)
c = gfc_next_char_literal (in_string);
if (c == '\n')
c = '\0';
+ }
+
+ if (gfc_option.flag_backslash && c == '\\')
+ {
+ locus old_locus = gfc_current_locus;
+
+ switch (gfc_next_char_literal (1))
+ {
+ case 'a':
+ c = '\a';
+ break;
+ case 'b':
+ c = '\b';
+ break;
+ case 't':
+ c = '\t';
+ break;
+ case 'f':
+ c = '\f';
+ break;
+ case 'n':
+ c = '\n';
+ break;
+ case 'r':
+ c = '\r';
+ break;
+ case 'v':
+ c = '\v';
+ break;
+ case '\\':
+ c = '\\';
+ break;
- if (mode == MODE_COPY)
- *format_string++ = c;
+ default:
+ /* Unknown backslash codes are simply not expanded. */
+ gfc_current_locus = old_locus;
+ break;
+ }
}
+ if (mode == MODE_COPY)
+ *format_string++ = c;
+
c = TOUPPER (c);
return c;
}
More information about the Fortran
mailing list