Bug 203577 - Syntax highlighting broken on #define statements with curly brackets
Syntax highlighting broken on #define statements with curly brackets
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: vim (Show other bugs)
rawhide
All Linux
medium Severity medium
: ---
: ---
Assigned To: Karsten Hopp
David Lawrence
:
: 203899 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-08-22 11:09 EDT by Josh Boyer
Modified: 2007-11-30 17:11 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-02-12 09:59:50 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Screenshot of broken highlighting (1011.12 KB, image/png)
2006-08-22 11:11 EDT, Josh Boyer
no flags Details
C file that illustrates broken highlighting (215 bytes, text/plain)
2006-08-22 11:15 EDT, Josh Boyer
no flags Details

  None (edit)
Description Josh Boyer 2006-08-22 11:09:47 EDT
Description of problem:

When vim encounters a #define with curly brackets '{' in it, the syntax
highlighting gets confused and thinks the rest of that file is part of the #define.

Version-Release number of selected component (if applicable):

[jwboyer@zod linux]$ rpm -q vim-X11
vim-X11-7.0.042-0.fc5

How reproducible:

Always

Steps to Reproduce:
1. Create a .c file with a #define in the middle that contains {
2. Open file in vim and make sure syntax highlighting is enabled
3. Marvel at the broken highlighting
  
Actual results:

Broken highlighting

Expected results:

Correct highlighting

Additional info:

I'll attach a screenshot and example file shortly.
Comment 1 Josh Boyer 2006-08-22 11:11:49 EDT
Created attachment 134642 [details]
Screenshot of broken highlighting
Comment 2 Josh Boyer 2006-08-22 11:15:12 EDT
Created attachment 134643 [details]
C file that illustrates broken highlighting
Comment 3 Karsten Hopp 2006-08-24 09:08:40 EDT
*** Bug 203899 has been marked as a duplicate of this bug. ***
Comment 4 Josh Boyer 2007-01-05 13:25:11 EST
This is still present in FC-6.  Any updates?
Comment 5 Gilboa Davara 2007-01-06 10:13:06 EST
Did anyone report it upstream to vim.org?

- Gilboa
Comment 6 Josh Boyer 2007-01-06 16:13:16 EST
(In reply to comment #5)
> Did anyone report it upstream to vim.org?

Not that I know of.  I'm not aware of a bugzilla for vim.org
Comment 7 Gilboa Davara 2007-01-07 04:54:03 EST
OK. I reported it upstream via mail.

- Gibloa
Comment 8 Gilboa Davara 2007-01-07 10:23:26 EST
Bad news.
Here's the vim.org response. (By Bram Moolenaar)

"Vim doesn't support using {} inside ().  It's needed for detecting missing ). 
Best is to avoid these ugly macros or hide them away in an include file.

- Bram"
Comment 9 Josh Boyer 2007-01-07 10:45:51 EST
(In reply to comment #8)
> Bad news.
> Here's the vim.org response. (By Bram Moolenaar)
> 
> "Vim doesn't support using {} inside ().  It's needed for detecting missing ). 
> Best is to avoid these ugly macros or hide them away in an include file.

Which list did you post this to?  I'd like to know why it was working just fine
in versions before vim 7

Comment 10 Gilboa Davara 2007-01-07 11:08:15 EST
bugs@vim.org
Comment 11 Josh Boyer 2007-01-07 17:06:08 EST
(In reply to comment #10)
> bugs@vim.org

I can't find an archive for that.  Could you ask why this same file didn't have
the syntax highlighting issue in Vim 6?  It seems like a regression to me.
Comment 12 Gilboa Davara 2007-01-08 04:17:22 EST
Sadly enough, the comments I go were less then cooperative. ("Don't use macros!").
I'd suggest you all email vim.org and ask for a bug fix.

- Gilboa
Comment 13 Gilboa Davara 2007-01-08 04:18:13 EST
s/I go/I got/g
Comment 14 Josh Boyer 2007-01-08 14:47:54 EST
I got a bit more information.  Below is the response with a patch that seems to
fix the problem:

Josh -

> I've noticed that Vim 7 seems to have a syntax highlighting regression
> in comparison to Vim 6.x.  There's a screen shot and a sample file at:
> 
> https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=203577
> 
> It seems that someone has already emailed this list about it, but I
> can't find archives anywhere and I was wondering why files like this
> highlighted correctly in Vim 6.x but not in Vim 7.
> 
> Please CC me in response.

This doesn't look like valid C to me, Something like:

#define a()    ({ 0  })

Anyway, it's caused by the folding of { } blocks.  Try this change:


*** ../../../vim-7.0/runtime/syntax/c.vim	Sun May  7 17:52:22 2006
--- c.vim	Mon Jan  8 19:36:21 2007
***************
*** 64,69 ****
--- 64,71 ----
    endif
  endif
  
+ syntax region	cBlock		start="{" end="}" transparent fold
+ 
  "catch errors caused by wrong parenthesis and brackets
  " also accept <% for {, %> for }, <: for [ and :> for ] (C99)
  " But avoid matching <::.
***************
*** 147,154 ****
  " keep a // comment separately, it terminates a preproc. conditional
  syntax match	cCommentError	display "\*/"
  syntax match	cCommentStartError display "/\*"me=e-1 contained
- 
- syntax region	cBlock		start="{" end="}" transparent fold
  
  syn keyword	cOperator	sizeof
  if exists("c_gnu")
--- 149,154 ----


I'll have to verify this doesn't cause new problems.

- Bram
Comment 15 Josh Boyer 2007-02-11 11:25:38 EST
This is still present in rawhide/f7t1
Comment 16 Karsten Hopp 2007-02-12 09:59:50 EST
please test vim-7.0.192-1.fc7 when it shows up in rawhide and report any errors
which might be caused by this patch here.
Comment 17 Josh Boyer 2007-02-15 08:54:59 EST
(In reply to comment #16)
> please test vim-7.0.192-1.fc7 when it shows up in rawhide and report any errors
> which might be caused by this patch here.

I'll be sure to update and test this tonight.  Assuming it functions properly,
can we get an update to FC-6 for this issue?

FYI, I carried the above patch locally on my machine for a while and had no
issues so I don't expect any problems with the new packages assuming they have
the patch.
Comment 18 Josh Boyer 2007-02-26 16:05:53 EST
This update seems to be working without any issues.  I waited for a while to see
if anything else broke and I've found nothing wrong.

Is there a possibility to get an update for FC-6 that fixes this issue?
Comment 19 Fedora Update System 2007-03-02 12:06:13 EST
vim-7.0.201-1.fc6 has been pushed for fc6, which should resolve this issue.  If these problems are still present in this version, then please make note of it in this bug report.

Note You need to log in before you can comment on or make changes to this bug.