Skip to content

Commit da7ab3d

Browse files
authored
Merge pull request #819 from fortran-lang/gnikit/issue813
feat(linter): improve GNU regex for modern options
2 parents 3d79339 + 869ac59 commit da7ab3d

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
7878

7979
### Fixed
8080

81+
- Fixed GFortran version regex to allow for semver + build metadata
82+
([#813](https://github.com/fortran-lang/vscode-fortran-support/issues/813))
8183
- Fixed broken badges and replaced them with shields.io
8284
([[#815](https://github.com/fortran-lang/vscode-fortran-support/issues/815)])
8385
- Fixed regular expression for parsing version of GFortran in linter

src/features/linter-provider.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export class LinterSettings {
9999
// seemed to optimise away the stdout and regex would return null
100100
// The words between the parenthesis can have all sorts of special characters
101101
// account for all of them just to be safe
102-
const regex = /^GNU Fortran \([\S ]+\) (?<version>.*)$/gm;
102+
const regex = /^GNU Fortran \([\S ]+\) (?<msg>(?<version>\d+\.\d+\.\d+).*)$/gm;
103103
const output = child.stdout.toString();
104104
const match = regex.exec(output);
105105
const version = match ? match.groups.version : undefined;
@@ -108,9 +108,9 @@ export class LinterSettings {
108108
this.logger.info(`[lint] Found GNU Fortran version ${version}`);
109109
this.logger.debug(`[lint] Using Modern GNU Fortran diagnostics: ${this.modernGNU}`);
110110
return version;
111-
} else {
112-
this.logger.error(`[lint] invalid compiler version extracted ${version} from ${output}`);
113111
}
112+
this.logger.warn(`[lint] Unable to extract semver version ${match.groups.msg} from ${output}`);
113+
this.logger.warn(`[lint] Using GFortran with fallback options`);
114114
}
115115

116116
public get version(): string {

0 commit comments

Comments
 (0)