[Patch, libgfortran] String spring cleanup (or, spring string cleanup)

Janne Blomqvist blomqvist.janne@gmail.com
Sun May 20 17:50:00 GMT 2007


:ADDPATCH fortran:

Hi,

the following patch does some minor string cleanups in libgfortran. 
Mainly it does

1) Use gfc_charlen_type for the string lengths in the Fortran string 
functions instead of int, and size_t for C strings in the same functions.

2) In a few places where it's not blindingly obvious that the 
destination buffer will be big enough in every imaginable case, use 
snprintf instead of sprintf if it's available.

3) Use memcpy instead of strcpy and strcat. Faster as we don't have to 
scan the strings for \0 repeatedly (easily quadratic behavior in loops). 
Not really any buffer overflow reduction benefit as long as we still 
blindly trust that strlen will get it right.

Regtested on i686-pc-linux-gnu, ok for trunk?

-- 
Janne Blomqvist
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ChangeLog
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20070520/e985016e/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: string-cleanup.diff
Type: text/x-patch
Size: 10315 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20070520/e985016e/attachment.bin>


More information about the Fortran mailing list