annotate lib-src/etags.c @ 5157:1fae11d56ad2

redo memory-usage mechanism, add way of dynamically initializing Lisp objects -------------------- ChangeLog entries follow: -------------------- lisp/ChangeLog addition: 2010-03-18 Ben Wing <ben@xemacs.org> * diagnose.el (show-memory-usage): Rewrite to take into account API changes in memory-usage functions. src/ChangeLog addition: 2010-03-18 Ben Wing <ben@xemacs.org> * alloc.c: * alloc.c (disksave_object_finalization_1): * alloc.c (lisp_object_storage_size): * alloc.c (listu): * alloc.c (listn): * alloc.c (Fobject_memory_usage_stats): * alloc.c (compute_memusage_stats_length): * alloc.c (Fobject_memory_usage): * alloc.c (Ftotal_object_memory_usage): * alloc.c (malloced_storage_size): * alloc.c (common_init_alloc_early): * alloc.c (reinit_alloc_objects_early): * alloc.c (reinit_alloc_early): * alloc.c (init_alloc_once_early): * alloc.c (syms_of_alloc): * alloc.c (reinit_vars_of_alloc): * buffer.c: * buffer.c (struct buffer_stats): * buffer.c (compute_buffer_text_usage): * buffer.c (compute_buffer_usage): * buffer.c (buffer_memory_usage): * buffer.c (buffer_objects_create): * buffer.c (syms_of_buffer): * buffer.c (vars_of_buffer): * console-impl.h (struct console_methods): * dynarr.c (Dynarr_memory_usage): * emacs.c (main_1): * events.c (clear_event_resource): * extents.c: * extents.c (compute_buffer_extent_usage): * extents.c (extent_objects_create): * extents.h: * faces.c: * faces.c (compute_face_cachel_usage): * faces.c (face_objects_create): * faces.h: * general-slots.h: * glyphs.c: * glyphs.c (compute_glyph_cachel_usage): * glyphs.c (glyph_objects_create): * glyphs.h: * lisp.h: * lisp.h (struct usage_stats): * lrecord.h: * lrecord.h (enum lrecord_type): * lrecord.h (struct lrecord_implementation): * lrecord.h (MC_ALLOC_CALL_FINALIZER_FOR_DISKSAVE): * lrecord.h (DEFINE_DUMPABLE_LISP_OBJECT): * lrecord.h (DEFINE_DUMPABLE_SIZABLE_LISP_OBJECT): * lrecord.h (DEFINE_DUMPABLE_FROB_BLOCK_LISP_OBJECT): * lrecord.h (DEFINE_DUMPABLE_FROB_BLOCK_SIZABLE_LISP_OBJECT): * lrecord.h (DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT): * lrecord.h (DEFINE_DUMPABLE_SIZABLE_INTERNAL_LISP_OBJECT): * lrecord.h (DEFINE_NODUMP_LISP_OBJECT): * lrecord.h (DEFINE_NODUMP_SIZABLE_LISP_OBJECT): * lrecord.h (DEFINE_NODUMP_FROB_BLOCK_LISP_OBJECT): * lrecord.h (DEFINE_NODUMP_FROB_BLOCK_SIZABLE_LISP_OBJECT): * lrecord.h (DEFINE_NODUMP_INTERNAL_LISP_OBJECT): * lrecord.h (DEFINE_NODUMP_SIZABLE_INTERNAL_LISP_OBJECT): * lrecord.h (MAKE_LISP_OBJECT): * lrecord.h (DEFINE_DUMPABLE_MODULE_LISP_OBJECT): * lrecord.h (DEFINE_DUMPABLE_MODULE_SIZABLE_LISP_OBJECT): * lrecord.h (DEFINE_NODUMP_MODULE_LISP_OBJECT): * lrecord.h (DEFINE_NODUMP_MODULE_SIZABLE_LISP_OBJECT): * lrecord.h (MAKE_MODULE_LISP_OBJECT): * lrecord.h (INIT_LISP_OBJECT): * lrecord.h (INIT_MODULE_LISP_OBJECT): * lrecord.h (UNDEF_LISP_OBJECT): * lrecord.h (UNDEF_MODULE_LISP_OBJECT): * lrecord.h (DECLARE_LISP_OBJECT): * lrecord.h (DECLARE_MODULE_API_LISP_OBJECT): * lrecord.h (DECLARE_MODULE_LISP_OBJECT): * lstream.c: * lstream.c (syms_of_lstream): * lstream.c (vars_of_lstream): * marker.c: * marker.c (compute_buffer_marker_usage): * mc-alloc.c (mc_alloced_storage_size): * mc-alloc.h: * mule-charset.c: * mule-charset.c (struct charset_stats): * mule-charset.c (compute_charset_usage): * mule-charset.c (charset_memory_usage): * mule-charset.c (mule_charset_objects_create): * mule-charset.c (syms_of_mule_charset): * mule-charset.c (vars_of_mule_charset): * redisplay.c: * redisplay.c (compute_rune_dynarr_usage): * redisplay.c (compute_display_block_dynarr_usage): * redisplay.c (compute_glyph_block_dynarr_usage): * redisplay.c (compute_display_line_dynarr_usage): * redisplay.c (compute_line_start_cache_dynarr_usage): * redisplay.h: * scrollbar-gtk.c (gtk_compute_scrollbar_instance_usage): * scrollbar-msw.c (mswindows_compute_scrollbar_instance_usage): * scrollbar-x.c (x_compute_scrollbar_instance_usage): * scrollbar.c (compute_scrollbar_instance_usage): * scrollbar.h: * symbols.c: * symbols.c (reinit_symbol_objects_early): * symbols.c (init_symbols_once_early): * symbols.c (reinit_symbols_early): * symbols.c (defsymbol_massage_name_1): * symsinit.h: * ui-gtk.c: * ui-gtk.c (emacs_gtk_object_getprop): * ui-gtk.c (emacs_gtk_object_putprop): * ui-gtk.c (ui_gtk_objects_create): * unicode.c (compute_from_unicode_table_size_1): * unicode.c (compute_to_unicode_table_size_1): * unicode.c (compute_from_unicode_table_size): * unicode.c (compute_to_unicode_table_size): * window.c: * window.c (struct window_stats): * window.c (compute_window_mirror_usage): * window.c (compute_window_usage): * window.c (window_memory_usage): * window.c (window_objects_create): * window.c (syms_of_window): * window.c (vars_of_window): * window.h: Redo memory-usage mechanism, make it general; add way of dynamically initializing Lisp object types -- OBJECT_HAS_METHOD(), similar to CONSOLE_HAS_METHOD(). (1) Create OBJECT_HAS_METHOD(), OBJECT_HAS_PROPERTY() etc. for specifying that a Lisp object type has a particular method or property. Call such methods with OBJECT_METH, MAYBE_OBJECT_METH, OBJECT_METH_OR_GIVEN; retrieve properties with OBJECT_PROPERTY. Methods that formerly required a DEFINE_*GENERAL_LISP_OBJECT() to specify them (getprop, putprop, remprop, plist, disksave) now instead use the dynamic-method mechanism. The main benefit of this is that new methods or properties can be added without requiring that the declaration statements of all existing methods be modified. We have to make the `struct lrecord_implementation' non-const, but I don't think this should have any effect on speed -- the only possible method that's really speed-critical is the mark method, and we already extract those out into a separate (non-const) array for increased cache locality. Object methods need to be reinitialized after pdump, so we put them in separate functions such as face_objects_create(), extent_objects_create() and call them appropriately from emacs.c The only current object property (`memusage_stats_list') that objects can specify is a Lisp object and gets staticpro()ed so it only needs to be set during dump time, but because it references symbols that might not exist in a syms_of_() function, we initialize it in vars_of_(). There is also an object property (`num_extra_memusage_stats') that is automatically initialized based on `memusage_stats_list'; we do that in reinit_vars_of_alloc(), which is called after all vars_of_() functions are called. `disksaver' method was renamed `disksave' to correspond with the name normally given to the function (e.g. disksave_lstream()). (2) Generalize the memory-usage mechanism in `buffer-memory-usage', `window-memory-usage', `charset-memory-usage' into an object-type- specific mechanism called by a single function `object-memory-usage'. (Former function `object-memory-usage' renamed to `total-object-memory-usage'). Generalize the mechanism of different "slices" so that we can have different "classes" of memory described and different "slices" onto each class; `t' separates classes, `nil' separates slices. Currently we have three classes defined: the memory of an object itself, non-Lisp-object memory associated with the object (e.g. arrays or dynarrs stored as fields in the object), and Lisp-object memory associated with the object (other internal Lisp objects stored in the object). This isn't completely finished yet and we might need to further separate the "other internal Lisp objects" class into two classes. The memory-usage mechanism uses a `struct usage_stats' (renamed from `struct overhead_stats') to describe a malloc-view onto a set of allocated memory (listing how much was requested and various types of overhead) and a more general `struct generic_usage_stats' (with a `struct usage_stats' in it) to hold all statistics about object memory. `struct generic_usage_stats' contains an array of 32 Bytecounts, which are statistics of unspecified semantics. The intention is that individual types declare a corresponding struct (e.g. `struct window_stats') with the same structure but with specific fields in place of the array, corresponding to specific statistics. The number of such statistics is an object property computed from the list of tags (Lisp symbols describing the statistics) stored in `memusage_stats_list'. The idea here is to allow particular object types to customize the number and semantics of the statistics where completely avoiding consing. This doesn't matter so much yet, but the intention is to have the memory usage of all objects computed at the end of GC, at the same time as other statistics are currently computed. The values for all statistics for a single type would be added up to compute aggregate values for all objects of a specific type. To make this efficient, we can't allow any memory allocation at all. (3) Create some additional functions for creating lists that specify the elements directly as args rather than indirectly through an array: listn() (number of args given), listu() (list terminated by Qunbound). (4) Delete a bit of remaining unused C window_config stuff, also unused lrecord_type_popup_data.
author Ben Wing <ben@xemacs.org>
date Thu, 18 Mar 2010 10:50:06 -0500
parents 0f5bee973a7b
children 061f4f90f874
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1 /* Tags file maker to go with GNU Emacs -*- coding: latin-1 -*-
3972
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
2
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
3 Copyright (C) 1984 The Regents of the University of California
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
4
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
5 Redistribution and use in source and binary forms, with or without
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
6 modification, are permitted provided that the following conditions are
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
7 met:
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
8 1. Redistributions of source code must retain the above copyright
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
9 notice, this list of conditions and the following disclaimer.
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
10 2. Redistributions in binary form must reproduce the above copyright
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
11 notice, this list of conditions and the following disclaimer in the
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
12 documentation and/or other materials provided with the
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
13 distribution.
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
14 3. Neither the name of the University nor the names of its
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
15 contributors may be used to endorse or promote products derived
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
16 from this software without specific prior written permission.
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
17
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
18 THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS''
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
20 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
21 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
23 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
25 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
26 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
27 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
28 IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
29
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
30
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
31 Copyright (C) 1984, 1987, 1988, 1989, 1993, 1994, 1995, 1998, 1999,
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
32 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
33 Free Software Foundation, Inc.
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
34
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
35 This file is not considered part of GNU Emacs.
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
36
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
37 This program is free software; you can redistribute it and/or modify
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
38 it under the terms of the GNU General Public License as published by
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
39 the Free Software Foundation; either version 2 of the License, or
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
40 (at your option) any later version.
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
41
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
42 This program is distributed in the hope that it will be useful,
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
43 but WITHOUT ANY WARRANTY; without even the implied warranty of
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
44 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
45 GNU General Public License for more details.
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
46
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
47 You should have received a copy of the GNU General Public License
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
48 along with this program; if not, write to the Free Software Foundation,
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
49 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
50
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
51
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
52 /* NB To comply with the above BSD license, copyright information is
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
53 reproduced in etc/ETAGS.README. That file should be updated when the
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
54 above notices are.
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
55
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
56 To the best of our knowledge, this code was originally based on the
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
57 ctags.c distributed with BSD4.2, which was copyrighted by the
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
58 University of California, as described above. */
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
59
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 * Authors:
3972
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
63 * 1983 Ctags originally by Ken Arnold.
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
64 * 1984 Fortran added by Jim Kleckner.
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
65 * 1984 Ed Pelegri-Llopart added C typedefs.
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
66 * 1985 Emacs TAGS format by Richard Stallman.
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
67 * 1989 Sam Kendall added C++.
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
68 * 1992 Joseph B. Wells improved C and C++ parsing.
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
69 * 1993 Francesco Potort́ reorganised C and C++.
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
70 * 1994 Line-by-line regexp tags by Tom Tromey.
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
71 * 2001 Nested classes by Francesco Potort́ (concept by Mykola Dzyuba).
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
72 * 2002 #line directives by Francesco Potort́.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 *
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
74 * Francesco Potort́ <pot@gnu.org> has maintained and improved it since 1993.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
77 /*
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
78 * If you want to add support for a new language, start by looking at the LUA
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
79 * language, which is the simplest. Alternatively, consider shipping a
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
80 * configuration file containing regexp definitions for etags.
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
81 */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
82
3993
9bab7e657255 [xemacs-hg @ 2007-05-29 14:14:49 by stephent]
stephent
parents: 3972
diff changeset
83 char pot_etags_version[] = "@(#) pot revision number is 17.33";
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 #define TRUE 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 #define FALSE 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
88 #ifdef DEBUG
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
89 # undef DEBUG
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
90 # define DEBUG TRUE
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
91 #else
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
92 # define DEBUG FALSE
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
93 # define NDEBUG /* disable assert */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 #ifdef HAVE_CONFIG_H
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 # include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 /* On some systems, Emacs defines static as nothing for the sake
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 of unexec. We don't want that here since we don't use unexec. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 # undef static
3524
0a57cc6116d1 [xemacs-hg @ 2006-07-21 16:36:50 by stephent]
stephent
parents: 3517
diff changeset
101 # ifndef PTR /* for XEmacs */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
102 # define PTR void *
715
add5a821a048 [xemacs-hg @ 2001-12-24 07:44:55 by yoshiki]
yoshiki
parents: 709
diff changeset
103 # endif
3524
0a57cc6116d1 [xemacs-hg @ 2006-07-21 16:36:50 by stephent]
stephent
parents: 3517
diff changeset
104 # ifndef __P /* for XEmacs */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
105 # define __P(args) args
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
106 # endif
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
107 #else /* no config.h */
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
108 # if defined(__STDC__) && (__STDC__ || defined(__SUNPRO_C))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
109 # define __P(args) args /* use prototypes */
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
110 # define PTR void * /* for generic pointers */
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
111 # else /* not standard C */
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
112 # define __P(args) () /* no prototypes */
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
113 # define const /* remove const for old compilers' sake */
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
114 # define PTR long * /* don't use void* */
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
115 # endif
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
116 #endif /* !HAVE_CONFIG_H */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117
432
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 428
diff changeset
118 #ifndef _GNU_SOURCE
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 428
diff changeset
119 # define _GNU_SOURCE 1 /* enables some compiler checks on GNU */
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 428
diff changeset
120 #endif
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 428
diff changeset
121
3524
0a57cc6116d1 [xemacs-hg @ 2006-07-21 16:36:50 by stephent]
stephent
parents: 3517
diff changeset
122 /* WIN32_NATIVE is for XEmacs.
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
123 MSDOS, WINDOWSNT, DOS_NT are for Emacs. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
124 #ifdef WIN32_NATIVE
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
125 # undef MSDOS
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
126 # undef WINDOWSNT
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
127 # define WINDOWSNT
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
128 #endif /* WIN32_NATIVE */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
129
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
130 #ifdef MSDOS
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
131 # undef MSDOS
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
132 # define MSDOS TRUE
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
133 # include <fcntl.h>
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
134 # include <sys/param.h>
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
135 # include <io.h>
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
136 # ifndef HAVE_CONFIG_H
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
137 # define DOS_NT
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
138 # include <sys/config.h>
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
139 # endif
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
140 #else
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
141 # define MSDOS FALSE
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
142 #endif /* MSDOS */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
143
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
144 #ifdef WINDOWSNT
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 # include <stdlib.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 # include <fcntl.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 # include <string.h>
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
148 # include <direct.h>
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 # include <io.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 # define MAXPATHLEN _MAX_PATH
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
151 # undef HAVE_NTGUI
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
152 # undef DOS_NT
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
153 # define DOS_NT
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 # ifndef HAVE_GETCWD
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 # define HAVE_GETCWD
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 # endif /* undef HAVE_GETCWD */
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
157 #else /* not WINDOWSNT */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
158 # ifdef STDC_HEADERS
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
159 # include <stdlib.h>
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
160 # include <string.h>
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
161 # else /* no standard C headers */
3972
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
162 extern char *getenv ();
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
163 extern char *strcpy ();
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
164 extern char *strncpy ();
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
165 extern char *strcat ();
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
166 extern char *strncat ();
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
167 extern unsigned long strlen ();
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
168 extern PTR malloc ();
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
169 extern PTR realloc ();
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
170 # ifdef VMS
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
171 # define EXIT_SUCCESS 1
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
172 # define EXIT_FAILURE 0
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
173 # else /* no VMS */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
174 # define EXIT_SUCCESS 0
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
175 # define EXIT_FAILURE 1
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
176 # endif
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
177 # endif
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
178 #endif /* !WINDOWSNT */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 #ifdef HAVE_UNISTD_H
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 # include <unistd.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 #else
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
183 # if defined (HAVE_GETCWD) && !defined (WINDOWSNT)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
184 extern char *getcwd (char *buf, size_t size);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 # endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 #endif /* HAVE_UNISTD_H */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 #include <stdio.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 #include <ctype.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 #include <errno.h>
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
191 #ifndef errno
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
192 extern int errno;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
193 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 #include <sys/types.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 #include <sys/stat.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
197 #include <assert.h>
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
198 #ifdef NDEBUG
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
199 # undef assert /* some systems have a buggy assert.h */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
200 # define assert(x) ((void) 0)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
201 #endif
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
202
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 #if !defined (S_ISREG) && defined (S_IFREG)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
207 #ifdef NO_LONG_OPTIONS /* define this if you don't have GNU getopt */
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
208 # define NO_LONG_OPTIONS TRUE
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 # define getopt_long(argc,argv,optstr,lopts,lind) getopt (argc, argv, optstr)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 extern char *optarg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 extern int optind, opterr;
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
212 #else
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
213 # define NO_LONG_OPTIONS FALSE
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
214 # include <getopt.h>
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
215 #endif /* NO_LONG_OPTIONS */
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
216
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
217 #ifndef HAVE_CONFIG_H /* this is a standalone compilation */
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
218 # ifdef __CYGWIN__ /* compiling on Cygwin */
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
219 !!! NOTICE !!!
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
220 the regex.h distributed with Cygwin is not compatible with etags, alas!
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
221 If you want regular expression support, you should delete this notice and
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
222 arrange to use the GNU regex.h and regex.c.
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
223 # endif
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
224 #endif
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
225 #include <regex.h>
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 /* Define CTAGS to make the program "ctags" compatible with the usual one.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 Leave it undefined to make the program "etags", which makes emacs-style
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 tag tables and tags typedefs, #defines and struct/union/enum by default. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 #ifdef CTAGS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 # undef CTAGS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 # define CTAGS TRUE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 # define CTAGS FALSE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
237 #define streq(s,t) (assert((s)!=NULL || (t)!=NULL), !strcmp (s, t))
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
238 #define strcaseeq(s,t) (assert((s)!=NULL && (t)!=NULL), !etags_strcasecmp (s, t))
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
239 #define strneq(s,t,n) (assert((s)!=NULL || (t)!=NULL), !strncmp (s, t, n))
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
240 #define strncaseeq(s,t,n) (assert((s)!=NULL && (t)!=NULL), !etags_strncasecmp (s, t, n))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 #define CHARS 256 /* 2^sizeof(char) */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
243 #define CHAR(x) ((unsigned int)(x) & (CHARS - 1))
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
244 #define iswhite(c) (_wht[CHAR(c)]) /* c is white (see white) */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
245 #define notinname(c) (_nin[CHAR(c)]) /* c is not in a name (see nonam) */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
246 #define begtoken(c) (_btk[CHAR(c)]) /* c can start token (see begtk) */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
247 #define intoken(c) (_itk[CHAR(c)]) /* c can be in token (see midtk) */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
248 #define endtoken(c) (_etk[CHAR(c)]) /* c ends tokens (see endtk) */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
250 #define ISALNUM(c) isalnum (CHAR(c))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
251 #define ISALPHA(c) isalpha (CHAR(c))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
252 #define ISDIGIT(c) isdigit (CHAR(c))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
253 #define ISLOWER(c) islower (CHAR(c))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
254
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
255 #define lowcase(c) tolower (CHAR(c))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
256 #define upcase(c) toupper (CHAR(c))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
257
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 * xnew, xrnew -- allocate, reallocate storage
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 * SYNOPSIS: Type *xnew (int n, Type);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
263 * void xrnew (OldPointer, int n, Type);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
265 #if DEBUG
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 # include "chkmalloc.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 # define xnew(n,Type) ((Type *) trace_malloc (__FILE__, __LINE__, \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 (n) * sizeof (Type)))
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
269 # define xrnew(op,n,Type) ((op) = (Type *) trace_realloc (__FILE__, __LINE__, \
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
270 (char *) (op), (n) * sizeof (Type)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 # define xnew(n,Type) ((Type *) xmalloc ((n) * sizeof (Type)))
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
273 # define xrnew(op,n,Type) ((op) = (Type *) xrealloc ( \
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
274 (char *) (op), (n) * sizeof (Type)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
277 #define bool int
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
278
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
279 typedef void Lang_function __P((FILE *));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 typedef struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
283 char *suffix; /* file name suffix for this compressor */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
284 char *command; /* takes one arg and decompresses to stdout */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 } compressor;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 typedef struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
289 char *name; /* language name */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
290 char *help; /* detailed help for the language */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
291 Lang_function *function; /* parse function */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
292 char **suffixes; /* name suffixes of this language's files */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
293 char **filenames; /* names of this language's files */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
294 char **interpreters; /* interpreters for this language */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
295 bool metasource; /* source used to generate other sources */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 } language;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
298 typedef struct fdesc
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
299 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
300 struct fdesc *next; /* for the linked list */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
301 char *infname; /* uncompressed input file name */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
302 char *infabsname; /* absolute uncompressed input file name */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
303 char *infabsdir; /* absolute dir of input file */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
304 char *taggedfname; /* file name to write in tagfile */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
305 language *lang; /* language of file */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
306 char *prop; /* file properties to write in tagfile */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
307 bool usecharno; /* etags tags shall contain char number */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
308 bool written; /* entry written in the tags file */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
309 } fdesc;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
310
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 typedef struct node_st
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
312 { /* sorting structure */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
313 struct node_st *left, *right; /* left and right sons */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
314 fdesc *fdp; /* description of file to whom tag belongs */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
315 char *name; /* tag name */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
316 char *regex; /* search regexp */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
317 bool valid; /* write this tag on the tag file */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
318 bool is_func; /* function tag: use regexp in CTAGS mode */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
319 bool been_warned; /* warning already given for duplicated tag */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
320 int lno; /* line number tag is on */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 long cno; /* character number line starts on */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 } node;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 * A `linebuffer' is a structure which holds a line of text.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 * `readline_internal' reads a line from a stream into a linebuffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 * and works regardless of the length of the line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 * SIZE is the size of BUFFER, LEN is the length of the string in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 * BUFFER after readline reads it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 typedef struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 long size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 char *buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 } linebuffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
338 /* Used to support mixing of --lang and file names. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
339 typedef struct
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
340 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
341 enum {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
342 at_language, /* a language specification */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
343 at_regexp, /* a regular expression */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
344 at_filename, /* a file name */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
345 at_stdin, /* read from stdin here */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
346 at_end /* stop parsing the list */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
347 } arg_type; /* argument type */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
348 language *lang; /* language associated with the argument */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
349 char *what; /* the argument itself */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
350 } argument;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
351
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
352 /* Structure defining a regular expression. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
353 typedef struct regexp
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
354 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
355 struct regexp *p_next; /* pointer to next in list */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
356 language *lang; /* if set, use only for this language */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
357 char *pattern; /* the regexp pattern */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
358 char *name; /* tag name */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
359 struct re_pattern_buffer *pat; /* the compiled pattern */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
360 struct re_registers regs; /* re registers */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
361 bool error_signaled; /* already signaled for this regexp */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
362 bool force_explicit_name; /* do not allow implict tag name */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
363 bool ignore_case; /* ignore case when matching */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
364 bool multi_line; /* do a multi-line match on the whole file */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
365 } regexp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
366
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
367
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 /* Many compilers barf on this:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 Lang_function Ada_funcs;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 so let's write it this way */
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
371 static void Ada_funcs __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
372 static void Asm_labels __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
373 static void C_entries __P((int c_ext, FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
374 static void default_C_entries __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
375 static void plain_C_entries __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
376 static void Cjava_entries __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
377 static void Cobol_paragraphs __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
378 static void Cplusplus_entries __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
379 static void Cstar_entries __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
380 static void Erlang_functions __P((FILE *));
2554
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
381 static void Forth_words __P((FILE *));
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
382 static void Fortran_functions __P((FILE *));
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
383 static void HTML_labels __P((FILE *));
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
384 static void Lisp_functions __P((FILE *));
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
385 static void Lua_functions __P((FILE *));
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
386 static void Makefile_targets __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
387 static void Pascal_functions __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
388 static void Perl_functions __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
389 static void PHP_functions __P((FILE *));
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
390 static void PS_functions __P((FILE *));
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
391 static void Prolog_functions __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
392 static void Python_functions __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
393 static void Scheme_functions __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
394 static void TeX_commands __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
395 static void Texinfo_nodes __P((FILE *));
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
396 static void Yacc_entries __P((FILE *));
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
397 static void just_read_file __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
398
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
399 static void print_language_names __P((void));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
400 static void print_version __P((void));
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
401 static void print_help __P((argument *));
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
402 int main __P((int, char **));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
403
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
404 static compressor *get_compressor_from_suffix __P((char *, char **));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
405 static language *get_language_from_langname __P((const char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
406 static language *get_language_from_interpreter __P((char *));
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
407 static language *get_language_from_filename __P((char *, bool));
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
408 static void readline __P((linebuffer *, FILE *));
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
409 static long readline_internal __P((linebuffer *, FILE *));
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
410 static bool nocase_tail __P((char *));
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
411 static void get_tag __P((char *, char **));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
413 static void analyse_regex __P((char *));
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
414 static void free_regexps __P((void));
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
415 static void regex_tag_multiline __P((void));
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
416 static void error __P((const char *, const char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
417 static void suggest_asking_for_help __P((void));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
418 void fatal __P((char *, char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
419 static void pfatal __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
420 static void add_node __P((node *, node **));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
421
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
422 static void init __P((void));
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
423 static void process_file_name __P((char *, language *));
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
424 static void process_file __P((FILE *, char *, language *));
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
425 static void find_entries __P((FILE *));
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
426 static void free_tree __P((node *));
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
427 static void free_fdesc __P((fdesc *));
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
428 static void pfnote __P((char *, bool, char *, int, int, long));
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
429 static void make_tag __P((char *, int, bool, char *, int, int, long));
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
430 static void invalidate_nodes __P((fdesc *, node **));
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
431 static void put_entries __P((node *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
432
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
433 static char *concat __P((char *, char *, char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
434 static char *skip_spaces __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
435 static char *skip_non_spaces __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
436 static char *savenstr __P((char *, int));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
437 static char *savestr __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
438 static char *etags_strchr __P((const char *, int));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
439 static char *etags_strrchr __P((const char *, int));
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
440 static int etags_strcasecmp __P((const char *, const char *));
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
441 static int etags_strncasecmp __P((const char *, const char *, int));
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
442 static char *etags_getcwd __P((void));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
443 static char *relative_filename __P((char *, char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
444 static char *absolute_filename __P((char *, char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
445 static char *absolute_dirname __P((char *, char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
446 static bool filename_is_absolute __P((char *f));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
447 static void canonicalize_filename __P((char *));
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
448 static void linebuffer_init __P((linebuffer *));
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
449 static void linebuffer_setlen __P((linebuffer *, int));
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
450 static PTR xmalloc __P((unsigned int));
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
451 static PTR xrealloc __P((char *, unsigned int));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
454 static char searchar = '/'; /* use /.../ searches */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
455
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
456 static char *tagfile; /* output file */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
457 static char *progname; /* name this program was invoked with */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
458 static char *cwd; /* current working directory */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
459 static char *tagfiledir; /* directory of tagfile */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
460 static FILE *tagf; /* ioptr for tags file */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
461
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
462 static fdesc *fdhead; /* head of file description list */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
463 static fdesc *curfdp; /* current file description */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
464 static int lineno; /* line number of current line */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
465 static long charno; /* current character number */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
466 static long linecharno; /* charno of start of current line */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
467 static char *dbp; /* pointer to start of current tag */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
468
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
469 static const int invalidcharno = -1;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
470
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
471 static node *nodehead; /* the head of the binary tree of tags */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
472 static node *last_node; /* the last node created */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
473
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
474 static linebuffer lb; /* the current line */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
475 static linebuffer filebuf; /* a buffer containing the whole file */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
476 static linebuffer token_name; /* a buffer containing a tag name */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 /* boolean "functions" (see init) */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
479 static bool _wht[CHARS], _nin[CHARS], _itk[CHARS], _btk[CHARS], _etk[CHARS];
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
480 static char
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 /* white chars */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
482 *white = " \f\t\n\r\v",
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 /* not in a name */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
484 *nonam = " \f\t\n\r()=,;", /* look at make_tag before modifying! */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 /* token ending chars */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 *endtk = " \t\n\r\"'#()[]{}=-+%*/&|^~!<>;,.:?",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 /* token starting chars */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 *begtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$~@",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 /* valid in-token chars */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 *midtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$0123456789";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
492 static bool append_to_tagfile; /* -a: append to tags */
3972
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
493 /* The next five default to TRUE for etags, but to FALSE for ctags. */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
494 static bool typedefs; /* -t: create tags for C and Ada typedefs */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
495 static bool typedefs_or_cplusplus; /* -T: create tags for C typedefs, level */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 /* 0 struct/enum/union decls, and C++ */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 /* member functions. */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
498 static bool constantypedefs; /* -d: create tags for C #define, enum */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 /* constants and variables. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 /* -D: opposite of -d. Default under ctags. */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
501 static bool globals; /* create tags for global variables */
3972
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
502 static bool members; /* create tags for C member variables */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
503 static bool declarations; /* --declarations: tag them and extern in C&Co*/
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
504 static bool no_line_directive; /* ignore #line directives (undocumented) */
3876
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
505 static bool no_duplicates; /* no duplicate tags for ctags (undocumented) */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
506 static bool update; /* -u: update tags */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
507 static bool vgrind_style; /* -v: create vgrind style index output */
3876
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
508 static bool no_warnings; /* -w: suppress warnings (undocumented) */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
509 static bool cxref_style; /* -x: create cxref style output */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
510 static bool cplusplus; /* .[hc] means C++, not C */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
511 static bool ignoreindent; /* -I: ignore indentation in C */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
512 static bool packages_only; /* --packages-only: in Ada, only tag packages*/
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
513
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
514 /* STDIN is defined in LynxOS system headers */
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
515 #ifdef STDIN
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
516 # undef STDIN
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
517 #endif
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
518
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
519 #define STDIN 0x1001 /* returned by getopt_long on --parse-stdin */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
520 static bool parsing_stdin; /* --parse-stdin used */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
521
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
522 static regexp *p_head; /* list of all regexps */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
523 static bool need_filebuf; /* some regexes are multi-line */
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
524
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
525 static struct option longopts[] =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 {
3876
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
527 { "append", no_argument, NULL, 'a' },
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
528 { "packages-only", no_argument, &packages_only, TRUE },
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
529 { "c++", no_argument, NULL, 'C' },
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
530 { "declarations", no_argument, &declarations, TRUE },
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
531 { "no-line-directive", no_argument, &no_line_directive, TRUE },
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
532 { "no-duplicates", no_argument, &no_duplicates, TRUE },
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
533 { "help", no_argument, NULL, 'h' },
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
534 { "help", no_argument, NULL, 'H' },
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
535 { "ignore-indentation", no_argument, NULL, 'I' },
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
536 { "language", required_argument, NULL, 'l' },
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
537 { "members", no_argument, &members, TRUE },
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
538 { "no-members", no_argument, &members, FALSE },
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
539 { "output", required_argument, NULL, 'o' },
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
540 { "regex", required_argument, NULL, 'r' },
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
541 { "no-regex", no_argument, NULL, 'R' },
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
542 { "ignore-case-regex", required_argument, NULL, 'c' },
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
543 { "parse-stdin", required_argument, NULL, STDIN },
3876
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
544 { "version", no_argument, NULL, 'V' },
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
545
3090
95be8ad778e3 [xemacs-hg @ 2005-11-24 12:37:59 by malcolmp]
malcolmp
parents: 2554
diff changeset
546 #if CTAGS /* Ctags options */
3876
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
547 { "backward-search", no_argument, NULL, 'B' },
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
548 { "cxref", no_argument, NULL, 'x' },
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
549 { "defines", no_argument, NULL, 'd' },
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
550 { "globals", no_argument, &globals, TRUE },
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
551 { "typedefs", no_argument, NULL, 't' },
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
552 { "typedefs-and-c++", no_argument, NULL, 'T' },
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
553 { "update", no_argument, NULL, 'u' },
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
554 { "vgrind", no_argument, NULL, 'v' },
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
555 { "no-warn", no_argument, NULL, 'w' },
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
556
3090
95be8ad778e3 [xemacs-hg @ 2005-11-24 12:37:59 by malcolmp]
malcolmp
parents: 2554
diff changeset
557 #else /* Etags options */
3876
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
558 { "no-defines", no_argument, NULL, 'D' },
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
559 { "no-globals", no_argument, &globals, FALSE },
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
560 { "include", required_argument, NULL, 'i' },
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
561 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 { NULL }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
565 static compressor compressors[] =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 { "z", "gzip -d -c"},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 { "Z", "gzip -d -c"},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 { "gz", "gzip -d -c"},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 { "GZ", "gzip -d -c"},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 { "bz2", "bzip2 -d -c" },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 { NULL }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 * Language stuff.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 /* Ada code */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
580 static char *Ada_suffixes [] =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 { "ads", "adb", "ada", NULL };
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
582 static char Ada_help [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
583 "In Ada code, functions, procedures, packages, tasks and types are\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
584 tags. Use the `--packages-only' option to create tags for\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
585 packages only.\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
586 Ada tag names have suffixes indicating the type of entity:\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
587 Entity type: Qualifier:\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
588 ------------ ----------\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
589 function /f\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
590 procedure /p\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
591 package spec /s\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
592 package body /b\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
593 type /t\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
594 task /k\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
595 Thus, `M-x find-tag <RET> bidule/b <RET>' will go directly to the\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
596 body of the package `bidule', while `M-x find-tag <RET> bidule <RET>'\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
597 will just search for any tag `bidule'.";
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 /* Assembly code */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
600 static char *Asm_suffixes [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
601 { "a", /* Unix assembler */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
602 "asm", /* Microcontroller assembly */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
603 "def", /* BSO/Tasking definition includes */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
604 "inc", /* Microcontroller include files */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
605 "ins", /* Microcontroller include files */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
606 "s", "sa", /* Unix assembler */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
607 "S", /* cpp-processed Unix assembler */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
608 "src", /* BSO/Tasking C compiler output */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
609 NULL
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
610 };
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
611 static char Asm_help [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
612 "In assembler code, labels appearing at the beginning of a line,\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
613 followed by a colon, are tags.";
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
614
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 /* Note that .c and .h can be considered C++, if the --c++ flag was
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
617 given, or if the `class' or `template' keyowrds are met inside the file.
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
618 That is why default_C_entries is called for these. */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
619 static char *default_C_suffixes [] =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 { "c", "h", NULL };
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
621 static char default_C_help [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
622 "In C code, any C function or typedef is a tag, and so are\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
623 definitions of `struct', `union' and `enum'. `#define' macro\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
624 definitions and `enum' constants are tags unless you specify\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
625 `--no-defines'. Global variables are tags unless you specify\n\
3972
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
626 `--no-globals' and so are struct members unless you specify\n\
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
627 `--no-members'. Use of `--no-globals', `--no-defines' and\n\
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
628 `--no-members' can make the tags table file much smaller.\n\
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
629 You can tag function declarations and external variables by\n\
3972
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
630 using `--declarations'.";
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
631
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
632 static char *Cplusplus_suffixes [] =
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
633 { "C", "c++", "cc", "cpp", "cxx", "H", "h++", "hh", "hpp", "hxx",
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 "M", /* Objective C++ */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 "pdb", /* Postscript with C syntax */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 NULL };
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
637 static char Cplusplus_help [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
638 "In C++ code, all the tag constructs of C code are tagged. (Use\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
639 --help --lang=c --lang=c++ for full help.)\n\
3972
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
640 In addition to C tags, member functions are also recognized. Member\n\
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
641 variables are recognized unless you use the `--no-members' option.\n\
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
642 Tags for variables and functions in classes are named `CLASS::VARIABLE'\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
643 and `CLASS::FUNCTION'. `operator' definitions have tag names like\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
644 `operator+'.";
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
645
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
646 static char *Cjava_suffixes [] =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 { "java", NULL };
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
648 static char Cjava_help [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
649 "In Java code, all the tags constructs of C and C++ code are\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
650 tagged. (Use --help --lang=c --lang=c++ --lang=java for full help.)";
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
651
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
652
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
653 static char *Cobol_suffixes [] =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 { "COB", "cob", NULL };
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
655 static char Cobol_help [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
656 "In Cobol code, tags are paragraph names; that is, any word\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
657 starting in column 8 and followed by a period.";
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
658
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
659 static char *Cstar_suffixes [] =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 { "cs", "hs", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
662 static char *Erlang_suffixes [] =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 { "erl", "hrl", NULL };
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
664 static char Erlang_help [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
665 "In Erlang code, the tags are the functions, records and macros\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
666 defined in the file.";
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
667
2554
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
668 char *Forth_suffixes [] =
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
669 { "fth", "tok", NULL };
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
670 static char Forth_help [] =
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
671 "In Forth code, tags are words defined by `:',\n\
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
672 constant, code, create, defer, value, variable, buffer:, field.";
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
673
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
674 static char *Fortran_suffixes [] =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 { "F", "f", "f90", "for", NULL };
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
676 static char Fortran_help [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
677 "In Fortran code, functions, subroutines and block data are tags.";
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
678
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
679 static char *HTML_suffixes [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
680 { "htm", "html", "shtml", NULL };
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
681 static char HTML_help [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
682 "In HTML input files, the tags are the `title' and the `h1', `h2',\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
683 `h3' headers. Also, tags are `name=' in anchors and all\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
684 occurrences of `id='.";
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
685
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
686 static char *Lisp_suffixes [] =
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
687 { "cl", "clisp", "el", "l", "lisp", "LSP", "lsp", "ml", NULL };
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
688 static char Lisp_help [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
689 "In Lisp code, any function defined with `defun', any variable\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
690 defined with `defvar' or `defconst', and in general the first\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
691 argument of any expression that starts with `(def' in column zero\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
692 is a tag.";
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
693
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
694 static char *Lua_suffixes [] =
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
695 { "lua", "LUA", NULL };
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
696 static char Lua_help [] =
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
697 "In Lua scripts, all functions are tags.";
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
698
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
699 static char *Makefile_filenames [] =
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
700 { "Makefile", "makefile", "GNUMakefile", "Makefile.in", "Makefile.am", NULL};
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
701 static char Makefile_help [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
702 "In makefiles, targets are tags; additionally, variables are tags\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
703 unless you specify `--no-globals'.";
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
704
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
705 static char *Objc_suffixes [] =
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
706 { "lm", /* Objective lex file */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 "m", /* Objective C file */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 NULL };
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
709 static char Objc_help [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
710 "In Objective C code, tags include Objective C definitions for classes,\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
711 class categories, methods and protocols. Tags for variables and\n\
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
712 functions in classes are named `CLASS::VARIABLE' and `CLASS::FUNCTION'.\n\
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
713 (Use --help --lang=c --lang=objc --lang=java for full help.)";
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
714
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
715 static char *Pascal_suffixes [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
716 { "p", "pas", NULL };
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
717 static char Pascal_help [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
718 "In Pascal code, the tags are the functions and procedures defined\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
719 in the file.";
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
720 /* " // this is for working around an Emacs highlighting bug... */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
721
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
722 static char *Perl_suffixes [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
723 { "pl", "pm", NULL };
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
724 static char *Perl_interpreters [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
725 { "perl", "@PERL@", NULL };
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
726 static char Perl_help [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
727 "In Perl code, the tags are the packages, subroutines and variables\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
728 defined by the `package', `sub', `my' and `local' keywords. Use\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
729 `--globals' if you want to tag global variables. Tags for\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
730 subroutines are named `PACKAGE::SUB'. The name for subroutines\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
731 defined in the default package is `main::SUB'.";
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
732
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
733 static char *PHP_suffixes [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
734 { "php", "php3", "php4", NULL };
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
735 static char PHP_help [] =
3972
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
736 "In PHP code, tags are functions, classes and defines. Unless you use\n\
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
737 the `--no-members' option, vars are tags too.";
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
738
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
739 static char *plain_C_suffixes [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
740 { "pc", /* Pro*C file */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
741 NULL };
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
742
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
743 static char *PS_suffixes [] =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 { "ps", "psw", NULL }; /* .psw is for PSWrap */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
745 static char PS_help [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
746 "In PostScript code, the tags are the functions.";
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
747
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
748 static char *Prolog_suffixes [] =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 { "prolog", NULL };
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
750 static char Prolog_help [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
751 "In Prolog code, tags are predicates and rules at the beginning of\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
752 line.";
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
753
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
754 static char *Python_suffixes [] =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 { "py", NULL };
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
756 static char Python_help [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
757 "In Python code, `def' or `class' at the beginning of a line\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
758 generate a tag.";
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 /* Can't do the `SCM' or `scm' prefix with a version number. */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
761 static char *Scheme_suffixes [] =
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
762 { "oak", "sch", "scheme", "SCM", "scm", "SM", "sm", "ss", "t", NULL };
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
763 static char Scheme_help [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
764 "In Scheme code, tags include anything defined with `def' or with a\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
765 construct whose name starts with `def'. They also include\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
766 variables set with `set!' at top level in the file.";
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
767
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
768 static char *TeX_suffixes [] =
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
769 { "bib", "clo", "cls", "ltx", "sty", "TeX", "tex", NULL };
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
770 static char TeX_help [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
771 "In LaTeX text, the argument of any of the commands `\\chapter',\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
772 `\\section', `\\subsection', `\\subsubsection', `\\eqno', `\\label',\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
773 `\\ref', `\\cite', `\\bibitem', `\\part', `\\appendix', `\\entry',\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
774 `\\index', `\\def', `\\newcommand', `\\renewcommand',\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
775 `\\newenvironment' or `\\renewenvironment' is a tag.\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
776 \n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
777 Other commands can be specified by setting the environment variable\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
778 `TEXTAGS' to a colon-separated list like, for example,\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
779 TEXTAGS=\"mycommand:myothercommand\".";
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
780
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
781
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
782 static char *Texinfo_suffixes [] =
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
783 { "texi", "texinfo", "txi", NULL };
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
784 static char Texinfo_help [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
785 "for texinfo files, lines starting with @node are tagged.";
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
786
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
787 static char *Yacc_suffixes [] =
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
788 { "y", "y++", "ym", "yxx", "yy", NULL }; /* .ym is Objective yacc file */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
789 static char Yacc_help [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
790 "In Bison or Yacc input files, each rule defines as a tag the\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
791 nonterminal it constructs. The portions of the file that contain\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
792 C code are parsed as C code (use --help --lang=c --lang=yacc\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
793 for full help).";
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
794
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
795 static char auto_help [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
796 "`auto' is not a real language, it indicates to use\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
797 a default language for files base on file name suffix and file contents.";
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
798
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
799 static char none_help [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
800 "`none' is not a real language, it indicates to only do\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
801 regexp processing on files.";
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
802
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
803 static char no_lang_help [] =
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
804 "No detailed help available for this language.";
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
805
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 * Table of languages.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 * It is ok for a given function to be listed under more than one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 * name. I just didn't.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
814 static language lang_names [] =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
816 { "ada", Ada_help, Ada_funcs, Ada_suffixes },
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
817 { "asm", Asm_help, Asm_labels, Asm_suffixes },
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
818 { "c", default_C_help, default_C_entries, default_C_suffixes },
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
819 { "c++", Cplusplus_help, Cplusplus_entries, Cplusplus_suffixes },
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
820 { "c*", no_lang_help, Cstar_entries, Cstar_suffixes },
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
821 { "cobol", Cobol_help, Cobol_paragraphs, Cobol_suffixes },
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
822 { "erlang", Erlang_help, Erlang_functions, Erlang_suffixes },
2554
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
823 { "forth", Forth_help, Forth_words, Forth_suffixes },
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
824 { "fortran", Fortran_help, Fortran_functions, Fortran_suffixes },
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
825 { "html", HTML_help, HTML_labels, HTML_suffixes },
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
826 { "java", Cjava_help, Cjava_entries, Cjava_suffixes },
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
827 { "lisp", Lisp_help, Lisp_functions, Lisp_suffixes },
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
828 { "lua", Lua_help, Lua_functions, Lua_suffixes },
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
829 { "makefile", Makefile_help,Makefile_targets,NULL,Makefile_filenames},
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
830 { "objc", Objc_help, plain_C_entries, Objc_suffixes },
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
831 { "pascal", Pascal_help, Pascal_functions, Pascal_suffixes },
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
832 { "perl",Perl_help,Perl_functions,Perl_suffixes,NULL,Perl_interpreters},
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
833 { "php", PHP_help, PHP_functions, PHP_suffixes },
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
834 { "postscript",PS_help, PS_functions, PS_suffixes },
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
835 { "proc", no_lang_help, plain_C_entries, plain_C_suffixes },
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
836 { "prolog", Prolog_help, Prolog_functions, Prolog_suffixes },
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
837 { "python", Python_help, Python_functions, Python_suffixes },
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
838 { "scheme", Scheme_help, Scheme_functions, Scheme_suffixes },
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
839 { "tex", TeX_help, TeX_commands, TeX_suffixes },
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
840 { "texinfo", Texinfo_help, Texinfo_nodes, Texinfo_suffixes },
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
841 { "yacc", Yacc_help,Yacc_entries,Yacc_suffixes,NULL,NULL,TRUE},
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
842 { "auto", auto_help }, /* default guessing scheme */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
843 { "none", none_help, just_read_file }, /* regexp matching only */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
844 { NULL } /* end of list */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845 };
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
846
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 print_language_names ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851 language *lang;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
852 char **name, **ext;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 puts ("\nThese are the currently supported languages, along with the\n\
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
855 default file names and dot suffixes:");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856 for (lang = lang_names; lang->name != NULL; lang++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
858 printf (" %-*s", 10, lang->name);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
859 if (lang->filenames != NULL)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
860 for (name = lang->filenames; *name != NULL; name++)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
861 printf (" %s", *name);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 if (lang->suffixes != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863 for (ext = lang->suffixes; *ext != NULL; ext++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864 printf (" .%s", *ext);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 puts ("");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 }
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
867 puts ("where `auto' means use default language for files based on file\n\
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868 name suffix, and `none' means only do regexp processing on files.\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869 If no language is specified and no matching suffix is found,\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 the first line of the file is read for a sharp-bang (#!) sequence\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 followed by the name of an interpreter. If no such sequence is found,\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872 Fortran is tried first; if no tags are found, C is tried next.\n\
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
873 When parsing any C file, a \"class\" or \"template\" keyword\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
874 switches to C++.");
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
875 puts ("Compressed files are supported using gzip and bzip2.\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
876 \n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
877 For detailed help on a given language use, for example,\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
878 etags --help --lang=ada.");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
881 #ifndef EMACS_NAME
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
882 # define EMACS_NAME "standalone"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 #endif
3972
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
884 #ifndef VERSION
3993
9bab7e657255 [xemacs-hg @ 2007-05-29 14:14:49 by stephent]
stephent
parents: 3972
diff changeset
885 # define VERSION "17.33"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 print_version ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889 {
3972
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
890 printf ("%s (%s %s)\n", (CTAGS) ? "ctags" : "etags", EMACS_NAME, VERSION);
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
891 puts ("Copyright (C) 2007 Free Software Foundation, Inc.");
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
892 puts ("This program is distributed under the terms in ETAGS.README");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
893
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
894 exit (EXIT_SUCCESS);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896
3993
9bab7e657255 [xemacs-hg @ 2007-05-29 14:14:49 by stephent]
stephent
parents: 3972
diff changeset
897 #ifndef PRINT_UNDOCUMENTED_OPTIONS_HELP
9bab7e657255 [xemacs-hg @ 2007-05-29 14:14:49 by stephent]
stephent
parents: 3972
diff changeset
898 # define PRINT_UNDOCUMENTED_OPTIONS_HELP FALSE
9bab7e657255 [xemacs-hg @ 2007-05-29 14:14:49 by stephent]
stephent
parents: 3972
diff changeset
899 #endif
9bab7e657255 [xemacs-hg @ 2007-05-29 14:14:49 by stephent]
stephent
parents: 3972
diff changeset
900
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 static void
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
902 print_help (argbuffer)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
903 argument *argbuffer;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
905 bool help_for_lang = FALSE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
906
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
907 for (; argbuffer->arg_type != at_end; argbuffer++)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
908 if (argbuffer->arg_type == at_language)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
909 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
910 if (help_for_lang)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
911 puts ("");
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
912 puts (argbuffer->lang->help);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
913 help_for_lang = TRUE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
914 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
915
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
916 if (help_for_lang)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
917 exit (EXIT_SUCCESS);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
918
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 printf ("Usage: %s [options] [[regex-option ...] file-name] ...\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 These are the options accepted by %s.\n", progname, progname);
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
922 if (NO_LONG_OPTIONS)
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
923 puts ("WARNING: long option names do not work with this executable,\n\
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
924 as it is not linked with GNU getopt.");
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
925 else
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
926 puts ("You may use unambiguous abbreviations for the long option names.");
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
927 puts (" A - as file name means read names from stdin (one per line).\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
928 Absolute names are stored in the output file as they are.\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
929 Relative ones are stored relative to the output file's directory.\n");
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
930
3090
95be8ad778e3 [xemacs-hg @ 2005-11-24 12:37:59 by malcolmp]
malcolmp
parents: 2554
diff changeset
931 puts ("-a, --append\n\
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 Append tag entries to existing tags file.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 puts ("--packages-only\n\
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
935 For Ada files, only generate tags for packages.");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 if (CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938 puts ("-B, --backward-search\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 Write the search commands for the tag entries using '?', the\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 backward-search command instead of '/', the forward-search command.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
942 /* This option is mostly obsolete, because etags can now automatically
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
943 detect C++. Retained for backward compatibility and for debugging and
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
944 experimentation. In principle, we could want to tag as C++ even
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
945 before any "class" or "template" keyword.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946 puts ("-C, --c++\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 Treat files whose name suffix defaults to C language as C++ files.");
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
948 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950 puts ("--declarations\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 In C and derived languages, create tags for function declarations,");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952 if (CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953 puts ("\tand create tags for extern variables if --globals is used.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 puts
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 ("\tand create tags for extern variables unless --no-globals is used.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958 if (CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959 puts ("-d, --defines\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960 Create tag entries for C #define constants and enum constants, too.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 puts ("-D, --no-defines\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963 Don't create tag entries for C #define constants and enum constants.\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964 This makes the tags file smaller.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966 if (!CTAGS)
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
967 puts ("-i FILE, --include=FILE\n\
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
968 Include a note in tag file indicating that, when searching for\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969 a tag, one should also consult the tags file FILE after\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970 checking the current file.");
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
971
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
972 puts ("-l LANG, --language=LANG\n\
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973 Force the following files to be considered as written in the\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974 named language up to the next --language=LANG option.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
975
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976 if (CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977 puts ("--globals\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978 Create tag entries for global variables in some languages.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 puts ("--no-globals\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981 Do not create tag entries for global variables in some\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982 languages. This makes the tags file smaller.");
3993
9bab7e657255 [xemacs-hg @ 2007-05-29 14:14:49 by stephent]
stephent
parents: 3972
diff changeset
983
9bab7e657255 [xemacs-hg @ 2007-05-29 14:14:49 by stephent]
stephent
parents: 3972
diff changeset
984 if (PRINT_UNDOCUMENTED_OPTIONS_HELP)
9bab7e657255 [xemacs-hg @ 2007-05-29 14:14:49 by stephent]
stephent
parents: 3972
diff changeset
985 puts ("--no-line-directive\n\
9bab7e657255 [xemacs-hg @ 2007-05-29 14:14:49 by stephent]
stephent
parents: 3972
diff changeset
986 Ignore #line preprocessor directives in C and derived languages.");
9bab7e657255 [xemacs-hg @ 2007-05-29 14:14:49 by stephent]
stephent
parents: 3972
diff changeset
987
3972
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
988 if (CTAGS)
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
989 puts ("--members\n\
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
990 Create tag entries for members of structures in some languages.");
3972
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
991 else
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
992 puts ("--no-members\n\
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
993 Do not create tag entries for members of structures\n\
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
994 in some languages.");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
996 puts ("-r REGEXP, --regex=REGEXP or --regex=@regexfile\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
997 Make a tag for each line matching a regular expression pattern\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
998 in the following files. {LANGUAGE}REGEXP uses REGEXP for LANGUAGE\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
999 files only. REGEXFILE is a file containing one REGEXP per line.\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1000 REGEXP takes the form /TAGREGEXP/TAGNAME/MODS, where TAGNAME/ is\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1001 optional. The TAGREGEXP pattern is anchored (as if preceded by ^).");
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1002 puts (" If TAGNAME/ is present, the tags created are named.\n\
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 For example Tcl named tags can be created with:\n\
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1004 --regex=\"/proc[ \\t]+\\([^ \\t]+\\)/\\1/.\".\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1005 MODS are optional one-letter modifiers: `i' means to ignore case,\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1006 `m' means to allow multi-line matches, `s' implies `m' and\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1007 causes dot to match any character, including newline.");
3993
9bab7e657255 [xemacs-hg @ 2007-05-29 14:14:49 by stephent]
stephent
parents: 3972
diff changeset
1008
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009 puts ("-R, --no-regex\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010 Don't create tags from regexps for the following files.");
3993
9bab7e657255 [xemacs-hg @ 2007-05-29 14:14:49 by stephent]
stephent
parents: 3972
diff changeset
1011
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1012 puts ("-I, --ignore-indentation\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1013 In C and C++ do not assume that a closing brace in the first\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1014 column is the final brace of a function or structure definition.");
3993
9bab7e657255 [xemacs-hg @ 2007-05-29 14:14:49 by stephent]
stephent
parents: 3972
diff changeset
1015
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 puts ("-o FILE, --output=FILE\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017 Write the tags to FILE.");
3993
9bab7e657255 [xemacs-hg @ 2007-05-29 14:14:49 by stephent]
stephent
parents: 3972
diff changeset
1018
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1019 puts ("--parse-stdin=NAME\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1020 Read from standard input and record tags as belonging to file NAME.");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 if (CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024 puts ("-t, --typedefs\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025 Generate tag entries for C and Ada typedefs.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026 puts ("-T, --typedefs-and-c++\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027 Generate tag entries for C typedefs, C struct/enum/union tags,\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028 and C++ member functions.");
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1029 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1030
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1031 if (CTAGS)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1032 puts ("-u, --update\n\
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033 Update the tag entries for the given files, leaving tag\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 entries for other files in place. Currently, this is\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1035 implemented by deleting the existing entries for the given\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036 files and then rewriting the new entries at the end of the\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037 tags file. It is often faster to simply rebuild the entire\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1038 tag file than to use this.");
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1039
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1040 if (CTAGS)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1041 {
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1042 puts ("-v, --vgrind\n\
3090
95be8ad778e3 [xemacs-hg @ 2005-11-24 12:37:59 by malcolmp]
malcolmp
parents: 2554
diff changeset
1043 Print on the standard output an index of items intended for\n\
95be8ad778e3 [xemacs-hg @ 2005-11-24 12:37:59 by malcolmp]
malcolmp
parents: 2554
diff changeset
1044 human consumption, similar to the output of vgrind. The index\n\
95be8ad778e3 [xemacs-hg @ 2005-11-24 12:37:59 by malcolmp]
malcolmp
parents: 2554
diff changeset
1045 is sorted, and gives the page number of each item.");
3993
9bab7e657255 [xemacs-hg @ 2007-05-29 14:14:49 by stephent]
stephent
parents: 3972
diff changeset
1046
9bab7e657255 [xemacs-hg @ 2007-05-29 14:14:49 by stephent]
stephent
parents: 3972
diff changeset
1047 if (PRINT_UNDOCUMENTED_OPTIONS_HELP)
9bab7e657255 [xemacs-hg @ 2007-05-29 14:14:49 by stephent]
stephent
parents: 3972
diff changeset
1048 puts ("-w, --no-duplicates\n\
3876
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
1049 Do not create duplicate tag entries, for compatibility with\n\
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
1050 traditional ctags.");
3993
9bab7e657255 [xemacs-hg @ 2007-05-29 14:14:49 by stephent]
stephent
parents: 3972
diff changeset
1051
9bab7e657255 [xemacs-hg @ 2007-05-29 14:14:49 by stephent]
stephent
parents: 3972
diff changeset
1052 if (PRINT_UNDOCUMENTED_OPTIONS_HELP)
9bab7e657255 [xemacs-hg @ 2007-05-29 14:14:49 by stephent]
stephent
parents: 3972
diff changeset
1053 puts ("-w, --no-warn\n\
3876
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
1054 Suppress warning messages about duplicate tag entries.");
3993
9bab7e657255 [xemacs-hg @ 2007-05-29 14:14:49 by stephent]
stephent
parents: 3972
diff changeset
1055
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056 puts ("-x, --cxref\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057 Like --vgrind, but in the style of cxref, rather than vgrind.\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058 The output uses line numbers instead of page numbers, but\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059 beyond that the differences are cosmetic; try both to see\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 which you like.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063 puts ("-V, --version\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064 Print the version of the program.\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1065 -h, --help\n\
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1066 Print this help message.\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1067 Followed by one or more `--language' options prints detailed\n\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1068 help about tag generation for the specified languages.");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1069
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1070 print_language_names ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072 puts ("");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073 puts ("Report bugs to bug-gnu-emacs@gnu.org");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1074
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1075 exit (EXIT_SUCCESS);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1076 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1077
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1078
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1079 #ifdef VMS /* VMS specific functions */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081 #define EOS '\0'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1082
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1083 /* This is a BUG! ANY arbitrary limit is a BUG!
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1084 Won't someone please fix this? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1085 #define MAX_FILE_SPEC_LEN 255
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1086 typedef struct {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1087 short curlen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088 char body[MAX_FILE_SPEC_LEN + 1];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1089 } vspec;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1090
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1091 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1092 v1.05 nmm 26-Jun-86 fn_exp - expand specification of list of file names
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1093 returning in each successive call the next file name matching the input
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1094 spec. The function expects that each in_spec passed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1095 to it will be processed to completion; in particular, up to and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096 including the call following that in which the last matching name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097 is returned, the function ignores the value of in_spec, and will
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1098 only start processing a new spec with the following call.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1099 If an error occurs, on return out_spec contains the value
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1100 of in_spec when the error occurred.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1101
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1102 With each successive file name returned in out_spec, the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1103 function's return value is one. When there are no more matching
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1104 names the function returns zero. If on the first call no file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105 matches in_spec, or there is any other error, -1 is returned.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1106 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1107
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108 #include <rmsdef.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 #include <descrip.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110 #define OUTSIZE MAX_FILE_SPEC_LEN
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1111 static short
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1112 fn_exp (out, in)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1113 vspec *out;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1114 char *in;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1115 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1116 static long context = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1117 static struct dsc$descriptor_s o;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1118 static struct dsc$descriptor_s i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1119 static bool pass1 = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1120 long status;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1121 short retval;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1122
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123 if (pass1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1124 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1125 pass1 = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1126 o.dsc$a_pointer = (char *) out;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1127 o.dsc$w_length = (short)OUTSIZE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1128 i.dsc$a_pointer = in;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1129 i.dsc$w_length = (short)strlen(in);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1130 i.dsc$b_dtype = DSC$K_DTYPE_T;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1131 i.dsc$b_class = DSC$K_CLASS_S;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1132 o.dsc$b_dtype = DSC$K_DTYPE_VT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1133 o.dsc$b_class = DSC$K_CLASS_VS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1134 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135 if ((status = lib$find_file(&i, &o, &context, 0, 0)) == RMS$_NORMAL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1136 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1137 out->body[out->curlen] = EOS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1138 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1139 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1140 else if (status == RMS$_NMF)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1141 retval = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1142 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1143 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1144 strcpy(out->body, in);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1145 retval = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1146 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1147 lib$find_file_end(&context);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1148 pass1 = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1149 return retval;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1150 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1151
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1152 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1153 v1.01 nmm 19-Aug-85 gfnames - return in successive calls the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1154 name of each file specified by the provided arg expanding wildcards.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1155 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1156 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1157 gfnames (arg, p_error)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1158 char *arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1159 bool *p_error;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1160 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1161 static vspec filename = {MAX_FILE_SPEC_LEN, "\0"};
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1162
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1163 switch (fn_exp (&filename, arg))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1164 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1165 case 1:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1166 *p_error = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1167 return filename.body;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1168 case 0:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1169 *p_error = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1170 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1171 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1172 *p_error = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1173 return filename.body;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1174 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1175 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1176
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1177 #ifndef OLD /* Newer versions of VMS do provide `system'. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1178 system (cmd)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1179 char *cmd;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1180 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1181 error ("%s", "system() function not implemented under VMS");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1182 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1183 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1184
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1185 #define VERSION_DELIM ';'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1186 char *massage_name (s)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1187 char *s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1188 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1189 char *start = s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1190
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1191 for ( ; *s; s++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1192 if (*s == VERSION_DELIM)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1193 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1194 *s = EOS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1195 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1196 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1197 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1198 *s = lowcase (*s);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1199 return start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1200 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1201 #endif /* VMS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1202
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1203
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1204 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1205 main (argc, argv)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1206 int argc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1207 char *argv[];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1208 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1209 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1210 unsigned int nincluded_files;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1211 char **included_files;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1212 argument *argbuffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1213 int current_arg, file_count;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1214 linebuffer filename_lb;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1215 bool help_asked = FALSE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1216 #ifdef VMS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1217 bool got_err;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1218 #endif
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1219 char *optstring;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1220 int opt;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1221
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1222
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1223 #ifdef DOS_NT
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1224 _fmode = O_BINARY; /* all of files are treated as binary files */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1225 #endif /* DOS_NT */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1226
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1227 progname = argv[0];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1228 nincluded_files = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1229 included_files = xnew (argc, char *);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1230 current_arg = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1231 file_count = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1232
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1233 /* Allocate enough no matter what happens. Overkill, but each one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1234 is small. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1235 argbuffer = xnew (argc, argument);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1236
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1237 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1238 * If etags, always find typedefs and structure tags. Why not?
3972
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
1239 * Also default to find macro constants, enum constants, struct
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
1240 * members and global variables.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1241 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1242 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1243 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1244 typedefs = typedefs_or_cplusplus = constantypedefs = TRUE;
3972
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
1245 globals = members = TRUE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1246 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1247
2554
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
1248 /* When the optstring begins with a '-' getopt_long does not rearrange the
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
1249 non-options arguments to be at the end, but leaves them alone. */
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
1250 optstring = concat (NO_LONG_OPTIONS ? "" : "-",
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
1251 "ac:Cf:Il:o:r:RSVhH",
3090
95be8ad778e3 [xemacs-hg @ 2005-11-24 12:37:59 by malcolmp]
malcolmp
parents: 2554
diff changeset
1252 (CTAGS) ? "BxdtTuvw" : "Di:");
95be8ad778e3 [xemacs-hg @ 2005-11-24 12:37:59 by malcolmp]
malcolmp
parents: 2554
diff changeset
1253
95be8ad778e3 [xemacs-hg @ 2005-11-24 12:37:59 by malcolmp]
malcolmp
parents: 2554
diff changeset
1254 while ((opt = getopt_long (argc, argv, optstring, longopts, NULL)) != EOF)
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1255 switch (opt)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1256 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1257 case 0:
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1258 /* If getopt returns 0, then it has already processed a
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1259 long-named option. We should do nothing. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1260 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1261
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1262 case 1:
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1263 /* This means that a file name has been seen. Record it. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1264 argbuffer[current_arg].arg_type = at_filename;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1265 argbuffer[current_arg].what = optarg;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1266 ++current_arg;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1267 ++file_count;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1268 break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1269
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1270 case STDIN:
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1271 /* Parse standard input. Idea by Vivek <vivek@etla.org>. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1272 argbuffer[current_arg].arg_type = at_stdin;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1273 argbuffer[current_arg].what = optarg;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1274 ++current_arg;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1275 ++file_count;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1276 if (parsing_stdin)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1277 fatal ("cannot parse standard input more than once", (char *)NULL);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1278 parsing_stdin = TRUE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1279 break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1280
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1281 /* Common options. */
3090
95be8ad778e3 [xemacs-hg @ 2005-11-24 12:37:59 by malcolmp]
malcolmp
parents: 2554
diff changeset
1282 case 'a': append_to_tagfile = TRUE; break;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1283 case 'C': cplusplus = TRUE; break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1284 case 'f': /* for compatibility with old makefiles */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1285 case 'o':
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1286 if (tagfile)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1287 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1288 error ("-o option may only be given once.", (char *)NULL);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1289 suggest_asking_for_help ();
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1290 /* NOTREACHED */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1291 }
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1292 tagfile = optarg;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1293 break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1294 case 'I':
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1295 case 'S': /* for backward compatibility */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1296 ignoreindent = TRUE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1297 break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1298 case 'l':
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1299 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1300 language *lang = get_language_from_langname (optarg);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1301 if (lang != NULL)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1302 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1303 argbuffer[current_arg].lang = lang;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1304 argbuffer[current_arg].arg_type = at_language;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1305 ++current_arg;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1306 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1307 }
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1308 break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1309 case 'c':
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1310 /* Backward compatibility: support obsolete --ignore-case-regexp. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1311 optarg = concat (optarg, "i", ""); /* memory leak here */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1312 /* FALLTHRU */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1313 case 'r':
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1314 argbuffer[current_arg].arg_type = at_regexp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1315 argbuffer[current_arg].what = optarg;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1316 ++current_arg;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1317 break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1318 case 'R':
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1319 argbuffer[current_arg].arg_type = at_regexp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1320 argbuffer[current_arg].what = NULL;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1321 ++current_arg;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1322 break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1323 case 'V':
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1324 print_version ();
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1325 break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1326 case 'h':
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1327 case 'H':
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1328 help_asked = TRUE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1329 break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1330
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1331 /* Etags options */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1332 case 'D': constantypedefs = FALSE; break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1333 case 'i': included_files[nincluded_files++] = optarg; break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1334
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1335 /* Ctags options. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1336 case 'B': searchar = '?'; break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1337 case 'd': constantypedefs = TRUE; break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1338 case 't': typedefs = TRUE; break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1339 case 'T': typedefs = typedefs_or_cplusplus = TRUE; break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1340 case 'u': update = TRUE; break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1341 case 'v': vgrind_style = TRUE; /*FALLTHRU*/
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1342 case 'x': cxref_style = TRUE; break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1343 case 'w': no_warnings = TRUE; break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1344 default:
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1345 suggest_asking_for_help ();
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1346 /* NOTREACHED */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1347 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1348
2554
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
1349 /* No more options. Store the rest of arguments. */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1350 for (; optind < argc; optind++)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1351 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1352 argbuffer[current_arg].arg_type = at_filename;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1353 argbuffer[current_arg].what = argv[optind];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1354 ++current_arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1355 ++file_count;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1356 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1357
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1358 argbuffer[current_arg].arg_type = at_end;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1359
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1360 if (help_asked)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1361 print_help (argbuffer);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1362 /* NOTREACHED */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1363
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1364 if (nincluded_files == 0 && file_count == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1365 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1366 error ("no input files specified.", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1367 suggest_asking_for_help ();
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1368 /* NOTREACHED */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1369 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1370
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1371 if (tagfile == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1372 tagfile = CTAGS ? "tags" : "TAGS";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1373 cwd = etags_getcwd (); /* the current working directory */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1374 if (cwd[strlen (cwd) - 1] != '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1375 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1376 char *oldcwd = cwd;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1377 cwd = concat (oldcwd, "/", "");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1378 free (oldcwd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1379 }
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
1380 /* Relative file names are made relative to the current directory. */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
1381 if (streq (tagfile, "-")
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
1382 || strneq (tagfile, "/dev/", 5))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1383 tagfiledir = cwd;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1384 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1385 tagfiledir = absolute_dirname (tagfile, cwd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1386
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1387 init (); /* set up boolean "functions" */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1388
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1389 linebuffer_init (&lb);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1390 linebuffer_init (&filename_lb);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1391 linebuffer_init (&filebuf);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1392 linebuffer_init (&token_name);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1393
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1394 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1395 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1396 if (streq (tagfile, "-"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1397 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1398 tagf = stdout;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1399 #ifdef DOS_NT
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1400 /* Switch redirected `stdout' to binary mode (setting `_fmode'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1401 doesn't take effect until after `stdout' is already open). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1402 if (!isatty (fileno (stdout)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1403 setmode (fileno (stdout), O_BINARY);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1404 #endif /* DOS_NT */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1405 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1406 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1407 tagf = fopen (tagfile, append_to_tagfile ? "a" : "w");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1408 if (tagf == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1409 pfatal (tagfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1410 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1411
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1412 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1413 * Loop through files finding functions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1414 */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1415 for (i = 0; i < current_arg; i++)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1416 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1417 static language *lang; /* non-NULL if language is forced */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1418 char *this_file;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1419
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1420 switch (argbuffer[i].arg_type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1421 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1422 case at_language:
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1423 lang = argbuffer[i].lang;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1424 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1425 case at_regexp:
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1426 analyse_regex (argbuffer[i].what);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1427 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1428 case at_filename:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1429 #ifdef VMS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1430 while ((this_file = gfnames (argbuffer[i].what, &got_err)) != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1431 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1432 if (got_err)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1433 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1434 error ("can't find file %s\n", this_file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1435 argc--, argv++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1436 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1437 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1438 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1439 this_file = massage_name (this_file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1440 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1441 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1442 this_file = argbuffer[i].what;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1443 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1444 /* Input file named "-" means read file names from stdin
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1445 (one per line) and use them. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1446 if (streq (this_file, "-"))
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1447 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1448 if (parsing_stdin)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1449 fatal ("cannot parse standard input AND read file names from it",
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1450 (char *)NULL);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1451 while (readline_internal (&filename_lb, stdin) > 0)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1452 process_file_name (filename_lb.buffer, lang);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1453 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1454 else
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1455 process_file_name (this_file, lang);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1456 #ifdef VMS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1457 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1458 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1459 break;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1460 case at_stdin:
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1461 this_file = argbuffer[i].what;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1462 process_file (stdin, this_file, lang);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1463 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1464 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1465 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1466
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1467 free_regexps ();
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1468 free (lb.buffer);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1469 free (filebuf.buffer);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1470 free (token_name.buffer);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1471
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1472 if (!CTAGS || cxref_style)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1473 {
3090
95be8ad778e3 [xemacs-hg @ 2005-11-24 12:37:59 by malcolmp]
malcolmp
parents: 2554
diff changeset
1474 /* Write the remaining tags to tagf (ETAGS) or stdout (CXREF). */
95be8ad778e3 [xemacs-hg @ 2005-11-24 12:37:59 by malcolmp]
malcolmp
parents: 2554
diff changeset
1475 put_entries (nodehead);
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1476 free_tree (nodehead);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1477 nodehead = NULL;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1478 if (!CTAGS)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1479 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1480 fdesc *fdp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1481
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1482 /* Output file entries that have no tags. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1483 for (fdp = fdhead; fdp != NULL; fdp = fdp->next)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1484 if (!fdp->written)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1485 fprintf (tagf, "\f\n%s,0\n", fdp->taggedfname);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1486
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1487 while (nincluded_files-- > 0)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1488 fprintf (tagf, "\f\n%s,include\n", *included_files++);
3090
95be8ad778e3 [xemacs-hg @ 2005-11-24 12:37:59 by malcolmp]
malcolmp
parents: 2554
diff changeset
1489
95be8ad778e3 [xemacs-hg @ 2005-11-24 12:37:59 by malcolmp]
malcolmp
parents: 2554
diff changeset
1490 if (fclose (tagf) == EOF)
95be8ad778e3 [xemacs-hg @ 2005-11-24 12:37:59 by malcolmp]
malcolmp
parents: 2554
diff changeset
1491 pfatal (tagfile);
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1492 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1493
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1494 exit (EXIT_SUCCESS);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1495 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1496
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1497 if (update)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1498 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1499 char cmd[BUFSIZ];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1500 for (i = 0; i < current_arg; ++i)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1501 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1502 switch (argbuffer[i].arg_type)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1503 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1504 case at_filename:
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1505 case at_stdin:
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1506 break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1507 default:
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1508 continue; /* the for loop */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1509 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1510 sprintf (cmd,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1511 "mv %s OTAGS;fgrep -v '\t%s\t' OTAGS >%s;rm OTAGS",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1512 tagfile, argbuffer[i].what, tagfile);
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1513 if (system (cmd) != EXIT_SUCCESS)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1514 fatal ("failed to execute shell command", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1515 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1516 append_to_tagfile = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1517 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1518
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1519 tagf = fopen (tagfile, append_to_tagfile ? "a" : "w");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1520 if (tagf == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1521 pfatal (tagfile);
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1522 put_entries (nodehead); /* write all the tags (CTAGS) */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1523 free_tree (nodehead);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1524 nodehead = NULL;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1525 if (fclose (tagf) == EOF)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1526 pfatal (tagfile);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1527
3090
95be8ad778e3 [xemacs-hg @ 2005-11-24 12:37:59 by malcolmp]
malcolmp
parents: 2554
diff changeset
1528 if (CTAGS)
95be8ad778e3 [xemacs-hg @ 2005-11-24 12:37:59 by malcolmp]
malcolmp
parents: 2554
diff changeset
1529 if (append_to_tagfile || update)
95be8ad778e3 [xemacs-hg @ 2005-11-24 12:37:59 by malcolmp]
malcolmp
parents: 2554
diff changeset
1530 {
3876
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
1531 char cmd[2*BUFSIZ+20];
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
1532 /* Maybe these should be used:
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
1533 setenv ("LC_COLLATE", "C", 1);
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
1534 setenv ("LC_ALL", "C", 1); */
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
1535 sprintf (cmd, "sort -u -o %.*s %.*s", BUFSIZ, tagfile, BUFSIZ, tagfile);
3090
95be8ad778e3 [xemacs-hg @ 2005-11-24 12:37:59 by malcolmp]
malcolmp
parents: 2554
diff changeset
1536 exit (system (cmd));
95be8ad778e3 [xemacs-hg @ 2005-11-24 12:37:59 by malcolmp]
malcolmp
parents: 2554
diff changeset
1537 }
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1538 return EXIT_SUCCESS;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1539 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1540
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1541
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1542 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1543 * Return a compressor given the file name. If EXTPTR is non-zero,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1544 * return a pointer into FILE where the compressor-specific
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1545 * extension begins. If no compressor is found, NULL is returned
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1546 * and EXTPTR is not significant.
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1547 * Idea by Vladimir Alexiev <vladimir@cs.ualberta.ca> (1998)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1548 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1549 static compressor *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1550 get_compressor_from_suffix (file, extptr)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1551 char *file;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1552 char **extptr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1553 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1554 compressor *compr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1555 char *slash, *suffix;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1556
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1557 /* This relies on FN to be after canonicalize_filename,
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1558 so we don't need to consider backslashes on DOS_NT. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1559 slash = etags_strrchr (file, '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1560 suffix = etags_strrchr (file, '.');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1561 if (suffix == NULL || suffix < slash)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1562 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1563 if (extptr != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1564 *extptr = suffix;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1565 suffix += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1566 /* Let those poor souls who live with DOS 8+3 file name limits get
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1567 some solace by treating foo.cgz as if it were foo.c.gz, etc.
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1568 Only the first do loop is run if not MSDOS */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1569 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1570 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1571 for (compr = compressors; compr->suffix != NULL; compr++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1572 if (streq (compr->suffix, suffix))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1573 return compr;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1574 if (!MSDOS)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1575 break; /* do it only once: not really a loop */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1576 if (extptr != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1577 *extptr = ++suffix;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1578 } while (*suffix != '\0');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1579 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1580 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1581
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1582
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1583
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1584 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1585 * Return a language given the name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1586 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1587 static language *
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1588 get_language_from_langname (name)
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
1589 const char *name;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1590 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1591 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1592
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1593 if (name == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1594 error ("empty language name", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1595 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1596 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1597 for (lang = lang_names; lang->name != NULL; lang++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1598 if (streq (name, lang->name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1599 return lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1600 error ("unknown language \"%s\"", name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1601 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1602
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1603 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1604 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1605
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1606
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1607 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1608 * Return a language given the interpreter name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1609 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1610 static language *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1611 get_language_from_interpreter (interpreter)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1612 char *interpreter;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1613 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1614 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1615 char **iname;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1616
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1617 if (interpreter == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1618 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1619 for (lang = lang_names; lang->name != NULL; lang++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1620 if (lang->interpreters != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1621 for (iname = lang->interpreters; *iname != NULL; iname++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1622 if (streq (*iname, interpreter))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1623 return lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1624
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1625 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1626 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1627
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1628
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1629
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1630 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1631 * Return a language given the file name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1632 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1633 static language *
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1634 get_language_from_filename (file, case_sensitive)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1635 char *file;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1636 bool case_sensitive;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1637 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1638 language *lang;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1639 char **name, **ext, *suffix;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1640
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1641 /* Try whole file name first. */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1642 for (lang = lang_names; lang->name != NULL; lang++)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1643 if (lang->filenames != NULL)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1644 for (name = lang->filenames; *name != NULL; name++)
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1645 if ((case_sensitive)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1646 ? streq (*name, file)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1647 : strcaseeq (*name, file))
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1648 return lang;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1649
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1650 /* If not found, try suffix after last dot. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1651 suffix = etags_strrchr (file, '.');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1652 if (suffix == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1653 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1654 suffix += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1655 for (lang = lang_names; lang->name != NULL; lang++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1656 if (lang->suffixes != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1657 for (ext = lang->suffixes; *ext != NULL; ext++)
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1658 if ((case_sensitive)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1659 ? streq (*ext, suffix)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1660 : strcaseeq (*ext, suffix))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1661 return lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1662 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1663 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1664
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1665
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1666 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1667 * This routine is called on each file argument.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1668 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1669 static void
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1670 process_file_name (file, lang)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1671 char *file;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1672 language *lang;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1673 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1674 struct stat stat_buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1675 FILE *inf;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1676 fdesc *fdp;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1677 compressor *compr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1678 char *compressed_name, *uncompressed_name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1679 char *ext, *real_name;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1680 int retval;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1681
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1682 canonicalize_filename (file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1683 if (streq (file, tagfile) && !streq (tagfile, "-"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1684 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1685 error ("skipping inclusion of %s in self.", file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1686 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1687 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1688 if ((compr = get_compressor_from_suffix (file, &ext)) == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1689 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1690 compressed_name = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1691 real_name = uncompressed_name = savestr (file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1692 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1693 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1694 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1695 real_name = compressed_name = savestr (file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1696 uncompressed_name = savenstr (file, ext - file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1697 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1698
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1699 /* If the canonicalized uncompressed name
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1700 has already been dealt with, skip it silently. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1701 for (fdp = fdhead; fdp != NULL; fdp = fdp->next)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1702 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1703 assert (fdp->infname != NULL);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1704 if (streq (uncompressed_name, fdp->infname))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1705 goto cleanup;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1706 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1707
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1708 if (stat (real_name, &stat_buf) != 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1709 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1710 /* Reset real_name and try with a different name. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1711 real_name = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1712 if (compressed_name != NULL) /* try with the given suffix */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1713 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1714 if (stat (uncompressed_name, &stat_buf) == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1715 real_name = uncompressed_name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1716 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1717 else /* try all possible suffixes */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1718 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1719 for (compr = compressors; compr->suffix != NULL; compr++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1720 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1721 compressed_name = concat (file, ".", compr->suffix);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1722 if (stat (compressed_name, &stat_buf) != 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1723 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1724 if (MSDOS)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1725 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1726 char *suf = compressed_name + strlen (file);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1727 size_t suflen = strlen (compr->suffix) + 1;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1728 for ( ; suf[1]; suf++, suflen--)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1729 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1730 memmove (suf, suf + 1, suflen);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1731 if (stat (compressed_name, &stat_buf) == 0)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1732 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1733 real_name = compressed_name;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1734 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1735 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1736 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1737 if (real_name != NULL)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1738 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1739 } /* MSDOS */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1740 free (compressed_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1741 compressed_name = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1742 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1743 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1744 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1745 real_name = compressed_name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1746 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1747 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1748 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1749 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1750 if (real_name == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1751 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1752 perror (file);
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1753 goto cleanup;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1754 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1755 } /* try with a different name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1756
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1757 if (!S_ISREG (stat_buf.st_mode))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1758 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1759 error ("skipping %s: it is not a regular file.", real_name);
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1760 goto cleanup;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1761 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1762 if (real_name == compressed_name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1763 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1764 char *cmd = concat (compr->command, " ", real_name);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1765 inf = (FILE *) popen (cmd, "r");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1766 free (cmd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1767 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1768 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1769 inf = fopen (real_name, "r");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1770 if (inf == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1771 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1772 perror (real_name);
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1773 goto cleanup;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1774 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1775
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1776 process_file (inf, uncompressed_name, lang);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1777
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1778 if (real_name == compressed_name)
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1779 retval = pclose (inf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1780 else
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1781 retval = fclose (inf);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1782 if (retval < 0)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1783 pfatal (file);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1784
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1785 cleanup:
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1786 if (compressed_name) free (compressed_name);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1787 if (uncompressed_name) free (uncompressed_name);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1788 last_node = NULL;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1789 curfdp = NULL;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1790 return;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1791 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1792
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1793 static void
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1794 process_file (fh, fn, lang)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1795 FILE *fh;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1796 char *fn;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1797 language *lang;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1798 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1799 static const fdesc emptyfdesc;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1800 fdesc *fdp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1801
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1802 /* Create a new input file description entry. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1803 fdp = xnew (1, fdesc);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1804 *fdp = emptyfdesc;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1805 fdp->next = fdhead;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1806 fdp->infname = savestr (fn);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1807 fdp->lang = lang;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1808 fdp->infabsname = absolute_filename (fn, cwd);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1809 fdp->infabsdir = absolute_dirname (fn, cwd);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1810 if (filename_is_absolute (fn))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1811 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1812 /* An absolute file name. Canonicalize it. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1813 fdp->taggedfname = absolute_filename (fn, NULL);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1814 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1815 else
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1816 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1817 /* A file name relative to cwd. Make it relative
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1818 to the directory of the tags file. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1819 fdp->taggedfname = relative_filename (fn, tagfiledir);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1820 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1821 fdp->usecharno = TRUE; /* use char position when making tags */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1822 fdp->prop = NULL;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1823 fdp->written = FALSE; /* not written on tags file yet */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1824
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1825 fdhead = fdp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1826 curfdp = fdhead; /* the current file description */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1827
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1828 find_entries (fh);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1829
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1830 /* If not Ctags, and if this is not metasource and if it contained no #line
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1831 directives, we can write the tags and free all nodes pointing to
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1832 curfdp. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1833 if (!CTAGS
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1834 && curfdp->usecharno /* no #line directives in this file */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1835 && !curfdp->lang->metasource)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1836 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1837 node *np, *prev;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1838
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1839 /* Look for the head of the sublist relative to this file. See add_node
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1840 for the structure of the node tree. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1841 prev = NULL;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1842 for (np = nodehead; np != NULL; prev = np, np = np->left)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1843 if (np->fdp == curfdp)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1844 break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1845
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1846 /* If we generated tags for this file, write and delete them. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1847 if (np != NULL)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1848 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1849 /* This is the head of the last sublist, if any. The following
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1850 instructions depend on this being true. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1851 assert (np->left == NULL);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1852
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1853 assert (fdhead == curfdp);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1854 assert (last_node->fdp == curfdp);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1855 put_entries (np); /* write tags for file curfdp->taggedfname */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1856 free_tree (np); /* remove the written nodes */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1857 if (prev == NULL)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1858 nodehead = NULL; /* no nodes left */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1859 else
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1860 prev->left = NULL; /* delete the pointer to the sublist */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1861 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1862 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1863 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1864
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1865 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1866 * This routine sets up the boolean pseudo-functions which work
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1867 * by setting boolean flags dependent upon the corresponding character.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1868 * Every char which is NOT in that string is not a white char. Therefore,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1869 * all of the array "_wht" is set to FALSE, and then the elements
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1870 * subscripted by the chars in "white" are set to TRUE. Thus "_wht"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1871 * of a char is TRUE if it is the string "white", else FALSE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1872 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1873 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1874 init ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1875 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1876 register char *sp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1877 register int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1878
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1879 for (i = 0; i < CHARS; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1880 iswhite(i) = notinname(i) = begtoken(i) = intoken(i) = endtoken(i) = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1881 for (sp = white; *sp != '\0'; sp++) iswhite (*sp) = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1882 for (sp = nonam; *sp != '\0'; sp++) notinname (*sp) = TRUE;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1883 notinname('\0') = notinname('\n');
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1884 for (sp = begtk; *sp != '\0'; sp++) begtoken (*sp) = TRUE;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1885 begtoken('\0') = begtoken('\n');
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1886 for (sp = midtk; *sp != '\0'; sp++) intoken (*sp) = TRUE;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1887 intoken('\0') = intoken('\n');
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1888 for (sp = endtk; *sp != '\0'; sp++) endtoken (*sp) = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1889 endtoken('\0') = endtoken('\n');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1890 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1891
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1892 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1893 * This routine opens the specified file and calls the function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1894 * which finds the function and type definitions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1895 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1896 static void
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1897 find_entries (inf)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1898 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1899 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1900 char *cp;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1901 language *lang = curfdp->lang;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1902 Lang_function *parser = NULL;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1903
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1904 /* If user specified a language, use it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1905 if (lang != NULL && lang->function != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1906 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1907 parser = lang->function;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1908 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1909
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1910 /* Else try to guess the language given the file name. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1911 if (parser == NULL)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1912 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1913 lang = get_language_from_filename (curfdp->infname, TRUE);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1914 if (lang != NULL && lang->function != NULL)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1915 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1916 curfdp->lang = lang;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1917 parser = lang->function;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1918 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1919 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1920
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1921 /* Else look for sharp-bang as the first two characters. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1922 if (parser == NULL
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1923 && readline_internal (&lb, inf) > 0
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1924 && lb.len >= 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1925 && lb.buffer[0] == '#'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1926 && lb.buffer[1] == '!')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1927 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1928 char *lp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1929
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1930 /* Set lp to point at the first char after the last slash in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1931 line or, if no slashes, at the first nonblank. Then set cp to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1932 the first successive blank and terminate the string. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1933 lp = etags_strrchr (lb.buffer+2, '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1934 if (lp != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1935 lp += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1936 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1937 lp = skip_spaces (lb.buffer + 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1938 cp = skip_non_spaces (lp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1939 *cp = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1940
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1941 if (strlen (lp) > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1942 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1943 lang = get_language_from_interpreter (lp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1944 if (lang != NULL && lang->function != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1945 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1946 curfdp->lang = lang;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1947 parser = lang->function;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1948 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1949 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1950 }
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1951
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1952 /* We rewind here, even if inf may be a pipe. We fail if the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1953 length of the first line is longer than the pipe block size,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1954 which is unlikely. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1955 rewind (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1956
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1957 /* Else try to guess the language given the case insensitive file name. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1958 if (parser == NULL)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1959 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1960 lang = get_language_from_filename (curfdp->infname, FALSE);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1961 if (lang != NULL && lang->function != NULL)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1962 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1963 curfdp->lang = lang;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1964 parser = lang->function;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1965 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1966 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1967
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1968 /* Else try Fortran or C. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1969 if (parser == NULL)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1970 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1971 node *old_last_node = last_node;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1972
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1973 curfdp->lang = get_language_from_langname ("fortran");
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1974 find_entries (inf);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1975
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1976 if (old_last_node == last_node)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1977 /* No Fortran entries found. Try C. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1978 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1979 /* We do not tag if rewind fails.
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1980 Only the file name will be recorded in the tags file. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1981 rewind (inf);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1982 curfdp->lang = get_language_from_langname (cplusplus ? "c++" : "c");
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1983 find_entries (inf);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1984 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1985 return;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1986 }
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1987
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1988 if (!no_line_directive
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1989 && curfdp->lang != NULL && curfdp->lang->metasource)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1990 /* It may be that this is a bingo.y file, and we already parsed a bingo.c
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1991 file, or anyway we parsed a file that is automatically generated from
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1992 this one. If this is the case, the bingo.c file contained #line
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1993 directives that generated tags pointing to this file. Let's delete
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1994 them all before parsing this file, which is the real source. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1995 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1996 fdesc **fdpp = &fdhead;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1997 while (*fdpp != NULL)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1998 if (*fdpp != curfdp
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
1999 && streq ((*fdpp)->taggedfname, curfdp->taggedfname))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2000 /* We found one of those! We must delete both the file description
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2001 and all tags referring to it. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2002 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2003 fdesc *badfdp = *fdpp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2004
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2005 /* Delete the tags referring to badfdp->taggedfname
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2006 that were obtained from badfdp->infname. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2007 invalidate_nodes (badfdp, &nodehead);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2008
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2009 *fdpp = badfdp->next; /* remove the bad description from the list */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2010 free_fdesc (badfdp);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2011 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2012 else
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2013 fdpp = &(*fdpp)->next; /* advance the list pointer */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2014 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2015
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2016 assert (parser != NULL);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2017
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2018 /* Generic initialisations before reading from file. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2019 linebuffer_setlen (&filebuf, 0); /* reset the file buffer */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2020
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2021 /* Generic initialisations before parsing file with readline. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2022 lineno = 0; /* reset global line number */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2023 charno = 0; /* reset global char number */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2024 linecharno = 0; /* reset global char number of line start */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2025
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2026 parser (inf);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2027
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2028 regex_tag_multiline ();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2029 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2030
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2031
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2032 /*
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2033 * Check whether an implicitly named tag should be created,
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2034 * then call `pfnote'.
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2035 * NAME is a string that is internally copied by this function.
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2036 *
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2037 * TAGS format specification
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2038 * Idea by Sam Kendall <kendall@mv.mv.com> (1997)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2039 * The following is explained in some more detail in etc/ETAGS.EBNF.
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2040 *
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2041 * make_tag creates tags with "implicit tag names" (unnamed tags)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2042 * if the following are all true, assuming NONAM=" \f\t\n\r()=,;":
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2043 * 1. NAME does not contain any of the characters in NONAM;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2044 * 2. LINESTART contains name as either a rightmost, or rightmost but
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2045 * one character, substring;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2046 * 3. the character, if any, immediately before NAME in LINESTART must
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2047 * be a character in NONAM;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2048 * 4. the character, if any, immediately after NAME in LINESTART must
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2049 * also be a character in NONAM.
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2050 *
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2051 * The implementation uses the notinname() macro, which recognises the
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2052 * characters stored in the string `nonam'.
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2053 * etags.el needs to use the same characters that are in NONAM.
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2054 */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2055 static void
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2056 make_tag (name, namelen, is_func, linestart, linelen, lno, cno)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2057 char *name; /* tag name, or NULL if unnamed */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2058 int namelen; /* tag length */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2059 bool is_func; /* tag is a function */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2060 char *linestart; /* start of the line where tag is */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2061 int linelen; /* length of the line where tag is */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2062 int lno; /* line number */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2063 long cno; /* character number */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2064 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2065 bool named = (name != NULL && namelen > 0);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2066
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2067 if (!CTAGS && named) /* maybe set named to false */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2068 /* Let's try to make an implicit tag name, that is, create an unnamed tag
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2069 such that etags.el can guess a name from it. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2070 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2071 int i;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2072 register char *cp = name;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2073
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2074 for (i = 0; i < namelen; i++)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2075 if (notinname (*cp++))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2076 break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2077 if (i == namelen) /* rule #1 */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2078 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2079 cp = linestart + linelen - namelen;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2080 if (notinname (linestart[linelen-1]))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2081 cp -= 1; /* rule #4 */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2082 if (cp >= linestart /* rule #2 */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2083 && (cp == linestart
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2084 || notinname (cp[-1])) /* rule #3 */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2085 && strneq (name, cp, namelen)) /* rule #2 */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2086 named = FALSE; /* use implicit tag name */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2087 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2088 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2089
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2090 if (named)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2091 name = savenstr (name, namelen);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2092 else
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2093 name = NULL;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2094 pfnote (name, is_func, linestart, linelen, lno, cno);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2095 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2096
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2097 /* Record a tag. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
2098 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2099 pfnote (name, is_func, linestart, linelen, lno, cno)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2100 char *name; /* tag name, or NULL if unnamed */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2101 bool is_func; /* tag is a function */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2102 char *linestart; /* start of the line where tag is */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2103 int linelen; /* length of the line where tag is */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2104 int lno; /* line number */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2105 long cno; /* character number */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2106 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2107 register node *np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2108
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2109 assert (name == NULL || name[0] != '\0');
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2110 if (CTAGS && name == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2111 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2112
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2113 np = xnew (1, node);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2114
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2115 /* If ctags mode, change name "main" to M<thisfilename>. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2116 if (CTAGS && !cxref_style && streq (name, "main"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2117 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2118 register char *fp = etags_strrchr (curfdp->taggedfname, '/');
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2119 np->name = concat ("M", fp == NULL ? curfdp->taggedfname : fp + 1, "");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2120 fp = etags_strrchr (np->name, '.');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2121 if (fp != NULL && fp[1] != '\0' && fp[2] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2122 fp[0] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2123 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2124 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2125 np->name = name;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2126 np->valid = TRUE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2127 np->been_warned = FALSE;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2128 np->fdp = curfdp;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2129 np->is_func = is_func;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2130 np->lno = lno;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2131 if (np->fdp->usecharno)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2132 /* Our char numbers are 0-base, because of C language tradition?
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2133 ctags compatibility? old versions compatibility? I don't know.
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2134 Anyway, since emacs's are 1-base we expect etags.el to take care
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2135 of the difference. If we wanted to have 1-based numbers, we would
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2136 uncomment the +1 below. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2137 np->cno = cno /* + 1 */ ;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2138 else
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2139 np->cno = invalidcharno;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2140 np->left = np->right = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2141 if (CTAGS && !cxref_style)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2142 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2143 if (strlen (linestart) < 50)
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2144 np->regex = concat (linestart, "$", "");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2145 else
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2146 np->regex = savenstr (linestart, 50);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2147 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2148 else
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2149 np->regex = savenstr (linestart, linelen);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2150
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2151 add_node (np, &nodehead);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2152 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2153
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2154 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2155 * free_tree ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2156 * recurse on left children, iterate on right children.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2157 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
2158 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2159 free_tree (np)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2160 register node *np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2161 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2162 while (np)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2163 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2164 register node *node_right = np->right;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2165 free_tree (np->left);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2166 if (np->name != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2167 free (np->name);
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2168 free (np->regex);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2169 free (np);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2170 np = node_right;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2171 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2172 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2173
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2174 /*
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2175 * free_fdesc ()
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2176 * delete a file description
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2177 */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2178 static void
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2179 free_fdesc (fdp)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2180 register fdesc *fdp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2181 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2182 if (fdp->infname != NULL) free (fdp->infname);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2183 if (fdp->infabsname != NULL) free (fdp->infabsname);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2184 if (fdp->infabsdir != NULL) free (fdp->infabsdir);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2185 if (fdp->taggedfname != NULL) free (fdp->taggedfname);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2186 if (fdp->prop != NULL) free (fdp->prop);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2187 free (fdp);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2188 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2189
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2190 /*
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2191 * add_node ()
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2192 * Adds a node to the tree of nodes. In etags mode, sort by file
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2193 * name. In ctags mode, sort by tag name. Make no attempt at
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2194 * balancing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2195 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2196 * add_node is the only function allowed to add nodes, so it can
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2197 * maintain state.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2198 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
2199 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2200 add_node (np, cur_node_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2201 node *np, **cur_node_p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2202 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2203 register int dif;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2204 register node *cur_node = *cur_node_p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2205
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2206 if (cur_node == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2207 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2208 *cur_node_p = np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2209 last_node = np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2210 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2211 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2212
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2213 if (!CTAGS)
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2214 /* Etags Mode */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2215 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2216 /* For each file name, tags are in a linked sublist on the right
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2217 pointer. The first tags of different files are a linked list
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2218 on the left pointer. last_node points to the end of the last
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2219 used sublist. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2220 if (last_node != NULL && last_node->fdp == np->fdp)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2221 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2222 /* Let's use the same sublist as the last added node. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2223 assert (last_node->right == NULL);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2224 last_node->right = np;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2225 last_node = np;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2226 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2227 else if (cur_node->fdp == np->fdp)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2228 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2229 /* Scanning the list we found the head of a sublist which is
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2230 good for us. Let's scan this sublist. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2231 add_node (np, &cur_node->right);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2232 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2233 else
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2234 /* The head of this sublist is not good for us. Let's try the
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2235 next one. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2236 add_node (np, &cur_node->left);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2237 } /* if ETAGS mode */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2238
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2239 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2240 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2241 /* Ctags Mode */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2242 dif = strcmp (np->name, cur_node->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2243
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2244 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2245 * If this tag name matches an existing one, then
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2246 * do not add the node, but maybe print a warning.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2247 */
3876
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
2248 if (no_duplicates && !dif)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2249 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2250 if (np->fdp == cur_node->fdp)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2251 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2252 if (!no_warnings)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2253 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2254 fprintf (stderr, "Duplicate entry in file %s, line %d: %s\n",
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2255 np->fdp->infname, lineno, np->name);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2256 fprintf (stderr, "Second entry ignored\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2257 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2258 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2259 else if (!cur_node->been_warned && !no_warnings)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2260 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2261 fprintf
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2262 (stderr,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2263 "Duplicate entry in files %s and %s: %s (Warning only)\n",
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2264 np->fdp->infname, cur_node->fdp->infname, np->name);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2265 cur_node->been_warned = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2266 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2267 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2268 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2269
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2270 /* Actually add the node */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2271 add_node (np, dif < 0 ? &cur_node->left : &cur_node->right);
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2272 } /* if CTAGS mode */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2273 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2274
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2275 /*
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2276 * invalidate_nodes ()
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2277 * Scan the node tree and invalidate all nodes pointing to the
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2278 * given file description (CTAGS case) or free them (ETAGS case).
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2279 */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2280 static void
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2281 invalidate_nodes (badfdp, npp)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2282 fdesc *badfdp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2283 node **npp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2284 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2285 node *np = *npp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2286
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2287 if (np == NULL)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2288 return;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2289
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2290 if (CTAGS)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2291 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2292 if (np->left != NULL)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2293 invalidate_nodes (badfdp, &np->left);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2294 if (np->fdp == badfdp)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2295 np->valid = FALSE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2296 if (np->right != NULL)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2297 invalidate_nodes (badfdp, &np->right);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2298 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2299 else
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2300 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2301 assert (np->fdp != NULL);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2302 if (np->fdp == badfdp)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2303 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2304 *npp = np->left; /* detach the sublist from the list */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2305 np->left = NULL; /* isolate it */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2306 free_tree (np); /* free it */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2307 invalidate_nodes (badfdp, npp);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2308 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2309 else
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2310 invalidate_nodes (badfdp, &np->left);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2311 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2312 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2313
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2314
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2315 static int total_size_of_entries __P((node *));
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2316 static int number_len __P((long));
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2317
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2318 /* Length of a non-negative number's decimal representation. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2319 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2320 number_len (num)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2321 long num;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2322 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2323 int len = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2324 while ((num /= 10) > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2325 len += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2326 return len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2327 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2328
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2329 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2330 * Return total number of characters that put_entries will output for
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2331 * the nodes in the linked list at the right of the specified node.
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2332 * This count is irrelevant with etags.el since emacs 19.34 at least,
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2333 * but is still supplied for backward compatibility.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2334 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
2335 static int
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2336 total_size_of_entries (np)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2337 register node *np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2338 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2339 register int total = 0;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2340
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2341 for (; np != NULL; np = np->right)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2342 if (np->valid)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2343 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2344 total += strlen (np->regex) + 1; /* pat\177 */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2345 if (np->name != NULL)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2346 total += strlen (np->name) + 1; /* name\001 */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2347 total += number_len ((long) np->lno) + 1; /* lno, */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2348 if (np->cno != invalidcharno) /* cno */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2349 total += number_len (np->cno);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2350 total += 1; /* newline */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2351 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2352
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2353 return total;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2354 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2355
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2356 static void
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2357 put_entries (np)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2358 register node *np;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2359 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2360 register char *sp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2361 static fdesc *fdp = NULL;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2362
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2363 if (np == NULL)
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2364 return;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2365
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2366 /* Output subentries that precede this one */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2367 if (CTAGS)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2368 put_entries (np->left);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2369
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2370 /* Output this entry */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2371 if (np->valid)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2372 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2373 if (!CTAGS)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2374 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2375 /* Etags mode */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2376 if (fdp != np->fdp)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2377 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2378 fdp = np->fdp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2379 fprintf (tagf, "\f\n%s,%d\n",
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2380 fdp->taggedfname, total_size_of_entries (np));
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2381 fdp->written = TRUE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2382 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2383 fputs (np->regex, tagf);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2384 fputc ('\177', tagf);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2385 if (np->name != NULL)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2386 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2387 fputs (np->name, tagf);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2388 fputc ('\001', tagf);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2389 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2390 fprintf (tagf, "%d,", np->lno);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2391 if (np->cno != invalidcharno)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2392 fprintf (tagf, "%ld", np->cno);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2393 fputs ("\n", tagf);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2394 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2395 else
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2396 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2397 /* Ctags mode */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2398 if (np->name == NULL)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2399 error ("internal error: NULL name in ctags mode.", (char *)NULL);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2400
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2401 if (cxref_style)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2402 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2403 if (vgrind_style)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2404 fprintf (stdout, "%s %s %d\n",
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2405 np->name, np->fdp->taggedfname, (np->lno + 63) / 64);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2406 else
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2407 fprintf (stdout, "%-16s %3d %-16s %s\n",
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2408 np->name, np->lno, np->fdp->taggedfname, np->regex);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2409 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2410 else
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2411 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2412 fprintf (tagf, "%s\t%s\t", np->name, np->fdp->taggedfname);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2413
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2414 if (np->is_func)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2415 { /* function or #define macro with args */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2416 putc (searchar, tagf);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2417 putc ('^', tagf);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2418
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2419 for (sp = np->regex; *sp; sp++)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2420 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2421 if (*sp == '\\' || *sp == searchar)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2422 putc ('\\', tagf);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2423 putc (*sp, tagf);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2424 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2425 putc (searchar, tagf);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2426 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2427 else
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2428 { /* anything else; text pattern inadequate */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2429 fprintf (tagf, "%d", np->lno);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2430 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2431 putc ('\n', tagf);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2432 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2433 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2434 } /* if this node contains a valid tag */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2435
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2436 /* Output subentries that follow this one */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2437 put_entries (np->right);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2438 if (!CTAGS)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2439 put_entries (np->left);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2440 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2441
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2442
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2443 /* C extensions. */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2444 #define C_EXT 0x00fff /* C extensions */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2445 #define C_PLAIN 0x00000 /* C */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2446 #define C_PLPL 0x00001 /* C++ */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2447 #define C_STAR 0x00003 /* C* */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2448 #define C_JAVA 0x00005 /* JAVA */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2449 #define C_AUTO 0x01000 /* C, but switch to C++ if `class' is met */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2450 #define YACC 0x10000 /* yacc file */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2451
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2452 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2453 * The C symbol tables.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2454 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2455 enum sym_type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2456 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2457 st_none,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2458 st_C_objprot, st_C_objimpl, st_C_objend,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2459 st_C_gnumacro,
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2460 st_C_ignore, st_C_attribute,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2461 st_C_javastruct,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2462 st_C_operator,
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2463 st_C_class, st_C_template,
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2464 st_C_struct, st_C_extern, st_C_enum, st_C_define, st_C_typedef
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2465 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2466
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
2467 static unsigned int hash __P((const char *, unsigned int));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
2468 static struct C_stab_entry * in_word_set __P((const char *, unsigned int));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
2469 static enum sym_type C_symtype __P((char *, int, int));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
2470
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2471 /* Feed stuff between (but not including) %[ and %] lines to:
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2472 gperf -m 5
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2473 %[
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2474 %compare-strncmp
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2475 %enum
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2476 %struct-type
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2477 struct C_stab_entry { char *name; int c_ext; enum sym_type type; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2478 %%
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2479 if, 0, st_C_ignore
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2480 for, 0, st_C_ignore
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2481 while, 0, st_C_ignore
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2482 switch, 0, st_C_ignore
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2483 return, 0, st_C_ignore
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2484 __attribute__, 0, st_C_attribute
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2485 @interface, 0, st_C_objprot
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2486 @protocol, 0, st_C_objprot
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2487 @implementation,0, st_C_objimpl
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2488 @end, 0, st_C_objend
3876
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
2489 import, (C_JAVA & ~C_PLPL), st_C_ignore
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
2490 package, (C_JAVA & ~C_PLPL), st_C_ignore
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2491 friend, C_PLPL, st_C_ignore
3876
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
2492 extends, (C_JAVA & ~C_PLPL), st_C_javastruct
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
2493 implements, (C_JAVA & ~C_PLPL), st_C_javastruct
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
2494 interface, (C_JAVA & ~C_PLPL), st_C_struct
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2495 class, 0, st_C_class
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2496 namespace, C_PLPL, st_C_struct
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2497 domain, C_STAR, st_C_struct
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2498 union, 0, st_C_struct
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2499 struct, 0, st_C_struct
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2500 extern, 0, st_C_extern
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2501 enum, 0, st_C_enum
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2502 typedef, 0, st_C_typedef
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2503 define, 0, st_C_define
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2504 undef, 0, st_C_define
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2505 operator, C_PLPL, st_C_operator
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2506 template, 0, st_C_template
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2507 # DEFUN used in emacs, the next three used in glibc (SYSCALL only for mach).
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2508 DEFUN, 0, st_C_gnumacro
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2509 SYSCALL, 0, st_C_gnumacro
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2510 ENTRY, 0, st_C_gnumacro
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2511 PSEUDO, 0, st_C_gnumacro
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2512 # These are defined inside C functions, so currently they are not met.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2513 # EXFUN used in glibc, DEFVAR_* in emacs.
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2514 #EXFUN, 0, st_C_gnumacro
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2515 #DEFVAR_, 0, st_C_gnumacro
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2516 %]
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2517 and replace lines between %< and %> with its output, then:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2518 - remove the #if characterset check
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2519 - make in_word_set static and not inline. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2520 /*%<*/
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2521 /* C code produced by gperf version 3.0.1 */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2522 /* Command-line: gperf -m 5 */
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2523 /* Computed positions: -k'2-3' */
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2524
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2525 struct C_stab_entry { char *name; int c_ext; enum sym_type type; };
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2526 /* maximum key range = 33, duplicates = 0 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2527
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2528 #ifdef __GNUC__
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2529 __inline
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2530 #else
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2531 #ifdef __cplusplus
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2532 inline
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2533 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2534 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2535 static unsigned int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2536 hash (str, len)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2537 register const char *str;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2538 register unsigned int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2539 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2540 static unsigned char asso_values[] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2541 {
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2542 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2543 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2544 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2545 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2546 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2547 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2548 35, 35, 35, 35, 35, 35, 35, 35, 35, 15,
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2549 14, 35, 35, 35, 35, 35, 35, 35, 14, 35,
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2550 35, 35, 35, 12, 13, 35, 35, 35, 35, 12,
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2551 35, 35, 35, 35, 35, 1, 35, 16, 35, 6,
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2552 23, 0, 0, 35, 22, 0, 35, 35, 5, 0,
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2553 0, 15, 1, 35, 6, 35, 8, 19, 35, 16,
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2554 4, 5, 35, 35, 35, 35, 35, 35, 35, 35,
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2555 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2556 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2557 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2558 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2559 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2560 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2561 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2562 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2563 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2564 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2565 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2566 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2567 35, 35, 35, 35, 35, 35
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2568 };
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2569 register int hval = len;
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2570
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2571 switch (hval)
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2572 {
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2573 default:
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2574 hval += asso_values[(unsigned char)str[2]];
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2575 /*FALLTHROUGH*/
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2576 case 2:
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2577 hval += asso_values[(unsigned char)str[1]];
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2578 break;
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2579 }
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2580 return hval;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2581 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2582
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2583 static struct C_stab_entry *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2584 in_word_set (str, len)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2585 register const char *str;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2586 register unsigned int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2587 {
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2588 enum
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2589 {
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2590 TOTAL_KEYWORDS = 32,
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2591 MIN_WORD_LENGTH = 2,
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2592 MAX_WORD_LENGTH = 15,
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2593 MIN_HASH_VALUE = 2,
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2594 MAX_HASH_VALUE = 34
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2595 };
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2596
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2597 static struct C_stab_entry wordlist[] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2598 {
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2599 {""}, {""},
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2600 {"if", 0, st_C_ignore},
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2601 {""},
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2602 {"@end", 0, st_C_objend},
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2603 {"union", 0, st_C_struct},
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2604 {"define", 0, st_C_define},
3876
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
2605 {"import", (C_JAVA & ~C_PLPL), st_C_ignore},
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2606 {"template", 0, st_C_template},
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2607 {"operator", C_PLPL, st_C_operator},
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2608 {"@interface", 0, st_C_objprot},
3876
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
2609 {"implements", (C_JAVA & ~C_PLPL), st_C_javastruct},
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2610 {"friend", C_PLPL, st_C_ignore},
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2611 {"typedef", 0, st_C_typedef},
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2612 {"return", 0, st_C_ignore},
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2613 {"@implementation",0, st_C_objimpl},
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2614 {"@protocol", 0, st_C_objprot},
3876
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
2615 {"interface", (C_JAVA & ~C_PLPL), st_C_struct},
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2616 {"extern", 0, st_C_extern},
3876
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
2617 {"extends", (C_JAVA & ~C_PLPL), st_C_javastruct},
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2618 {"struct", 0, st_C_struct},
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2619 {"domain", C_STAR, st_C_struct},
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2620 {"switch", 0, st_C_ignore},
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2621 {"enum", 0, st_C_enum},
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2622 {"for", 0, st_C_ignore},
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2623 {"namespace", C_PLPL, st_C_struct},
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2624 {"class", 0, st_C_class},
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2625 {"while", 0, st_C_ignore},
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2626 {"undef", 0, st_C_define},
3876
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
2627 {"package", (C_JAVA & ~C_PLPL), st_C_ignore},
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2628 {"__attribute__", 0, st_C_attribute},
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2629 {"SYSCALL", 0, st_C_gnumacro},
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
2630 {"ENTRY", 0, st_C_gnumacro},
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2631 {"PSEUDO", 0, st_C_gnumacro},
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2632 {"DEFUN", 0, st_C_gnumacro}
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2633 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2634
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2635 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2636 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2637 register int key = hash (str, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2638
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2639 if (key <= MAX_HASH_VALUE && key >= 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2640 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2641 register const char *s = wordlist[key].name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2642
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2643 if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2644 return &wordlist[key];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2645 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2646 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2647 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2648 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2649 /*%>*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2650
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2651 static enum sym_type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2652 C_symtype (str, len, c_ext)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2653 char *str;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2654 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2655 int c_ext;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2656 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2657 register struct C_stab_entry *se = in_word_set (str, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2658
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2659 if (se == NULL || (se->c_ext && !(c_ext & se->c_ext)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2660 return st_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2661 return se->type;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2662 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2663
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2664
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2665 /*
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2666 * Ignoring __attribute__ ((list))
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2667 */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2668 static bool inattribute; /* looking at an __attribute__ construct */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2669
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2670 /*
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2671 * C functions and variables are recognized using a simple
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2672 * finite automaton. fvdef is its state variable.
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2673 */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2674 static enum
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2675 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2676 fvnone, /* nothing seen */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2677 fdefunkey, /* Emacs DEFUN keyword seen */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2678 fdefunname, /* Emacs DEFUN name seen */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2679 foperator, /* func: operator keyword seen (cplpl) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2680 fvnameseen, /* function or variable name seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2681 fstartlist, /* func: just after open parenthesis */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2682 finlist, /* func: in parameter list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2683 flistseen, /* func: after parameter list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2684 fignore, /* func: before open brace */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2685 vignore /* var-like: ignore until ';' */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2686 } fvdef;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2687
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2688 static bool fvextern; /* func or var: extern keyword seen; */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2689
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2690 /*
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2691 * typedefs are recognized using a simple finite automaton.
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2692 * typdef is its state variable.
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2693 */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2694 static enum
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2695 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2696 tnone, /* nothing seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2697 tkeyseen, /* typedef keyword seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2698 ttypeseen, /* defined type seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2699 tinbody, /* inside typedef body */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2700 tend, /* just before typedef tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2701 tignore /* junk after typedef tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2702 } typdef;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2703
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2704 /*
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2705 * struct-like structures (enum, struct and union) are recognized
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2706 * using another simple finite automaton. `structdef' is its state
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2707 * variable.
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2708 */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2709 static enum
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2710 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2711 snone, /* nothing seen yet,
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2712 or in struct body if bracelev > 0 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2713 skeyseen, /* struct-like keyword seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2714 stagseen, /* struct-like tag seen */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2715 scolonseen /* colon seen after struct-like tag */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2716 } structdef;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2717
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2718 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2719 * When objdef is different from onone, objtag is the name of the class.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2720 */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2721 static char *objtag = "<uninited>";
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2722
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2723 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2724 * Yet another little state machine to deal with preprocessor lines.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2725 */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2726 static enum
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2727 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2728 dnone, /* nothing seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2729 dsharpseen, /* '#' seen as first char on line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2730 ddefineseen, /* '#' and 'define' seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2731 dignorerest /* ignore rest of line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2732 } definedef;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2733
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2734 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2735 * State machine for Objective C protocols and implementations.
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2736 * Idea by Tom R.Hageman <tom@basil.icce.rug.nl> (1995)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2737 */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2738 static enum
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2739 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2740 onone, /* nothing seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2741 oprotocol, /* @interface or @protocol seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2742 oimplementation, /* @implementations seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2743 otagseen, /* class name seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2744 oparenseen, /* parenthesis before category seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2745 ocatseen, /* category name seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2746 oinbody, /* in @implementation body */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2747 omethodsign, /* in @implementation body, after +/- */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2748 omethodtag, /* after method name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2749 omethodcolon, /* after method colon */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2750 omethodparm, /* after method parameter */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2751 oignore /* wait for @end */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2752 } objdef;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2753
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2754
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2755 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2756 * Use this structure to keep info about the token read, and how it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2757 * should be tagged. Used by the make_C_tag function to build a tag.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2758 */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2759 static struct tok
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2760 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2761 char *line; /* string containing the token */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2762 int offset; /* where the token starts in LINE */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2763 int length; /* token length */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2764 /*
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2765 The previous members can be used to pass strings around for generic
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2766 purposes. The following ones specifically refer to creating tags. In this
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2767 case the token contained here is the pattern that will be used to create a
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2768 tag.
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2769 */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2770 bool valid; /* do not create a tag; the token should be
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2771 invalidated whenever a state machine is
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2772 reset prematurely */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2773 bool named; /* create a named tag */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2774 int lineno; /* source line number of tag */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2775 long linepos; /* source char number of tag */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2776 } token; /* latest token read */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2777
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2778 /*
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2779 * Variables and functions for dealing with nested structures.
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2780 * Idea by Mykola Dzyuba <mdzyuba@yahoo.com> (2001)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2781 */
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
2782 static void pushclass_above __P((int, char *, int));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
2783 static void popclass_above __P((int));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
2784 static void write_classname __P((linebuffer *, char *qualifier));
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2785
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2786 static struct {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2787 char **cname; /* nested class names */
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2788 int *bracelev; /* nested class brace level */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2789 int nl; /* class nesting level (elements used) */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2790 int size; /* length of the array */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2791 } cstack; /* stack for nested declaration tags */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2792 /* Current struct nesting depth (namespace, class, struct, union, enum). */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2793 #define nestlev (cstack.nl)
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
2794 /* After struct keyword or in struct body, not inside a nested function. */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2795 #define instruct (structdef == snone && nestlev > 0 \
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2796 && bracelev == cstack.bracelev[nestlev-1] + 1)
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2797
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2798 static void
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2799 pushclass_above (bracelev, str, len)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2800 int bracelev;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2801 char *str;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2802 int len;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2803 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2804 int nl;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2805
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2806 popclass_above (bracelev);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2807 nl = cstack.nl;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2808 if (nl >= cstack.size)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2809 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2810 int size = cstack.size *= 2;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2811 xrnew (cstack.cname, size, char *);
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2812 xrnew (cstack.bracelev, size, int);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2813 }
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2814 assert (nl == 0 || cstack.bracelev[nl-1] < bracelev);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2815 cstack.cname[nl] = (str == NULL) ? NULL : savenstr (str, len);
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2816 cstack.bracelev[nl] = bracelev;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2817 cstack.nl = nl + 1;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2818 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2819
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2820 static void
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2821 popclass_above (bracelev)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2822 int bracelev;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2823 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2824 int nl;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2825
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2826 for (nl = cstack.nl - 1;
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2827 nl >= 0 && cstack.bracelev[nl] >= bracelev;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2828 nl--)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2829 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2830 if (cstack.cname[nl] != NULL)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2831 free (cstack.cname[nl]);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2832 cstack.nl = nl;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2833 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2834 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2835
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2836 static void
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2837 write_classname (cn, qualifier)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2838 linebuffer *cn;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2839 char *qualifier;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2840 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2841 int i, len;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2842 int qlen = strlen (qualifier);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2843
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2844 if (cstack.nl == 0 || cstack.cname[0] == NULL)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2845 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2846 len = 0;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2847 cn->len = 0;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2848 cn->buffer[0] = '\0';
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2849 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2850 else
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2851 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2852 len = strlen (cstack.cname[0]);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2853 linebuffer_setlen (cn, len);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2854 strcpy (cn->buffer, cstack.cname[0]);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2855 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2856 for (i = 1; i < cstack.nl; i++)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2857 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2858 char *s;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2859 int slen;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2860
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2861 s = cstack.cname[i];
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2862 if (s == NULL)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2863 continue;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2864 slen = strlen (s);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2865 len += slen + qlen;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2866 linebuffer_setlen (cn, len);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2867 strncat (cn->buffer, qualifier, qlen);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2868 strncat (cn->buffer, s, slen);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2869 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2870 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2871
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2872
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
2873 static bool consider_token __P((char *, int, int, int *, int, int, bool *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
2874 static void make_C_tag __P((bool));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
2875
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2876 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2877 * consider_token ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2878 * checks to see if the current token is at the start of a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2879 * function or variable, or corresponds to a typedef, or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2880 * is a struct/union/enum tag, or #define, or an enum constant.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2881 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2882 * *IS_FUNC gets TRUE iff the token is a function or #define macro
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2883 * with args. C_EXTP points to which language we are looking at.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2884 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2885 * Globals
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2886 * fvdef IN OUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2887 * structdef IN OUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2888 * definedef IN OUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2889 * typdef IN OUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2890 * objdef IN OUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2891 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2892
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2893 static bool
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2894 consider_token (str, len, c, c_extp, bracelev, parlev, is_func_or_var)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2895 register char *str; /* IN: token pointer */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2896 register int len; /* IN: token length */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
2897 register int c; /* IN: first char after the token */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2898 int *c_extp; /* IN, OUT: C extensions mask */
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2899 int bracelev; /* IN: brace level */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2900 int parlev; /* IN: parenthesis level */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2901 bool *is_func_or_var; /* OUT: function or variable found */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2902 {
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2903 /* When structdef is stagseen, scolonseen, or snone with bracelev > 0,
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2904 structtype is the type of the preceding struct-like keyword, and
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2905 structbracelev is the brace level where it has been seen. */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2906 static enum sym_type structtype;
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2907 static int structbracelev;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2908 static enum sym_type toktype;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2909
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2910
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2911 toktype = C_symtype (str, len, *c_extp);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2912
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2913 /*
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2914 * Skip __attribute__
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2915 */
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2916 if (toktype == st_C_attribute)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2917 {
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2918 inattribute = TRUE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2919 return FALSE;
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2920 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2921
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2922 /*
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2923 * Advance the definedef state machine.
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2924 */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2925 switch (definedef)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2926 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2927 case dnone:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2928 /* We're not on a preprocessor line. */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2929 if (toktype == st_C_gnumacro)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2930 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2931 fvdef = fdefunkey;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2932 return FALSE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2933 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2934 break;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2935 case dsharpseen:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2936 if (toktype == st_C_define)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2937 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2938 definedef = ddefineseen;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2939 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2940 else
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2941 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2942 definedef = dignorerest;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2943 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2944 return FALSE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2945 case ddefineseen:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2946 /*
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2947 * Make a tag for any macro, unless it is a constant
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2948 * and constantypedefs is FALSE.
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2949 */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2950 definedef = dignorerest;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2951 *is_func_or_var = (c == '(');
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2952 if (!*is_func_or_var && !constantypedefs)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2953 return FALSE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2954 else
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2955 return TRUE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2956 case dignorerest:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2957 return FALSE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2958 default:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2959 error ("internal error: definedef value.", (char *)NULL);
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2960 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2961
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2962 /*
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2963 * Now typedefs
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2964 */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2965 switch (typdef)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2966 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2967 case tnone:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2968 if (toktype == st_C_typedef)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2969 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2970 if (typedefs)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2971 typdef = tkeyseen;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2972 fvextern = FALSE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2973 fvdef = fvnone;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2974 return FALSE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2975 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2976 break;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2977 case tkeyseen:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2978 switch (toktype)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2979 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2980 case st_none:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2981 case st_C_class:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2982 case st_C_struct:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2983 case st_C_enum:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2984 typdef = ttypeseen;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2985 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2986 break;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2987 case ttypeseen:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2988 if (structdef == snone && fvdef == fvnone)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2989 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2990 fvdef = fvnameseen;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2991 return TRUE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2992 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2993 break;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2994 case tend:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2995 switch (toktype)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2996 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2997 case st_C_class:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2998 case st_C_struct:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
2999 case st_C_enum:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3000 return FALSE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3001 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3002 return TRUE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3003 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3004
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3005 /*
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3006 * This structdef business is NOT invoked when we are ctags and the
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3007 * file is plain C. This is because a struct tag may have the same
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3008 * name as another tag, and this loses with ctags.
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3009 */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3010 switch (toktype)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3011 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3012 case st_C_javastruct:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3013 if (structdef == stagseen)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3014 structdef = scolonseen;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3015 return FALSE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3016 case st_C_template:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3017 case st_C_class:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3018 if ((*c_extp & C_AUTO) /* automatic detection of C++ language */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3019 && bracelev == 0
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3020 && definedef == dnone && structdef == snone
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3021 && typdef == tnone && fvdef == fvnone)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3022 *c_extp = (*c_extp | C_PLPL) & ~C_AUTO;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3023 if (toktype == st_C_template)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3024 break;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3025 /* FALLTHRU */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3026 case st_C_struct:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3027 case st_C_enum:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3028 if (parlev == 0
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3029 && fvdef != vignore
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3030 && (typdef == tkeyseen
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3031 || (typedefs_or_cplusplus && structdef == snone)))
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3032 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3033 structdef = skeyseen;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3034 structtype = toktype;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3035 structbracelev = bracelev;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3036 if (fvdef == fvnameseen)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3037 fvdef = fvnone;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3038 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3039 return FALSE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3040 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3041
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3042 if (structdef == skeyseen)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3043 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3044 structdef = stagseen;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3045 return TRUE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3046 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3047
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3048 if (typdef != tnone)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3049 definedef = dnone;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3050
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3051 /* Detect Objective C constructs. */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3052 switch (objdef)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3053 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3054 case onone:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3055 switch (toktype)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3056 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3057 case st_C_objprot:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3058 objdef = oprotocol;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3059 return FALSE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3060 case st_C_objimpl:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3061 objdef = oimplementation;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3062 return FALSE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3063 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3064 break;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3065 case oimplementation:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3066 /* Save the class tag for functions or variables defined inside. */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3067 objtag = savenstr (str, len);
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3068 objdef = oinbody;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3069 return FALSE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3070 case oprotocol:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3071 /* Save the class tag for categories. */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3072 objtag = savenstr (str, len);
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3073 objdef = otagseen;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3074 *is_func_or_var = TRUE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3075 return TRUE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3076 case oparenseen:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3077 objdef = ocatseen;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3078 *is_func_or_var = TRUE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3079 return TRUE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3080 case oinbody:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3081 break;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3082 case omethodsign:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3083 if (parlev == 0)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3084 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3085 fvdef = fvnone;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3086 objdef = omethodtag;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3087 linebuffer_setlen (&token_name, len);
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3088 strncpy (token_name.buffer, str, len);
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3089 token_name.buffer[len] = '\0';
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3090 return TRUE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3091 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3092 return FALSE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3093 case omethodcolon:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3094 if (parlev == 0)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3095 objdef = omethodparm;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3096 return FALSE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3097 case omethodparm:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3098 if (parlev == 0)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3099 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3100 fvdef = fvnone;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3101 objdef = omethodtag;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3102 linebuffer_setlen (&token_name, token_name.len + len);
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3103 strncat (token_name.buffer, str, len);
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3104 return TRUE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3105 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3106 return FALSE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3107 case oignore:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3108 if (toktype == st_C_objend)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3109 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3110 /* Memory leakage here: the string pointed by objtag is
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3111 never released, because many tests would be needed to
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3112 avoid breaking on incorrect input code. The amount of
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3113 memory leaked here is the sum of the lengths of the
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3114 class tags.
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3115 free (objtag); */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3116 objdef = onone;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3117 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3118 return FALSE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3119 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3120
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3121 /* A function, variable or enum constant? */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3122 switch (toktype)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3123 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3124 case st_C_extern:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3125 fvextern = TRUE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3126 switch (fvdef)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3127 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3128 case finlist:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3129 case flistseen:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3130 case fignore:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3131 case vignore:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3132 break;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3133 default:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3134 fvdef = fvnone;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3135 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3136 return FALSE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3137 case st_C_ignore:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3138 fvextern = FALSE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3139 fvdef = vignore;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3140 return FALSE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3141 case st_C_operator:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3142 fvdef = foperator;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3143 *is_func_or_var = TRUE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3144 return TRUE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3145 case st_none:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3146 if (constantypedefs
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3147 && structdef == snone
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3148 && structtype == st_C_enum && bracelev > structbracelev)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3149 return TRUE; /* enum constant */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3150 switch (fvdef)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3151 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3152 case fdefunkey:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3153 if (bracelev > 0)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3154 break;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3155 fvdef = fdefunname; /* GNU macro */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3156 *is_func_or_var = TRUE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3157 return TRUE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3158 case fvnone:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3159 switch (typdef)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3160 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3161 case ttypeseen:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3162 return FALSE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3163 case tnone:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3164 if ((strneq (str, "asm", 3) && endtoken (str[3]))
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3165 || (strneq (str, "__asm__", 7) && endtoken (str[7])))
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3166 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3167 fvdef = vignore;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3168 return FALSE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3169 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3170 break;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3171 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3172 /* FALLTHRU */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3173 case fvnameseen:
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3174 if (len >= 10 && strneq (str+len-10, "::operator", 10))
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3175 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3176 if (*c_extp & C_AUTO) /* automatic detection of C++ */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3177 *c_extp = (*c_extp | C_PLPL) & ~C_AUTO;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3178 fvdef = foperator;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3179 *is_func_or_var = TRUE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3180 return TRUE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3181 }
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3182 if (bracelev > 0 && !instruct)
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3183 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3184 fvdef = fvnameseen; /* function or variable */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3185 *is_func_or_var = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3186 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3187 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3188 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3189 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3190
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3191 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3192 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3193
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3194
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3195 /*
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3196 * C_entries often keeps pointers to tokens or lines which are older than
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3197 * the line currently read. By keeping two line buffers, and switching
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3198 * them at end of line, it is possible to use those pointers.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3199 */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3200 static struct
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3201 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3202 long linepos;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3203 linebuffer lb;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3204 } lbs[2];
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3205
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3206 #define current_lb_is_new (newndx == curndx)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3207 #define switch_line_buffers() (curndx = 1 - curndx)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3208
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3209 #define curlb (lbs[curndx].lb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3210 #define newlb (lbs[newndx].lb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3211 #define curlinepos (lbs[curndx].linepos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3212 #define newlinepos (lbs[newndx].linepos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3213
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3214 #define plainc ((c_ext & C_EXT) == C_PLAIN)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3215 #define cplpl (c_ext & C_PLPL)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3216 #define cjava ((c_ext & C_JAVA) == C_JAVA)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3217
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3218 #define CNL_SAVE_DEFINEDEF() \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3219 do { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3220 curlinepos = charno; \
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3221 readline (&curlb, inf); \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3222 lp = curlb.buffer; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3223 quotednl = FALSE; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3224 newndx = curndx; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3225 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3226
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3227 #define CNL() \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3228 do { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3229 CNL_SAVE_DEFINEDEF(); \
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3230 if (savetoken.valid) \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3231 { \
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3232 token = savetoken; \
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3233 savetoken.valid = FALSE; \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3234 } \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3235 definedef = dnone; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3236 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3237
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3238
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3239 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3240 make_C_tag (isfun)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3241 bool isfun;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3242 {
3876
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
3243 /* This function is never called when token.valid is FALSE, but
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3244 we must protect against invalid input or internal errors. */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3245 if (!DEBUG && !token.valid)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3246 return;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3247
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3248 if (token.valid)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3249 make_tag (token_name.buffer, token_name.len, isfun, token.line,
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3250 token.offset+token.length+1, token.lineno, token.linepos);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3251 else /* this case is optimised away if !DEBUG */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3252 make_tag (concat ("INVALID TOKEN:-->", token_name.buffer, ""),
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3253 token_name.len + 17, isfun, token.line,
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3254 token.offset+token.length+1, token.lineno, token.linepos);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3255
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3256 token.valid = FALSE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3257 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3258
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3259
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3260 /*
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3261 * C_entries ()
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3262 * This routine finds functions, variables, typedefs,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3263 * #define's, enum constants and struct/union/enum definitions in
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3264 * C syntax and adds them to the list.
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3265 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3266 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3267 C_entries (c_ext, inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3268 int c_ext; /* extension of C */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3269 FILE *inf; /* input file */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3270 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3271 register char c; /* latest char read; '\0' for end of line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3272 register char *lp; /* pointer one beyond the character `c' */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3273 int curndx, newndx; /* indices for current and new lb */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3274 register int tokoff; /* offset in line of start of current token */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3275 register int toklen; /* length of current token */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3276 char *qualifier; /* string used to qualify names */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3277 int qlen; /* length of qualifier */
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3278 int bracelev; /* current brace level */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3279 int bracketlev; /* current bracket level */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3280 int parlev; /* current parenthesis level */
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3281 int attrparlev; /* __attribute__ parenthesis level */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3282 int templatelev; /* current template level */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3283 int typdefbracelev; /* bracelev where a typedef struct body begun */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3284 bool incomm, inquote, inchar, quotednl, midtoken;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3285 bool yacc_rules; /* in the rules part of a yacc file */
3876
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
3286 struct tok savetoken = {0}; /* token saved during preprocessor handling */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3287
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3288
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3289 linebuffer_init (&lbs[0].lb);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3290 linebuffer_init (&lbs[1].lb);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3291 if (cstack.size == 0)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3292 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3293 cstack.size = (DEBUG) ? 1 : 4;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3294 cstack.nl = 0;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3295 cstack.cname = xnew (cstack.size, char *);
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3296 cstack.bracelev = xnew (cstack.size, int);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3297 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3298
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3299 tokoff = toklen = typdefbracelev = 0; /* keep compiler quiet */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3300 curndx = newndx = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3301 lp = curlb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3302 *lp = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3303
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3304 fvdef = fvnone; fvextern = FALSE; typdef = tnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3305 structdef = snone; definedef = dnone; objdef = onone;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3306 yacc_rules = FALSE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3307 midtoken = inquote = inchar = incomm = quotednl = FALSE;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3308 token.valid = savetoken.valid = FALSE;
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3309 bracelev = bracketlev = parlev = attrparlev = templatelev = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3310 if (cjava)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3311 { qualifier = "."; qlen = 1; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3312 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3313 { qualifier = "::"; qlen = 2; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3314
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3315
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3316 while (!feof (inf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3317 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3318 c = *lp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3319 if (c == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3320 {
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3321 /* If we are at the end of the line, the next character is a
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3322 '\0'; do not skip it, because it is what tells us
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3323 to read the next line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3324 if (*lp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3325 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3326 quotednl = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3327 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3328 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3329 lp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3330 c = ' ';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3331 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3332 else if (incomm)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3333 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3334 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3335 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3336 case '*':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3337 if (*lp == '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3338 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3339 c = *lp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3340 incomm = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3341 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3342 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3343 case '\0':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3344 /* Newlines inside comments do not end macro definitions in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3345 traditional cpp. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3346 CNL_SAVE_DEFINEDEF ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3347 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3348 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3349 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3350 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3351 else if (inquote)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3352 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3353 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3354 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3355 case '"':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3356 inquote = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3357 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3358 case '\0':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3359 /* Newlines inside strings do not end macro definitions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3360 in traditional cpp, even though compilers don't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3361 usually accept them. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3362 CNL_SAVE_DEFINEDEF ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3363 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3364 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3365 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3366 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3367 else if (inchar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3368 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3369 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3370 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3371 case '\0':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3372 /* Hmmm, something went wrong. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3373 CNL ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3374 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3375 case '\'':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3376 inchar = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3377 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3378 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3379 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3380 }
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3381 else if (bracketlev > 0)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3382 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3383 switch (c)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3384 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3385 case ']':
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3386 if (--bracketlev > 0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3387 continue;
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3388 break;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3389 case '\0':
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3390 CNL_SAVE_DEFINEDEF ();
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3391 break;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3392 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3393 continue;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3394 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3395 else switch (c)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3396 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3397 case '"':
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3398 inquote = TRUE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3399 if (inattribute)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3400 break;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3401 switch (fvdef)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3402 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3403 case fdefunkey:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3404 case fstartlist:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3405 case finlist:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3406 case fignore:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3407 case vignore:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3408 break;
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3409 default:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3410 fvextern = FALSE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3411 fvdef = fvnone;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3412 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3413 continue;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3414 case '\'':
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3415 inchar = TRUE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3416 if (inattribute)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3417 break;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3418 if (fvdef != finlist && fvdef != fignore && fvdef !=vignore)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3419 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3420 fvextern = FALSE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3421 fvdef = fvnone;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3422 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3423 continue;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3424 case '/':
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3425 if (*lp == '*')
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3426 {
3972
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
3427 incomm = TRUE;
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3428 lp++;
3972
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
3429 c = ' ';
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3430 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3431 else if (/* cplpl && */ *lp == '/')
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3432 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3433 c = '\0';
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3434 }
3972
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
3435 break;
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3436 case '%':
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3437 if ((c_ext & YACC) && *lp == '%')
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3438 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3439 /* Entering or exiting rules section in yacc file. */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3440 lp++;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3441 definedef = dnone; fvdef = fvnone; fvextern = FALSE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3442 typdef = tnone; structdef = snone;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3443 midtoken = inquote = inchar = incomm = quotednl = FALSE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3444 bracelev = 0;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3445 yacc_rules = !yacc_rules;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3446 continue;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3447 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3448 else
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3449 break;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3450 case '#':
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3451 if (definedef == dnone)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3452 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3453 char *cp;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3454 bool cpptoken = TRUE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3455
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3456 /* Look back on this line. If all blanks, or nonblanks
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3457 followed by an end of comment, this is a preprocessor
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3458 token. */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3459 for (cp = newlb.buffer; cp < lp-1; cp++)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3460 if (!iswhite (*cp))
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3461 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3462 if (*cp == '*' && *(cp+1) == '/')
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3463 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3464 cp++;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3465 cpptoken = TRUE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3466 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3467 else
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3468 cpptoken = FALSE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3469 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3470 if (cpptoken)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3471 definedef = dsharpseen;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3472 } /* if (definedef == dnone) */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3473 continue;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3474 case '[':
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3475 bracketlev++;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3476 continue;
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3477 } /* switch (c) */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3478
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3479
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3480 /* Consider token only if some involved conditions are satisfied. */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3481 if (typdef != tignore
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3482 && definedef != dignorerest
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3483 && fvdef != finlist
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3484 && templatelev == 0
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3485 && (definedef != dnone
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3486 || structdef != scolonseen)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3487 && !inattribute)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3488 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3489 if (midtoken)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3490 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3491 if (endtoken (c))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3492 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3493 if (c == ':' && *lp == ':' && begtoken (lp[1]))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3494 /* This handles :: in the middle,
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3495 but not at the beginning of an identifier.
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3496 Also, space-separated :: is not recognised. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3497 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3498 if (c_ext & C_AUTO) /* automatic detection of C++ */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3499 c_ext = (c_ext | C_PLPL) & ~C_AUTO;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3500 lp += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3501 toklen += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3502 c = lp[-1];
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3503 goto still_in_token;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3504 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3505 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3506 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3507 bool funorvar = FALSE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3508
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3509 if (yacc_rules
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3510 || consider_token (newlb.buffer + tokoff, toklen, c,
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3511 &c_ext, bracelev, parlev,
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3512 &funorvar))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3513 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3514 if (fvdef == foperator)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3515 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3516 char *oldlp = lp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3517 lp = skip_spaces (lp-1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3518 if (*lp != '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3519 lp += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3520 while (*lp != '\0'
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3521 && !iswhite (*lp) && *lp != '(')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3522 lp += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3523 c = *lp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3524 toklen += lp - oldlp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3525 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3526 token.named = FALSE;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3527 if (!plainc
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3528 && nestlev > 0 && definedef == dnone)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3529 /* in struct body */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3530 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3531 write_classname (&token_name, qualifier);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3532 linebuffer_setlen (&token_name,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3533 token_name.len+qlen+toklen);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3534 strcat (token_name.buffer, qualifier);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3535 strncat (token_name.buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3536 newlb.buffer + tokoff, toklen);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3537 token.named = TRUE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3538 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3539 else if (objdef == ocatseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3540 /* Objective C category */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3541 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3542 int len = strlen (objtag) + 2 + toklen;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3543 linebuffer_setlen (&token_name, len);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3544 strcpy (token_name.buffer, objtag);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3545 strcat (token_name.buffer, "(");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3546 strncat (token_name.buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3547 newlb.buffer + tokoff, toklen);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3548 strcat (token_name.buffer, ")");
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3549 token.named = TRUE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3550 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3551 else if (objdef == omethodtag
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3552 || objdef == omethodparm)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3553 /* Objective C method */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3554 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3555 token.named = TRUE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3556 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3557 else if (fvdef == fdefunname)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3558 /* GNU DEFUN and similar macros */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3559 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3560 bool defun = (newlb.buffer[tokoff] == 'F');
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3561 int off = tokoff;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3562 int len = toklen;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3563
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3564 /* Rewrite the tag so that emacs lisp DEFUNs
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3565 can be found by their elisp name */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3566 if (defun)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3567 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3568 off += 1;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3569 len -= 1;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3570 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3571 linebuffer_setlen (&token_name, len);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3572 strncpy (token_name.buffer,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3573 newlb.buffer + off, len);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3574 token_name.buffer[len] = '\0';
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3575 if (defun)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3576 while (--len >= 0)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3577 if (token_name.buffer[len] == '_')
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3578 token_name.buffer[len] = '-';
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3579 token.named = defun;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3580 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3581 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3582 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3583 linebuffer_setlen (&token_name, toklen);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3584 strncpy (token_name.buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3585 newlb.buffer + tokoff, toklen);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3586 token_name.buffer[toklen] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3587 /* Name macros and members. */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3588 token.named = (structdef == stagseen
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3589 || typdef == ttypeseen
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3590 || typdef == tend
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3591 || (funorvar
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3592 && definedef == dignorerest)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3593 || (funorvar
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3594 && definedef == dnone
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3595 && structdef == snone
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3596 && bracelev > 0));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3597 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3598 token.lineno = lineno;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3599 token.offset = tokoff;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3600 token.length = toklen;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3601 token.line = newlb.buffer;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3602 token.linepos = newlinepos;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3603 token.valid = TRUE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3604
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3605 if (definedef == dnone
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3606 && (fvdef == fvnameseen
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3607 || fvdef == foperator
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3608 || structdef == stagseen
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3609 || typdef == tend
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3610 || typdef == ttypeseen
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3611 || objdef != onone))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3612 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3613 if (current_lb_is_new)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3614 switch_line_buffers ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3615 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3616 else if (definedef != dnone
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3617 || fvdef == fdefunname
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3618 || instruct)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3619 make_C_tag (funorvar);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3620 }
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3621 else /* not yacc and consider_token failed */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3622 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3623 if (inattribute && fvdef == fignore)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3624 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3625 /* We have just met __attribute__ after a
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3626 function parameter list: do not tag the
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3627 function again. */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3628 fvdef = fvnone;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3629 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3630 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3631 midtoken = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3632 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3633 } /* if (endtoken (c)) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3634 else if (intoken (c))
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3635 still_in_token:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3636 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3637 toklen++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3638 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3639 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3640 } /* if (midtoken) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3641 else if (begtoken (c))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3642 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3643 switch (definedef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3644 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3645 case dnone:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3646 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3647 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3648 case fstartlist:
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3649 /* This prevents tagging fb in
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3650 void (__attribute__((noreturn)) *fb) (void);
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3651 Fixing this is not easy and not very important. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3652 fvdef = finlist;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3653 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3654 case flistseen:
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3655 if (plainc || declarations)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3656 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3657 make_C_tag (TRUE); /* a function */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3658 fvdef = fignore;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3659 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3660 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3661 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3662 if (structdef == stagseen && !cjava)
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3663 {
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3664 popclass_above (bracelev);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3665 structdef = snone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3666 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3667 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3668 case dsharpseen:
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3669 savetoken = token;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3670 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3671 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3672 if (!yacc_rules || lp == newlb.buffer + 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3673 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3674 tokoff = lp - 1 - newlb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3675 toklen = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3676 midtoken = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3677 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3678 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3679 } /* if (begtoken) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3680 } /* if must look at token */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3681
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3682
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3683 /* Detect end of line, colon, comma, semicolon and various braces
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3684 after having handled a token.*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3685 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3686 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3687 case ':':
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3688 if (inattribute)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3689 break;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3690 if (yacc_rules && token.offset == 0 && token.valid)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3691 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3692 make_C_tag (FALSE); /* a yacc function */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3693 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3694 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3695 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3696 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3697 switch (objdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3698 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3699 case otagseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3700 objdef = oignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3701 make_C_tag (TRUE); /* an Objective C class */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3702 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3703 case omethodtag:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3704 case omethodparm:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3705 objdef = omethodcolon;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3706 linebuffer_setlen (&token_name, token_name.len + 1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3707 strcat (token_name.buffer, ":");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3708 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3709 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3710 if (structdef == stagseen)
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3711 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3712 structdef = scolonseen;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3713 break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3714 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3715 /* Should be useless, but may be work as a safety net. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3716 if (cplpl && fvdef == flistseen)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3717 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3718 make_C_tag (TRUE); /* a function */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3719 fvdef = fignore;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3720 break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3721 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3722 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3723 case ';':
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3724 if (definedef != dnone || inattribute)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3725 break;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3726 switch (typdef)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3727 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3728 case tend:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3729 case ttypeseen:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3730 make_C_tag (FALSE); /* a typedef */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3731 typdef = tnone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3732 fvdef = fvnone;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3733 break;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3734 case tnone:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3735 case tinbody:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3736 case tignore:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3737 switch (fvdef)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3738 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3739 case fignore:
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3740 if (typdef == tignore || cplpl)
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3741 fvdef = fvnone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3742 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3743 case fvnameseen:
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3744 if ((globals && bracelev == 0 && (!fvextern || declarations))
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3745 || (members && instruct))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3746 make_C_tag (FALSE); /* a variable */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3747 fvextern = FALSE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3748 fvdef = fvnone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3749 token.valid = FALSE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3750 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3751 case flistseen:
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3752 if ((declarations
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3753 && (cplpl || !instruct)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3754 && (typdef == tnone || (typdef != tignore && instruct)))
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3755 || (members
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3756 && plainc && instruct))
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3757 make_C_tag (TRUE); /* a function */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3758 /* FALLTHRU */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3759 default:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3760 fvextern = FALSE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3761 fvdef = fvnone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3762 if (declarations
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3763 && cplpl && structdef == stagseen)
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3764 make_C_tag (FALSE); /* forward declaration */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3765 else
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3766 token.valid = FALSE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3767 } /* switch (fvdef) */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3768 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3769 default:
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3770 if (!instruct)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3771 typdef = tnone;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3772 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3773 if (structdef == stagseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3774 structdef = snone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3775 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3776 case ',':
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3777 if (definedef != dnone || inattribute)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3778 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3779 switch (objdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3780 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3781 case omethodtag:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3782 case omethodparm:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3783 make_C_tag (TRUE); /* an Objective C method */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3784 objdef = oinbody;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3785 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3786 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3787 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3788 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3789 case fdefunkey:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3790 case foperator:
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3791 case fstartlist:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3792 case finlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3793 case fignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3794 case vignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3795 break;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3796 case fdefunname:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3797 fvdef = fignore;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3798 break;
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3799 case fvnameseen:
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3800 if (parlev == 0
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3801 && ((globals
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3802 && bracelev == 0
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3803 && templatelev == 0
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3804 && (!fvextern || declarations))
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3805 || (members && instruct)))
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3806 make_C_tag (FALSE); /* a variable */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3807 break;
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3808 case flistseen:
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3809 if ((declarations && typdef == tnone && !instruct)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3810 || (members && typdef != tignore && instruct))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3811 {
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3812 make_C_tag (TRUE); /* a function */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3813 fvdef = fvnameseen;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3814 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3815 else if (!declarations)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3816 fvdef = fvnone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3817 token.valid = FALSE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3818 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3819 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3820 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3821 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3822 if (structdef == stagseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3823 structdef = snone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3824 break;
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3825 case ']':
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3826 if (definedef != dnone || inattribute)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3827 break;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3828 if (structdef == stagseen)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3829 structdef = snone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3830 switch (typdef)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3831 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3832 case ttypeseen:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3833 case tend:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3834 typdef = tignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3835 make_C_tag (FALSE); /* a typedef */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3836 break;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3837 case tnone:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3838 case tinbody:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3839 switch (fvdef)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3840 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3841 case foperator:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3842 case finlist:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3843 case fignore:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3844 case vignore:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3845 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3846 case fvnameseen:
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3847 if ((members && bracelev == 1)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3848 || (globals && bracelev == 0
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3849 && (!fvextern || declarations)))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3850 make_C_tag (FALSE); /* a variable */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3851 /* FALLTHRU */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3852 default:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3853 fvdef = fvnone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3854 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3855 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3856 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3857 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3858 case '(':
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3859 if (inattribute)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3860 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3861 attrparlev++;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3862 break;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3863 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3864 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3865 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3866 if (objdef == otagseen && parlev == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3867 objdef = oparenseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3868 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3869 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3870 case fvnameseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3871 if (typdef == ttypeseen
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3872 && *lp != '*'
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3873 && !instruct)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3874 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3875 /* This handles constructs like:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3876 typedef void OperatorFun (int fun); */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3877 make_C_tag (FALSE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3878 typdef = tignore;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3879 fvdef = fignore;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3880 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3881 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3882 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3883 case foperator:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3884 fvdef = fstartlist;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3885 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3886 case flistseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3887 fvdef = finlist;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3888 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3889 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3890 parlev++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3891 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3892 case ')':
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3893 if (inattribute)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3894 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3895 if (--attrparlev == 0)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3896 inattribute = FALSE;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3897 break;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3898 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3899 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3900 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3901 if (objdef == ocatseen && parlev == 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3902 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3903 make_C_tag (TRUE); /* an Objective C category */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3904 objdef = oignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3905 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3906 if (--parlev == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3907 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3908 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3909 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3910 case fstartlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3911 case finlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3912 fvdef = flistseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3913 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3914 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3915 if (!instruct
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3916 && (typdef == tend
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3917 || typdef == ttypeseen))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3918 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3919 typdef = tignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3920 make_C_tag (FALSE); /* a typedef */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3921 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3922 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3923 else if (parlev < 0) /* can happen due to ill-conceived #if's. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3924 parlev = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3925 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3926 case '{':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3927 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3928 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3929 if (typdef == ttypeseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3930 {
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
3931 /* Whenever typdef is set to tinbody (currently only
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3932 here), typdefbracelev should be set to bracelev. */
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
3933 typdef = tinbody;
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3934 typdefbracelev = bracelev;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3935 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3936 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3937 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3938 case flistseen:
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3939 make_C_tag (TRUE); /* a function */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3940 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3941 case fignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3942 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3943 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3944 case fvnone:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3945 switch (objdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3946 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3947 case otagseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3948 make_C_tag (TRUE); /* an Objective C class */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3949 objdef = oignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3950 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3951 case omethodtag:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3952 case omethodparm:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3953 make_C_tag (TRUE); /* an Objective C method */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3954 objdef = oinbody;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3955 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3956 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3957 /* Neutralize `extern "C" {' grot. */
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3958 if (bracelev == 0 && structdef == snone && nestlev == 0
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3959 && typdef == tnone)
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3960 bracelev = -1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3961 }
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3962 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3963 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3964 switch (structdef)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3965 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3966 case skeyseen: /* unnamed struct */
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3967 pushclass_above (bracelev, NULL, 0);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3968 structdef = snone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3969 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3970 case stagseen: /* named struct or enum */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3971 case scolonseen: /* a class */
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3972 pushclass_above (bracelev,token.line+token.offset, token.length);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3973 structdef = snone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3974 make_C_tag (FALSE); /* a struct or enum */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3975 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3976 }
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3977 bracelev++;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3978 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3979 case '*':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3980 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3981 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3982 if (fvdef == fstartlist)
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3983 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3984 fvdef = fvnone; /* avoid tagging `foo' in `foo (*bar()) ()' */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3985 token.valid = FALSE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3986 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3987 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3988 case '}':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3989 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3990 break;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3991 if (!ignoreindent && lp == newlb.buffer + 1)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3992 {
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3993 if (bracelev != 0)
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
3994 token.valid = FALSE;
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3995 bracelev = 0; /* reset brace level if first column */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3996 parlev = 0; /* also reset paren level, just in case... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3997 }
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3998 else if (bracelev > 0)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
3999 bracelev--;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4000 else
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4001 token.valid = FALSE; /* something gone amiss, token unreliable */
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
4002 popclass_above (bracelev);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4003 structdef = snone;
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
4004 /* Only if typdef == tinbody is typdefbracelev significant. */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
4005 if (typdef == tinbody && bracelev <= typdefbracelev)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4006 {
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
4007 assert (bracelev == typdefbracelev);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4008 typdef = tend;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4009 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4010 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4011 case '=':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4012 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4013 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4014 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4015 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4016 case foperator:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4017 case finlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4018 case fignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4019 case vignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4020 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4021 case fvnameseen:
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
4022 if ((members && bracelev == 1)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
4023 || (globals && bracelev == 0 && (!fvextern || declarations)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4024 make_C_tag (FALSE); /* a variable */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4025 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4026 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4027 fvdef = vignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4028 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4029 break;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4030 case '<':
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
4031 if (cplpl
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
4032 && (structdef == stagseen || fvdef == fvnameseen))
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4033 {
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
4034 templatelev++;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4035 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4036 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4037 goto resetfvdef;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4038 case '>':
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
4039 if (templatelev > 0)
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4040 {
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
4041 templatelev--;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4042 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4043 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4044 goto resetfvdef;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4045 case '+':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4046 case '-':
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
4047 if (objdef == oinbody && bracelev == 0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4048 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4049 objdef = omethodsign;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4050 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4051 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4052 /* FALLTHRU */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4053 resetfvdef:
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
4054 case '#': case '~': case '&': case '%': case '/':
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
4055 case '|': case '^': case '!': case '.': case '?':
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4056 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4057 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4058 /* These surely cannot follow a function tag in C. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4059 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4060 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4061 case foperator:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4062 case finlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4063 case fignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4064 case vignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4065 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4066 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4067 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4068 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4069 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4070 case '\0':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4071 if (objdef == otagseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4072 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4073 make_C_tag (TRUE); /* an Objective C class */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4074 objdef = oignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4075 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4076 /* If a macro spans multiple lines don't reset its state. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4077 if (quotednl)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4078 CNL_SAVE_DEFINEDEF ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4079 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4080 CNL ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4081 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4082 } /* switch (c) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4083
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4084 } /* while not eof */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4085
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4086 free (lbs[0].lb.buffer);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4087 free (lbs[1].lb.buffer);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4088 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4089
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4090 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4091 * Process either a C++ file or a C file depending on the setting
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4092 * of a global flag.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4093 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4094 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4095 default_C_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4096 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4097 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4098 C_entries (cplusplus ? C_PLPL : C_AUTO, inf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4099 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4100
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4101 /* Always do plain C. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4102 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4103 plain_C_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4104 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4105 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4106 C_entries (0, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4107 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4108
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4109 /* Always do C++. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4110 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4111 Cplusplus_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4112 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4113 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4114 C_entries (C_PLPL, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4115 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4116
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4117 /* Always do Java. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4118 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4119 Cjava_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4120 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4121 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4122 C_entries (C_JAVA, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4123 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4125 /* Always do C*. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4126 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4127 Cstar_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4128 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4129 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4130 C_entries (C_STAR, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4131 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4132
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4133 /* Always do Yacc. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4134 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4135 Yacc_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4136 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4137 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4138 C_entries (YACC, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4139 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4140
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4141
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4142 /* Useful macros. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4143 #define LOOP_ON_INPUT_LINES(file_pointer, line_buffer, char_pointer) \
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4144 for (; /* loop initialization */ \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4145 !feof (file_pointer) /* loop test */ \
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4146 && /* instructions at start of loop */ \
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4147 (readline (&line_buffer, file_pointer), \
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4148 char_pointer = line_buffer.buffer, \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4149 TRUE); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4150 )
2554
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
4151
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
4152 #define LOOKING_AT(cp, kw) /* kw is the keyword, a literal string */ \
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
4153 ((assert("" kw), TRUE) /* syntax error if not a literal string */ \
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
4154 && strneq ((cp), kw, sizeof(kw)-1) /* cp points at kw */ \
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
4155 && notinname ((cp)[sizeof(kw)-1]) /* end of kw */ \
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
4156 && ((cp) = skip_spaces((cp)+sizeof(kw)-1))) /* skip spaces */
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
4157
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
4158 /* Similar to LOOKING_AT but does not use notinname, does not skip */
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
4159 #define LOOKING_AT_NOCASE(cp, kw) /* the keyword is a literal string */ \
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
4160 ((assert("" kw), TRUE) /* syntax error if not a literal string */ \
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
4161 && strncaseeq ((cp), kw, sizeof(kw)-1) /* cp points at kw */ \
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
4162 && ((cp) += sizeof(kw)-1)) /* skip spaces */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4163
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4164 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4165 * Read a file, but do no processing. This is used to do regexp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4166 * matching on files that have no language defined.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4167 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4168 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4169 just_read_file (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4170 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4171 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4172 register char *dummy;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4173
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4174 LOOP_ON_INPUT_LINES (inf, lb, dummy)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4175 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4176 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4177
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4178
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4179 /* Fortran parsing */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4180
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4181 static void F_takeprec __P((void));
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4182 static void F_getit __P((FILE *));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4183
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4184 static void
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4185 F_takeprec ()
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4186 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4187 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4188 if (*dbp != '*')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4189 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4190 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4191 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4192 if (strneq (dbp, "(*)", 3))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4193 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4194 dbp += 3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4195 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4196 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4197 if (!ISDIGIT (*dbp))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4198 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4199 --dbp; /* force failure */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4200 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4201 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4202 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4203 dbp++;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4204 while (ISDIGIT (*dbp));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4205 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4206
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4207 static void
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4208 F_getit (inf)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4209 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4210 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4211 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4212
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4213 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4214 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4215 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4216 readline (&lb, inf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4217 dbp = lb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4218 if (dbp[5] != '&')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4219 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4220 dbp += 6;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4221 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4222 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4223 if (!ISALPHA (*dbp) && *dbp != '_' && *dbp != '$')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4224 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4225 for (cp = dbp + 1; *cp != '\0' && intoken (*cp); cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4226 continue;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4227 make_tag (dbp, cp-dbp, TRUE,
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4228 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4229 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4230
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4231
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4232 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4233 Fortran_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4234 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4235 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4236 LOOP_ON_INPUT_LINES (inf, lb, dbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4237 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4238 if (*dbp == '%')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4239 dbp++; /* Ratfor escape to fortran */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4240 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4241 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4242 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4243 switch (lowcase (*dbp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4244 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4245 case 'i':
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4246 if (nocase_tail ("integer"))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4247 F_takeprec ();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4248 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4249 case 'r':
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4250 if (nocase_tail ("real"))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4251 F_takeprec ();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4252 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4253 case 'l':
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4254 if (nocase_tail ("logical"))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4255 F_takeprec ();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4256 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4257 case 'c':
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4258 if (nocase_tail ("complex") || nocase_tail ("character"))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4259 F_takeprec ();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4260 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4261 case 'd':
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4262 if (nocase_tail ("double"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4263 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4264 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4265 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4266 continue;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4267 if (nocase_tail ("precision"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4268 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4269 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4270 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4271 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4272 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4273 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4274 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4275 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4276 switch (lowcase (*dbp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4277 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4278 case 'f':
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4279 if (nocase_tail ("function"))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4280 F_getit (inf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4281 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4282 case 's':
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4283 if (nocase_tail ("subroutine"))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4284 F_getit (inf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4285 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4286 case 'e':
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4287 if (nocase_tail ("entry"))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4288 F_getit (inf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4289 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4290 case 'b':
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4291 if (nocase_tail ("blockdata") || nocase_tail ("block data"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4292 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4293 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4294 if (*dbp == '\0') /* assume un-named */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4295 make_tag ("blockdata", 9, TRUE,
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4296 lb.buffer, dbp - lb.buffer, lineno, linecharno);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4297 else
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4298 F_getit (inf); /* look for name */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4299 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4300 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4301 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4302 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4303 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4304
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4305
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4306 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4307 * Ada parsing
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4308 * Original code by
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4309 * Philippe Waroquiers (1998)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4310 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4311
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4312 static void Ada_getit __P((FILE *, char *));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4313
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4314 /* Once we are positioned after an "interesting" keyword, let's get
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4315 the real tag value necessary. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4316 static void
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4317 Ada_getit (inf, name_qualifier)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4318 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4319 char *name_qualifier;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4320 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4321 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4322 char *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4323 char c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4324
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4325 while (!feof (inf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4326 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4327 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4328 if (*dbp == '\0'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4329 || (dbp[0] == '-' && dbp[1] == '-'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4330 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4331 readline (&lb, inf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4332 dbp = lb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4333 }
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4334 switch (lowcase(*dbp))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4335 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4336 case 'b':
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4337 if (nocase_tail ("body"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4338 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4339 /* Skipping body of procedure body or package body or ....
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4340 resetting qualifier to body instead of spec. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4341 name_qualifier = "/b";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4342 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4343 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4344 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4345 case 't':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4346 /* Skipping type of task type or protected type ... */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4347 if (nocase_tail ("type"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4348 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4349 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4350 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4351 if (*dbp == '"')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4352 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4353 dbp += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4354 for (cp = dbp; *cp != '\0' && *cp != '"'; cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4355 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4356 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4357 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4358 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4359 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4360 for (cp = dbp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4361 (*cp != '\0'
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4362 && (ISALPHA (*cp) || ISDIGIT (*cp) || *cp == '_' || *cp == '.'));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4363 cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4364 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4365 if (cp == dbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4366 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4367 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4368 c = *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4369 *cp = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4370 name = concat (dbp, name_qualifier, "");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4371 *cp = c;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4372 make_tag (name, strlen (name), TRUE,
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4373 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4374 free (name);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4375 if (c == '"')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4376 dbp = cp + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4377 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4378 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4379 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4380
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4381 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4382 Ada_funcs (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4383 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4384 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4385 bool inquote = FALSE;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4386 bool skip_till_semicolumn = FALSE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4387
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4388 LOOP_ON_INPUT_LINES (inf, lb, dbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4389 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4390 while (*dbp != '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4391 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4392 /* Skip a string i.e. "abcd". */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4393 if (inquote || (*dbp == '"'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4394 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4395 dbp = etags_strchr ((inquote) ? dbp : dbp+1, '"');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4396 if (dbp != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4397 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4398 inquote = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4399 dbp += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4400 continue; /* advance char */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4401 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4402 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4403 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4404 inquote = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4405 break; /* advance line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4406 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4407 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4408
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4409 /* Skip comments. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4410 if (dbp[0] == '-' && dbp[1] == '-')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4411 break; /* advance line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4412
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4413 /* Skip character enclosed in single quote i.e. 'a'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4414 and skip single quote starting an attribute i.e. 'Image. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4415 if (*dbp == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4416 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4417 dbp++ ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4418 if (*dbp != '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4419 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4420 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4421 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4422
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4423 if (skip_till_semicolumn)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4424 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4425 if (*dbp == ';')
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4426 skip_till_semicolumn = FALSE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4427 dbp++;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4428 continue; /* advance char */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4429 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4430
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4431 /* Search for beginning of a token. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4432 if (!begtoken (*dbp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4433 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4434 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4435 continue; /* advance char */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4436 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4437
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4438 /* We are at the beginning of a token. */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4439 switch (lowcase(*dbp))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4440 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4441 case 'f':
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4442 if (!packages_only && nocase_tail ("function"))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4443 Ada_getit (inf, "/f");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4444 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4445 break; /* from switch */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4446 continue; /* advance char */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4447 case 'p':
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4448 if (!packages_only && nocase_tail ("procedure"))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4449 Ada_getit (inf, "/p");
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4450 else if (nocase_tail ("package"))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4451 Ada_getit (inf, "/s");
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4452 else if (nocase_tail ("protected")) /* protected type */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4453 Ada_getit (inf, "/t");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4454 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4455 break; /* from switch */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4456 continue; /* advance char */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4457
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4458 case 'u':
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4459 if (typedefs && !packages_only && nocase_tail ("use"))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4460 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4461 /* when tagging types, avoid tagging use type Pack.Typename;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4462 for this, we will skip everything till a ; */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4463 skip_till_semicolumn = TRUE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4464 continue; /* advance char */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4465 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4466
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4467 case 't':
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4468 if (!packages_only && nocase_tail ("task"))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4469 Ada_getit (inf, "/k");
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4470 else if (typedefs && !packages_only && nocase_tail ("type"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4471 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4472 Ada_getit (inf, "/t");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4473 while (*dbp != '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4474 dbp += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4475 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4476 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4477 break; /* from switch */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4478 continue; /* advance char */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4479 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4480
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4481 /* Look for the end of the token. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4482 while (!endtoken (*dbp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4483 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4484
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4485 } /* advance char */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4486 } /* advance line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4487 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4488
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4489
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4490 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4491 * Unix and microcontroller assembly tag handling
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4492 * Labels: /^[a-zA-Z_.$][a-zA_Z0-9_.$]*[: ^I^J]/
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4493 * Idea by Bob Weiner, Motorola Inc. (1994)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4494 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4495 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4496 Asm_labels (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4497 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4498 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4499 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4500
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4501 LOOP_ON_INPUT_LINES (inf, lb, cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4502 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4503 /* If first char is alphabetic or one of [_.$], test for colon
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4504 following identifier. */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4505 if (ISALPHA (*cp) || *cp == '_' || *cp == '.' || *cp == '$')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4506 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4507 /* Read past label. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4508 cp++;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4509 while (ISALNUM (*cp) || *cp == '_' || *cp == '.' || *cp == '$')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4510 cp++;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4511 if (*cp == ':' || iswhite (*cp))
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4512 /* Found end of label, so copy it and add it to the table. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4513 make_tag (lb.buffer, cp - lb.buffer, TRUE,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4514 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4515 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4516 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4517 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4518
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4519
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4520 /*
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4521 * Perl support
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4522 * Perl sub names: /^sub[ \t\n]+[^ \t\n{]+/
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4523 * Perl variable names: /^(my|local).../
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4524 * Original code by Bart Robinson <lomew@cs.utah.edu> (1995)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4525 * Additions by Michael Ernst <mernst@alum.mit.edu> (1997)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4526 * Ideas by Kai Großjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> (2001)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4527 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4528 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4529 Perl_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4530 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4531 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4532 char *package = savestr ("main"); /* current package name */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4533 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4534
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4535 LOOP_ON_INPUT_LINES (inf, lb, cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4536 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4537 skip_spaces(cp);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4538
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4539 if (LOOKING_AT (cp, "package"))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4540 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4541 free (package);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4542 get_tag (cp, &package);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4543 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4544 else if (LOOKING_AT (cp, "sub"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4545 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4546 char *pos;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4547 char *sp = cp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4548
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4549 while (!notinname (*cp))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4550 cp++;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4551 if (cp == sp)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4552 continue; /* nothing found */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4553 if ((pos = etags_strchr (sp, ':')) != NULL
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4554 && pos < cp && pos[1] == ':')
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4555 /* The name is already qualified. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4556 make_tag (sp, cp - sp, TRUE,
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4557 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4558 else
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4559 /* Qualify it. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4560 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4561 char savechar, *name;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4562
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4563 savechar = *cp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4564 *cp = '\0';
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4565 name = concat (package, "::", sp);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4566 *cp = savechar;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4567 make_tag (name, strlen(name), TRUE,
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4568 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4569 free (name);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4570 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4571 }
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4572 else if (globals) /* only if we are tagging global vars */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4573 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4574 /* Skip a qualifier, if any. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4575 bool qual = LOOKING_AT (cp, "my") || LOOKING_AT (cp, "local");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4576 /* After "my" or "local", but before any following paren or space. */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4577 char *varstart = cp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4578
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4579 if (qual /* should this be removed? If yes, how? */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4580 && (*cp == '$' || *cp == '@' || *cp == '%'))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4581 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4582 varstart += 1;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4583 do
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4584 cp++;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4585 while (ISALNUM (*cp) || *cp == '_');
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4586 }
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4587 else if (qual)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4588 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4589 /* Should be examining a variable list at this point;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4590 could insist on seeing an open parenthesis. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4591 while (*cp != '\0' && *cp != ';' && *cp != '=' && *cp != ')')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4592 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4593 }
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4594 else
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4595 continue;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4596
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4597 make_tag (varstart, cp - varstart, FALSE,
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4598 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4599 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4600 }
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
4601 free (package);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4602 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4603
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4604
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4605 /*
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4606 * Python support
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4607 * Look for /^[\t]*def[ \t\n]+[^ \t\n(:]+/ or /^class[ \t\n]+[^ \t\n(:]+/
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4608 * Idea by Eric S. Raymond <esr@thyrsus.com> (1997)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4609 * More ideas by seb bacon <seb@jamkit.com> (2002)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4610 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4611 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4612 Python_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4613 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4614 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4615 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4616
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4617 LOOP_ON_INPUT_LINES (inf, lb, cp)
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4618 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4619 cp = skip_spaces (cp);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4620 if (LOOKING_AT (cp, "def") || LOOKING_AT (cp, "class"))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4621 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4622 char *name = cp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4623 while (!notinname (*cp) && *cp != ':')
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4624 cp++;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4625 make_tag (name, cp - name, TRUE,
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4626 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4627 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4628 }
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4629 }
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4630
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4631
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4632 /*
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4633 * PHP support
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4634 * Look for:
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4635 * - /^[ \t]*function[ \t\n]+[^ \t\n(]+/
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4636 * - /^[ \t]*class[ \t\n]+[^ \t\n]+/
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4637 * - /^[ \t]*define\(\"[^\"]+/
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4638 * Only with --members:
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4639 * - /^[ \t]*var[ \t\n]+\$[^ \t\n=;]/
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4640 * Idea by Diez B. Roggisch (2001)
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4641 */
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4642 static void
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4643 PHP_functions (inf)
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4644 FILE *inf;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4645 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4646 register char *cp, *name;
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4647 bool search_identifier = FALSE;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4648
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4649 LOOP_ON_INPUT_LINES (inf, lb, cp)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4650 {
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4651 cp = skip_spaces (cp);
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4652 name = cp;
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4653 if (search_identifier
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4654 && *cp != '\0')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4655 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4656 while (!notinname (*cp))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4657 cp++;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4658 make_tag (name, cp - name, TRUE,
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4659 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4660 search_identifier = FALSE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4661 }
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4662 else if (LOOKING_AT (cp, "function"))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4663 {
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4664 if(*cp == '&')
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4665 cp = skip_spaces (cp+1);
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4666 if(*cp != '\0')
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4667 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4668 name = cp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4669 while (!notinname (*cp))
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4670 cp++;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4671 make_tag (name, cp - name, TRUE,
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4672 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4673 }
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4674 else
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4675 search_identifier = TRUE;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4676 }
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4677 else if (LOOKING_AT (cp, "class"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4678 {
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4679 if (*cp != '\0')
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4680 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4681 name = cp;
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4682 while (*cp != '\0' && !iswhite (*cp))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4683 cp++;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4684 make_tag (name, cp - name, FALSE,
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4685 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4686 }
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4687 else
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4688 search_identifier = TRUE;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4689 }
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4690 else if (strneq (cp, "define", 6)
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4691 && (cp = skip_spaces (cp+6))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4692 && *cp++ == '('
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4693 && (*cp == '"' || *cp == '\''))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4694 {
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4695 char quote = *cp++;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4696 name = cp;
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4697 while (*cp != quote && *cp != '\0')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4698 cp++;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4699 make_tag (name, cp - name, FALSE,
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4700 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4701 }
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4702 else if (members
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4703 && LOOKING_AT (cp, "var")
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4704 && *cp == '$')
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4705 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4706 name = cp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4707 while (!notinname(*cp))
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4708 cp++;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4709 make_tag (name, cp - name, FALSE,
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4710 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4711 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4712 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4713 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4714
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4715
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4716 /*
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4717 * Cobol tag functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4718 * We could look for anything that could be a paragraph name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4719 * i.e. anything that starts in column 8 is one word and ends in a full stop.
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4720 * Idea by Corny de Souza (1993)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4721 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4722 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4723 Cobol_paragraphs (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4724 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4725 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4726 register char *bp, *ep;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4727
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4728 LOOP_ON_INPUT_LINES (inf, lb, bp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4729 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4730 if (lb.len < 9)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4731 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4732 bp += 8;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4733
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4734 /* If eoln, compiler option or comment ignore whole line. */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4735 if (bp[-1] != ' ' || !ISALNUM (bp[0]))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4736 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4737
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4738 for (ep = bp; ISALNUM (*ep) || *ep == '-'; ep++)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4739 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4740 if (*ep++ == '.')
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4741 make_tag (bp, ep - bp, TRUE,
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4742 lb.buffer, ep - lb.buffer + 1, lineno, linecharno);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4743 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4744 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4745
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4746
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4747 /*
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4748 * Makefile support
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4749 * Ideas by Assar Westerlund <assar@sics.se> (2001)
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4750 */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4751 static void
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4752 Makefile_targets (inf)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4753 FILE *inf;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4754 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4755 register char *bp;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4756
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4757 LOOP_ON_INPUT_LINES (inf, lb, bp)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4758 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4759 if (*bp == '\t' || *bp == '#')
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4760 continue;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4761 while (*bp != '\0' && *bp != '=' && *bp != ':')
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4762 bp++;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4763 if (*bp == ':' || (globals && *bp == '='))
3876
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
4764 {
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
4765 /* We should detect if there is more than one tag, but we do not.
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
4766 We just skip initial and final spaces. */
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
4767 char * namestart = skip_spaces (lb.buffer);
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
4768 while (--bp > namestart)
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
4769 if (!notinname (*bp))
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
4770 break;
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
4771 make_tag (namestart, bp - namestart + 1, TRUE,
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
4772 lb.buffer, bp - lb.buffer + 2, lineno, linecharno);
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
4773 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4774 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4775 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4776
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4777
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4778 /*
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4779 * Pascal parsing
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4780 * Original code by Mosur K. Mohan (1989)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4781 *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4782 * Locates tags for procedures & functions. Doesn't do any type- or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4783 * var-definitions. It does look for the keyword "extern" or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4784 * "forward" immediately following the procedure statement; if found,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4785 * the tag is skipped.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4786 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4787 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4788 Pascal_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4789 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4790 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4791 linebuffer tline; /* mostly copied from C_entries */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4792 long save_lcno;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4793 int save_lineno, namelen, taglen;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4794 char c, *name;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4795
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4796 bool /* each of these flags is TRUE iff: */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4797 incomment, /* point is inside a comment */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4798 inquote, /* point is inside '..' string */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4799 get_tagname, /* point is after PROCEDURE/FUNCTION
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4800 keyword, so next item = potential tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4801 found_tag, /* point is after a potential tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4802 inparms, /* point is within parameter-list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4803 verify_tag; /* point has passed the parm-list, so the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4804 next token will determine whether this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4805 is a FORWARD/EXTERN to be ignored, or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4806 whether it is a real tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4807
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4808 save_lcno = save_lineno = namelen = taglen = 0; /* keep compiler quiet */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4809 name = NULL; /* keep compiler quiet */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4810 dbp = lb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4811 *dbp = '\0';
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4812 linebuffer_init (&tline);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4813
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4814 incomment = inquote = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4815 found_tag = FALSE; /* have a proc name; check if extern */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4816 get_tagname = FALSE; /* found "procedure" keyword */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4817 inparms = FALSE; /* found '(' after "proc" */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4818 verify_tag = FALSE; /* check if "extern" is ahead */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4819
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4820
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4821 while (!feof (inf)) /* long main loop to get next char */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4822 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4823 c = *dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4824 if (c == '\0') /* if end of line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4825 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4826 readline (&lb, inf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4827 dbp = lb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4828 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4829 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4830 if (!((found_tag && verify_tag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4831 || get_tagname))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4832 c = *dbp++; /* only if don't need *dbp pointing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4833 to the beginning of the name of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4834 the procedure or function */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4835 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4836 if (incomment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4837 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4838 if (c == '}') /* within { } comments */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4839 incomment = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4840 else if (c == '*' && *dbp == ')') /* within (* *) comments */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4841 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4842 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4843 incomment = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4844 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4845 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4846 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4847 else if (inquote)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4848 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4849 if (c == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4850 inquote = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4851 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4852 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4853 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4854 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4855 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4856 case '\'':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4857 inquote = TRUE; /* found first quote */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4858 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4859 case '{': /* found open { comment */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4860 incomment = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4861 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4862 case '(':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4863 if (*dbp == '*') /* found open (* comment */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4864 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4865 incomment = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4866 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4867 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4868 else if (found_tag) /* found '(' after tag, i.e., parm-list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4869 inparms = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4870 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4871 case ')': /* end of parms list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4872 if (inparms)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4873 inparms = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4874 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4875 case ';':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4876 if (found_tag && !inparms) /* end of proc or fn stmt */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4877 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4878 verify_tag = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4879 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4880 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4881 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4882 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4883 if (found_tag && verify_tag && (*dbp != ' '))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4884 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4885 /* Check if this is an "extern" declaration. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4886 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4887 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4888 if (lowcase (*dbp == 'e'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4889 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4890 if (nocase_tail ("extern")) /* superfluous, really! */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4891 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4892 found_tag = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4893 verify_tag = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4894 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4895 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4896 else if (lowcase (*dbp) == 'f')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4897 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4898 if (nocase_tail ("forward")) /* check for forward reference */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4899 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4900 found_tag = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4901 verify_tag = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4902 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4903 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4904 if (found_tag && verify_tag) /* not external proc, so make tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4905 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4906 found_tag = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4907 verify_tag = FALSE;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4908 make_tag (name, namelen, TRUE,
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4909 tline.buffer, taglen, save_lineno, save_lcno);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4910 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4911 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4912 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4913 if (get_tagname) /* grab name of proc or fn */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4914 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4915 char *cp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4916
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4917 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4918 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4919
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4920 /* Find block name. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4921 for (cp = dbp + 1; *cp != '\0' && !endtoken (*cp); cp++)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4922 continue;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4923
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4924 /* Save all values for later tagging. */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4925 linebuffer_setlen (&tline, lb.len);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4926 strcpy (tline.buffer, lb.buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4927 save_lineno = lineno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4928 save_lcno = linecharno;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4929 name = tline.buffer + (dbp - lb.buffer);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4930 namelen = cp - dbp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4931 taglen = cp - lb.buffer + 1;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4932
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4933 dbp = cp; /* set dbp to e-o-token */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4934 get_tagname = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4935 found_tag = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4936 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4937
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4938 /* And proceed to check for "extern". */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4939 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4940 else if (!incomment && !inquote && !found_tag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4941 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4942 /* Check for proc/fn keywords. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4943 switch (lowcase (c))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4944 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4945 case 'p':
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4946 if (nocase_tail ("rocedure")) /* c = 'p', dbp has advanced */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4947 get_tagname = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4948 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4949 case 'f':
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4950 if (nocase_tail ("unction"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4951 get_tagname = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4952 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4953 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4954 }
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4955 } /* while not eof */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4956
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4957 free (tline.buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4958 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4959
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4960
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4961 /*
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4962 * Lisp tag functions
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4963 * look for (def or (DEF, quote or QUOTE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4964 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4965
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4966 static void L_getit __P((void));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4967
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4968 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4969 L_getit ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4970 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4971 if (*dbp == '\'') /* Skip prefix quote */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4972 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4973 else if (*dbp == '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4974 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4975 dbp++;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4976 /* Try to skip "(quote " */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4977 if (!LOOKING_AT (dbp, "quote") && !LOOKING_AT (dbp, "QUOTE"))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4978 /* Ok, then skip "(" before name in (defstruct (foo)) */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4979 dbp = skip_spaces (dbp);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4980 }
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4981 get_tag (dbp, NULL);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4982 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4983
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4984 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4985 Lisp_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4986 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4987 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4988 LOOP_ON_INPUT_LINES (inf, lb, dbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4989 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4990 if (dbp[0] != '(')
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4991 continue;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4992
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4993 if (strneq (dbp+1, "def", 3) || strneq (dbp+1, "DEF", 3))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4994 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4995 dbp = skip_non_spaces (dbp);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4996 dbp = skip_spaces (dbp);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4997 L_getit ();
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4998 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
4999 else
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5000 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5001 /* Check for (foo::defmumble name-defined ... */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5002 do
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5003 dbp++;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5004 while (!notinname (*dbp) && *dbp != ':');
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5005 if (*dbp == ':')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5006 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5007 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5008 dbp++;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5009 while (*dbp == ':');
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5010
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5011 if (strneq (dbp, "def", 3) || strneq (dbp, "DEF", 3))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5012 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5013 dbp = skip_non_spaces (dbp);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5014 dbp = skip_spaces (dbp);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5015 L_getit ();
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5016 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5017 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5018 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5019 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5020 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5021
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5022
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5023 /*
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
5024 * Lua script language parsing
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
5025 * Original code by David A. Capello <dacap@users.sourceforge.net> (2004)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
5026 *
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
5027 * "function" and "local function" are tags if they start at column 1.
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
5028 */
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
5029 static void
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
5030 Lua_functions (inf)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
5031 FILE *inf;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
5032 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
5033 register char *bp;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
5034
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
5035 LOOP_ON_INPUT_LINES (inf, lb, bp)
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
5036 {
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
5037 if (bp[0] != 'f' && bp[0] != 'l')
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
5038 continue;
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
5039
3876
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
5040 (void)LOOKING_AT (bp, "local"); /* skip possible "local" */
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
5041
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
5042 if (LOOKING_AT (bp, "function"))
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
5043 get_tag (bp, NULL);
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
5044 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
5045 }
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
5046
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
5047
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
5048 /*
2554
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5049 * Postscript tags
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5050 * Just look for lines where the first character is '/'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5051 * Also look at "defineps" for PSWrap
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5052 * Ideas by:
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5053 * Richard Mlynarik <mly@adoc.xerox.com> (1997)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5054 * Masatake Yamato <masata-y@is.aist-nara.ac.jp> (1999)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5055 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5056 static void
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5057 PS_functions (inf)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5058 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5059 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5060 register char *bp, *ep;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5061
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5062 LOOP_ON_INPUT_LINES (inf, lb, bp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5063 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5064 if (bp[0] == '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5065 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5066 for (ep = bp+1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5067 *ep != '\0' && *ep != ' ' && *ep != '{';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5068 ep++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5069 continue;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5070 make_tag (bp, ep - bp, TRUE,
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5071 lb.buffer, ep - lb.buffer + 1, lineno, linecharno);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5072 }
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5073 else if (LOOKING_AT (bp, "defineps"))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5074 get_tag (bp, NULL);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5075 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5076 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5077
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5078
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5079 /*
2554
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5080 * Forth tags
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5081 * Ignore anything after \ followed by space or in ( )
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5082 * Look for words defined by :
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5083 * Look for constant, code, create, defer, value, and variable
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5084 * OBP extensions: Look for buffer:, field,
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5085 * Ideas by Eduardo Horvath <eeh@netbsd.org> (2004)
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5086 */
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5087 static void
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5088 Forth_words (inf)
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5089 FILE *inf;
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5090 {
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5091 register char *bp;
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5092
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5093 LOOP_ON_INPUT_LINES (inf, lb, bp)
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5094 while ((bp = skip_spaces (bp))[0] != '\0')
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5095 if (bp[0] == '\\' && iswhite(bp[1]))
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5096 break; /* read next line */
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5097 else if (bp[0] == '(' && iswhite(bp[1]))
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5098 do /* skip to ) or eol */
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5099 bp++;
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5100 while (*bp != ')' && *bp != '\0');
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5101 else if ((bp[0] == ':' && iswhite(bp[1]) && bp++)
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5102 || LOOKING_AT_NOCASE (bp, "constant")
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5103 || LOOKING_AT_NOCASE (bp, "code")
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5104 || LOOKING_AT_NOCASE (bp, "create")
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5105 || LOOKING_AT_NOCASE (bp, "defer")
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5106 || LOOKING_AT_NOCASE (bp, "value")
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5107 || LOOKING_AT_NOCASE (bp, "variable")
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5108 || LOOKING_AT_NOCASE (bp, "buffer:")
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5109 || LOOKING_AT_NOCASE (bp, "field"))
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5110 get_tag (skip_spaces (bp), NULL); /* Yay! A definition! */
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5111 else
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5112 bp = skip_non_spaces (bp);
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5113 }
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5114
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5115
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
5116 /*
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5117 * Scheme tag functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5118 * look for (def... xyzzy
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5119 * (def... (xyzzy
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5120 * (def ... ((...(xyzzy ....
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5121 * (set! xyzzy
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5122 * Original code by Ken Haase (1985?)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5123 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5124 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5125 Scheme_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5126 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5127 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5128 register char *bp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5129
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5130 LOOP_ON_INPUT_LINES (inf, lb, bp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5131 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5132 if (strneq (bp, "(def", 4) || strneq (bp, "(DEF", 4))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5133 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5134 bp = skip_non_spaces (bp+4);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5135 /* Skip over open parens and white space */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5136 while (notinname (*bp))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5137 bp++;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5138 get_tag (bp, NULL);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5139 }
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5140 if (LOOKING_AT (bp, "(SET!") || LOOKING_AT (bp, "(set!"))
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5141 get_tag (bp, NULL);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5142 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5143 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5144
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5145
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5146 /* Find tags in TeX and LaTeX input files. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5147
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5148 /* TEX_toktab is a table of TeX control sequences that define tags.
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5149 * Each entry records one such control sequence.
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5150 *
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5151 * Original code from who knows whom.
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5152 * Ideas by:
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5153 * Stefan Monnier (2002)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5154 */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5155
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5156 static linebuffer *TEX_toktab = NULL; /* Table with tag tokens */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5157
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5158 /* Default set of control sequences to put into TEX_toktab.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5159 The value of environment var TEXTAGS is prepended to this. */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5160 static char *TEX_defenv = "\
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5161 :chapter:section:subsection:subsubsection:eqno:label:ref:cite:bibitem\
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5162 :part:appendix:entry:index:def\
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5163 :newcommand:renewcommand:newenvironment:renewenvironment";
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5164
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5165 static void TEX_mode __P((FILE *));
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5166 static void TEX_decode_env __P((char *, char *));
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5167
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5168 static char TEX_esc = '\\';
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5169 static char TEX_opgrp = '{';
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5170 static char TEX_clgrp = '}';
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5171
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5172 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5173 * TeX/LaTeX scanning loop.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5174 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5175 static void
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5176 TeX_commands (inf)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5177 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5178 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5179 char *cp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5180 linebuffer *key;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5181
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5182 /* Select either \ or ! as escape character. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5183 TEX_mode (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5184
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5185 /* Initialize token table once from environment. */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5186 if (TEX_toktab == NULL)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5187 TEX_decode_env ("TEXTAGS", TEX_defenv);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5188
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5189 LOOP_ON_INPUT_LINES (inf, lb, cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5190 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5191 /* Look at each TEX keyword in line. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5192 for (;;)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5193 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5194 /* Look for a TEX escape. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5195 while (*cp++ != TEX_esc)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5196 if (cp[-1] == '\0' || cp[-1] == '%')
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5197 goto tex_next_line;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5198
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5199 for (key = TEX_toktab; key->buffer != NULL; key++)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5200 if (strneq (cp, key->buffer, key->len))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5201 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5202 register char *p;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5203 int namelen, linelen;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5204 bool opgrp = FALSE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5205
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5206 cp = skip_spaces (cp + key->len);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5207 if (*cp == TEX_opgrp)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5208 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5209 opgrp = TRUE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5210 cp++;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5211 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5212 for (p = cp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5213 (!iswhite (*p) && *p != '#' &&
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5214 *p != TEX_opgrp && *p != TEX_clgrp);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5215 p++)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5216 continue;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5217 namelen = p - cp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5218 linelen = lb.len;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5219 if (!opgrp || *p == TEX_clgrp)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5220 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5221 while (*p != '\0' && *p != TEX_opgrp && *p != TEX_clgrp)
3876
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
5222 p++;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5223 linelen = p - lb.buffer + 1;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5224 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5225 make_tag (cp, namelen, TRUE,
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5226 lb.buffer, linelen, lineno, linecharno);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5227 goto tex_next_line; /* We only tag a line once */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5228 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5229 }
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5230 tex_next_line:
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5231 ;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5232 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5233 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5234
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5235 #define TEX_LESC '\\'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5236 #define TEX_SESC '!'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5237
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5238 /* Figure out whether TeX's escapechar is '\\' or '!' and set grouping
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5239 chars accordingly. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5240 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5241 TEX_mode (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5242 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5243 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5244 int c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5245
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5246 while ((c = getc (inf)) != EOF)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5247 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5248 /* Skip to next line if we hit the TeX comment char. */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5249 if (c == '%')
3876
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
5250 while (c != '\n' && c != EOF)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5251 c = getc (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5252 else if (c == TEX_LESC || c == TEX_SESC )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5253 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5254 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5255
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5256 if (c == TEX_LESC)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5257 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5258 TEX_esc = TEX_LESC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5259 TEX_opgrp = '{';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5260 TEX_clgrp = '}';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5261 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5262 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5263 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5264 TEX_esc = TEX_SESC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5265 TEX_opgrp = '<';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5266 TEX_clgrp = '>';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5267 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5268 /* If the input file is compressed, inf is a pipe, and rewind may fail.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5269 No attempt is made to correct the situation. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5270 rewind (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5271 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5272
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5273 /* Read environment and prepend it to the default string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5274 Build token table. */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5275 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5276 TEX_decode_env (evarname, defenv)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5277 char *evarname;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5278 char *defenv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5279 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5280 register char *env, *p;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5281 int i, len;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5282
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5283 /* Append default string to environment. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5284 env = getenv (evarname);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5285 if (!env)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5286 env = defenv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5287 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5288 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5289 char *oldenv = env;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5290 env = concat (oldenv, defenv, "");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5291 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5292
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5293 /* Allocate a token table */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5294 for (len = 1, p = env; p;)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5295 if ((p = etags_strchr (p, ':')) && *++p != '\0')
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5296 len++;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5297 TEX_toktab = xnew (len, linebuffer);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5298
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5299 /* Unpack environment string into token table. Be careful about */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5300 /* zero-length strings (leading ':', "::" and trailing ':') */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5301 for (i = 0; *env != '\0';)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5302 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5303 p = etags_strchr (env, ':');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5304 if (!p) /* End of environment string. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5305 p = env + strlen (env);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5306 if (p - env > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5307 { /* Only non-zero strings. */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5308 TEX_toktab[i].buffer = savenstr (env, p - env);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5309 TEX_toktab[i].len = p - env;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5310 i++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5311 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5312 if (*p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5313 env = p + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5314 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5315 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5316 TEX_toktab[i].buffer = NULL; /* Mark end of table. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5317 TEX_toktab[i].len = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5318 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5319 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5320 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5321 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5322
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5323
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5324 /* Texinfo support. Dave Love, Mar. 2000. */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5325 static void
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5326 Texinfo_nodes (inf)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5327 FILE * inf;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5328 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5329 char *cp, *start;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5330 LOOP_ON_INPUT_LINES (inf, lb, cp)
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5331 if (LOOKING_AT (cp, "@node"))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5332 {
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5333 start = cp;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5334 while (*cp != '\0' && *cp != ',')
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5335 cp++;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5336 make_tag (start, cp - start, TRUE,
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5337 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5338 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5339 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5340
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5341
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5342 /*
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5343 * HTML support.
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5344 * Contents of <title>, <h1>, <h2>, <h3> are tags.
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5345 * Contents of <a name=xxx> are tags with name xxx.
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5346 *
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5347 * Francesco Potort́, 2002.
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5348 */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5349 static void
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5350 HTML_labels (inf)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5351 FILE * inf;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5352 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5353 bool getnext = FALSE; /* next text outside of HTML tags is a tag */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5354 bool skiptag = FALSE; /* skip to the end of the current HTML tag */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5355 bool intag = FALSE; /* inside an html tag, looking for ID= */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5356 bool inanchor = FALSE; /* when INTAG, is an anchor, look for NAME= */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5357 char *end;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5358
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5359
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5360 linebuffer_setlen (&token_name, 0); /* no name in buffer */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5361
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5362 LOOP_ON_INPUT_LINES (inf, lb, dbp)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5363 for (;;) /* loop on the same line */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5364 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5365 if (skiptag) /* skip HTML tag */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5366 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5367 while (*dbp != '\0' && *dbp != '>')
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5368 dbp++;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5369 if (*dbp == '>')
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5370 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5371 dbp += 1;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5372 skiptag = FALSE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5373 continue; /* look on the same line */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5374 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5375 break; /* go to next line */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5376 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5377
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5378 else if (intag) /* look for "name=" or "id=" */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5379 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5380 while (*dbp != '\0' && *dbp != '>'
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5381 && lowcase (*dbp) != 'n' && lowcase (*dbp) != 'i')
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5382 dbp++;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5383 if (*dbp == '\0')
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5384 break; /* go to next line */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5385 if (*dbp == '>')
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5386 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5387 dbp += 1;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5388 intag = FALSE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5389 continue; /* look on the same line */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5390 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5391 if ((inanchor && LOOKING_AT_NOCASE (dbp, "name="))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5392 || LOOKING_AT_NOCASE (dbp, "id="))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5393 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5394 bool quoted = (dbp[0] == '"');
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5395
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5396 if (quoted)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5397 for (end = ++dbp; *end != '\0' && *end != '"'; end++)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5398 continue;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5399 else
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5400 for (end = dbp; *end != '\0' && intoken (*end); end++)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5401 continue;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5402 linebuffer_setlen (&token_name, end - dbp);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5403 strncpy (token_name.buffer, dbp, end - dbp);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5404 token_name.buffer[end - dbp] = '\0';
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5405
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5406 dbp = end;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5407 intag = FALSE; /* we found what we looked for */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5408 skiptag = TRUE; /* skip to the end of the tag */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5409 getnext = TRUE; /* then grab the text */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5410 continue; /* look on the same line */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5411 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5412 dbp += 1;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5413 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5414
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5415 else if (getnext) /* grab next tokens and tag them */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5416 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5417 dbp = skip_spaces (dbp);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5418 if (*dbp == '\0')
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5419 break; /* go to next line */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5420 if (*dbp == '<')
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5421 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5422 intag = TRUE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5423 inanchor = (lowcase (dbp[1]) == 'a' && !intoken (dbp[2]));
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5424 continue; /* look on the same line */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5425 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5426
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5427 for (end = dbp + 1; *end != '\0' && *end != '<'; end++)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5428 continue;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5429 make_tag (token_name.buffer, token_name.len, TRUE,
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5430 dbp, end - dbp, lineno, linecharno);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5431 linebuffer_setlen (&token_name, 0); /* no name in buffer */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5432 getnext = FALSE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5433 break; /* go to next line */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5434 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5435
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5436 else /* look for an interesting HTML tag */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5437 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5438 while (*dbp != '\0' && *dbp != '<')
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5439 dbp++;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5440 if (*dbp == '\0')
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5441 break; /* go to next line */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5442 intag = TRUE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5443 if (lowcase (dbp[1]) == 'a' && !intoken (dbp[2]))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5444 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5445 inanchor = TRUE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5446 continue; /* look on the same line */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5447 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5448 else if (LOOKING_AT_NOCASE (dbp, "<title>")
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5449 || LOOKING_AT_NOCASE (dbp, "<h1>")
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5450 || LOOKING_AT_NOCASE (dbp, "<h2>")
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5451 || LOOKING_AT_NOCASE (dbp, "<h3>"))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5452 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5453 intag = FALSE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5454 getnext = TRUE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5455 continue; /* look on the same line */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5456 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5457 dbp += 1;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5458 }
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5459 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5460 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5461
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5462
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5463 /*
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5464 * Prolog support
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5465 *
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5466 * Assumes that the predicate or rule starts at column 0.
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5467 * Only the first clause of a predicate or rule is added.
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5468 * Original code by Sunichirou Sugou (1989)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5469 * Rewritten by Anders Lindgren (1996)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5470 */
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5471 static int prolog_pr __P((char *, char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5472 static void prolog_skip_comment __P((linebuffer *, FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5473 static int prolog_atom __P((char *, int));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5474
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5475 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5476 Prolog_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5477 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5478 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5479 char *cp, *last;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5480 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5481 int allocated;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5482
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5483 allocated = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5484 len = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5485 last = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5486
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5487 LOOP_ON_INPUT_LINES (inf, lb, cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5488 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5489 if (cp[0] == '\0') /* Empty line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5490 continue;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5491 else if (iswhite (cp[0])) /* Not a predicate */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5492 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5493 else if (cp[0] == '/' && cp[1] == '*') /* comment. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5494 prolog_skip_comment (&lb, inf);
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5495 else if ((len = prolog_pr (cp, last)) > 0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5496 {
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5497 /* Predicate or rule. Store the function name so that we
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5498 only generate a tag for the first clause. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5499 if (last == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5500 last = xnew(len + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5501 else if (len + 1 > allocated)
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5502 xrnew (last, len + 1, char);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5503 allocated = len + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5504 strncpy (last, cp, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5505 last[len] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5506 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5507 }
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
5508 if (last != NULL)
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
5509 free (last);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5510 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5511
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5512
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5513 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5514 prolog_skip_comment (plb, inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5515 linebuffer *plb;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5516 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5517 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5518 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5519
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5520 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5521 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5522 for (cp = plb->buffer; *cp != '\0'; cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5523 if (cp[0] == '*' && cp[1] == '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5524 return;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5525 readline (plb, inf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5526 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5527 while (!feof(inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5528 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5529
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5530 /*
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5531 * A predicate or rule definition is added if it matches:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5532 * <beginning of line><Prolog Atom><whitespace>(
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5533 * or <beginning of line><Prolog Atom><whitespace>:-
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5534 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5535 * It is added to the tags database if it doesn't match the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5536 * name of the previous clause header.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5537 *
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5538 * Return the size of the name of the predicate or rule, or 0 if no
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5539 * header was found.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5540 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5541 static int
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5542 prolog_pr (s, last)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5543 char *s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5544 char *last; /* Name of last clause. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5545 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5546 int pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5547 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5548
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5549 pos = prolog_atom (s, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5550 if (pos < 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5551 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5552
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5553 len = pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5554 pos = skip_spaces (s + pos) - s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5555
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5556 if ((s[pos] == '.'
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5557 || (s[pos] == '(' && (pos += 1))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5558 || (s[pos] == ':' && s[pos + 1] == '-' && (pos += 2)))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5559 && (last == NULL /* save only the first clause */
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
5560 || len != (int)strlen (last)
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5561 || !strneq (s, last, len)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5562 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5563 make_tag (s, len, TRUE, s, pos, lineno, linecharno);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5564 return len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5565 }
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5566 else
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5567 return 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5568 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5569
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5570 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5571 * Consume a Prolog atom.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5572 * Return the number of bytes consumed, or -1 if there was an error.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5573 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5574 * A prolog atom, in this context, could be one of:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5575 * - An alphanumeric sequence, starting with a lower case letter.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5576 * - A quoted arbitrary string. Single quotes can escape themselves.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5577 * Backslash quotes everything.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5578 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5579 static int
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5580 prolog_atom (s, pos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5581 char *s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5582 int pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5583 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5584 int origpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5585
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5586 origpos = pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5587
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5588 if (ISLOWER(s[pos]) || (s[pos] == '_'))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5589 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5590 /* The atom is unquoted. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5591 pos++;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5592 while (ISALNUM(s[pos]) || (s[pos] == '_'))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5593 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5594 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5595 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5596 return pos - origpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5597 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5598 else if (s[pos] == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5599 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5600 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5601
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5602 for (;;)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5603 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5604 if (s[pos] == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5605 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5606 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5607 if (s[pos] != '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5608 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5609 pos++; /* A double quote */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5610 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5611 else if (s[pos] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5612 /* Multiline quoted atoms are ignored. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5613 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5614 else if (s[pos] == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5615 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5616 if (s[pos+1] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5617 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5618 pos += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5619 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5620 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5621 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5622 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5623 return pos - origpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5624 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5625 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5626 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5627 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5628
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5629
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5630 /*
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5631 * Support for Erlang
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5632 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5633 * Generates tags for functions, defines, and records.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5634 * Assumes that Erlang functions start at column 0.
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5635 * Original code by Anders Lindgren (1996)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5636 */
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5637 static int erlang_func __P((char *, char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5638 static void erlang_attribute __P((char *));
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5639 static int erlang_atom __P((char *));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5640
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5641 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5642 Erlang_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5643 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5644 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5645 char *cp, *last;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5646 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5647 int allocated;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5648
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5649 allocated = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5650 len = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5651 last = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5652
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5653 LOOP_ON_INPUT_LINES (inf, lb, cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5654 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5655 if (cp[0] == '\0') /* Empty line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5656 continue;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5657 else if (iswhite (cp[0])) /* Not function nor attribute */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5658 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5659 else if (cp[0] == '%') /* comment */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5660 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5661 else if (cp[0] == '"') /* Sometimes, strings start in column one */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5662 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5663 else if (cp[0] == '-') /* attribute, e.g. "-define" */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5664 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5665 erlang_attribute (cp);
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
5666 if (last != NULL)
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
5667 {
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
5668 free (last);
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
5669 last = NULL;
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
5670 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5671 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5672 else if ((len = erlang_func (cp, last)) > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5673 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5674 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5675 * Function. Store the function name so that we only
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5676 * generates a tag for the first clause.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5677 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5678 if (last == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5679 last = xnew (len + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5680 else if (len + 1 > allocated)
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5681 xrnew (last, len + 1, char);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5682 allocated = len + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5683 strncpy (last, cp, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5684 last[len] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5685 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5686 }
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
5687 if (last != NULL)
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
5688 free (last);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5689 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5690
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5691
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5692 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5693 * A function definition is added if it matches:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5694 * <beginning of line><Erlang Atom><whitespace>(
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5695 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5696 * It is added to the tags database if it doesn't match the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5697 * name of the previous clause header.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5698 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5699 * Return the size of the name of the function, or 0 if no function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5700 * was found.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5701 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5702 static int
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5703 erlang_func (s, last)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5704 char *s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5705 char *last; /* Name of last clause. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5706 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5707 int pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5708 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5709
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5710 pos = erlang_atom (s);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5711 if (pos < 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5712 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5713
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5714 len = pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5715 pos = skip_spaces (s + pos) - s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5716
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5717 /* Save only the first clause. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5718 if (s[pos++] == '('
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5719 && (last == NULL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5720 || len != (int)strlen (last)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5721 || !strneq (s, last, len)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5722 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5723 make_tag (s, len, TRUE, s, pos, lineno, linecharno);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5724 return len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5725 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5726
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5727 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5728 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5729
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5730
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5731 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5732 * Handle attributes. Currently, tags are generated for defines
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5733 * and records.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5734 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5735 * They are on the form:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5736 * -define(foo, bar).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5737 * -define(Foo(M, N), M+N).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5738 * -record(graph, {vtab = notable, cyclic = true}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5739 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5740 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5741 erlang_attribute (s)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5742 char *s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5743 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5744 char *cp = s;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5745
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5746 if ((LOOKING_AT (cp, "-define") || LOOKING_AT (cp, "-record"))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5747 && *cp++ == '(')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5748 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5749 int len = erlang_atom (skip_spaces (cp));
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5750 if (len > 0)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5751 make_tag (cp, len, TRUE, s, cp + len - s, lineno, linecharno);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5752 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5753 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5754 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5755
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5756
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5757 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5758 * Consume an Erlang atom (or variable).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5759 * Return the number of bytes consumed, or -1 if there was an error.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5760 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5761 static int
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5762 erlang_atom (s)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5763 char *s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5764 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5765 int pos = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5766
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5767 if (ISALPHA (s[pos]) || s[pos] == '_')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5768 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5769 /* The atom is unquoted. */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5770 do
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5771 pos++;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5772 while (ISALNUM (s[pos]) || s[pos] == '_');
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5773 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5774 else if (s[pos] == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5775 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5776 for (pos++; s[pos] != '\''; pos++)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5777 if (s[pos] == '\0' /* multiline quoted atoms are ignored */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5778 || (s[pos] == '\\' && s[++pos] == '\0'))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5779 return 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5780 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5781 }
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5782
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5783 return pos;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5784 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5785
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5786
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5787 static char *scan_separators __P((char *));
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5788 static void add_regex __P((char *, language *));
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5789 static char *substitute __P((char *, char *, struct re_registers *));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5790
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5791 /*
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5792 * Take a string like "/blah/" and turn it into "blah", verifying
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5793 * that the first and last characters are the same, and handling
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5794 * quoted separator characters. Actually, stops on the occurrence of
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5795 * an unquoted separator. Also process \t, \n, etc. and turn into
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5796 * appropriate characters. Works in place. Null terminates name string.
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5797 * Returns pointer to terminating separator, or NULL for
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5798 * unterminated regexps.
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5799 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5800 static char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5801 scan_separators (name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5802 char *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5803 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5804 char sep = name[0];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5805 char *copyto = name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5806 bool quoted = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5807
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5808 for (++name; *name != '\0'; ++name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5809 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5810 if (quoted)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5811 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5812 switch (*name)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5813 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5814 case 'a': *copyto++ = '\007'; break; /* BEL (bell) */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5815 case 'b': *copyto++ = '\b'; break; /* BS (back space) */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5816 case 'd': *copyto++ = 0177; break; /* DEL (delete) */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5817 case 'e': *copyto++ = 033; break; /* ESC (delete) */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5818 case 'f': *copyto++ = '\f'; break; /* FF (form feed) */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5819 case 'n': *copyto++ = '\n'; break; /* NL (new line) */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5820 case 'r': *copyto++ = '\r'; break; /* CR (carriage return) */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5821 case 't': *copyto++ = '\t'; break; /* TAB (horizontal tab) */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5822 case 'v': *copyto++ = '\v'; break; /* VT (vertical tab) */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5823 default:
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5824 if (*name == sep)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5825 *copyto++ = sep;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5826 else
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5827 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5828 /* Something else is quoted, so preserve the quote. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5829 *copyto++ = '\\';
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5830 *copyto++ = *name;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5831 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5832 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5833 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5834 quoted = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5835 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5836 else if (*name == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5837 quoted = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5838 else if (*name == sep)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5839 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5840 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5841 *copyto++ = *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5842 }
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5843 if (*name != sep)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5844 name = NULL; /* signal unterminated regexp */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5845
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5846 /* Terminate copied string. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5847 *copyto = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5848 return name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5849 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5850
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5851 /* Look at the argument of --regex or --no-regex and do the right
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5852 thing. Same for each line of a regexp file. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5853 static void
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5854 analyse_regex (regex_arg)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5855 char *regex_arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5856 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5857 if (regex_arg == NULL)
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5858 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5859 free_regexps (); /* --no-regex: remove existing regexps */
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5860 return;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5861 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5862
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5863 /* A real --regexp option or a line in a regexp file. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5864 switch (regex_arg[0])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5865 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5866 /* Comments in regexp file or null arg to --regex. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5867 case '\0':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5868 case ' ':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5869 case '\t':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5870 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5871
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5872 /* Read a regex file. This is recursive and may result in a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5873 loop, which will stop when the file descriptors are exhausted. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5874 case '@':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5875 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5876 FILE *regexfp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5877 linebuffer regexbuf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5878 char *regexfile = regex_arg + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5879
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5880 /* regexfile is a file containing regexps, one per line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5881 regexfp = fopen (regexfile, "r");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5882 if (regexfp == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5883 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5884 pfatal (regexfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5885 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5886 }
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5887 linebuffer_init (&regexbuf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5888 while (readline_internal (&regexbuf, regexfp) > 0)
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5889 analyse_regex (regexbuf.buffer);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5890 free (regexbuf.buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5891 fclose (regexfp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5892 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5893 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5894
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5895 /* Regexp to be used for a specific language only. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5896 case '{':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5897 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5898 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5899 char *lang_name = regex_arg + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5900 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5901
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5902 for (cp = lang_name; *cp != '}'; cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5903 if (*cp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5904 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5905 error ("unterminated language name in regex: %s", regex_arg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5906 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5907 }
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5908 *cp++ = '\0';
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5909 lang = get_language_from_langname (lang_name);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5910 if (lang == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5911 return;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5912 add_regex (cp, lang);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5913 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5914 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5915
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5916 /* Regexp to be used for any language. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5917 default:
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5918 add_regex (regex_arg, NULL);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5919 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5920 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5921 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5922
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5923 /* Separate the regexp pattern, compile it,
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5924 and care for optional name and modifiers. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5925 static void
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5926 add_regex (regexp_pattern, lang)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5927 char *regexp_pattern;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5928 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5929 {
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
5930 static struct re_pattern_buffer zeropattern;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5931 char sep, *pat, *name, *modifiers;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5932 const char *err;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5933 struct re_pattern_buffer *patbuf;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5934 regexp *rp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5935 bool
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5936 force_explicit_name = TRUE, /* do not use implicit tag names */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5937 ignore_case = FALSE, /* case is significant */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5938 multi_line = FALSE, /* matches are done one line at a time */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5939 single_line = FALSE; /* dot does not match newline */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5940
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5941
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5942 if (strlen(regexp_pattern) < 3)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5943 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5944 error ("null regexp", (char *)NULL);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5945 return;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5946 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5947 sep = regexp_pattern[0];
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5948 name = scan_separators (regexp_pattern);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5949 if (name == NULL)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5950 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5951 error ("%s: unterminated regexp", regexp_pattern);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5952 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5953 }
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5954 if (name[1] == sep)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5955 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5956 error ("null name for regexp \"%s\"", regexp_pattern);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5957 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5958 }
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5959 modifiers = scan_separators (name);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5960 if (modifiers == NULL) /* no terminating separator --> no name */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5961 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5962 modifiers = name;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5963 name = "";
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5964 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5965 else
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5966 modifiers += 1; /* skip separator */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5967
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5968 /* Parse regex modifiers. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5969 for (; modifiers[0] != '\0'; modifiers++)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5970 switch (modifiers[0])
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5971 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5972 case 'N':
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5973 if (modifiers == name)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5974 error ("forcing explicit tag name but no name, ignoring", NULL);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5975 force_explicit_name = TRUE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5976 break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5977 case 'i':
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5978 ignore_case = TRUE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5979 break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5980 case 's':
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5981 single_line = TRUE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5982 /* FALLTHRU */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5983 case 'm':
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5984 multi_line = TRUE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5985 need_filebuf = TRUE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5986 break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5987 default:
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5988 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5989 char wrongmod [2];
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5990 wrongmod[0] = modifiers[0];
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5991 wrongmod[1] = '\0';
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5992 error ("invalid regexp modifier `%s', ignoring", wrongmod);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5993 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5994 break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
5995 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5996
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5997 patbuf = xnew (1, struct re_pattern_buffer);
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
5998 *patbuf = zeropattern;
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
5999 if (ignore_case)
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6000 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6001 static char lc_trans[CHARS];
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6002 int i;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6003 for (i = 0; i < CHARS; i++)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6004 lc_trans[i] = lowcase (i);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6005 patbuf->translate = lc_trans; /* translation table to fold case */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6006 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6007
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6008 if (multi_line)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6009 pat = concat ("^", regexp_pattern, ""); /* anchor to beginning of line */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6010 else
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6011 pat = regexp_pattern;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6012
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6013 if (single_line)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6014 re_set_syntax (RE_SYNTAX_EMACS | RE_DOT_NEWLINE);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6015 else
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6016 re_set_syntax (RE_SYNTAX_EMACS);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6017
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6018 err = re_compile_pattern (pat, strlen (regexp_pattern), patbuf);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6019 if (multi_line)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6020 free (pat);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6021 if (err != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6022 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6023 error ("%s while compiling pattern", err);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6024 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6025 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6026
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6027 rp = p_head;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6028 p_head = xnew (1, regexp);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6029 p_head->pattern = savestr (regexp_pattern);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6030 p_head->p_next = rp;
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
6031 p_head->lang = lang;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
6032 p_head->pat = patbuf;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6033 p_head->name = savestr (name);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6034 p_head->error_signaled = FALSE;
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6035 p_head->force_explicit_name = force_explicit_name;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6036 p_head->ignore_case = ignore_case;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6037 p_head->multi_line = multi_line;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6038 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6039
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6040 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6041 * Do the substitutions indicated by the regular expression and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6042 * arguments.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6043 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6044 static char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6045 substitute (in, out, regs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6046 char *in, *out;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6047 struct re_registers *regs;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6048 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6049 char *result, *t;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6050 int size, dig, diglen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6051
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6052 result = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6053 size = strlen (out);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6054
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6055 /* Pass 1: figure out how much to allocate by finding all \N strings. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6056 if (out[size - 1] == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6057 fatal ("pattern error in \"%s\"", out);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6058 for (t = etags_strchr (out, '\\');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6059 t != NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6060 t = etags_strchr (t + 2, '\\'))
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6061 if (ISDIGIT (t[1]))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6062 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6063 dig = t[1] - '0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6064 diglen = regs->end[dig] - regs->start[dig];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6065 size += diglen - 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6066 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6067 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6068 size -= 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6069
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6070 /* Allocate space and do the substitutions. */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6071 assert (size >= 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6072 result = xnew (size + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6073
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6074 for (t = result; *out != '\0'; out++)
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6075 if (*out == '\\' && ISDIGIT (*++out))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6076 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6077 dig = *out - '0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6078 diglen = regs->end[dig] - regs->start[dig];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6079 strncpy (t, in + regs->start[dig], diglen);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6080 t += diglen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6081 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6082 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6083 *t++ = *out;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6084 *t = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6085
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6086 assert (t <= result + size);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6087 assert (t - result == (int)strlen (result));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6088
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6089 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6090 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6091
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6092 /* Deallocate all regexps. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6093 static void
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6094 free_regexps ()
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6095 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6096 regexp *rp;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6097 while (p_head != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6098 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6099 rp = p_head->p_next;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6100 free (p_head->pattern);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6101 free (p_head->name);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6102 free (p_head);
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6103 p_head = rp;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6104 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6105 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6106 }
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6107
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6108 /*
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6109 * Reads the whole file as a single string from `filebuf' and looks for
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6110 * multi-line regular expressions, creating tags on matches.
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6111 * readline already dealt with normal regexps.
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6112 *
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6113 * Idea by Ben Wing <ben@666.com> (2002).
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6114 */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6115 static void
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6116 regex_tag_multiline ()
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6117 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6118 char *buffer = filebuf.buffer;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6119 regexp *rp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6120 char *name;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6121
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6122 for (rp = p_head; rp != NULL; rp = rp->p_next)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6123 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6124 int match = 0;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6125
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6126 if (!rp->multi_line)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6127 continue; /* skip normal regexps */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6128
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6129 /* Generic initialisations before parsing file from memory. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6130 lineno = 1; /* reset global line number */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6131 charno = 0; /* reset global char number */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6132 linecharno = 0; /* reset global char number of line start */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6133
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6134 /* Only use generic regexps or those for the current language. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6135 if (rp->lang != NULL && rp->lang != curfdp->lang)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6136 continue;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6137
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6138 while (match >= 0 && match < filebuf.len)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6139 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6140 match = re_search (rp->pat, buffer, filebuf.len, charno,
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6141 filebuf.len - match, &rp->regs);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6142 switch (match)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6143 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6144 case -2:
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6145 /* Some error. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6146 if (!rp->error_signaled)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6147 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6148 error ("regexp stack overflow while matching \"%s\"",
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6149 rp->pattern);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6150 rp->error_signaled = TRUE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6151 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6152 break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6153 case -1:
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6154 /* No match. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6155 break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6156 default:
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6157 if (match == rp->regs.end[0])
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6158 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6159 if (!rp->error_signaled)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6160 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6161 error ("regexp matches the empty string: \"%s\"",
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6162 rp->pattern);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6163 rp->error_signaled = TRUE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6164 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6165 match = -3; /* exit from while loop */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6166 break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6167 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6168
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6169 /* Match occurred. Construct a tag. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6170 while (charno < rp->regs.end[0])
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6171 if (buffer[charno++] == '\n')
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6172 lineno++, linecharno = charno;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6173 name = rp->name;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6174 if (name[0] == '\0')
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6175 name = NULL;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6176 else /* make a named tag */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6177 name = substitute (buffer, rp->name, &rp->regs);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6178 if (rp->force_explicit_name)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6179 /* Force explicit tag name, if a name is there. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6180 pfnote (name, TRUE, buffer + linecharno,
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6181 charno - linecharno + 1, lineno, linecharno);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6182 else
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6183 make_tag (name, strlen (name), TRUE, buffer + linecharno,
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6184 charno - linecharno + 1, lineno, linecharno);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6185 break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6186 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6187 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6188 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6189 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6190
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6191
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6192 static bool
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6193 nocase_tail (cp)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6194 char *cp;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6195 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6196 register int len = 0;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6197
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6198 while (*cp != '\0' && lowcase (*cp) == lowcase (dbp[len]))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6199 cp++, len++;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6200 if (*cp == '\0' && !intoken (dbp[len]))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6201 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6202 dbp += len;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6203 return TRUE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6204 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6205 return FALSE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6206 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6207
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6208 static void
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6209 get_tag (bp, namepp)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6210 register char *bp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6211 char **namepp;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6212 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6213 register char *cp = bp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6214
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6215 if (*bp != '\0')
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6216 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6217 /* Go till you get to white space or a syntactic break */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6218 for (cp = bp + 1; !notinname (*cp); cp++)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6219 continue;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6220 make_tag (bp, cp - bp, TRUE,
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6221 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6222 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6223
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6224 if (namepp != NULL)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6225 *namepp = savenstr (bp, cp - bp);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6226 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6227
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6228 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6229 * Read a line of text from `stream' into `lbp', excluding the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6230 * newline or CR-NL, if any. Return the number of characters read from
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6231 * `stream', which is the length of the line including the newline.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6232 *
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6233 * On DOS or Windows we do not count the CR character, if any before the
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6234 * NL, in the returned length; this mirrors the behavior of Emacs on those
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6235 * platforms (for text files, it translates CR-NL to NL as it reads in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6236 * file).
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6237 *
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6238 * If multi-line regular expressions are requested, each line read is
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6239 * appended to `filebuf'.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6240 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6241 static long
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6242 readline_internal (lbp, stream)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6243 linebuffer *lbp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6244 register FILE *stream;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6245 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6246 char *buffer = lbp->buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6247 register char *p = lbp->buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6248 register char *pend;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6249 int chars_deleted;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6250
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6251 pend = p + lbp->size; /* Separate to avoid 386/IX compiler bug. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6252
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6253 for (;;)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6254 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6255 register int c = getc (stream);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6256 if (p == pend)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6257 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6258 /* We're at the end of linebuffer: expand it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6259 lbp->size *= 2;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6260 xrnew (buffer, lbp->size, char);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6261 p += buffer - lbp->buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6262 pend = buffer + lbp->size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6263 lbp->buffer = buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6264 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6265 if (c == EOF)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6266 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6267 *p = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6268 chars_deleted = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6269 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6270 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6271 if (c == '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6272 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6273 if (p > buffer && p[-1] == '\r')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6274 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6275 p -= 1;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6276 #ifdef DOS_NT
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6277 /* Assume CRLF->LF translation will be performed by Emacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6278 when loading this file, so CRs won't appear in the buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6279 It would be cleaner to compensate within Emacs;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6280 however, Emacs does not know how many CRs were deleted
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6281 before any given point in the file. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6282 chars_deleted = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6283 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6284 chars_deleted = 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6285 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6286 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6287 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6288 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6289 chars_deleted = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6290 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6291 *p = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6292 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6293 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6294 *p++ = c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6295 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6296 lbp->len = p - buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6297
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6298 if (need_filebuf /* we need filebuf for multi-line regexps */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6299 && chars_deleted > 0) /* not at EOF */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6300 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6301 while (filebuf.size <= filebuf.len + lbp->len + 1) /* +1 for \n */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6302 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6303 /* Expand filebuf. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6304 filebuf.size *= 2;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6305 xrnew (filebuf.buffer, filebuf.size, char);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6306 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6307 strncpy (filebuf.buffer + filebuf.len, lbp->buffer, lbp->len);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6308 filebuf.len += lbp->len;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6309 filebuf.buffer[filebuf.len++] = '\n';
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6310 filebuf.buffer[filebuf.len] = '\0';
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6311 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6312
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6313 return lbp->len + chars_deleted;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6314 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6315
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6316 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6317 * Like readline_internal, above, but in addition try to match the
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6318 * input line against relevant regular expressions and manage #line
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6319 * directives.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6320 */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6321 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6322 readline (lbp, stream)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6323 linebuffer *lbp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6324 FILE *stream;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6325 {
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6326 long result;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6327
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6328 linecharno = charno; /* update global char number of line start */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6329 result = readline_internal (lbp, stream); /* read line */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6330 lineno += 1; /* increment global line number */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6331 charno += result; /* increment global char number */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6332
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6333 /* Honour #line directives. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6334 if (!no_line_directive)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6335 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6336 static bool discard_until_line_directive;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6337
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6338 /* Check whether this is a #line directive. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6339 if (result > 12 && strneq (lbp->buffer, "#line ", 6))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6340 {
3876
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
6341 unsigned int lno;
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
6342 int start = 0;
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
6343
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
6344 if (sscanf (lbp->buffer, "#line %u \"%n", &lno, &start) >= 1
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
6345 && start > 0) /* double quote character found */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6346 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6347 char *endp = lbp->buffer + start;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6348
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6349 while ((endp = etags_strchr (endp, '"')) != NULL
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6350 && endp[-1] == '\\')
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6351 endp++;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6352 if (endp != NULL)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6353 /* Ok, this is a real #line directive. Let's deal with it. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6354 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6355 char *taggedabsname; /* absolute name of original file */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6356 char *taggedfname; /* name of original file as given */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6357 char *name; /* temp var */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6358
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6359 discard_until_line_directive = FALSE; /* found it */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6360 name = lbp->buffer + start;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6361 *endp = '\0';
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6362 canonicalize_filename (name); /* for DOS */
3876
a827a51c3241 [xemacs-hg @ 2007-03-24 11:46:37 by stephent]
stephent
parents: 3524
diff changeset
6363 taggedabsname = absolute_filename (name, tagfiledir);
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6364 if (filename_is_absolute (name)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6365 || filename_is_absolute (curfdp->infname))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6366 taggedfname = savestr (taggedabsname);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6367 else
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6368 taggedfname = relative_filename (taggedabsname,tagfiledir);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6369
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6370 if (streq (curfdp->taggedfname, taggedfname))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6371 /* The #line directive is only a line number change. We
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6372 deal with this afterwards. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6373 free (taggedfname);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6374 else
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6375 /* The tags following this #line directive should be
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6376 attributed to taggedfname. In order to do this, set
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6377 curfdp accordingly. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6378 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6379 fdesc *fdp; /* file description pointer */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6380
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6381 /* Go look for a file description already set up for the
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6382 file indicated in the #line directive. If there is
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6383 one, use it from now until the next #line
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6384 directive. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6385 for (fdp = fdhead; fdp != NULL; fdp = fdp->next)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6386 if (streq (fdp->infname, curfdp->infname)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6387 && streq (fdp->taggedfname, taggedfname))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6388 /* If we remove the second test above (after the &&)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6389 then all entries pertaining to the same file are
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6390 coalesced in the tags file. If we use it, then
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6391 entries pertaining to the same file but generated
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6392 from different files (via #line directives) will
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6393 go into separate sections in the tags file. These
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6394 alternatives look equivalent. The first one
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6395 destroys some apparently useless information. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6396 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6397 curfdp = fdp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6398 free (taggedfname);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6399 break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6400 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6401 /* Else, if we already tagged the real file, skip all
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6402 input lines until the next #line directive. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6403 if (fdp == NULL) /* not found */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6404 for (fdp = fdhead; fdp != NULL; fdp = fdp->next)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6405 if (streq (fdp->infabsname, taggedabsname))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6406 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6407 discard_until_line_directive = TRUE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6408 free (taggedfname);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6409 break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6410 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6411 /* Else create a new file description and use that from
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6412 now on, until the next #line directive. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6413 if (fdp == NULL) /* not found */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6414 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6415 fdp = fdhead;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6416 fdhead = xnew (1, fdesc);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6417 *fdhead = *curfdp; /* copy curr. file description */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6418 fdhead->next = fdp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6419 fdhead->infname = savestr (curfdp->infname);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6420 fdhead->infabsname = savestr (curfdp->infabsname);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6421 fdhead->infabsdir = savestr (curfdp->infabsdir);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6422 fdhead->taggedfname = taggedfname;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6423 fdhead->usecharno = FALSE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6424 fdhead->prop = NULL;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6425 fdhead->written = FALSE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6426 curfdp = fdhead;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6427 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6428 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6429 free (taggedabsname);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6430 lineno = lno - 1;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6431 readline (lbp, stream);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6432 return;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6433 } /* if a real #line directive */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6434 } /* if #line is followed by a a number */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6435 } /* if line begins with "#line " */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6436
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6437 /* If we are here, no #line directive was found. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6438 if (discard_until_line_directive)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6439 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6440 if (result > 0)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6441 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6442 /* Do a tail recursion on ourselves, thus discarding the contents
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6443 of the line buffer. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6444 readline (lbp, stream);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6445 return;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6446 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6447 /* End of file. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6448 discard_until_line_directive = FALSE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6449 return;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6450 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6451 } /* if #line directives should be considered */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6452
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6453 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6454 int match;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6455 regexp *rp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6456 char *name;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6457
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6458 /* Match against relevant regexps. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6459 if (lbp->len > 0)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6460 for (rp = p_head; rp != NULL; rp = rp->p_next)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6461 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6462 /* Only use generic regexps or those for the current language.
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6463 Also do not use multiline regexps, which is the job of
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6464 regex_tag_multiline. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6465 if ((rp->lang != NULL && rp->lang != fdhead->lang)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6466 || rp->multi_line)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6467 continue;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6468
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6469 match = re_match (rp->pat, lbp->buffer, lbp->len, 0, &rp->regs);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6470 switch (match)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6471 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6472 case -2:
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6473 /* Some error. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6474 if (!rp->error_signaled)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6475 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6476 error ("regexp stack overflow while matching \"%s\"",
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6477 rp->pattern);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6478 rp->error_signaled = TRUE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6479 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6480 break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6481 case -1:
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6482 /* No match. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6483 break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6484 case 0:
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6485 /* Empty string matched. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6486 if (!rp->error_signaled)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6487 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6488 error ("regexp matches the empty string: \"%s\"", rp->pattern);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6489 rp->error_signaled = TRUE;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6490 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6491 break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6492 default:
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6493 /* Match occurred. Construct a tag. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6494 name = rp->name;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6495 if (name[0] == '\0')
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6496 name = NULL;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6497 else /* make a named tag */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6498 name = substitute (lbp->buffer, rp->name, &rp->regs);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6499 if (rp->force_explicit_name)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6500 /* Force explicit tag name, if a name is there. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6501 pfnote (name, TRUE, lbp->buffer, match, lineno, linecharno);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6502 else
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6503 make_tag (name, strlen (name), TRUE,
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6504 lbp->buffer, match, lineno, linecharno);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6505 break;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6506 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6507 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6508 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6509 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6510
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6511
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6512 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6513 * Return a pointer to a space of size strlen(cp)+1 allocated
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6514 * with xnew where the string CP has been copied.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6515 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6516 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6517 savestr (cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6518 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6519 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6520 return savenstr (cp, strlen (cp));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6521 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6522
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6523 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6524 * Return a pointer to a space of size LEN+1 allocated with xnew where
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6525 * the string CP has been copied for at most the first LEN characters.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6526 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6527 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6528 savenstr (cp, len)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6529 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6530 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6531 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6532 register char *dp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6533
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6534 dp = xnew (len + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6535 strncpy (dp, cp, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6536 dp[len] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6537 return dp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6538 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6539
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6540 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6541 * Return the ptr in sp at which the character c last
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6542 * appears; NULL if not found
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6543 *
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6544 * Identical to POSIX strrchr, included for portability.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6545 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6546 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6547 etags_strrchr (sp, c)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6548 register const char *sp;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6549 register int c;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6550 {
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 432
diff changeset
6551 register const char *r;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6552
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6553 r = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6554 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6555 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6556 if (*sp == c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6557 r = sp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6558 } while (*sp++);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6559 return (char *)r;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6560 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6561
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6562 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6563 * Return the ptr in sp at which the character c first
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6564 * appears; NULL if not found
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6565 *
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6566 * Identical to POSIX strchr, included for portability.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6567 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6568 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6569 etags_strchr (sp, c)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6570 register const char *sp;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6571 register int c;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6572 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6573 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6574 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6575 if (*sp == c)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6576 return (char *)sp;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6577 } while (*sp++);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6578 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6579 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6580
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6581 /*
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6582 * Compare two strings, ignoring case for alphabetic characters.
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6583 *
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6584 * Same as BSD's strcasecmp, included for portability.
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6585 */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6586 static int
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6587 etags_strcasecmp (s1, s2)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6588 register const char *s1;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6589 register const char *s2;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6590 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6591 while (*s1 != '\0'
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6592 && (ISALPHA (*s1) && ISALPHA (*s2)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6593 ? lowcase (*s1) == lowcase (*s2)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6594 : *s1 == *s2))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6595 s1++, s2++;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6596
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6597 return (ISALPHA (*s1) && ISALPHA (*s2)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6598 ? lowcase (*s1) - lowcase (*s2)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6599 : *s1 - *s2);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6600 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6601
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6602 /*
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6603 * Compare two strings, ignoring case for alphabetic characters.
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6604 * Stop after a given number of characters
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6605 *
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6606 * Same as BSD's strncasecmp, included for portability.
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6607 */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6608 static int
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6609 etags_strncasecmp (s1, s2, n)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6610 register const char *s1;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6611 register const char *s2;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6612 register int n;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6613 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6614 while (*s1 != '\0' && n-- > 0
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6615 && (ISALPHA (*s1) && ISALPHA (*s2)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6616 ? lowcase (*s1) == lowcase (*s2)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6617 : *s1 == *s2))
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6618 s1++, s2++;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6619
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6620 if (n < 0)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6621 return 0;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6622 else
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6623 return (ISALPHA (*s1) && ISALPHA (*s2)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6624 ? lowcase (*s1) - lowcase (*s2)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6625 : *s1 - *s2);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6626 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6627
2554
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
6628 /* Skip spaces (end of string is not space), return new pointer. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6629 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6630 skip_spaces (cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6631 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6632 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6633 while (iswhite (*cp))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6634 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6635 return cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6636 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6637
2554
94f848eb8e4b [xemacs-hg @ 2005-02-03 18:09:26 by james]
james
parents: 2325
diff changeset
6638 /* Skip non spaces, except end of string, return new pointer. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6639 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6640 skip_non_spaces (cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6641 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6642 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6643 while (*cp != '\0' && !iswhite (*cp))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6644 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6645 return cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6646 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6647
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6648 /* Print error message and exit. */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6649 void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6650 fatal (s1, s2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6651 char *s1, *s2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6652 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6653 error (s1, s2);
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6654 exit (EXIT_FAILURE);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6655 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6656
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6657 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6658 pfatal (s1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6659 char *s1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6660 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6661 perror (s1);
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6662 exit (EXIT_FAILURE);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6663 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6664
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6665 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6666 suggest_asking_for_help ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6667 {
2325
9d8bfee6e672 [xemacs-hg @ 2004-10-07 14:51:11 by james]
james
parents: 2225
diff changeset
6668 fprintf (stderr, "\tTry `%s %s' for a complete list of options.\n",
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
6669 progname, NO_LONG_OPTIONS ? "-h" : "--help");
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6670 exit (EXIT_FAILURE);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6671 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6672
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6673 /* Print error message. `s1' is printf control string, `s2' is arg for it. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6674 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6675 error (s1, s2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6676 const char *s1, *s2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6677 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6678 fprintf (stderr, "%s: ", progname);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6679 fprintf (stderr, s1, s2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6680 fprintf (stderr, "\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6681 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6682
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6683 /* Return a newly-allocated string whose contents
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6684 concatenate those of s1, s2, s3. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6685 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6686 concat (s1, s2, s3)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6687 char *s1, *s2, *s3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6688 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6689 int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6690 char *result = xnew (len1 + len2 + len3 + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6691
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6692 strcpy (result, s1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6693 strcpy (result + len1, s2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6694 strcpy (result + len1 + len2, s3);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6695 result[len1 + len2 + len3] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6696
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6697 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6698 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6699
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6700
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6701 /* Does the same work as the system V getcwd, but does not need to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6702 guess the buffer size in advance. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6703 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6704 etags_getcwd ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6705 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6706 #ifdef HAVE_GETCWD
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6707 int bufsize = 200;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6708 char *path = xnew (bufsize, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6709
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6710 while (getcwd (path, bufsize) == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6711 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6712 if (errno != ERANGE)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6713 pfatal ("getcwd");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6714 bufsize *= 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6715 free (path);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6716 path = xnew (bufsize, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6717 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6718
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6719 canonicalize_filename (path);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6720 return path;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6721
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6722 #else /* not HAVE_GETCWD */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6723 #if MSDOS
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6724
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6725 char *p, path[MAXPATHLEN + 1]; /* Fixed size is safe on MSDOS. */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6726
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6727 getwd (path);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6728
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6729 for (p = path; *p != '\0'; p++)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6730 if (*p == '\\')
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6731 *p = '/';
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6732 else
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6733 *p = lowcase (*p);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6734
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6735 return strdup (path);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6736 #else /* not MSDOS */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6737 linebuffer path;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6738 FILE *pipe;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6739
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6740 linebuffer_init (&path);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6741 pipe = (FILE *) popen ("pwd 2>/dev/null", "r");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6742 if (pipe == NULL || readline_internal (&path, pipe) == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6743 pfatal ("pwd");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6744 pclose (pipe);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6745
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6746 return path.buffer;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6747 #endif /* not MSDOS */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6748 #endif /* not HAVE_GETCWD */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6749 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6750
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6751 /* Return a newly allocated string containing the file name of FILE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6752 relative to the absolute directory DIR (which should end with a slash). */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6753 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6754 relative_filename (file, dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6755 char *file, *dir;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6756 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6757 char *fp, *dp, *afn, *res;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6758 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6759
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6760 /* Find the common root of file and dir (with a trailing slash). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6761 afn = absolute_filename (file, cwd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6762 fp = afn;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6763 dp = dir;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6764 while (*fp++ == *dp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6765 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6766 fp--, dp--; /* back to the first differing char */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6767 #ifdef DOS_NT
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6768 if (fp == afn && afn[0] != '/') /* cannot build a relative name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6769 return afn;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6770 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6771 do /* look at the equal chars until '/' */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6772 fp--, dp--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6773 while (*fp != '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6774
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6775 /* Build a sequence of "../" strings for the resulting relative file name. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6776 i = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6777 while ((dp = etags_strchr (dp + 1, '/')) != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6778 i += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6779 res = xnew (3*i + strlen (fp + 1) + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6780 res[0] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6781 while (i-- > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6782 strcat (res, "../");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6783
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6784 /* Add the file name relative to the common root of file and dir. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6785 strcat (res, fp + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6786 free (afn);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6787
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6788 return res;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6789 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6790
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6791 /* Return a newly allocated string containing the absolute file name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6792 of FILE given DIR (which should end with a slash). */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6793 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6794 absolute_filename (file, dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6795 char *file, *dir;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6796 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6797 char *slashp, *cp, *res;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6798
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6799 if (filename_is_absolute (file))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6800 res = savestr (file);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6801 #ifdef DOS_NT
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6802 /* We don't support non-absolute file names with a drive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6803 letter, like `d:NAME' (it's too much hassle). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6804 else if (file[1] == ':')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6805 fatal ("%s: relative file names with drive letters not supported", file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6806 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6807 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6808 res = concat (dir, file, "");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6809
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6810 /* Delete the "/dirname/.." and "/." substrings. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6811 slashp = etags_strchr (res, '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6812 while (slashp != NULL && slashp[0] != '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6813 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6814 if (slashp[1] == '.')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6815 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6816 if (slashp[2] == '.'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6817 && (slashp[3] == '/' || slashp[3] == '\0'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6818 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6819 cp = slashp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6820 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6821 cp--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6822 while (cp >= res && !filename_is_absolute (cp));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6823 if (cp < res)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6824 cp = slashp; /* the absolute name begins with "/.." */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6825 #ifdef DOS_NT
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6826 /* Under MSDOS and NT we get `d:/NAME' as absolute
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6827 file name, so the luser could say `d:/../NAME'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6828 We silently treat this as `d:/NAME'. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6829 else if (cp[0] != '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6830 cp = slashp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6831 #endif
4768
0f5bee973a7b Etags: use memmove instead of strcpy to move characters within a string. See
Jerry James <james@xemacs.org>
parents: 3993
diff changeset
6832 memmove (cp, slashp + 3, strlen (slashp + 3) + 1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6833 slashp = cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6834 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6835 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6836 else if (slashp[2] == '/' || slashp[2] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6837 {
4768
0f5bee973a7b Etags: use memmove instead of strcpy to move characters within a string. See
Jerry James <james@xemacs.org>
parents: 3993
diff changeset
6838 memmove (slashp, slashp + 2, strlen (slashp + 2) + 1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6839 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6840 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6841 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6842
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6843 slashp = etags_strchr (slashp + 1, '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6844 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6845
3517
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
6846 if (res[0] == '\0') /* just a safety net: should never happen */
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
6847 {
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
6848 free (res);
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
6849 return savestr ("/");
10ee8fade35d [xemacs-hg @ 2006-07-19 15:22:34 by stephent]
stephent
parents: 3090
diff changeset
6850 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6851 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6852 return res;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6853 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6854
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6855 /* Return a newly allocated string containing the absolute
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6856 file name of dir where FILE resides given DIR (which should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6857 end with a slash). */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6858 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6859 absolute_dirname (file, dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6860 char *file, *dir;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6861 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6862 char *slashp, *res;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6863 char save;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6864
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6865 canonicalize_filename (file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6866 slashp = etags_strrchr (file, '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6867 if (slashp == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6868 return savestr (dir);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6869 save = slashp[1];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6870 slashp[1] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6871 res = absolute_filename (file, dir);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6872 slashp[1] = save;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6873
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6874 return res;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6875 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6876
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6877 /* Whether the argument string is an absolute file name. The argument
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6878 string must have been canonicalized with canonicalize_filename. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6879 static bool
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6880 filename_is_absolute (fn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6881 char *fn;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6882 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6883 return (fn[0] == '/'
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6884 #ifdef DOS_NT
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6885 || (ISALPHA(fn[0]) && fn[1] == ':' && fn[2] == '/')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6886 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6887 );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6888 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6889
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6890 /* Translate backslashes into slashes. Works in place. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6891 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6892 canonicalize_filename (fn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6893 register char *fn;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6894 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6895 #ifdef DOS_NT
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6896 /* Canonicalize drive letter case. */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6897 if (fn[0] != '\0' && fn[1] == ':' && ISLOWER (fn[0]))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6898 fn[0] = upcase (fn[0]);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6899 /* Convert backslashes to slashes. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6900 for (; *fn != '\0'; fn++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6901 if (*fn == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6902 *fn = '/';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6903 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6904 /* No action. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6905 fn = NULL; /* shut up the compiler */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6906 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6907 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6908
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6909
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6910 /* Initialize a linebuffer for use */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6911 static void
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6912 linebuffer_init (lbp)
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6913 linebuffer *lbp;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6914 {
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6915 lbp->size = (DEBUG) ? 3 : 200;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6916 lbp->buffer = xnew (lbp->size, char);
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6917 lbp->buffer[0] = '\0';
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6918 lbp->len = 0;
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6919 }
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6920
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6921 /* Set the minimum size of a string contained in a linebuffer. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
6922 static void
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6923 linebuffer_setlen (lbp, toksize)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6924 linebuffer *lbp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6925 int toksize;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6926 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6927 while (lbp->size <= toksize)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6928 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6929 lbp->size *= 2;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6930 xrnew (lbp->buffer, lbp->size, char);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6931 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
6932 lbp->len = toksize;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6933 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6934
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6935 /* Like malloc but get fatal error if memory is exhausted. */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6936 static PTR
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6937 xmalloc (size)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6938 unsigned int size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6939 {
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
6940 PTR result = (PTR) malloc (size);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6941 if (result == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6942 fatal ("virtual memory exhausted", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6943 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6944 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6945
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6946 static PTR
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6947 xrealloc (ptr, size)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6948 char *ptr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6949 unsigned int size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6950 {
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
6951 PTR result = (PTR) realloc (ptr, size);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6952 if (result == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6953 fatal ("virtual memory exhausted", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6954 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6955 }
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
6956
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
6957 /*
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
6958 * Local Variables:
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
6959 * indent-tabs-mode: t
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
6960 * tab-width: 8
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6961 * fill-column: 79
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6962 * c-font-lock-extra-types: ("FILE" "bool" "language" "linebuffer" "fdesc" "node" "regexp")
3972
6cd3955b7e4d [xemacs-hg @ 2007-05-21 03:50:13 by stephent]
stephent
parents: 3877
diff changeset
6963 * c-file-style: "gnu"
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
6964 * End:
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
6965 */
2225
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6966
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6967 /* arch-tag: 8a9b748d-390c-4922-99db-2eeefa921051
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6968 (do not change this comment) */
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6969
4968c73cb252 [xemacs-hg @ 2004-08-20 04:40:08 by james]
james
parents: 920
diff changeset
6970 /* etags.c ends here */