"Eric M. Ludlam" <eric@...> [Tue, 19 January 2010 (23:21 EST)] wrote:
> Hi Brian,
> It's been a while, but I finally got to integrating your patch.
I wouldn't dare make any comments about taking a while. I've been away
for a bit (and I like to turn procrastination into an art form).
> I've been able to figure out what is going on, and can now use the
> hideif code directly without copying it. I also have a better idea of
> how many lines of code you wrote vs copied from hideif. If you can get
> a release to the FSF that would be great.
> You can just write to copyright-clerk@.... Tell them you have
> contributions to both EMACS and CEDET, and you will be sent the forms by
> email which you will need to send back via paper.
I will be sending them an email in the very near future.
> Despite all that, I ran all my test suites and they pass, and I've
> checked this code into CVS. I can pull it out later if you have issues
> getting paper work signed and ready for the FSF.
I found a small omission in your code around using (hif-mathify).
Since the values taken from 'cpp -E -dM -x c++ /dev/null' in (semantic-gcc-setup)
are added to semantic-lex-c-preprocessor-symbol-map as strings,
hif-mathify needs to deal with such items:
__SIZEOF_LONG__ "8" ==> 8
__GNUC__ "4" ==> 8
__DEC32_MIN_EXP__ "(-94)" ==> "(-94)"
__cplusplus "1" ==> 1
__DBL_HAS_DENORM__ "1" ==> 1
__DEC64_MIN_EXP__ "(-382)" ==> "(-382)"
__FLT_DENORM_MIN__ "1.40129846e-45F" ==> 1.40129846e-45
Here is the advice I have added to deal with these types of strings that
are added to SPP when using GCC:
(defadvice hif-mathify (around hif-mathify-around-advice activate)
(let* ((value (ad-get-arg 0)))
(if (and (stringp value)
(string-match "^\\(-?[0-9][.0-9]*\\([-+eE0-9]+\\)?\\)\\([FDL]+\\)?$" value))
(setq ad-return-value (string-to-number (substring value (match-beginning 1) (match-end 1))))
Originally I had overwritten hif-mathify with the following, but I think
the advice follows your changes, and is a little more robust:
;; this is just the code that I used originally
;; (defun semantic-c-lex-mathify (val-in)
;; "Treat VAL as a number: if it's t or nil, use 1 or 0."
;; (let ((val (cond ((stringp val-in) (string-to-number val-in))
;; (t val-in))))
;; (cond ((eq val t) 1)
;; ((null val) 0)
;; (t val))))
I thought about adding them to the
semantic-lex-c-preprocessor-symbol-map as numbers, but wasn't certain
if that was the preferred way.
> (setq semantic-c-takeover-hideif t)
This feature totally rocks, I'm glad you did it, because I was trying to
figure out how to do it and you beat me to the punch.