diff options
author | urbanjost <urbanjost@comcast.net> | 2021-01-31 17:42:27 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-31 17:42:27 -0500 |
commit | b2ae7db694017256517bacdae050cdf82b3cf73c (patch) | |
tree | 60c875da21cf05165bf97c9b974e1d1bc21de05c | |
parent | 712d5edc3903921633829b984326de61310aea39 (diff) | |
parent | a16e812730c1b438e887679df44d7b83ba584f8e (diff) | |
download | fpm-b2ae7db694017256517bacdae050cdf82b3cf73c.tar.gz fpm-b2ae7db694017256517bacdae050cdf82b3cf73c.zip |
Merge branch 'master' into update_new
-rw-r--r-- | fpm/src/fpm_command_line.f90 | 5 | ||||
-rw-r--r-- | fpm/src/fpm_filesystem.f90 | 13 | ||||
-rw-r--r-- | fpm/src/fpm_source_parsing.f90 | 4 | ||||
-rw-r--r-- | fpm/test/new_test/new_test.f90 | 5 |
4 files changed, 19 insertions, 8 deletions
diff --git a/fpm/src/fpm_command_line.f90 b/fpm/src/fpm_command_line.f90 index cfa6cb9..0217154 100644 --- a/fpm/src/fpm_command_line.f90 +++ b/fpm/src/fpm_command_line.f90 @@ -857,9 +857,8 @@ contains ' ', & 'OPTIONS ', & ' NAME the name of the project directory to create. The name ', & - ' must be a valid Fortran name composed of 1 to 63 ', & - ' ASCII alphanumeric characters and underscores, ', & - ' starting with a letter. ', & + ' must be made of up to 63 ASCII letters, digits, underscores, ', & + ' or hyphens, and start with a letter. ', & ' ', & ' The default is to create the src/, app/, and test/ directories. ', & ' If any of the following options are specified then only the ', & diff --git a/fpm/src/fpm_filesystem.f90 b/fpm/src/fpm_filesystem.f90 index 5811cd4..ea3d9d3 100644 --- a/fpm/src/fpm_filesystem.f90 +++ b/fpm/src/fpm_filesystem.f90 @@ -8,7 +8,7 @@ use,intrinsic :: iso_fortran_env, only : stdin=>input_unit, stdout=>output_unit, 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, to_fortran_name - public :: fileopen, fileclose, filewrite, warnwrite + public :: fileopen, fileclose, filewrite, warn integer, parameter :: LINE_BUFFER_LEN = 1000 @@ -570,4 +570,15 @@ pure function to_fortran_name(string) result(res) res = replace(string, SPECIAL_CHARACTERS, '_') end function to_fortran_name +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 diff --git a/fpm/src/fpm_source_parsing.f90 b/fpm/src/fpm_source_parsing.f90 index fc0b629..76cb560 100644 --- a/fpm/src/fpm_source_parsing.f90 +++ b/fpm/src/fpm_source_parsing.f90 @@ -87,7 +87,7 @@ function parse_f_source(f_filename,error) result(f_source) close(fh) ! Ignore empty files, returned as FPM_UNIT_UNKNOW - if (len_trim(string_cat(file_lines,' ')) < 1) return + if (len_trim(file_lines) < 1) return f_source%digest = fnv_1a(file_lines) @@ -392,7 +392,7 @@ function parse_c_source(c_filename,error) result(c_source) close(fh) ! Ignore empty files, returned as FPM_UNIT_UNKNOW - if (len_trim(string_cat(file_lines,' ')) < 1) then + if (len_trim(file_lines) < 1) then c_source%unit_type = FPM_UNIT_UNKNOWN return end if diff --git a/fpm/test/new_test/new_test.f90 b/fpm/test/new_test/new_test.f90 index c284002..4ff00c3 100644 --- a/fpm/test/new_test/new_test.f90 +++ b/fpm/test/new_test/new_test.f90 @@ -78,10 +78,11 @@ logical :: IS_OS_WINDOWS if( is_dir('name-with-hyphens') ) then tally=[tally,.true.] - else + + else write(*,*)'ERROR: directory name-with-hyphens/ exists' tally=[tally,.false.] - endif + endif ! assuming hidden files in .git and .gitignore are ignored for now TESTS: do i=1,size(directories) |