------- Additional Comments From Tobias dot Schlueter at physik dot uni-muenchen dot de 2005-08-14 22:02 ------- Subject: Re: MAXPATHLEN usage in fortran/{scanner,module}.c
Steve Kargl wrote: > The attached patches uses alloca to remove the use of PATH_MAX > from gfortran. It also fixes one other nearby hardcoded buffer. > > This has been bubblestrapped and regression tested on amd64-*-freebsd. > > 2005-08-01 Steven G. Kargl <[EMAIL PROTECTED]> > > PR fortran/23065 > * gfortran.h: Remove PATH_MAX definition. > * module.c (write_module,gfc_dump_module): Use alloca to allocate > buffers. > * scanner.s (gfc_release_include_path,form_from_filename): Ditto. ^ typo. > --- 1131,1142 ---- > const char *fileext; > int i; > > ! /* Find end of file name. Note, filename is either a NULL pointer or > ! a NUL terminated string. */ > i = 0; > ! while (filename[i] != '\0') > i++; > > /* Find last period. */ > while (i >= 0 && (filename[i] != '.')) > i--; If filename ever were a NULL pointer this would break, but it won't ever be because gfc_post_options explicitly sets it to the empty string if no filename is supplied on the command line. The patch is ok if you remove the if in the beginning of gfc_new_file, i.e. change try gfc_new_file (const char *filename, gfc_source_form form) { try result; if (filename != NULL) { gfc_source_file = gfc_getmem (strlen (filename) + 1); strcpy (gfc_source_file, filename); } else gfc_source_file = NULL; to gcc_assert(filename) plus the if part. thanks, - Tobi -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23065