Am Mo., 17. Sep. 2018 um 21:21 Uhr schrieb Janus Weil <ja...@gcc.gnu.org>: > > Instead, for the sake of gfortran, how about a macro like this? > > #define gfc_str_startswith(str, pref) \ > (strncmp ((str), (pref), strlen (pref)) == 0) > > (In fact I just noticed that something like this already exists in > trans-intrinsic.c, so I would just move it into gfortran.h and rename > it.) > > > > Looking at gcc/fortran alone there are > > gcc/fortran/interface.c: if (strncmp (mode, "unformatted", 9) == 0) // 11 ! > > I think this one could actually be a 'strcmp'? > > > > gcc/fortran/module.c: && (strncmp (name, "__vtab_", 5) == 0 // 7 ! > > gcc/fortran/module.c: || strncmp (name, "__vtype_", 6) == 0)) > > // 8! > > gcc/fortran/module.c: || (strncmp (name, "__vtab_", 5) != 0 // > > 7! > > gcc/fortran/module.c: && strncmp (name, "__vtype_", 6) > > != 0)) // 8! > > Here the new macro could be applied (and in a few other cases as > well), see attached patch. > > I'm regtesting the patch now. Ok for trunk if it passes?
The regtest was successful. I don't think the off-by-two error for the vtab/vtype comparisons is a big problem in practice, since the number of internal symbols with leading underscores is very limited, but of course it should still be fixed ... Cheers, Janus