Closed Bug 1730960 Opened 3 years ago Closed 11 months ago

Preprocessor should fail on, or handle, '# ifdef' (space between # and ifdef)

Categories

(Firefox Build System :: General, defect, P3)

defect

Tracking

(firefox115 fixed)

RESOLVED FIXED
115 Branch
Tracking Status
firefox115 --- fixed

People

(Reporter: standard8, Assigned: sergesanspaille)

References

Details

Attachments

(1 file, 1 obsolete file)

We've just found two long standing bugs (2yr) in our preferences (see "See Also") which were both caused by code in StaticPrefsList.yaml of this form:

# ifdef XP_WIN
  value: 1
# else
  value: 0
# endif

There is even a warning at the start of this file:

# Note finally that this file is preprocessed by preprocessor.py, not the C++
# preprocessor. As a result, the following things may be surprising.
...
# - Spaces aren't permitted between the leading '#' and the name of a
#   directive, e.g. `#ifdef XYZ` works but `# ifdef XYZ` does not.

We should either make the preprocessor fail on ifdefs with a space, or it should handle them.

Priority: -- → P3

This way it matches the C pre processor behavior many people are used
to.

The way this change is implemented also allows for non-command comments
to exist, e.g.

    #hello

Used to be an error and it no longer is, it's just copy-pasted.

Assignee: nobody → sguelton
Status: NEW → ASSIGNED
Severity: -- → S3
Attachment #9328855 - Attachment description: Bug 1730960 - Allow spaces between marker and preprocessor command r=standard8 → Bug 1730960 - Allow spaces between marker and preprocessor command r=standard8!
Attachment #9328855 - Attachment description: Bug 1730960 - Allow spaces between marker and preprocessor command r=standard8! → Bug 1730960 - Allow spaces between marker and preprocessor, and change comment marker command r=glandium

Because the preprocessor handles both comments in the form of

some comment

And commands in the form of

#some command

And due to C preprocessor heritage, people tend to write

some command

which is considered a comment and not a command. Detect this situation
and generate an hard error when meeting such ambiguous commands.

Pushed by sguelton@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/51302571bf80
Detect ambiguous preprocessor.py commands r=glandium
Pushed by sguelton@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/9ee47853c14c
Detect ambiguous preprocessor.py commands r=glandium
Attachment #9328855 - Attachment is obsolete: true

Patch updated and pushed again. Sorry for the noise.

Flags: needinfo?(sguelton)
Pushed by sguelton@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/34f3d7c398a2
Detect ambiguous preprocessor.py commands r=glandium
Status: ASSIGNED → RESOLVED
Closed: 11 months ago
Resolution: --- → FIXED
Target Milestone: --- → 115 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: