emacs-devel
[Top][All Lists]
Advanced

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

Bug in hide-ifdef-mode


From: martin rudalics
Subject: Bug in hide-ifdef-mode
Date: Sat, 19 Jan 2008 17:51:24 +0100
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

To reproduce with Emacs -Q: Open src/data.c and do M-x hide-ifdef-mode.

Should get you something like:

Debugger entered--Lisp error: (error "Bad token in parenthesized expression: 
125")
  signal(error ("Bad token in parenthesized expression: 125"))
  error("Bad token in parenthesized expression: %s" 125)
  hif-factor()
  hif-math()
  hif-eq-expr()
  hif-and-expr()
  hif-or-expr()
  hif-expr()
  hif-parse-if-exp((lparen FLT_RADIX equal 2 and FLT_MANT_DIG equal 24 and 
FLT_MIN_EXP equal hif-minus 125 and FLT_MAX_EXP equal 128 rparen))
  hif-canonicalize()
  hif-possibly-hide()
  hide-ifdef-guts()
  hif-recurse-on(1351 1547)
  hif-possibly-hide()
  hide-ifdef-guts()
  hide-ifdefs()
  hide-ifdef-mode(toggle)
  call-interactively(hide-ifdef-mode)
  execute-extended-command(nil)
  call-interactively(execute-extended-command)

The bug occurs when `hif-factor' tries to parse the unary minus in:

#if (FLT_RADIX == 2 && FLT_MANT_DIG == 24 \
     && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128)

The attached, somewhat naive, patch fixes the bug for me.  Could someone
who uses `hide-ifdef-mode' on a regular basis check whether that fix
breaks something else.  Thanks in advance.
*** progmodes/hideif.el Sat Jan 19 14:53:52 2008
--- progmodes/hideif.el Sat Jan 19 17:16:20 2008
***************
*** 473,478 ****
--- 473,486 ----
     ((numberp hif-token)
      (prog1 hif-token (hif-nexttoken)))
  
+    ((memq hif-token '(hif-minus hif-plus))
+     (let (result math-op)
+       (while (memq hif-token '(hif-plus hif-minus))
+       (setq math-op hif-token)
+       (hif-nexttoken)
+       (setq result (list math-op result (hif-factor))))
+       result))
+ 
     (t                                 ; identifier
      (let ((ident hif-token))
        (if (memq ident '(or and))

reply via email to

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