aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpm/src/fpm_filesystem.f9015
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