all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Marshall, Simon" <Simon.Marshall@misys.com>
To: <bug-cc-mode@gnu.org>
Cc: emacs-pretest-bug@gnu.org
Subject: RE: Font-lock does not fontify const pointer declaration
Date: Thu, 17 Apr 2008 13:14:33 +0100	[thread overview]
Message-ID: <6EE216E1AA959543A555C60FF34FB76703C6BED5__44582.8507341959$1208434892$gmane$org@maileube01.misys.global.ad> (raw)
In-Reply-To: 20080417084918.GA2019@muc.de

Hi Alan, again, thanks, this fixes the problem in 22.2.  (I also
compiled cc-fonts.el.) 

Simon.

-----Original Message-----
From: Alan Mackenzie [mailto:acm@muc.de] 
Sent: 17 April 2008 09:49
To: Marshall, Simon
Cc: 'bug-cc-mode@gnu.org'; 'emacs-pretest-bug@gnu.org'
Subject: Re: Font-lock does not fontify const pointer declaration

Good Morning, Simon!

On Thu, Sep 14, 2006 at 03:32:38PM +0100, Marshall, Simon wrote:
> Emacs 19-21 fontifies the following C/C++ snippet:

>   int *p;			// ok
>   const int *p;		// ok
>   int *const p;		// not ok in CVS emacs
>   const int *const p;	// not ok in CVS emacs

> so that "p" is in font-lock-variable-name-face.  

> In Emacs CVS, it does not fontify "p" when p is declared as a const
pointer.

This was a bug in one of the regexps parsing declarators, namely
c-type-decl-prefix-key.  It was recognising "const" as an identifier,
because the explicit check for "const\|throw\|volatile" came later in
the
regexp than "[[:alpha:]_]....".

Please apply the following patch, which fixes it, and let me know if it
works or not.  PLEASE NOTE: because a macro in cc-langs has changed, you
need to recompile cc-{mode,engine}.el.  Here's a recipe for this, after
patching the files:

M-x byte-compile-file cc-langs.el
M-x load-file cc-langs.elc
M-x byte-compile-file cc-mode.el
M-x load-file cc-mode.elc
M-x byte-compile-file cc-engine.el
M-x load-file cc-engine.el

M-x c++-mode



Index: cc-langs.el
===================================================================
RCS file: /cvsroot/cc-mode/cc-mode/cc-langs.el,v
retrieving revision 5.267.2.16
diff -c -r5.267.2.16 cc-langs.el
*** cc-langs.el	15 Apr 2008 20:05:59 -0000	5.267.2.16
--- cc-langs.el	17 Apr 2008 08:12:30 -0000
***************
*** 2596,2610 ****
    c++  (concat "\\("
  	       "[*\(&]"
  	       "\\|"
! 	       (concat "\\("	; 2
  		       ;; If this matches there's special treatment in
  		       ;; `c-font-lock-declarators' and
  		       ;; `c-font-lock-declarations' that check for a
  		       ;; complete name followed by ":: *".
  		       (c-lang-const c-identifier-start)
  		       "\\)")
- 	       "\\|"
- 	       (c-lang-const c-type-decl-prefix-key)
  	       "\\)"
  	       "\\([^=]\\|$\\)")
    pike "\\(\\*\\)\\([^=]\\|$\\)")
--- 2596,2610 ----
    c++  (concat "\\("
  	       "[*\(&]"
  	       "\\|"
! 	       (c-lang-const c-type-decl-prefix-key)
! 	       "\\|"
! 	       (concat "\\("   ; 3
  		       ;; If this matches there's special treatment in
  		       ;; `c-font-lock-declarators' and
  		       ;; `c-font-lock-declarations' that check for a
  		       ;; complete name followed by ":: *".
  		       (c-lang-const c-identifier-start)
  		       "\\)")
  	       "\\)"
  	       "\\([^=]\\|$\\)")
    pike "\\(\\*\\)\\([^=]\\|$\\)")
Index: cc-engine.el
===================================================================
RCS file: /cvsroot/cc-mode/cc-mode/cc-engine.el,v
retrieving revision 5.539.2.17
diff -c -r5.539.2.17 cc-engine.el
*** cc-engine.el	15 Apr 2008 20:05:59 -0000	5.539.2.17
--- cc-engine.el	17 Apr 2008 08:12:35 -0000
***************
*** 5399,5406 ****
        ;; `c-font-lock-declarators'.)
        (while (and (looking-at c-type-decl-prefix-key)
  		  (if (and (c-major-mode-is 'c++-mode)
! 			   (match-beginning 2))
! 		      ;; If the second submatch matches in C++ then
  		      ;; we're looking at an identifier that's a
  		      ;; prefix only if it specifies a member pointer.
  		      (when (setq got-identifier (c-forward-name))
--- 5400,5407 ----
        ;; `c-font-lock-declarators'.)
        (while (and (looking-at c-type-decl-prefix-key)
  		  (if (and (c-major-mode-is 'c++-mode)
! 			   (match-beginning 3))
! 		      ;; If the third submatch matches in C++ then
  		      ;; we're looking at an identifier that's a
  		      ;; prefix only if it specifies a member pointer.
  		      (when (setq got-identifier (c-forward-name))
Index: cc-fonts.el
===================================================================
RCS file: /cvsroot/cc-mode/cc-mode/cc-fonts.el,v
retrieving revision 5.205.2.6
diff -c -r5.205.2.6 cc-fonts.el
*** cc-fonts.el	15 Apr 2008 18:31:12 -0000	5.205.2.6
--- cc-fonts.el	17 Apr 2008 08:12:36 -0000
***************
*** 866,873 ****
  	      ;; `c-forward-decl-or-cast-1'.)
  	      (while (and (looking-at c-type-decl-prefix-key)
  			  (if (and (c-major-mode-is 'c++-mode)
! 				   (match-beginning 2))
! 			      ;; If the second submatch matches in C++
then
  			      ;; we're looking at an identifier that's a
  			      ;; prefix only if it specifies a member
pointer.
  			      (progn
--- 866,873 ----
  	      ;; `c-forward-decl-or-cast-1'.)
  	      (while (and (looking-at c-type-decl-prefix-key)
  			  (if (and (c-major-mode-is 'c++-mode)
! 				   (match-beginning 3))
! 			      ;; If the third submatch matches in C++
then
  			      ;; we're looking at an identifier that's a
  			      ;; prefix only if it specifies a member
pointer.
  			      (progn


> Simon.

-- 
Alan Mackenzie (Nuremberg, Germany).


 "Misys" is the trade name for Misys plc (registered in England and Wales). Registration Number: 01360027. Registered office: Burleigh House, Chapel Oak, Salford Priors, Evesham WR11 8SP. For a list of Misys group operating companies please go to http://www.misys.com/html/about_us/group_operating_companies/. This email and any attachments have been scanned for known viruses using multiple scanners. 
 
We believe that this email and any attachments are virus free, however the recipient must take full responsibility for virus checking. This email message is intended for the named recipient only. It may be privileged and/or confidential. If you are not the named recipient of this email please notify us immediately and do not copy it or use it for any purpose, nor disclose its contents to any other person. This email does not constitute the commencement of legal relations between you and Misys plc. Please refer to the executed contract between you and the relevant member of the Misys group for the identity of the contracting party with which you are dealing. 




      parent reply	other threads:[~2008-04-17 12:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <81CCA6588E60BB42BE68BD029ED482600A82C2AF@wimex2.wim.midas-kapiti.com>
2008-04-17  8:49 ` Font-lock does not fontify const pointer declaration Alan Mackenzie
     [not found] ` <20080417084918.GA2019@muc.de>
2008-04-17 12:14   ` Marshall, Simon [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='6EE216E1AA959543A555C60FF34FB76703C6BED5__44582.8507341959$1208434892$gmane$org@maileube01.misys.global.ad' \
    --to=simon.marshall@misys.com \
    --cc=bug-cc-mode@gnu.org \
    --cc=emacs-pretest-bug@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.