diff --git a/ford/sourceform.py b/ford/sourceform.py index 8c838cdf..4f0b7c21 100644 --- a/ford/sourceform.py +++ b/ford/sourceform.py @@ -661,7 +661,7 @@ class FortranContainer(FortranBase): re.IGNORECASE | re.VERBOSE, ) FUNCTION_RE = re.compile( - r"""^(?:(?P.+?)\s+)? # Optional attributes (including type) + r"""^(?:(?P.+?)\s*)? # Optional attributes (including type) function\s+(?P\w+)\s* # Required function name (?P\([^()]*\))? # Required arguments (?=(?:.*result\s*\(\s*(?P\w+)\s*\))?) # Optional result name diff --git a/test/test_sourceform.py b/test/test_sourceform.py index 65b50501..f2e1c301 100644 --- a/test/test_sourceform.py +++ b/test/test_sourceform.py @@ -2256,3 +2256,15 @@ def test_blocks_with_type(parse_fortran_file): source = parse_fortran_file(data) module = source.modules[0] assert len(module.subroutines) == 1 + + +def test_no_space_after_character_type(parse_fortran_file): + data = """\ + CHARACTER(LEN=250)FUNCTION FirstWord( sString ) RESULT( sRes ) + CHARACTER(LEN=250)sString + END FUNCTION FirstWord + """ + + source = parse_fortran_file(data) + function = source.functions[0] + assert function.name.lower() == "firstword"