[PATCH, gfortran] Fix trailing whitespace in getenv ...
Janne Blomqvist
jblomqvi@cc.hut.fi
Tue Aug 31 06:11:00 GMT 2004
On Mon, Aug 30, 2004 at 02:05:28PM -0700, Steve Kargl wrote:
> The attached patch removes trailing whitespace from the
> the variable NAME prior to the call to getenv.
A big thanks to Steve for volunteering to clean up my mess.
> BTW, g77
> can't handle an environmental variable with a space in the
> variable name.
Nice. Now we can brag that gfortran implements (some) g77 intrinsics
better than g77 itself! ;-)
Well, to the point. *Disclaimer* I don't have the source here at work,
so this is from memory.
As you know, the name_nt array is a copy of the name array with a '\0'
added at the end so that the libc getenv can find the end of the
string. Now, C99 allows variable declarations after executable
statements in a function. Thus, name_nt can be declared after the
whitespace has been counted, saving some stack space (gcc allocates
VLA:s on the stack). E.g. if someone calls getenv with a 1000
character string containing 'HOME' and the rest whitespace, name_nt
would be only 5 characters and not 1001.
Does this sound reasonable or did I forget some crucial detail?
--
Janne Blomqvist
More information about the Fortran
mailing list