Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement %elif #710

Closed
wants to merge 5 commits into from
Closed

Conversation

pavlinamv
Copy link
Contributor

No description provided.

after_classification:
if (match != -1) {
if (lineType->id & (LINE_IF | LINE_IFARCH | LINE_IFNARCH | LINE_IFOS |
LINE_IFNOS)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This calls for a bitmask, something like LINE_IFANY, which can be used to trap all the types with one symbol. Makes the line shorter and more readable. (fwiw no I'm not reviewing, just taking a look)

@pavlinamv
Copy link
Contributor Author

Panu's comments are incorporated.

rl->lastConditional = lineType;
spec->readStack = rl;
spec->line[0] = '\0';
} else if (lineType->id & (LINE_ELIF | LINE_ELIFARCH | LINE_ELIFOS)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The various ELIF's are another candidate for a bit mask, this set is repeated at least twice in the patch (used earlier in the "dont expand in false branch" check). In general, when addressing something, it pays to look for similar cases/opportunities/bugs, they're quite often there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is changed in the new version.

No functional change, preparation for %elif.
 informative

The original message like e.g.:

error: /data/rpmbuild/SPECS/iftest.spec:8: bad %if condition

is changed to

error: /data/rpmbuild/SPECS/iftest.spec:8: Bad %if condition:  nonsense-3

Preparation for %elif.
There may be several %elifs within the same %if statement.
They must be placed after %if and before %endif and %else
(if %else is contained). The first %elif expression (if any)
that evaluates to TRUE would be executed.

In scope of %if you can use any of the new operators - %elif, %elifarch,
%elifos. Similarly for %ifos, %ifnos, %ifarch and %ifnarch.

The expression after %elif (resp. %elifos or %elifarch) is expandedd iff
the expression can influence the execution of the %elif branch.
E.g.: an %elif expression after the first %elif expression that
evaluates to TRUE is not expanded.
@pavlinamv
Copy link
Contributor Author

Corrected the commit message of the first commit.

@ffesti
Copy link
Contributor

ffesti commented May 27, 2019

Ok, Rebased and merged.

@ffesti ffesti closed this May 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants