After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 656671 - Macros in RPM SPEC files do not have to have braces
Macros in RPM SPEC files do not have to have braces
Status: VERIFIED FIXED
Product: gtksourceview
Classification: Platform
Component: Syntax files
3.0.x
Other All
: Normal normal
: ---
Assigned To: GTK Sourceview maintainers
GTK Sourceview maintainers
Depends on:
Blocks:
 
 
Reported: 2011-08-16 16:21 UTC by Göran Uddeborg
Modified: 2011-09-11 14:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
closes bug? (823 bytes, patch)
2011-09-08 16:49 UTC, Carnë Draug
accepted-commit_now Details | Review

Description Göran Uddeborg 2011-08-16 16:21:14 UTC
The syntax file for RPM SPEC files, rpmspec.lang, only highlights defined macro names if they are enclosed in braces, like this

  %{name}

However, just like in bash, the braces are optional most of the time.  While using braces is much more common in SPEC files than in bash scripts, an expression like

  %name

is still syntactically correct.  The highlighting already works for macros with names that start with an underscore, but all such macro uses should be highlighted.

I tested this using gedit on Fedora 15 with gtksourceview 3.0.5.
Comment 1 Carnë Draug 2011-09-08 16:49:45 UTC
Created attachment 196012 [details] [review]
closes bug?

If I understood correctly, currently only the "other-macro" context needs fixing. Could you please test this patch see if it works?

I can see now that it would still highlight something like

%{other-macro
%other-macro}

which I think would be incorrect but some other contexts that have the braces as optional use the same solution. Also, there's a few contexts that still have the braces as compulsory. They are

    <context id="conditional-macro" style-ref="conditional-macro">
        <match>%\{\?[A-Za-z0-9_]+\}</match>
    </context>

and

    <context id="conditional-define" style-ref="define" end-at-line-end="true">
      <start>%\{\!\?.*%define</start>
      <end>\}</end>
      <include>
        <context ref="def:line-continue" ignore-style="true"/>
      </include>
    </context>

should these also be fixed?
Comment 2 Ignacio Casal Quinteiro (nacho) 2011-09-08 16:51:57 UTC
Review of attachment 196012 [details] [review]:

Let's get this pushed.
Comment 3 Carnë Draug 2011-09-08 17:10:35 UTC
Pushed. This problem has been fixed in the development version. The fix will be
available in the next major software release.

I never used a rpm based distro so I don't know if should fixed the contexts mentioned on reply #1. Please reopen the bug if I should.

Thank you for your bug report.
Comment 4 Göran Uddeborg 2011-09-11 14:45:53 UTC
I tried the patch, and it looks good in gedit.

As for the conditional macro you ask about in comment 1.  The full syntax is

  %{?symbol: text}

If "symbol" is defined, then insert "text", otherwise nothing.  The exclamation point negates the test, and the conditional-define simply colors a specific use of this feature in a different way.

There is a special case of this use.  If ": text" is omitted, the inserted text is the value of "symbol".  So

  %{?symbol}

inserts the value of %symbol if it has any, and otherwise nothing.  In this special case, the brackets are actually optional.  "%?symbol" works the same way.

In all other uses, the brackets are compulsory.  I don't think it is worth it to try to cover this special case in the syntax highlighting.

So as far as I'm concerned, this patch solves the problem.