* Add '&' to hif-token-regexp
@ 2008-03-27 12:51 lgfang
0 siblings, 0 replies; only message in thread
From: lgfang @ 2008-03-27 12:51 UTC (permalink / raw)
To: bug-gnu-emacs, fanglungang
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 -: garyo@avs.com 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 -: garyo@avs.com 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-03-27 12:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-27 12:51 Add '&' to hif-token-regexp lgfang
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).