bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Add '&' to hif-token-regexp


From: lgfang
Subject: Add '&' to hif-token-regexp
Date: Thu, 27 Mar 2008 20:51:50 +0800
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (berkeley-unix)

Hi, 

I found that the hif-token-regexp doesn't deal with bit-wise-and ('&').
I understand that it is a very bad idea to use '&' in ifdef lines.
However, our legacy code does contain such lines.  So I patched the
"hideif.el".  Following is my emacs version info and my patch.
 
Since whether show or hide an ifdef block depends on your customized
hide-ifdef-env rather than MACROs defined in source files, to be
frank, the functionality of this patch may not very useful.  However,
it will not raise error on "#if (a & b)" any longer and therefore
would not block other operations (as to my configuration, hide-ifdef
is one of many c mode hooks).

Following is my emacs version and my patch:

In GNU Emacs 22.1.1 (i386-mingw-nt5.1.2600)

 of 2007-06-02 on RELEASE

Windowing system distributor `Microsoft Corp.', version 5.1.2600

configured using `configure --with-gcc (3.4) --cflags -Ic:/gnuwin32/include'
 
------ 8< ----------- my patch 8< ------------------------
*** hideif.el   2008-03-26 13:51:16.000000000 +0800
--- hideif.el.new       2008-03-26 14:06:01.000000000 +0800
***************
*** 310,316 ****
  ;; pattern to match initial identifier, !, &&, ||, (, or ).
  ;; Added ==, + and -: address@hidden 8/9/94
  (defconst hif-token-regexp
!   "\\(&&\\|||\\|[!=]=\\|!\\|[()+?:-]\\|[<>]=?\\|\\w+\\)")
  
  (defun hif-tokenize (start end)
    "Separate string between START and END into a list of tokens."
--- 310,316 ----
  ;; pattern to match initial identifier, !, &&, ||, (, or ).
  ;; Added ==, + and -: address@hidden 8/9/94
  (defconst hif-token-regexp
!   "\\(&&\\|||\\|[!=]=\\|!\\|[&()+?:-]\\|[<>]=?\\|\\w+\\)")
  
  (defun hif-tokenize (start end)
    "Separate string between START and END into a list of tokens."
***************
*** 343,348 ****
--- 343,349 ----
                     ((string-equal token "<=") 'hif-less-equal)
                     ((string-equal token "+") 'hif-plus)
                     ((string-equal token "-") 'hif-minus)
+                    ((string-equal token "&") 'hif-logand)
                     ((string-equal token "?") 'hif-conditional)
                     ((string-equal token ":") 'hif-colon)
                     ((string-match "\\`[0-9]*\\'" token)
***************
*** 416,422 ****
         math : factor | math '+|-' factor."
    (let ((result (hif-factor))
        (math-op nil))
!     (while (memq hif-token '(hif-plus hif-minus))
        (setq math-op hif-token)
        (hif-nexttoken)
        (setq result (list math-op result (hif-factor))))
--- 417,423 ----
         math : factor | math '+|-' factor."
    (let ((result (hif-factor))
        (math-op nil))
!     (while (memq hif-token '(hif-logand hif-plus hif-minus))
        (setq math-op hif-token)
        (hif-nexttoken)
        (setq result (list math-op result (hif-factor))))
***************
*** 480,485 ****
--- 481,489 ----
  (defun hif-minus (a b)
    "Like ordinary minus but treat t and nil as 1 and 0."
    (- (hif-mathify a) (hif-mathify b)))
+ (defun hif-logand (a b)
+   "Lik ordinary logand bug treat t and nil as 1 and 0."
+   (logand (hif-mathify a) (hif-mathify b)))
  (defun hif-notequal (a b)
    "Like (not (equal A B)) but as one symbol."
    (not (equal a b)))

----------------- 8< ------------------------

Regards,

-- 
Fang, lungang





reply via email to

[Prev in Thread] Current Thread [Next in Thread]