From: weisman@osf.ORG (Dave Weisman)
Subject: Small bug in harris-tags
Organization: Open Software Foundation
Distribution: gnu
Date: Tue, 10 Nov 1992 23:50:13 GMT

There is a small bug in the Harris tags package.  The symptom is
that when using etags files, the wrong location may sometimes be
found.
 
In the function find-tag there are several places where the
buffer-local variable traditional-tags-table is (incorrectly)
examined outside of its buffer.  The fix is to make a copy while
in the correct buffer and subsequently examine the copy.  Context
diff follows.
 
Dave
 
======================================================================
 
*** c:/demacs/lisp2/harris-ta.el	Sat Aug 22 19:41:28 1992
--- c:/demacs/lispdw/harris-ta.el	Mon Nov  9 14:10:48 1992
***************
*** 320,326
    (interactive (if current-prefix-arg
  		   '(nil t)
  		 (find-tag-tag "Find tag: ")))
!   (let (buffer file linebeg startpos startline)
      (save-excursion
        (visit-tags-table-buffer)
        (if next (setq tagname last-tag)
 
--- 320,326 -----
    (interactive (if current-prefix-arg
  		   '(nil t)
  		 (find-tag-tag "Find tag: ")))
!   (let (buffer file linebeg startpos startline traditional-tags-table-copy)
      (save-excursion
        (visit-tags-table-buffer)
  
***************
*** 323,328
    (let (buffer file linebeg startpos startline)
      (save-excursion
        (visit-tags-table-buffer)
        (if next (setq tagname last-tag)
  	(goto-char (point-min))
  	(setq last-tag tagname))
 
--- 323,332 -----
    (let (buffer file linebeg startpos startline traditional-tags-table-copy)
      (save-excursion
        (visit-tags-table-buffer)
+ 
+       ;; We need a local copy for when we're out of the tags buffer. 
+       (setq traditional-tags-table-copy traditional-tags-table)
+ 
        (if next (setq tagname last-tag)
  	(goto-char (point-min))
  	(setq last-tag tagname))
***************
*** 367,373
        (setq tags-file-name tags-file))
      (widen)
      (push-mark)
!     (let ((offset (if traditional-tags-table 1000 20))
  	  found
  	  (pat (concat (if traditional-tags-table "^" "^[ \t]*")
  		       (regexp-quote linebeg))))
 
--- 371,377 -----
        (setq tags-file-name tags-file))
      (widen)
      (push-mark)
!     (let ((offset (if traditional-tags-table-copy 1000 20))
  	  found
  	  (pat (concat (if traditional-tags-table-copy "^" "^[ \t]*")
  		       (regexp-quote linebeg))))
***************
*** 369,375
      (push-mark)
      (let ((offset (if traditional-tags-table 1000 20))
  	  found
! 	  (pat (concat (if traditional-tags-table "^" "^[ \t]*")
  		       (regexp-quote linebeg))))
        (or traditional-tags-table
  	  (setq startpos (if (null startline)
 
--- 373,379 -----
      (push-mark)
      (let ((offset (if traditional-tags-table-copy 1000 20))
  	  found
! 	  (pat (concat (if traditional-tags-table-copy "^" "^[ \t]*")
  		       (regexp-quote linebeg))))
        (or traditional-tags-table-copy
  	  (setq startpos (if (null startline)
***************
*** 371,377
  	  found
  	  (pat (concat (if traditional-tags-table "^" "^[ \t]*")
  		       (regexp-quote linebeg))))
!       (or traditional-tags-table
  	  (setq startpos (if (null startline)
  			     (point-min)
  			   (goto-char 1)
 
--- 375,381 -----
  	  found
  	  (pat (concat (if traditional-tags-table-copy "^" "^[ \t]*")
  		       (regexp-quote linebeg))))
!       (or traditional-tags-table-copy
  	  (setq startpos (if (null startline)
  			     (point-min)
  			   (goto-char 1)
***************
*** 385,391
  	      (re-search-forward pat (+ startpos offset) t))
  	(setq offset (* 3 offset)))
        (or found
! 	  (if traditional-tags-table
  	      (or (re-search-forward pat nil t)
  		  (error "%s not found in %s" pat file))
  	    (re-search-forward pat))))
 
--- 389,395 -----
  	      (re-search-forward pat (+ startpos offset) t))
  	(setq offset (* 3 offset)))
        (or found
! 	  (if traditional-tags-table-copy
  	      (or (re-search-forward pat nil t)
  		  (error "%s not found in %s" pat file))
  	    (re-search-forward pat))))


--

-- Dave


Newsgroups: gnu.emacs.bug