[PATCH, fortran] Simplify constant substrings
David Edelsohn
dje@watson.ibm.com
Fri Jul 22 16:29:00 GMT 2005
>>>>> 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
primary.c:match_string_constant() does.
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[2] and
has length 10-2=8. Or did I misunderstand the Fortran internals?
Thanks, David
More information about the Fortran
mailing list