MetOffice / MetOffice/SimSys_Scripts

Identification of CPP directives in UMDP3_checker

Open
#240 1 comment 0 reactions 1 assignee Claimed by @r-sharp View on GitHub
enhancement
Dominant language
Python
Stars
9
Forks
19
Avg merge
5d 48m
Merged PRs (30d)
4

Description

The current C pre-processor pattern assumes that there are no spaces between the start of a line and the `#` symbol:

```py
comment_line = re.compile(r"!.*$")
cpp_command_line = re.compile(r"^#.*$")
word_splitter = re.compile(r"\b\w+\b")
```

However, the [GNU C pre-processor manual](https://gcc.gnu.org/onlinedocs/cpp/The-preprocessing-language.html) explicitly says that spaces before the hash symbol are allowed:

> Preprocessing directives are lines in your program that start with ‘#’. Whitespace is allowed before and after the ‘#’. The ‘#’ is followed by an identifier, the directive name. It specifies the operation to perform.

The pattern should probably allow leading whitespace. This doesn't seem to cause problems for the UM, but it may result in unexpected failures in other code bases.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.