206206
207207# match namelist names
208208NML_RE = re .compile (r"(/\w+/)" , RE_FLAGS )
209+ # find namelists and data statements
210+ NML_STMT_RE = re .compile (SOL_STR + r"NAMELIST.*/.*/" , RE_FLAGS )
211+ DATA_STMT_RE = re .compile (SOL_STR + r"DATA\s+\w" , RE_FLAGS )
209212
210213class F90Indenter (object ):
211214 """
@@ -779,7 +782,7 @@ def add_whitespace_context(line, spacey):
779782 line_parts .append (line [str_end + 1 :])
780783
781784 # format namelists with spaces around /
782- if re .match (r"namelist.*/.*/" , line , RE_FLAGS ):
785+ if NML_STMT_RE .match (line ):
783786 for pos , part in enumerate (line_parts ):
784787 # exclude comments, strings:
785788 if not re .match (r"['\"!]" , part , RE_FLAGS ):
@@ -791,8 +794,8 @@ def add_whitespace_context(line, spacey):
791794 for pos , part in enumerate (line_parts ):
792795 # exclude comments, strings:
793796 if not re .search (r"^['\"!]" , part , RE_FLAGS ):
794- # also exclude / if we see a namelist
795- if not re .match (r"namelist.*/.*/" , line , RE_FLAGS ):
797+ # also exclude / if we see a namelist and data statement
798+ if not ( NML_STMT_RE .match (line ) or DATA_STMT_RE . match ( line ) ):
796799 partsplit = lr_re .split (part )
797800 line_parts [pos ] = (' ' * spacey [n_op + 2 ]).join (partsplit )
798801
0 commit comments