Re: [Rpm-maint] [rpm-software-management/rpm] Warn if %else is after %else (#649)

2019-05-20 Thread Panu Matilainen
Somewhere along the line the commit message became so abstract it doesn't 
really say anything, and mention of moving the definitions around was dropped 
(such things should always be explicitly stated) but I'm just too sick and 
tired of this thing to demand another round.

-- 
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/649#issuecomment-493925375___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] Warn if %else is after %else (#649)

2019-05-20 Thread Panu Matilainen
Merged #649 into master.

-- 
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/649#event-2352619698___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] Warn if %else is after %else (#649)

2019-05-19 Thread pavlinamv
Rebase + fixes are done.

-- 
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/649#issuecomment-493749504___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] Warn if %else is after %else (#649)

2019-05-17 Thread Panu Matilainen
pmatilai commented on this pull request.



> @@ -462,6 +430,22 @@ int readLine(rpmSpec spec, int strip)
 lineType = parseLineType(s);
 if (!lineType)
goto after_classification;
+
+/* check ordering of the conditional */
+if (lineType->isConditional &&
+   (spec->readStack->lastConditional->id & lineType->wrongPrecursors)) {
+   /* the conditional can't be after %endif or the 1. conditional */
+   if (spec->readStack->lastConditional->id == LINE_ENDIF)
+   rpmlog(RPMLOG_ERR,_("%s:%d: %s with no %%if\n"),
+   ofi->fileName, ofi->lineNum, lineType->text);
+   else
+   /* wrong ordering of the last two conditionals */
+   rpmlog(RPMLOG_ERR,_("%s:%d: %s after %s\n"),

Erm, actually... I guess the most common message format is just "line %d: 
" but in a few places filename is also included. All wonderfully 
inconsistent, and fixing all that is beyond scope of this pr. So guess that 
doesn't matter.

-- 
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/649#discussion_r285095341___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] Warn if %else is after %else (#649)

2019-05-17 Thread Panu Matilainen
pmatilai commented on this pull request.



> @@ -462,6 +430,22 @@ int readLine(rpmSpec spec, int strip)
 lineType = parseLineType(s);
 if (!lineType)
goto after_classification;
+
+/* check ordering of the conditional */
+if (lineType->isConditional &&
+   (spec->readStack->lastConditional->id & lineType->wrongPrecursors)) {
+   /* the conditional can't be after %endif or the 1. conditional */
+   if (spec->readStack->lastConditional->id == LINE_ENDIF)
+   rpmlog(RPMLOG_ERR,_("%s:%d: %s with no %%if\n"),
+   ofi->fileName, ofi->lineNum, lineType->text);
+   else
+   /* wrong ordering of the last two conditionals */
+   rpmlog(RPMLOG_ERR,_("%s:%d: %s after %s\n"),

Oh, and one more thing I just realized: most of our error messages are of the 
format "%s: line %d: ", lets be consistent with that in both these 
messages. 

-- 
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/649#discussion_r285088063___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] Warn if %else is after %else (#649)

2019-05-17 Thread Panu Matilainen
Please rebase and fix the two cosmetics mentioned above, after that I think 
we're good to go finally.

-- 
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/649#issuecomment-493409681___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] Warn if %else is after %else (#649)

2019-05-17 Thread Panu Matilainen
pmatilai commented on this pull request.



> @@ -462,6 +430,22 @@ int readLine(rpmSpec spec, int strip)
 lineType = parseLineType(s);
 if (!lineType)
goto after_classification;
+
+/* check ordering of the conditional */
+if (lineType->isConditional &&
+   (spec->readStack->lastConditional->id & lineType->wrongPrecursors)) {
+   /* the conditional can't be after %endif or the 1. conditional */
+   if (spec->readStack->lastConditional->id == LINE_ENDIF)
+   rpmlog(RPMLOG_ERR,_("%s:%d: %s with no %%if\n"),
+   ofi->fileName, ofi->lineNum, lineType->text);
+   else
+   /* wrong ordering of the last two conditionals */
+   rpmlog(RPMLOG_ERR,_("%s:%d: %s after %s\n"),

Both the if-block and else-block consist of multiple physical lines, do use { } 
blocks in these cases to make it clearer. Also the /* wrong ordering */ comment 
is on odd indentation level here.

-- 
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/649#pullrequestreview-238855898___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] Warn if %else is after %else (#649)

2019-05-17 Thread Panu Matilainen
pmatilai commented on this pull request.



> @@ -462,6 +430,22 @@ int readLine(rpmSpec spec, int strip)
 lineType = parseLineType(s);
 if (!lineType)
goto after_classification;
+
+/* check ordering of the conditional */
+if (lineType->isConditional &&
+   (spec->readStack->lastConditional->id & lineType->wrongPrecursors)) {

The condition continuation is on the same indentation level as the if-block it 
surrounds, which makes it easy to misread. Please fix the indentation, using 
well named helper variables to shorten the condition is usually the best way to 
do that.

This was probably there in previous rounds too, sorry for not noticing.

-- 
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/649#pullrequestreview-238855362___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] Warn if %else is after %else (#649)

2019-05-16 Thread pavlinamv
Commit message is corrected.

-- 
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/649#issuecomment-492949023___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] Warn if %else is after %else (#649)

2019-05-14 Thread Florian Festi
Typo in the first sentence of the commit message: "odrering"

-- 
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/649#issuecomment-492232761___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] Warn if %else is after %else (#649)

2019-05-14 Thread pavlinamv
pavlinamv commented on this pull request.



> +size_t textLen;
+const char *text;
+int withArgs;
+int isConditional;
+int wrongPrecursors;
+const char *info_text;
+} * parsedSpecLine;
+
+static struct parsedSpecLine_s const lineTypes[] = {
+{ LINE_ENDIF,  LEN_AND_STR("%endif")  , 0, 1, LINE_ENDIF, "with no 
%%if"},
+{ LINE_ELSE,   LEN_AND_STR("%else")   , 0, 1, LINE_ENDIF | LINE_ELSE, 
"after %%else" },
+{ LINE_IF, LEN_AND_STR("%if") , 1, 1, 0, "after %%if"},
+{ LINE_IFARCH, LEN_AND_STR("%ifarch") , 1, 1, 0, "after %%ifarch"},
+{ LINE_IFNARCH,LEN_AND_STR("%ifnarch"), 1, 1, 0, "after %%ifnarch"},
+{ LINE_IFOS,   LEN_AND_STR("%ifos")   , 1, 1, 0, "after %%ifos"},
+{ LINE_IFNOS,  LEN_AND_STR("%ifnos")  , 1, 1, 0, "after %%ifnos"},

>The %ifs should not have any info text because there are no such error cases, 
>and the texts should be marked for translation.

>Programmatically constructed messages tend to be a problem for translators, 
>might better to have the whole string in one piece, ie "%s with no %s" and "%s 
>after %s" to allow translators to at least reorder the words.

Changed in the new version

>  Also, isn't this now missing the else-with-no-if case, or am I just 
> misreading it?

No in this case it wrote e.g.
/data/SPECS/attrtest.spec:1: %%endif with no %%if
/data/SPECS/configtest.spec:1: %%else with no %%if

> Hmm, "with no" could just as well be changed into "before", which makes the 
> messages more in line with each other: this is just about the order of 
> things, so things are either before or after its proper place.

This message appears e.g. in case that in spec file is only one conditional: 
%endif. So in this case there is no %if after the %endif, thus changing "with 
no" into "before" good idea.

-- 
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/649#discussion_r283789959___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] Warn if %else is after %else (#649)

2019-05-14 Thread pavlinamv
pavlinamv commented on this pull request.



> @@ -462,6 +430,16 @@ int readLine(rpmSpec spec, int strip)
 lineType = parseLineType(s);
 if (!lineType)
goto after_classification;
+
+/* for a conditional check its ordering */
+if (lineType->isConditional &&
+   (spec->readStack->lastConditional->id & lineType->wrongPrecursors)) {
+   rpmlog(RPMLOG_ERR,_("%s:%d: Got %%%s %s\n"),

Removed in the new version.

-- 
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/649#discussion_r283789969___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] Warn if %else is after %else (#649)

2019-05-13 Thread Panu Matilainen
pmatilai requested changes on this pull request.

Hmm, there seems to be some GH review-tool wonkiness here, I made several 
comments on the latest round and haven't touched this because those issues 
haven't been addressed. But now I noticed that those comments appear as 
"pending" so I guess you haven't seen them at all because GH thinks I haven't 
actually submitted them. *Sigh*

> +size_t textLen;
+const char *text;
+int withArgs;
+int isConditional;
+int wrongPrecursors;
+const char *info_text;
+} * parsedSpecLine;
+
+static struct parsedSpecLine_s const lineTypes[] = {
+{ LINE_ENDIF,  LEN_AND_STR("%endif")  , 0, 1, LINE_ENDIF, "with no 
%%if"},
+{ LINE_ELSE,   LEN_AND_STR("%else")   , 0, 1, LINE_ENDIF | LINE_ELSE, 
"after %%else" },
+{ LINE_IF, LEN_AND_STR("%if") , 1, 1, 0, "after %%if"},
+{ LINE_IFARCH, LEN_AND_STR("%ifarch") , 1, 1, 0, "after %%ifarch"},
+{ LINE_IFNARCH,LEN_AND_STR("%ifnarch"), 1, 1, 0, "after %%ifnarch"},
+{ LINE_IFOS,   LEN_AND_STR("%ifos")   , 1, 1, 0, "after %%ifos"},
+{ LINE_IFNOS,  LEN_AND_STR("%ifnos")  , 1, 1, 0, "after %%ifnos"},

The %ifs should not have any info text because there are no such error cases, 
and the texts should be marked for translation. 

Programmatically constructed messages tend to be a problem for translators, 
might better to have the whole string in one piece, ie "%s with no %s" and "%s 
after %s" to allow translators to at least reorder the words.

> @@ -462,6 +430,16 @@ int readLine(rpmSpec spec, int strip)
 lineType = parseLineType(s);
 if (!lineType)
goto after_classification;
+
+/* for a conditional check its ordering */
+if (lineType->isConditional &&
+   (spec->readStack->lastConditional->id & lineType->wrongPrecursors)) {
+   rpmlog(RPMLOG_ERR,_("%s:%d: Got %%%s %s\n"),

While we're changing the message, *please* drop the stupid "Got" from there. It 
serves no purpose other being an extra hurdle to translators.

> +size_t textLen;
+const char *text;
+int withArgs;
+int isConditional;
+int wrongPrecursors;
+const char *info_text;
+} * parsedSpecLine;
+
+static struct parsedSpecLine_s const lineTypes[] = {
+{ LINE_ENDIF,  LEN_AND_STR("%endif")  , 0, 1, LINE_ENDIF, "with no 
%%if"},
+{ LINE_ELSE,   LEN_AND_STR("%else")   , 0, 1, LINE_ENDIF | LINE_ELSE, 
"after %%else" },
+{ LINE_IF, LEN_AND_STR("%if") , 1, 1, 0, "after %%if"},
+{ LINE_IFARCH, LEN_AND_STR("%ifarch") , 1, 1, 0, "after %%ifarch"},
+{ LINE_IFNARCH,LEN_AND_STR("%ifnarch"), 1, 1, 0, "after %%ifnarch"},
+{ LINE_IFOS,   LEN_AND_STR("%ifos")   , 1, 1, 0, "after %%ifos"},
+{ LINE_IFNOS,  LEN_AND_STR("%ifnos")  , 1, 1, 0, "after %%ifnos"},

Hmm, "with no" could just as well be changed into "before", which makes the 
messages more in line with each other: this is just about the order of things, 
so things are either before or after its proper place.

Also, isn't this now missing the else-with-no-if case, or am I just misreading 
it?

-- 
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/649#pullrequestreview-231615676___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] Warn if %else is after %else (#649)

2019-04-25 Thread pavlinamv
Your comments are incorporated in the new version.

-- 
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/649#issuecomment-486536987___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] Warn if %else is after %else (#649)

2019-04-15 Thread Panu Matilainen
Maybe I didn't say anything about LINE_DEFAULT specifically, just generally 
about the 0 enum. The hole and the comment seem just strange now, I'd rather 
see that LINE_DEFAULT 0 in the enum even if it's not used at all in the code as 
that's along the general style. Nothing forces you to put that in the table! As 
for the table, %include is not an actual branch either so the branchType is not 
really an optimal name either, especially since everything else here is called 
line-something. Why not just lineTypes, which I suggested as the most obvious 
candidate? One can obviously bikeshed over preferred names forever and that's 
not meaningful at all, but *consistency* is important. 

-- 
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/649#issuecomment-483134750___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] Warn if %else is after %else (#649)

2019-04-12 Thread pavlinamv
> Hmm, why not? Having that LINE_DEFAULT kind of thing to represent all the 
> normal lines seemed useful. Perhaps you misunderstood what I meant by the 
> earlier comments?

Please in which comment you spoke about LINE_DEFAULT?
The implemented algorithm (added in #625) works differently and adding 
LINE_DEFAULT will lead to many subsequent changes with almost no gain. Moreover 
it can make the situation more complicated. Now if a line is "default", no 
branchType entry for the line is found. If there will be "LINE_DEFAULT" what 
value should "text" in branchType table contain?  

-- 
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/649#issuecomment-482779241___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] Warn if %else is after %else (#649)

2019-04-12 Thread Panu Matilainen
Oh and BTW, I know its easy for commit messages and reality to get out of sync 
when doing multiple versions. Try to review them yourself too: read it as a 
story, and ask yourself does that story make sense without looking at the 
actual code.

-- 
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/649#issuecomment-482557187___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] Warn if %else is after %else (#649)

2019-04-12 Thread Panu Matilainen
Anyway, overall looks quite nice. Bonus points if you can preserve the more 
accurate error message information, it seems like one could figure the 
after/without type info from the bitfield order maybe.

The biggest problem here is the commit messages :) The first commit mumbles 
something about removing zero value that will be used in the next commit, but 
that's not really true in this version. In fact for this version, you wouldn't 
need the value changes at all AFAICS. The second message is worse:

>  Use a general warning if a spec file conditional is on a wrong position

It's not a warning, it's an error.

> To parsedSpecLine_s and ReadLevelEntry were added additional data
> such that now it is able to make general type of error if ordering of
> conditionals is wrong.

This hubbub doesn't really convey what was achieved here, I barely understand 
even though I know what it's talking about. Please try rewriting in plain 
English, thanks :) 

-- 
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/649#issuecomment-482556636___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] Warn if %else is after %else (#649)

2019-04-12 Thread Panu Matilainen
pmatilai commented on this pull request.



> @@ -268,6 +268,7 @@ rpmSpec newSpec(void)
 spec->readStack = xcalloc(1, sizeof(*spec->readStack));
 spec->readStack->next = NULL;
 spec->readStack->reading = 1;
+spec->readStack->lastConditional = LINE_ENDIF;

This seems like a bit of a hack compared to having that LINE_DEFAULT value, but 
not a big deal.

-- 
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/649#pullrequestreview-226047837___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] Warn if %else is after %else (#649)

2019-04-12 Thread Panu Matilainen
pmatilai commented on this pull request.



> @@ -49,6 +50,18 @@ struct Source * next;
 
 typedef struct Package_s * Package;
 
+/* Do not use number 0 for a line type */

Hmm, why not? Having that LINE_DEFAULT kind of thing to represent all the 
normal lines seemed useful. Perhaps you misunderstood what I meant by the 
earlier comments?

-- 
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/649#pullrequestreview-226046985___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] Warn if %else is after %else (#649)

2019-04-11 Thread pavlinamv
All your comments are incorporated in the new version.
First two commits are now in a single commit.The second now add a general type 
of an error for inappropriate ordering of conditionals + change of 
implementedTypes name.

-- 
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/649#issuecomment-482099096___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] Warn if %else is after %else (#649)

2019-04-11 Thread Panu Matilainen
Hmm, just realized I misplaced this comment so the context is missing:

>No problem with the change itself, but the commit message doesn't really 
>convey what's going on.
On first sight the diff looks like excessive white-space changes or something, 
you need to look quite closely to see that the whole thing is renumbered to add 
room at the start.

The context kinda becomes clear later in the comment, but to be explicit: the 
comment is about the enum changes.

On a related note, there's a piece of generic advise in this situation: always 
leave value zero free for default/generic case in enums, otherwise you'll come 
to regret it sooner or later :grin: I should've spotted and commented on that 
during review.


-- 
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/649#issuecomment-482002179___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] Warn if %else is after %else (#649)

2019-04-11 Thread Panu Matilainen
Well, the point is to have a specific name. lineTypes seems fairly obvious 
candidate, branchTypes would be less bad, which is not to say it's a good name. 
Good names are often harder than the code itself. 

-- 
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/649#issuecomment-482000426___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] Warn if %else is after %else (#649)

2019-04-11 Thread pavlinamv
Please, do you have any idea what name can be used instead of implementedTypes?

-- 
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/649#issuecomment-481998368___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] Warn if %else is after %else (#649)

2019-04-11 Thread Panu Matilainen
> Another issue is that the %if-%else-%endif sanity checking now looks even 
> more ad-hoc because some things look at spec->redStack->next and others at 
> spec->readStack->ifStage.

BTW what I meant by that is there might be an opportunity here to unify all 
those %if-related checks to use ifStage which would probably make the whole 
thing far more obvious and readable. And taking that further, you could store 
the compatibility information in the implementedTypes[] table [*] and then 
instead of adding more checks, simply do a general check against the 
information in the table, you can even construct the different error messages 
from there because the table has the names. *That* would be a real improvement.

Also realized here that you don't actually *need* to move the enum to the 
header because it's only used for a fancy name of initializing the value to 0, 
which is redundant as it is because it's calloc()'ed to begin with. No 
objection to moving it though, just a remark.

-- 
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/649#issuecomment-481988312___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


Re: [Rpm-maint] [rpm-software-management/rpm] Warn if %else is after %else (#649)

2019-04-10 Thread Panu Matilainen
pmatilai commented on this pull request.



> @@ -480,6 +480,13 @@ int readLine(rpmSpec spec, int strip)
ofi->fileName, ofi->lineNum);
return PART_ERROR;
}
+   if ((spec->readStack->ifStage == LINE_ELSE)) {
+   /* Got an else after %else ! */
+   rpmlog(RPMLOG_ERR,
+   _("%s:%d: Got a %%else after %%else\n"),
+   ofi->fileName, ofi->lineNum);

The comment here is useless and redundant, the error message says the same 
thing, and the rpmlog() call is needlessly spread over three lines when it 
easily fits two. While those aren't actual errors,  along those two you also 
copy-pasted the grammar error from the preceding check ;) 

Something being in the codebase doesn't necessarily mean it's correct and good 
to copy around, especially in code this old (1998-2001). I'd rather see the 
superfluous comment removed and grammar error fixed in the older message too 
than add more.

Another issue is that the %if-%else-%endif sanity checking now looks even more 
ad-hoc because some things look at spec->redStack->next and others at 
spec->readStack->ifStage. I

-- 
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/649#pullrequestreview-224904957___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint