@@ -2,11 +2,11 @@ module fpm_filesystem
2
2
use fpm_environment, only: get_os_type, &
3
3
OS_UNKNOWN, OS_LINUX, OS_MACOS, OS_WINDOWS, &
4
4
OS_CYGWIN, OS_SOLARIS, OS_FREEBSD
5
- use fpm_strings, only: f_string, string_t, split
5
+ use fpm_strings, only: f_string, replace, string_t, split
6
6
implicit none
7
7
private
8
8
public :: basename, canon_path, dirname, is_dir, join_path, number_of_rows, read_lines, list_files, env_variable, &
9
- mkdir, exists, get_temp_filename, windows_path, unix_path, getline, delete_file
9
+ mkdir, exists, get_temp_filename, windows_path, unix_path, getline, delete_file, to_fortran_name
10
10
11
11
integer , parameter :: LINE_BUFFER_LEN = 1000
12
12
@@ -465,4 +465,15 @@ subroutine delete_file(file)
465
465
end subroutine delete_file
466
466
467
467
468
+ pure function to_fortran_name (string ) result(res)
469
+ ! Returns string with special characters replaced with an underscore.
470
+ ! For now, only a hyphen is treated as a special character, but this can be
471
+ ! expanded to other characters if needed.
472
+ character (* ), intent (in ) :: string
473
+ character (len (string)) :: res
474
+ character , parameter :: SPECIAL_CHARACTERS(* ) = [' -' ]
475
+ res = replace (string, SPECIAL_CHARACTERS, ' _' )
476
+ end function to_fortran_name
477
+
478
+
468
479
end module fpm_filesystem
0 commit comments