This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH, fortran] Simplify constant substrings
- From: David Edelsohn <dje at watson dot ibm dot com>
- To: Steven Bosscher <stevenb at suse dot de>
- Cc: fortran at gcc dot gnu dot org, Paul Brook <paul at codesourcery dot com>, gcc-patches at gcc dot gnu dot org
- Date: Fri, 22 Jul 2005 12:29:24 -0400
- Subject: Re: [PATCH, fortran] Simplify constant substrings
- References: <200507220453.j6M4rCd26890@makai.watson.ibm.com> <firstname.lastname@example.org>
>>>>> Steven Bosscher writes:
Steven> In a number of places we add an extra '\0' at the end of the string
Steven> value for debugging purposes. That would mean for your patch, if we
Steven> want to be consistent with, well, everywhere else in gfortran, that
Steven> you'd have to add the extra '\0' too:
Steven> However, Paul dislikes the idea of the extra '\0'. I think that if
Steven> we are going to drop it here, then we should drop it everywhere else
Steven> too. But I actually think the extra '\0' is useful because it allows
Steven> you to print value.character.string from gdb.
Steven> Thoughs, anyone?
I was trying to follow the implementation in
data.c:create_character_initializer(). That function does not appear to
append a NULL terminator to the string, although
My patch does need to allocate an extra byte if the string should
have a NULL terminator. "start--" sets the correct beginning of the C
zero-based array of characters relative to Fortran one-based numbering.
"end-start" is the length of the active Fortran string without the NULL
terminator. Position "end" is never referenced directly. For example,
Fortran string str(3:10) begins at C array value.character.string and
has length 10-2=8. Or did I misunderstand the Fortran internals?