|
88 | 88 | sys.stdin = utf8_reader(sys.stdin) |
89 | 89 | sys.stdout = utf8_writer(sys.stdout) |
90 | 90 |
|
91 | | -from .fparse_utils import (VAR_DECL_RE, OMP_RE, OMP_DIR_RE, |
| 91 | +from .fparse_utils import (VAR_DECL_RE, OMP_COND_RE, |
92 | 92 | InputStream, CharFilter, |
93 | 93 | FprettifyException, FprettifyParseException, FprettifyInternalException, |
94 | 94 | CPP_RE, NOTFORTRAN_LINE_RE, FYPP_LINE_RE, RE_FLAGS, STR_OPEN_RE) |
@@ -1058,7 +1058,7 @@ def reformat_ffile(infile, outfile, impose_indent=True, indent_size=3, strict_in |
1058 | 1058 |
|
1059 | 1059 | auto_align, auto_format, in_format_off_block = parse_fprettify_directives( |
1060 | 1060 | lines, comment_lines, in_format_off_block, orig_filename, stream.line_nr) |
1061 | | - f_line, lines, is_omp, is_omp_conditional = preprocess_omp( |
| 1061 | + f_line, lines, is_omp_conditional = preprocess_omp( |
1062 | 1062 | f_line, lines) |
1063 | 1063 | f_line, lines, label = preprocess_labels(f_line, lines) |
1064 | 1064 |
|
@@ -1129,7 +1129,7 @@ def reformat_ffile(infile, outfile, impose_indent=True, indent_size=3, strict_in |
1129 | 1129 |
|
1130 | 1130 | # rm subsequent blank lines |
1131 | 1131 | skip_blank = EMPTY_RE.search( |
1132 | | - f_line) and not any(comments) and not is_omp and not label |
| 1132 | + f_line) and not any(comments) and not is_omp_conditional and not label |
1133 | 1133 |
|
1134 | 1134 |
|
1135 | 1135 | def format_comments(lines, comments, strip_comments): |
@@ -1182,13 +1182,12 @@ def parse_fprettify_directives(lines, comment_lines, in_format_off_block, filena |
1182 | 1182 | def preprocess_omp(f_line, lines): |
1183 | 1183 | """convert omp conditional to normal fortran""" |
1184 | 1184 |
|
1185 | | - is_omp = OMP_RE.search(f_line) |
1186 | | - is_omp_conditional = bool(is_omp and not OMP_DIR_RE.search(f_line)) |
| 1185 | + is_omp_conditional = bool(OMP_COND_RE.search(f_line)) |
1187 | 1186 | if is_omp_conditional: |
1188 | | - f_line = OMP_RE.sub(' ', f_line, count=1) |
1189 | | - lines = [OMP_RE.sub(' ', l, count=1) for l in lines] |
| 1187 | + f_line = OMP_COND_RE.sub(' ', f_line, count=1) |
| 1188 | + lines = [OMP_COND_RE.sub(' ', l, count=1) for l in lines] |
1190 | 1189 |
|
1191 | | - return [f_line, lines, is_omp, is_omp_conditional] |
| 1190 | + return [f_line, lines, is_omp_conditional] |
1192 | 1191 |
|
1193 | 1192 | def preprocess_labels(f_line, lines): |
1194 | 1193 | """remove statement labels""" |
@@ -1370,13 +1369,13 @@ def write_formatted_line(outfile, indent, lines, orig_lines, indent_special, lle |
1370 | 1369 | label_use = '' |
1371 | 1370 |
|
1372 | 1371 | if ind_use + line_length <= (llength+1): # llength (default 132) plus 1 newline char |
1373 | | - outfile.write('!$' * is_omp_conditional + label_use + |
1374 | | - ' ' * (ind_use - 2 * is_omp_conditional - len(label_use) + |
| 1372 | + outfile.write('!$ ' * is_omp_conditional + label_use + |
| 1373 | + ' ' * (ind_use - 3 * is_omp_conditional - len(label_use) + |
1375 | 1374 | len(line) - len(line.lstrip(' '))) + |
1376 | 1375 | line.lstrip(' ')) |
1377 | 1376 | elif line_length <= (llength+1): |
1378 | | - outfile.write('!$' * is_omp_conditional + label_use + ' ' * |
1379 | | - ((llength+1) - 2 * is_omp_conditional - len(label_use) - |
| 1377 | + outfile.write('!$ ' * is_omp_conditional + label_use + ' ' * |
| 1378 | + ((llength+1) - 3 * is_omp_conditional - len(label_use) - |
1380 | 1379 | len(line.lstrip(' '))) + line.lstrip(' ')) |
1381 | 1380 |
|
1382 | 1381 | log_message(LINESPLIT_MESSAGE+" (limit: "+str(llength)+")", "warning", |
|
0 commit comments