Syntax highlighting problems for C

3 views
Skip to first unread message

Dasn

unread,
Mar 17, 2008, 7:56:22 AM3/17/08
to vim...@googlegroups.com
The highlighting of a multi-line comment is broken after #define

" Language: C
" Last Change: 2008 Mar 05

$ cat test.c
#define TEST 4 /* hello
comment */
--
Dasn

Bram Moolenaar

unread,
Mar 17, 2008, 5:28:33 PM3/17/08
to Dasn, vim...@googlegroups.com

Dasn wrote:

Works fine for me. Try using ftp://ftp.vim.org/pub/vim/runtime/syntax/c.vim


Why is it that so many people don't sign messages with their real name?
It's like talking to people in a completely dark room.

--
hundred-and-one symptoms of being an internet addict:
143. You dream in pallettes of 216 websafe colors.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Vladimir Marek

unread,
Mar 18, 2008, 4:25:27 AM3/18/08
to vim...@googlegroups.com

Also broken for me. Using

vim -u /dev/null --noplugin -c "syn on" test.c

:version
VIM - Vi IMproved 7.1 (2007 May 12, compiled Mar 17 2008 15:33:40)
Included patches: 1-283

:!head -4 $VIMRUNTIME/syntax/c.vim
" Vim syntax file
" Language: C
" Maintainer: Bram Moolenaar <Br...@vim.org>


" Last Change: 2008 Mar 05

Solaris, self compiled

--
Vlad

Ben Schmidt

unread,
Mar 18, 2008, 4:47:42 AM3/18/08
to vim...@googlegroups.com

I think the attached patch will fix it. I think it's better to let the change and
code comments speak for themselves than to try to explain it.

Ben.

c.vim.patch

Vladimir Marek

unread,
Mar 18, 2008, 4:59:34 AM3/18/08
to vim...@googlegroups.com
> I think the attached patch will fix it. I think it's better to let the change and
> code comments speak for themselves than to try to explain it.

Indeed it does for me.

Thank you
--
Vlad

Bram Moolenaar

unread,
Mar 19, 2008, 4:55:38 PM3/19/08
to Vladimir Marek, vim...@googlegroups.com

Vladimir Marek wrote:

Aha, I didn't see the problem because I have c_comment_strings defined.
Without it I can see the problem. It's easy to fix:

*** c.vim~ Wed Mar 5 12:20:50 2008
--- c.vim Wed Mar 19 21:44:52 2008
***************
*** 149,157 ****
else
syn region cCommentL start="//" skip="\\$" end="$" keepend contains=@cCommentGroup,cSpaceError,@Spell
if exists("c_no_comment_fold")
! syn region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cSpaceError,@Spell
else
! syn region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cSpaceError,@Spell fold
endif
endif
" keep a // comment separately, it terminates a preproc. conditional
--- 149,157 ----
else
syn region cCommentL start="//" skip="\\$" end="$" keepend contains=@cCommentGroup,cSpaceError,@Spell
if exists("c_no_comment_fold")
! syn region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cSpaceError,@Spell extend
else
! syn region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cSpaceError,@Spell fold extend
endif
endif
" keep a // comment separately, it terminates a preproc. conditional

--
hundred-and-one symptoms of being an internet addict:

155. You forget to eat because you're too busy surfing the net.

Reply all
Reply to author
Forward
0 new messages