Subject: 24.0.92; etags misses C tags due to brackets

From: Eli Zaretskii <[email-masked]>
Date: Sat, 24 Dec 2011 11:08:07 +0200

cd src
 ../lib-src/etags xdisp.c -o xdisp.TAGS

Then look at xdisp.TAGS and you will see many functions missing from
the tags table.  Specifically, all the functions between lines 9097
and 21242 are not tagged.  Here's the relevant excerpt from the tags
table:

  in_display_vector_p ^?9025,284143
  add_to_log ^?9042,284592
  message_log_maybe_newline ^?9079,285427
  message_dolog ^?9096,285971
  display_count_lines ^?21243,659558
  display_string ^?21385,663522

Note the gap between line number 9096 and 21243.  This misses a large
number of functions that are actually present in xdisp.c.

What causes that is this fragment from message_dolog:

		      char dupstr[sizeof " [ times]"
				  + INT_STRLEN_BOUND (printmax_t)];

If you remove it, the problem goes away.

Looking at the code in etags.c:C_entries, I think that the problem
might be here:

      else if (bracketlev > 0)
	{
	  switch (c)
	    {
	    case ']':
	      if (--bracketlev > 0)
		continue;
	      break;
	    case '\0':
	      CNL_SAVE_DEFINEDEF ();
	      break;
	    }
	  continue;
	}

This seems to ignore everything except ']' inside brackets [], but it
does not pay attention to strings, comments, 'c' character constants
etc. that can happen inside brackets, and which can also include
bracket characters.

In GNU Emacs 24.0.92.1 (i386-mingw-nt5.1.2600)
 of 2011-12-02 on HOME-C4E4A596F7
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4)'

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: ENU
  value of $XMODIFIERS: nil
  locale-coding-system: cp1255
  default enable-multibyte-characters: t

Major mode: Mail

Minor modes in effect:
  shell-dirtrack-mode: t
  auto-fill-function: mail-mode-auto-fill
  flyspell-mode: t
  diff-auto-refine-mode: t
  desktop-save-mode: t
  show-paren-mode: t
  display-time-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  temp-buffer-resize-mode: t
  line-number-mode: t
  abbrev-mode: t

Recent input:
C-z C-z C-z C-z C-z C-z C-z C-z C-z C-z C-z C-z C-z 
C-z C-z C-z C-z C-z C-z C-z C-z C-z C-x b <return> 
C-SPC C-u 2 1 2 4 3 C-x g <prior> <prior> <prior> <prior> 
<prior> <prior> <prior> <prior> <prior> C-z C-z C-z 
C-z C-z C-z C-z C-z C-z C-z C-z C-z C-z C-z C-z C-z 
C-z C-z C-z C-z C-z C-z C-z C-z C-z C-z C-z <next> 
<prior> C-x C-x C-x b <return> M-z M-z M-z M-z M-z 
M-z M-z M-z M-z M-z M-z M-z M-z M-z M-z M-z M-z M-z 
M-z M-z M-z M-z M-z M-z M-z M-z M-z M-z M-z M-z M-z 
M-z M-z M-z M-z M-z M-z C-z C-z C-z C-z C-z C-z C-z 
C-z C-z C-z C-z C-z C-z C-z C-z C-z C-z C-z C-z C-z 
C-z C-z C-z C-z M-z M-z M-z M-z M-z M-z M-z M-z M-z 
M-z M-z M-z M-z M-z M-z M-z M-z M-z M-z M-z M-z M-z 
M-z M-z <next> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <C-right> <right> <right> C-r C-w C-r <M-left> 
<prior> C-z C-z C-z C-z C-z C-z C-z C-z C-z C-z C-z 
C-z C-z C-z C-z C-z C-z C-z C-z C-z C-z C-z C-z C-z 
C-z C-z C-x C-x <M-left> <prior> <prior> <prior> <next> 
<next> <next> <next> <next> <next> <prior> <next> <next> 
<next> <next> <next> <next> <prior> <next> <next> <next> 
<next> <next> <next> <prior> <prior> <prior> <prior> 
<prior> <prior> <prior> <prior> <prior> <prior> <prior> 
<prior> <prior> C-z C-z C-z C-z C-z C-z C-z C-z C-z 
C-z C-z C-z C-z <switch-frame> <switch-frame> <help-echo> 
<help-echo> <help-echo> <help-echo> <help-echo> <switch-frame> 
M-x r e p C-g <help-echo> <switch-frame> <switch-frame> 
<help-echo> <help-echo> <help-echo> <switch-frame> 
<switch-frame> <help-echo> <switch-frame> <help-echo> 
M-x r e p o r t - e m <tab> <return>

Recent messages:
Saving file d:/gnu/bzr/emacs/trunk/src/xdisp.c...
Wrote d:/gnu/bzr/emacs/trunk/src/xdisp.c
Undo!
Saving file d:/gnu/bzr/emacs/trunk/src/xdisp.c...
Wrote d:/gnu/bzr/emacs/trunk/src/xdisp.c
Undo!
Saving file d:/gnu/bzr/emacs/trunk/src/xdisp.c...
Wrote d:/gnu/bzr/emacs/trunk/src/xdisp.c
Mark set [4 times]
Mark saved where search started
Quit

Load-path shadows:
None found.

Features:
(shadow emacsbug ind-util shell thingatpt add-log texinfo iso-transl
tar-mode etags mule-util ebuff-menu electric cus-start cus-load quail
help-mode view network-stream starttls tls smtpmail auth-source eieio
assoc gnus-util password-cache dabbrev mailalias sendmail
multi-isearch rmailout ld-script sh-script executable dired-x dired
tcl parse-time nxml-uchnm rng-xsd xsd-regexp rng-cmpct rng-nxml
rng-valid rng-loc rng-uri rng-parse nxml-parse rng-match rng-dt
rng-util rng-pttrn nxml-ns nxml-mode nxml-outln nxml-rap nxml-util
nxml-glyph nxml-enc xmltok sgml-mode arc-mode archive-mode generic
conf-mode newcomment org-wl org-w3m org-vm org-rmail org-mhe org-mew
org-irc org-jsinfo org-infojs org-html org-exp ob-exp org-exp-blocks
org-agenda org-info org-gnus org-docview org-bibtex bibtex org-bbdb
org byte-opt warnings bytecomp byte-compile cconv macroexp advice
help-fns advice-preload ob-emacs-lisp ob-tangle ob-ref ob-lob ob-table
org-footnote org-src ob-comint ob-keys ob ob-eval org-pcomplete
pcomplete comint ring org-list org-faces org-compat org-entities
org-macs cal-menu calendar cal-loaddefs jka-compr vc-cvs flyspell
ispell noutline outline make-mode diff-mode easy-mmode autorevert info
vc-bzr cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align
cc-engine cc-vars cc-defs regexp-opt qp rmailsum rmailmm message
format-spec rfc822 mml easymenu mml-sec mm-decode mm-bodies mm-encode
mailabbrev gmm-utils mailheader mail-parse rfc2231 rmail rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils desktop server
filecache saveplace midnight generic-x paren battery time time-date
tooltip ediff-hook vc-hooks lisp-float-type mwheel dos-w32 disp-table
ls-lisp w32-win w32-vars tool-bar dnd fontset image fringe lisp-mode
register page menu-bar rfn-eshadow timer select scroll-bar mouse
jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer loaddefs button faces cus-face files text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process multi-tty
emacs)