[Rpm-maint] [rpm-software-management/rpm] Forbid 'if' richops in 'or' context and 'unless' richops in 'and' con… (#317)

Jan Pokorný notifications at github.com
Mon Nov 5 17:09:20 UTC 2018


I've stumbled upon this code:

```c
    if ((op == RPMRICHOP_WITH || op == RPMRICHOP_WITHOUT) && (check & RICHPARSE_NO_WITH) != 0) {
	if (emsg)
	    rasprintf(emsg, _("Illegal ops in with/without"));
	return RPMRC_FAIL;
    }
```
in contrast to:
```c
    if ((op == RPMRICHOP_AND || op == RPMRICHOP_IF) && (check & RICHPARSE_NO_AND) != 0) {
	if (emsg)
	    rasprintf(emsg, _("Illegal context for 'unless', please use 'or' instead"));
	return RPMRC_FAIL;
    }
    if ((op == RPMRICHOP_OR || op == RPMRICHOP_UNLESS) && (check & RICHPARSE_NO_OR) != 0) {
	if (emsg)
	    rasprintf(emsg, _("Illegal context for 'if', please use 'and' instead"));
	return RPMRC_FAIL;
    }
```

Without much digging, the conditiontion are spot-on in the former sample
(in an intuitive grasp), but these detections are suddenly flipped in
the latter, breaking the formerly built intuition!

What's even stranger is that the diagnostic message is actually emitted
just fine for `unless -> or` case.

I am buffled, if that's alright, perhaps an explaining comment would be
good to have to get not cause confusion about seemingly flipping the
logic.

Thanks for considering, @mlschroe.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/317#issuecomment-435954685
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20181105/91560cf6/attachment.html>


More information about the Rpm-maint mailing list