diff options
author | milancurcic <caomaco@gmail.com> | 2021-01-12 17:01:47 -0500 |
---|---|---|
committer | milancurcic <caomaco@gmail.com> | 2021-01-12 17:01:47 -0500 |
commit | 2cb994d105e2a3f4e10df2bca3c3d2045d1d1356 (patch) | |
tree | 526238acb368acabef5df374e1c1c97ce613644d | |
parent | 7af51a6a109099443164285fb97f8ca41e46ee3a (diff) | |
download | fpm-2cb994d105e2a3f4e10df2bca3c3d2045d1d1356.tar.gz fpm-2cb994d105e2a3f4e10df2bca3c3d2045d1d1356.zip |
add function to replace special characters to undercores
-rw-r--r-- | fpm/src/fpm_filesystem.f90 | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/fpm/src/fpm_filesystem.f90 b/fpm/src/fpm_filesystem.f90 index f221917..7ed99dc 100644 --- a/fpm/src/fpm_filesystem.f90 +++ b/fpm/src/fpm_filesystem.f90 @@ -2,11 +2,11 @@ module fpm_filesystem use fpm_environment, only: get_os_type, & OS_UNKNOWN, OS_LINUX, OS_MACOS, OS_WINDOWS, & OS_CYGWIN, OS_SOLARIS, OS_FREEBSD - use fpm_strings, only: f_string, string_t, split + use fpm_strings, only: f_string, replace, string_t, split implicit none private public :: basename, canon_path, dirname, is_dir, join_path, number_of_rows, read_lines, list_files, env_variable, & - mkdir, exists, get_temp_filename, windows_path, unix_path, getline, delete_file + mkdir, exists, get_temp_filename, windows_path, unix_path, getline, delete_file, to_fortran_name integer, parameter :: LINE_BUFFER_LEN = 1000 @@ -465,4 +465,15 @@ subroutine delete_file(file) end subroutine delete_file +pure function to_fortran_name(string) result(res) + ! Returns string with special characters replaced with an underscore. + ! For now, only a hyphen is treated as a special character, but this can be + ! expanded to other characters if needed. + character(*), intent(in) :: string + character(len(string)) :: res + character, parameter :: SPECIAL_CHARACTERS(*) = ['-'] + res = replace(string, SPECIAL_CHARACTERS, '_') +end function to_fortran_name + + end module fpm_filesystem |