From: tomo Date: Tue, 3 Jun 2008 09:15:11 +0000 (+0000) Subject: XEmacs 21.4.21. X-Git-Tag: r21-4-21~1 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=89559a53b9683058a6cea41ce3f8f6c9bd067238;p=chise%2Fxemacs-chise.git XEmacs 21.4.21. --- diff --git a/ChangeLog b/ChangeLog index cf1f2ea..5c790dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2007-10-07 Vin Shelton + + * XEmacs 21.4.21 is released + +2007-08-18 Vin Shelton + + * modules/ldap/eldap.c: Declare that we use deprecated API. + Thanks to Mats Lidell for the report & patch: + <871wgnqunm.fsf@spencer.lidell.homelinux.net>. + 2006-12-09 Vin Shelton * XEmacs 21.4.20 is released diff --git a/etc/ETAGS.ChangeLog b/etc/ETAGS.ChangeLog new file mode 100644 index 0000000..8db17a1 --- /dev/null +++ b/etc/ETAGS.ChangeLog @@ -0,0 +1,849 @@ +2007-05-18 Francesco Potortì + + * etags.c: Extern definitions of some more pointer functions for + standalone compilation, especially important for 64bit platforms. + (main, print_help): --members is now the default for etags. + (C_entries): Parse start of C comment as a space == end of token. + This is not necessary for C++ comment, already parsed as newline. + +2007-02-05 Francesco Potortì + + * etags.c (default_C_help, Cplusplus_help, PHP_help, print_help) + (main): Now --members is the default for etags, not for ctags yet. + +2007-01-02 Francesco Potortì + + * etags.c (longopts): New undocumented option --no-duplicates. + (no_duplicates): Static variables for the above option. + (print_help): Do not print help for --no-warn, now undocumented. + (add_node): Allow duplicate tags in ctags mode unless --no-duplicates. + (main): Pass the -u option to sort in ctags mode. + +2006-12-28 Francesco Potortì + + * etags.c (readline): When creating a relative file name from a + #line directive, leave the file name alone. The previous + behaviour was to make it relative to the tags file directory, + under the hypothesis that the #line directive file name was + relative to the directory of the tagged file. That hypothesis is + wrong with Cpp and Lex. + +2006-12-20 Francesco Potortì + + * etags.c (C_entries): DEFUN names were longer by one: corrected. + (Makefile_targets): Do not include spaces in tag names. + +2006-08-12 Kevin Ryde + + * etags.c (readline): Check for double quote after #line. + +2006-08-12 Jan Djärv + + * etags.c (readline): sscanf could in principle return 2. + +2006-08-12 Francesco Potortì + + * etags.c (readline): lno is unsigned. + (TeX_commands): Use p++ (rather than *p++) to increment p. + (Lua_functions): Explicitely discard LOOKING_AT's return value. + +2006-08-07 Masatake YAMATO + + * etags.c (TEX_mode): Check getc retruns EOF. + File ended without newline causes infinite loop. + +2002-07-14 Adrian Aichner (tiny change) + + * etags.c: It's XEmacs, not Xemacs: change all the occurences. + +2006-07-10 Francesco Potortì + + * etags.c [ETAGS_REGEXPS]: #ifdef's deleted, define unconditionally. + [LONG_OPTIONS]: Changed to NO_LONG_OPTIONS, now normally undefined. + (Objc_suffixes): Suggest using --lang=c for full help. + (C_entries): Initialise savetoken to 0 to shut up the compiler. + +2006-07-10 Francesco Potortì + + * etags.c (absolute_filename): Free unused space (cosmetic change). + (in_word_set): In C, also tag #undef symbols. + +2006-05-02 Francesco Potortì + + * etags.c (Perl_functions): Free space allocated for var package. + (Erlang_functions): Possibly free space allocated for var last. + (Prolog_functions): Possibly free space allocated for var last. + +2005-11-18 Hideki IWAMOTO (tiny change) + + * etags.c (main): Cxref mode writes to stdout: do not close tagf, + which was never opened. + +2005-09-27 Francesco Potortì + + * etags.c: Preliminary Forth support. + (prolog_pr): Cast strlen to int before comparison. + (LOOKING_AT, LOOKING_AT_NOCASE): Let the preprocessor check that + the second argument is indeed a literal string. + (main): In append mode, sort the tags file after writing it. + +2005-09-27 Emanuele Giaquinta (tiny change) + + * etags.c (longopts, print_help, main): The -a (--append) option + can be used in ctags also; for one, the Linux make file uses it. + +2004-09-13 Francesco Potortì + + * etags.c (main): When relative file names are given as argument, + make them relative to the current working dir, rather than + relative to the output tags file, if the latter is in /dev. + +2004-09-13 David A. Capello (tiny change) + + * etags.c: (Lua_suffixes, Lua_help, lang_names, Lua_functions): + Support the Lua scripting language . + +2004-09-13 Francesco Potortì + + * etags.c [EXIT_SUCCESS, EXIT_FAILURE]: Define them when no + is available. + (enum sym_type): New st_C_attribute value for parsing + gcc's __attribute__. Deleted st_C_typespec value. + (gperf, in_word_set): Use gperf 3, options changed. Added the + __attribute__ keyword, removed all the st_C_typespec keywords, + changed attribute for Java to (C_JAVA & !C_PLPL). + (inattribute): New global bool, part of the C state machine. + (cblev): Identifier renamed to bracelev throughout. + (consider_token, C_entries): Numerous changes for making the + parser more robust and adding support for __attribute__. + +2004-09-08 Francesco Potortì + + * etags.c: Add arch taglines + [LONG_OPTIONS]: make it TRUE (ifdef) or FALSE for ease of use. + [GOOD, BAD]: renamed to EXIT_SUCCESS, EXIT_FAILURE. + (suggest_asking_for_help): Fix having macros in a printf statement. + (consider_token): check C++ `operator' only when the token len is + long enough. + +2003-01-09 Francesco Potortì + + * etags.c: changes for language-sepcific help by Philippe + Waroquiers applied and largely revised. + (language): Added a `help' member. + (arg_type): Added an at_end constant. + (plain_C_suffixes): Some items removed from here. + (Objc_suffixes): And put here (new constant). + (Ada_help, Asm_help, default_C_help, Cplusplus_help, Cjava_help, + Cobol_help, Erlang_help, Fortran_help, HTML_help, Lisp_help, + Makefile_help, Objc_help, Pascal_help, Perl_help, PHP_help, + PS_help, Prolog_help, Python_help, Scheme_help, TeX_help, + Texinfo_help, Yacc_help, auto_help, none-help, no_lang_help): New + constants. + (PS_functions, PS_suffixes): Renamed from Postscript_functions and + Postscript_suffixes. + (lang_names): Adapted to the new language structure, new language + "objc" added (was previously merged with "proc"). + (print_language_names): Some help strings corrected. + (print_help): Now takes an argument and possibly prints lang help. + (print_help): Some help strings corrected. Documents + language-specific help. + (main): Only print help after having parsed all the arguments. + +2002-09-03 Francesco Potorti` + + * etags.c (regex_tag_multiline, readline): Never pass pfnote a + string that cannot be freed. + +2002-08-30 Francesco Potorti` + + * etags.c (consider_token, C_entries): Switch to C++ parsing when + auto-detection is enabled and the `::' qualifier is met. + (consider_token, C_entries): Several bugs corrected that tagged + some declarations even though --declarations was not used. + (plainc): New macro. + (C_entries): Use it. + (C_entries): Several cosmetic changes. + (C_entries): Invalidate the token is some cases. + +2002-08-29 Francesco Potorti` + + * etags.c (C_entries): Corrected a problem with const C++ funcs. + (ignoreindent): Renamed from noindentypedefs. + (cjava, cplpl): They are now macros instead of local vars. + +2002-08-28 Francesco Potorti` + + * etags.c (HTML_labels): Tag ID= also. + +2002-08-27 Francesco Potorti` + + * etags.c (Ada_funcs): Do not tag "use type Xxxx;". + +2002-06-25 Francesco Potorti` + + * etags.c: New language HTML. + (make_tag): Never generate null length tag names. + (linebuffer_init): Renamed from initbuffer. All callers changed. + (pattern): Structure renamed to `regexp', member regex renamed to + pattern. + (node_st): Member pat renamed to regex. + (pattern); New member force_explicit_name, for future use. Now + always set to true, cannot be reset. + (add_regex, regex_tag_multiline, readline): Use it. + (main): Free some global structures. + +2002-06-21 Francesco Potorti` + + * etags.c (fdesc): New member `written'. + (readline, process_file): Initialise it. + (put_entries): Set it. + (main): Use it to create entries for files without tags. + (total_size_of_entries): Do not count invalid tags. + (etags_strcasecmp): Like BSD's, for compatibility. + (strcaseeq): Make it into a macro. + +2002-06-21 Francesco Potorti` + + * etags.c: (F_getit, Fortran_functions, Ada_getit, Asm_labels) + (Python_functions, PHP_functions, PHP_functions, PHP_functions) + (PHP_functions, PHP_functions, Cobol_paragraphs) + (Makefile_targets, Postscript_functions, Texinfo_nodes) + (prolog_pr, erlang_func, erlang_attribute) + (Perl_functions, Perl_functions, Pascal_functions) + (TeX_commands, get_tag): Use make_tag instead of pfnote. + (get_tag): Prototype changed, all callers changed. + +2002-06-20 Francesco Potorti` + + * etags.c: Use, together with etags.el, an optimised form of tags, + which are almost always unnamed. etags.el looks for an explicit + tag name, then for an implicit one. See make_tag for details. + The change is both forwards and backwards compatible. + (make_tag): New function (was the disabled function new_pfnote). + (make_C_tag): Use it. + +2002-06-19 Francesco Potorti` + + * etags.c (add_regex): Invalid regexp modifiers are ignored. + (Makefile_targets): Tag variables unless --no-globals. + (LOOP_ON_INPUT_LINES): Serious bug corrected. + +2002-06-13 Francesco Potorti` + + * etags.c (erlang_atom, erlang_attribute): Bugs corrected. + (invalidate_nodes): Bug corrected. + (print_help): Better help for regexps. + +2002-06-12 Francesco Potorti` + + * etags.c (arg_type): at_icregexp label removed (obsolete). + (pattern): New member multi_line for multi-line regexps. + (filebuf): A global buffer containing the whole file as a string + for multi-line regexp matching. + (need_filebuf): Global flag raised if multi-line regexps used. + (print_help): Document new regexp modifiers, remove references to + obsolete option --ignore-case-regexp. + (main): Do not set regexp syntax and translation table here. + (main): Treat -c option as a backward compatibility hack. + (main, find_entries): Init and free filebuf. + (find_entries): Call regex_tag_multiline after the regular parser. + (scan_separators): Check for untermintaed regexp and return NULL. + (analyse_regex, add_regex): Remove the ignore_case argument, which + is now a modifier to the regexp. All callers changed. + (add_regex): Manage the regexp modifiers. + (regex_tag_multiline): New function. Reads from filebuf. + (readline_internal): If necessary, copy the whole file into filebuf. + (readline): Skip multi-line regexps, leave them to regex_tag_multiline. + +2002-06-11 Francesco Potorti` + + * etags.c (add_regex): Better check for null regexps. + (readline): Check for regex matching null string. + +2002-06-07 Francesco Potorti` + + * etags.c (find_entries): Reorganisation. + +2002-06-07 Francesco Potorti` + + * etags.c (scan_separators): Support all character escape + sequences supported by gcc. + (find_entries): rewind unconditionally. + (find_entries): Do not call language functions directly, now calls + itself. + (find_entries): Do general initialisations here. + (CNL_SAVE_DEFINEDEF, C_entries, LOOP_ON_INPUT_LINES, F_getit) + (Ada_getit, Pascal_functions, Pascal_functions) + (prolog_skip_comment): Do not do them here. + (readline_internal): Increment lineno here. + (readline): Conditionally undo readline_internal increment. + (readline): Do not return a value. + +2002-06-06 Francesco Potorti` + + * etags.c (enum arg_type): New label at_stdin. + (STDIN): New constant. + (parsing_stdin): New flag. + (longopts): New option --parse-stdin=NAME. + (print_help): Document it. + (main): Handle it. + (process_file): Split into process_file and process_file_name. + (process_file_name): New function. + +2002-06-06 Francesco Potorti` + + * etags.c (main): Avoid a buffer overrun with sprintf. + (TEX_cmt): Make it a static char and move it before TeX_commands. + (TeX_commands): Skip comments. + (TEX_defenv): Now contains more contructs. + (TeX_commands): Shorten the tag to the brace after the name. + (TeX_commands): Allow for names with embedded spaces. + (TeX_commands): Names now include the initial backslash. + (TeX_commands): Names do not include numeric args #n. + (TeX_commands): Correct line char number in tags. + (TEX_tabent, TEX_token): Deleted. + (TeX_commands, TEX_decode_env): Streamlined. + +2002-05-31 Paul Eggert + + * etags.c (main): Use `sort -o TAGFILE TAGFILE' instead of + `sort TAGFILE -o TAGFILE', as POSIX 1003.1-2001 disallows + the latter usage. + +2002-04-22 Francesco Potorti` + + * etags.c: (last_node): Make it a global variable. + (process_file): Print the tags from the nodes as soon as + possible, and delete the nodes. This brings down the memory + occupancy as etags to almost the same level as when the #line + directives were not parsed. + (free_fdesc): New function. + (find_entries): Use it. + (invalidate_nodes): In etags mode, do not just mark the nodes as + invalid, do delete them. + +2002-04-16 Francesco Potorti` + + * etags.c (find_entries): Bug fix in list management. + +2002-04-15 Francesco Potorti` + + * etags.c (get_language_from_filename): Add one argument. + (strcaseeq): New function. + (get_language_from_filename): Use it to do a case insenstitive + comparison if called with appropriate args. + (find_entries): Try with case insensitive match. + (process_file): Bug fixed. + +2002-04-13 Francesco Potorti` + + * etags.c (find_entries): Delete tags previously obtained from + file xxx.c's #line directives when parsing file xxx.y. This is + generally done for automatically generated files containing + #line directives. This handles the case when xxx.y is tagged + before xxx.c, and the entries of xxx.c pointing to xxx.y should + be discarded. + (language): Added the metasource member. Initializers changed. + (invalidate_nodes): New function. + +2002-03-21 Francesco Potorti` + + * etags.c (readline): Discard lines after having found a #line + directive pointing to an already tagged file. This handles the + case when xxx.y is tagged before xxx.c, and the entries of + xxx.c pointing to xxx.y should be discarded. + +2002-03-15 Francesco Potorti` + + * etags.c (fdesc): New structure for keeping track of input files. + (fdesc): Remove `file' member (a string) and use instead a pointer + to a file description structure. + (curfile, curfiledir, curtagfname, curlang, nocharno, + forced_lang): Global variables removed in favor of fdhead and + curfdp, pointers to file description strucures. + (longopts, main, print_help): Use the CTAGS conditional to include + or exclude options that work on etags or ctags only. + (process_file, find_entries, pfnote, add_node, put_entries, + readline): Use fdhead and curfdp. + (process_file, find_entries): Do not take an arg string, all + callers changed. + +2002-03-13 Francesco Potorti` + + * etags.c (longopts, print_help, main): Test CTAGS to disallow + options that are not right for either etags or ctags. + +2002-03-12 Francesco Potorti` + + * etags.c (number_len, total_size_of_entries): Define them also + in CTAGS mode, because gcc does not compile all refs away. + (Python_functions, PHP_functions): Name tags, for ctags' sake. + (TeX_commands): Name tags. Correction of old disabled code. + +2002-03-06 Francesco Potorti` + + * etags.c (Python_functions): Consider indented "def" and "class". + +2002-03-05 Francesco Potorti` + + * etags.c (curfiledir, curtagfname): New global variables. + (process_file): Initialise them. + (readline): Canonicalize the name found in #line directive. + +2002-03-05 Francesco Potorti` + + * etags.c: Honour #line directives. + (no_line_directive): New global var; set it for old behaviour. + (main): Remove some #ifdef in the getopt switch. + (add_node, put_entries): Code added to merge different chunks of + nodes referring to the same file. Currently the tags are just + appended, without any check for duplicates. + (Perl_functions): Do not special case ctags. + (readline): Identify #line directives and do the right thing. + (nocharno, invalidcharno): New global vars. + (process_file): Reset nocharno. + (readline): Set nocharno. + (pfnote): Read nocharno and maybe put invalidcharno in node. + (total_size_of_entries, put_entries): Use invalidcharno. + +2002-03-04 Francesco Potorti` + + * etags.c: Keep the whole tag table in memory, even in etags mode. + (main): Call put_entries here even in CTAGS mode. + (main, process_file): Check the return values of fclose and pclose. + (process_file): Do not call put_entries after parsing each file. + (process_file): Canonicalise file names even for ctags. + (process_file): Set curfile here... + (find_entries): ... not here any more. + (add_node): In etags mode, build a linked list of entries (on + right pointer) for each file, and link the first entry of each + file on left nodes. + (put_entries): Print here the name of the file. + (put_entries): Print the entries starting from the first file. + (number_len, total_size_of_entries): Define these only iin etags + mode, make the second work only on the right nodes. + +2002-01-03 Francesco Potorti` + + * etags.c: Make all global variables static. + +2001-12-21 Francesco Potorti` + + * etags.c (Perl_functions): Tag packages and use them in sub tags. + (get_tag): Return a pointer to the tag that is found. + +2001-12-21 Francesco Potorti` + + * etags.c (LOOKING_AT): Use !intoken instead of iswhite. + (F_takeprec): Renamed from takeprec. All callers changed. + (F_getit): Renamed from getit. All callers changed. + (nocase_tail): Renamed from tail. All callers changed. + (Ada_getit): Renamed from adagetit. All callers changed. + (L_getit): Simplified by using get_tag. + (Perl_functions, Postscript_functions, erlang_attribute): Use the + modified LOOKING_AT. + (notinname): Removed '[' and added ')' to the recognised chars. + (LOOKING_AT, get_tag, PHP_functions): Use notinname. + (Ada_getit, Ada_funcs, Python_functions, Scheme_functions): + Clarified, using strneq or notinname. + (L_isdef, L_isquote): Removed. + (Lisp_functions, L_getit): Clarified. + +2001-12-17 Francesco Potorti` + + * etags.c: [P_]: Renamed to __P for consistency with config.h. + [HAVE_CONFIG_H]: Let config.h deal with __P. + [__STDC__] [!HAVE_CONFIG_H]: Define PTR as in config.h. + [!__STDC__] [!HAVE_CONFIG_H]: Do not undefine static, because + gperf code needs it. + [HAVE_CONFIG_H] [!PTR]: Define PTR (for use with Xemacs). + [HAVE_CONFIG_H] [!__P]: Define __P (for use with Xemacs). + (xmalloc, xrealloc): Use PTR instead of long *. + (bool): Make it a define, not a typedef, for C++ compilers. + (pattern): Members renamed to avoid name clash in some C++ compilers. + (get_language_from_langname): Use const argument. + +2001-12-12 Francesco Potorti` + + * etags.c (PHP_functions): New function by Diez B. Roggisch, + heavily adapted by me, for parsing PHP. + (LOOKING_AT): New macro. + (Perl_functions, Python_functions, PHP_functions) + (Scheme_functions, Texinfo_nodes): Use it. + (Perl_functions): Use strneq. + (prolog_pred): Renamed to prolog_pr. + (prolog_pr): Recognise Prolog rules (thanks to Geert Kloosterman) + in addition to predicates. + [ETAGS_REGEXPS] [!HAVE_CONFIG_H] [__CYGWIN__]: Prevent + unmodified compile, as Cygwin's regex.h is incompatible with us + (thanks to Markus Hoenicka). + [!HAVE_CONFIG_H] [!__STDC__]: #define const as the empty string. + +2001-05-11 Francesco Potorti` + + * etags.c (add_regex): Reset the whole newly allocated pattern + buffer instead of the individual members. It's safer and works + with Xemacs. + +2001-02-23 Francesco Potorti` + + * etags.c (enum sym_type): New label st_C_template. + (gperf input): Use it for switching to C++ from C. + (consider_token): Do it. + +2001-02-16 Francesco Potorti` + + * etags.c (C_entries): Initialise typdefcblev to quiet compilers. + +2001-02-06 Francesco Potorti` + + * etags.c [!HAVE_CONFIG_H] [!__STDC__]: #define static as nothing. + +2001-01-31 Francesco Potorti` + + * etags.c: [NDEBUG] #undef assert and #define it as ((void)0), for + the sake of some buggy assert.h (e.g. in MinGW and sunos4 pcc). + (C_entries): Tag token renamed to still_in_token because sunos4 + pcc wants to expand it as the token() macro even though it has no + arguments. + +2001-01-30 Francesco Potorti` + + * etags.c: [WIN32-NATIVE]: #undef MSDOS, #undef WINDOWSNT and + #define it for the sake of Xemacs. + [WINDOWSNT]: #undef HAVE_NTGUI even if built without + HAVE_CONFIG_H. This change only affects a standalone etags. + [WINDOWSNT]: #undef DOS_NT and #define it even if built with + HAVE_CONFIG_H. This change does nothing in Emacs, as DOS_NT is + always defined when HAVE_CONFIG_H and WINDOWS are both defined. + [!HAVE_UNISTD_H]: use defined(WINDOWSNT) instead of the bare + WINDOWSNT, as this is the correct way to use it. + +2001-01-28 Francesco Potorti` + + * etags.c: Be capable to parse nested struct-like structures. + (structdef, structtag): Struct state machine revisited. + (struct tok): Revisited. + (cstack, nestlev, instruct): New struct and macros. + (pushclass_above, popclass_above, write_classname): New functions + for dealing with nested class names, inspired by Mykola Dzyuba. + (consider_token, make_C_tag, C_entries): Many changes for dealing + with arbitrarily nested structures. + (etags_getcwd): #if MSDOS, not #ifdef MSDOS! + (C_entries): Consider templates in C++. + (sym_type): New constant st_C_class for detecting "class" also in + C mode. + (C_AUTO): New macro for automatic detection of C++. + (consider_token): Automatic set C++ mode. + (C_entries): New security check for yacc. + (print_language_names, print_help): Mention the autodetect + feature, do not show help for the -C option, now mostly useless. + (C_entries): Tag C++ forward declarations if --declarations. + (C_entries): Don't be fooled by things like XDEFUN. + (consider_token): Discard asm pseudo function. + +2001-01-25 Francesco Potorti` + + * etags.c (struct tok): Renamed from struct token. + (token): Renamed from tok. + (structtype): Make it a local variable. + [DEBUG]: Use assert. + (xrnew): Change the synopsis. + (typedefs_or_cplusplus): Renamed from typedefs_and_cplusplus. + (grow_linebuffer): Don't call xrnew when not needed. + (token): buffer renamed to line. + (C_entries): Three calls to inibuffer moved here from main. + (C_entries): Removed all references to var methodlen, delete it. + (linebuffer_setlen): Was grow_buffer, now also sets len. + (consider_token, C_entries, Pascal_functions): Use it. + (C_entries): Preventing problems relative to extern "C". + (C_entries): Can tag more than one variable or func separated by + comma when --declarations is used. + (C_entries): More accurate tagging of members and declarations. + (yacc_rules): Was global, made local to C_entries. + (next_token_is_func): Removed. + (fvdef): New constants fdefunkey, fdefunname. + (consider_token, C_entries): Use them. + (C_entries): Build proper lisp names for Emacs DEFUNs. + +2001-01-15 Francesco Potorti` + + * etags.c (print_language_names): Print filenames in addition to + suffixes. + +2001-01-12 Francesco Potorti` + + * etags.c (get_language_from_langname): Renamed from + get_language_from_name. + (get_language_from_filename): Renamed from + get_language_from_suffix. Now first looks for the complete file + name. + (language): New member char **filenames. + (Makefile_filenames): List of possible filenames for makefiles. + (lang_names): Added a NULL member for every entry, added an entry + for makefiles. + (Makefile_targets): New function, inspired by Assar Westerlund + . + +2000-11-07 Francesco Potortì + + * etags.c (Texinfo_nodes): Renamed from Texinfo_fuctions and made + it conformant to the style of the rest of the code. + +2000-02-10 Francesco Potorti` + + * etags.c (iswhite): Redefined not to consider '\0' as white + space, and use it throughout in place of isspace, thus preventing a + potential signed char to int conversion problem. + (MSDOS): #undefine befere redefining + +2000-02-04 Francesco Potorti` + + * etags.c (many functions): Add prototypes. + +2000-01-31 Francesco Potorti` + + * etags.c [MSDOS]: Set MSDOS to 1 if #defined, 0 otherwise. + (get_compressor_from_suffix, process_file): Use MSDOS in if clause. + (etags_strchr, etags_strrchr): Use const char * and int as arguments. + (getenv, getcwd): Only declare them if necessary. + (EMACS_NAME): New constant macro. + (print_version): Use it. + (P_) [__STDC__]: Macro for defining function prototypes. + +2000-01-18 Fabrice Popineau + + * etags.c [WINDOWSNT]: #include + +2000-01-18 Martin Buchholz + + * etags.c (all functions): Made them static. + (all functions): Write prototypes. + +1999-11-19 Francesco Potorti` + + * etags.c (_GNU_SOURCE): Define only if undefined. + (get_scheme): Declaration deleted. + (main): error was called with an integer as second arg, instead of + a char pointer. + (canonicalize_filename): Bug removed. + +1999-11-18 Dave Love + + * etags.c (C_entries): Rename label `intoken', avoiding K&R + lossage from name clash with macro. + +1999-09-14 Francesco Potorti` + + * etags.c: Add suffix psw for PSWrap. + (L_getit): Generalize a "cp!=' '" into "!isspace(*cp)". + (Postscript_functions): Add code for PSWrap. + (Scheme_functions): Use local pointer and new get_tag function. + (get_tag): New name for old get_scheme. + (process_file): Do not free NULL when file does not exist. + (typdef): ttypedefseen renamed to tkeyseen, new label ttypeseen. + (C_entries): Modifications that make --members tag even inside + typedefs and C nested structs (one level only). + (consider_token): Corrected a bug which prevented tagging of enum + constants. + (C_stab_entry): Added if, for, while, switch, return as + st_C_ignore. This makes it simpler to work when cblev!=0. + +1999-04-21 Francesco Potorti` + + * etags.c (C_entries): tag member function declarations when + --declarations is used. + +1999-04-20 Francesco Potorti` + + * etags.c (C_entries, consider_token): C++ `operator' now is + tagged in most cases. + As before, :: is not recognised if surrounded by spaces. + +1999-01-14 Francesco Potorti` + + * etags.c (relative_filename): Account for DOS file names such + that is impossible to make one relative to another. + +1998-10-09 Francesco Potorti` + + * etags.c (sym_type): New st_C_extern tag. + (gperf input): Use it for spotting external declarations. + (print_help): Document the new behaviour of --declarations. + (fvextern): New global variable. + (consider_token, C_entries): Use it. + +1998-06-19 Francesco Potorti` + + * etags.c (HAVE_GETCWD) [WINDOWSNT]: Define if undefined. + (etags_getcwd): Remove test for WINDOWSNT. + +1998-06-16 Eli Zaretskii + + * etags.c (process_file) [MSDOS]: If foo.c.gz is not found, try + foo.cgz, foo.cz, etc. + +1998-06-15 Francesco Potorti` + + * etags.c (declarations): New global switch. + (longopts): Describe it. + (print_help): Document it. + (C_entries): Use it. + (process_file): Don't process a file twice. + +1998-06-02 Francesco Potorti` + + * etags.c (Fortran_functions): No tags for "procedure". + +1998-05-29 Eli Zaretskii + + * etags.c (get_compressor_from_suffix): Second argument EXTPTR, if + non-zero, returns a pointer to where the extension begins; callers + changed. + [MSDOS]: Support DOS file names by handling e.g. foo.cgz as if it + were foo.c.gz. + +1998-05-18 Francesco Potorti` + + * etags.c (sym_type, C_stab_entry): New constant st_C_operator. + (fvdev): New constant foperator. + (consider_token): Use it to get "operator" in C++. + (C_entries): Extend length of operator@ function name. + (C_entries): Use foperator when necessary. + +1998-05-13 Francesco Potorti` + + * etags.c (main) [!ETAGS_REGEXPS]: Do not call free_patterns. + +1998-05-12 Francesco Potorti` + + * etags.c (compressor): New struct for compressed files. + (get_compressor_from_suffix): New function. + (get_language_from_suffix): Use it. Also, semantics changed. + (process_file): Consider compressed files, close file. + (find_entries): Use different call arg for get_language_from_suffix, + don't close file. + +1998-05-11 Francesco Potorti` + + * etags.c (main): Call free_tree. + (find_entries): Do not free curfile. + (pfnote): Cosmetic change: NULL and '\0' where appropriate. + (prolog_pred, erlang_func, substitute): Cast strlen to int when + comparing. + (canonicalize_filename): Shut up compiler warning. + (Perl_functions): Make tag significant. + +1997-11-27 Dave Love + + * etags.c (longopts, optstring): New option --ignore-case-regex (-c). + (argument_type): New member at_icregexp. + (lc_trans): New global. + (main): Fill lc_trans. Process -c args. + (add_regex): New arg determining whether to use translation table. + (analyse_regex): New arg. Use it for add_regex. + +1997-09-30 Francesco Potorti` + + * etags.c (init): Cosmetic change: NULL --> '\0'. + (erlang_attribute): Bug corrected (uninitialized variable). + (filename_is_absolute): New function replaces absolutefn macro and + corrects a bug. All callers changed. + (canonicalize_filename): New function. + (process_file, etags_getcwd, absolute_dirname): Use it. + (relative_filename, absolute_filename): Removed var shadowing. + (C_entries, Pascal_functions): Add fake initializations to keep + compilers quiet. + (TeX_functions, Prolog_functions, Erlang_functions): Cleanup. + +1997-09-20 Francesco Potorti` + + * etags.c (xrnew): New macro. All callers of xrealloc changed. + (language): New typedef (was struct lang_entry). + (curlang): New global variable. + (node): typedef renamed from NODE. + (linebuffer): New typedef (was struct linebuffer). + (pattern): New typedef (was struct pattern). Some members added. + Now used as element of a linked list. + (patterns, num_patterns): Global variables deleted. + (p_head): New global variable. + (forced_lang): New global variable (replaces lang_func). + (get_language_from_name, get_language_from_interpreter, + get_language_from_suffix): Semantics changed. All callers changed. + (last_node): New global variable. + (free_tree, add_node, put_entries, total_size_of_entries): Change + name of local vars to avoid clashes with typedef node. + (number_len): Rewritten for elegance. + (token): New typedef replaces TOKEN. + (analyse_regex, add_regex): Rewritten for new functionality. + (free_patterns): New function called from main and add_regex. + (initbuffer, readline_internal, readline, grow_linebuffer): + Change name of local vars to avoid clashes with typedef + linebuffer. + (readline): Rewritten for new functionality. + +1997-09-04 Francesco Potorti` + + * etags.c: (Scheme_suffixes): New suffix ".ss". + (print_help): --globals is now used for more than C-type languages. + (Perl_functions): Tag global variables ("my" and "local"). + +1997-08-22 Francesco Potorti` + + * etags.c (print_help): Some messages clarified. + (LOOP_ON_INPUT_LINES): New macro. + (just_read_file, Fortran_functions, Asm_labels, Perl_functions, + Python_functions, Cobol_paragraphs, Pascal_functions, + Lisp_functions, Postscript_functions, Scheme_functions, + TeX_functions, Prolog_functions, Erlang_functions): Use it. + (Cobol_paragraphs, Postscript_functions, TeX_functions, + Prolog_functions, Erlang_functions): Use a local variable instead + of the global variable dbp. + (Pascal_functions, L_isquote, Scheme_functions): Use GNU coding + standard indentation. + +1997-08-21 Francesco Potorti` + + * etags.c (Python_suffixes, lang_names, Python_functions): Python + support. + (skip_spaces, skip_non_spaces): Utility functions. + (find_entries, takeprec, getit, Fortran_functions, Perl_functions, + Python_functions, L_getit, Lisp_functions, Scheme_functions, + prolog_pred, erlanf_func, erlang_attribute): Use them. + (eat_white): Deleted. + +1997-08-20 Francesco Potorti` + + * etags.c (CHAR, init): Keep into account non US-ASCII + characters and compilers with default signed chars. + (L_getit): Tag "(defstruct (foo", "(defun (operator" and similar + constructs. + +1997-07-04 Francesco Potorti` + + * (C_stab_entry): "interface" in Java behaves like "class". + +1997-06-23 Francesco Potorti` + + * etags.c: (HAVE_NTGUI) [WINDOWSNT]: #undef if HAVE_CONFIG_H. + (main): Put interval syntax here. + (add_regex): And remove it from here. + +1997-06-17 Francesco Potorti` + + * etags.c (suggest_asking_for_help): Provide a + meaningful help message with and without LONG_OPTIONS. + +1997-06-09 Francesco Potorti` + + * etags.c: [MSDOS]: Include it, don't include string.h. + : Don't test MSDOS when including them. + (white, nonam, endtk): Like elsewhere, use \r instead of \013. + (put_entries): Correctly use %ld instead of %d in printf. + +1997-06-04 Francesco Potorti` + + * etags.c: [HAVE_UNISTD_H]: Include conditionally, else + declare getcwd if HAVE_GETCWD. + (consider_token): Dead break instruction removed. diff --git a/etc/ETAGS.EBNF b/etc/ETAGS.EBNF new file mode 100644 index 0000000..1ac6689 --- /dev/null +++ b/etc/ETAGS.EBNF @@ -0,0 +1,114 @@ +-*- indented-text -*- + +See the end of this file for copyright information. + +This file contains two sections: + +1) An EBNF (Extended Backus-Naur Form) description of the format of + the tags file created by etags.c and interpreted by etags.el; +2) A discussion of tag names and implicit tag names. + +====================== 1) EBNF tag file description ===================== + +Productions created from current behaviour to aid extensions +Francesco Potorti` 2002 +---------------- + +FF ::= #x0c /* tag section starter */ + +LF ::= #x0a /* line terminator */ + +DEL ::= #x7f /* pattern terminator */ + +SOH ::= #x01 /* name terminator */ + +regchar ::= [^#x0a#x0c#x7f] /* regular character */ + +regstring ::= { regchar } /* regular string */ + +unsint ::= [0-9] { [0-9] } /* non-negative integer */ + + + +tagfile ::= { tagsection } /* a tags file */ + +tagsection ::= FF LF ( includesec | regularsec ) LF + +includesec ::= filename ",include" [ LF fileprop ] + +regularsec ::= filename "," [ unsint ] [ LF fileprop ] { LF tag } + +filename ::= regchar regstring /* a file name */ + +fileprop ::= "(" regstring ")" /* an elisp alist */ + +tag ::= directtag | patterntag + +directtag ::= DEL realposition /* no pattern */ + +patterntag ::= pattern DEL [ tagname SOH ] position + +pattern ::= regstring /* a tag pattern */ + +tagname ::= regchar regstring /* a tag name */ + +position ::= realposition | "," /* charpos,linepos */ + +realposition ::= "," unsint | unsint "," | unsint "," unsint + +==================== end of EBNF tag file description ==================== + + + +======================= 2) discussion of tag names ======================= + +- WHAT ARE TAG NAMES +Tag lines in a tags file are usually made from the above defined pattern +and by an optional tag name. The pattern is a string that is searched +in the source file to find the tagged line. + +- WHY TAG NAMES ARE GOOD +When a user looks for a tag, Emacs first compares the tag with the tag +names contained in the tags file. If no match is found, Emacs compares +the tag with the patterns. The tag name is then the preferred way to +look for tags in the tags file, because when the tag name is present +Emacs can find a tag faster and more accurately. These tag names are +part of tag lines in the tags file, so we call them "explicit". + +- WHY IMPLICIT TAG NAMES ARE EVEN BETTER +When a tag line has no name, but a name can be deduced from the pattern, +we say that the tag line has an implicit tag name. Often tag names are +redundant; this happens when the name of a tag is an easily guessable +substring of the tag pattern. We define a set of rules to decide +whether it is possible to deduce the tag name from the pattern, and make +an unnamed tag in those cases. The name deduced from the pattern of an +unnamed tag is the implicit name of that tag. + When the user looks for a tag, and Emacs finds no explicit tag names +that match it, Emacs then looks for an tag whose implicit tag name +matches the request. etags.c uses implicit tag names when possible, in +order to reduce the size of the tags file. + An implicit tag name is deduced from the pattern by discarding the +last character if it is one of ` \f\t\n\r()=,;', then taking all the +rightmost consecutive characters in the pattern which are not one of +those. + +===================== end of discussion of tag names ===================== + +Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 +Free Software Foundation, Inc. + +COPYING PERMISSIONS: + + This document is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/etc/ETAGS.README b/etc/ETAGS.README new file mode 100644 index 0000000..aef3aa6 --- /dev/null +++ b/etc/ETAGS.README @@ -0,0 +1,49 @@ +etags is distributed under the following conditions: + + +Copyright (C) 1984 The Regents of the University of California + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the + distribution. +3. Neither the name of the University nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Copyright (C) 1984, 1987, 1988, 1989, 1993, 1994, 1995, 1998, 1999, + 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 + Free Software Foundation, Inc. + +This file is not considered part of GNU Emacs. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/etc/photos/didier.png b/etc/photos/didier.png new file mode 100644 index 0000000..f7b40c2 Binary files /dev/null and b/etc/photos/didier.png differ diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 184dc6d..f481972 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog @@ -1,3 +1,7 @@ +2007-10-07 Vin Shelton + + * XEmacs 21.4.21 is released + 2006-12-09 Vin Shelton * XEmacs 21.4.20 is released diff --git a/lib-src/etags.c b/lib-src/etags.c index e1b6aeb..d2e0008 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c @@ -1,6 +1,36 @@ /* Tags file maker to go with GNU Emacs -*- coding: latin-1 -*- - Copyright (C) 1984, 87, 88, 89, 93, 94, 95, 98, 99, 2000, 2001 - Free Software Foundation, Inc. and Ken Arnold + +Copyright (C) 1984 The Regents of the University of California + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the + distribution. +3. Neither the name of the University nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Copyright (C) 1984, 1987, 1988, 1989, 1993, 1994, 1995, 1998, 1999, + 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 + Free Software Foundation, Inc. This file is not considered part of GNU Emacs. @@ -16,23 +46,41 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, -Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + + +/* NB To comply with the above BSD license, copyright information is +reproduced in etc/ETAGS.README. That file should be updated when the +above notices are. + +To the best of our knowledge, this code was originally based on the +ctags.c distributed with BSD4.2, which was copyrighted by the +University of California, as described above. */ + /* * Authors: - * Ctags originally by Ken Arnold. - * Fortran added by Jim Kleckner. - * Ed Pelegri-Llopart added C typedefs. - * Gnu Emacs TAGS format and modifications by RMS? + * 1983 Ctags originally by Ken Arnold. + * 1984 Fortran added by Jim Kleckner. + * 1984 Ed Pelegri-Llopart added C typedefs. + * 1985 Emacs TAGS format by Richard Stallman. * 1989 Sam Kendall added C++. - * 1993 Francesco Potortì reorganised C and C++ based on work by Joe Wells. - * 1994 Regexp tags by Tom Tromey. - * 2001 Nested classes by Francesco Potortì based on work by Mykola Dzyuba. + * 1992 Joseph B. Wells improved C and C++ parsing. + * 1993 Francesco Potortì reorganised C and C++. + * 1994 Line-by-line regexp tags by Tom Tromey. + * 2001 Nested classes by Francesco Potortì (concept by Mykola Dzyuba). + * 2002 #line directives by Francesco Potortì. * - * Francesco Potortì has maintained it since 1993. + * Francesco Potortì has maintained and improved it since 1993. + */ + +/* + * If you want to add support for a new language, start by looking at the LUA + * language, which is the simplest. Alternatively, consider shipping a + * configuration file containing regexp definitions for etags. */ -char pot_etags_version[] = "@(#) pot revision number is 14.15"; +char pot_etags_version[] = "@(#) pot revision number is 17.33"; #define TRUE 1 #define FALSE 0 @@ -45,20 +93,27 @@ char pot_etags_version[] = "@(#) pot revision number is 14.15"; # define NDEBUG /* disable assert */ #endif -#if defined(__STDC__) && (__STDC__ || defined(__SUNPRO_C)) -# define P_(proto) proto -#else -# define P_(proto) () -#endif - #ifdef HAVE_CONFIG_H # include /* On some systems, Emacs defines static as nothing for the sake of unexec. We don't want that here since we don't use unexec. */ # undef static -# define ETAGS_REGEXPS /* use the regexp features */ -# define LONG_OPTIONS /* accept long options */ -#endif /* HAVE_CONFIG_H */ +# ifndef PTR /* for XEmacs */ +# define PTR void * +# endif +# ifndef __P /* for XEmacs */ +# define __P(args) args +# endif +#else /* no config.h */ +# if defined(__STDC__) && (__STDC__ || defined(__SUNPRO_C)) +# define __P(args) args /* use prototypes */ +# define PTR void * /* for generic pointers */ +# else /* not standard C */ +# define __P(args) () /* no prototypes */ +# define const /* remove const for old compilers' sake */ +# define PTR long * /* don't use void* */ +# endif +#endif /* !HAVE_CONFIG_H */ #ifndef _GNU_SOURCE # define _GNU_SOURCE 1 /* enables some compiler checks on GNU */ @@ -99,12 +154,26 @@ char pot_etags_version[] = "@(#) pot revision number is 14.15"; # ifndef HAVE_GETCWD # define HAVE_GETCWD # endif /* undef HAVE_GETCWD */ -#else /* !WINDOWSNT */ +#else /* not WINDOWSNT */ # ifdef STDC_HEADERS # include # include -# else - extern char *getenv (); +# else /* no standard C headers */ + extern char *getenv (); + extern char *strcpy (); + extern char *strncpy (); + extern char *strcat (); + extern char *strncat (); + extern unsigned long strlen (); + extern PTR malloc (); + extern PTR realloc (); +# ifdef VMS +# define EXIT_SUCCESS 1 +# define EXIT_FAILURE 0 +# else /* no VMS */ +# define EXIT_SUCCESS 0 +# define EXIT_FAILURE 1 +# endif # endif #endif /* !WINDOWSNT */ @@ -135,17 +204,25 @@ char pot_etags_version[] = "@(#) pot revision number is 14.15"; # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) #endif -#ifdef LONG_OPTIONS -# include -#else +#ifdef NO_LONG_OPTIONS /* define this if you don't have GNU getopt */ +# define NO_LONG_OPTIONS TRUE # define getopt_long(argc,argv,optstr,lopts,lind) getopt (argc, argv, optstr) extern char *optarg; extern int optind, opterr; -#endif /* LONG_OPTIONS */ - -#ifdef ETAGS_REGEXPS -# include -#endif /* ETAGS_REGEXPS */ +#else +# define NO_LONG_OPTIONS FALSE +# include +#endif /* NO_LONG_OPTIONS */ + +#ifndef HAVE_CONFIG_H /* this is a standalone compilation */ +# ifdef __CYGWIN__ /* compiling on Cygwin */ + !!! NOTICE !!! + the regex.h distributed with Cygwin is not compatible with etags, alas! +If you want regular expression support, you should delete this notice and + arrange to use the GNU regex.h and regex.c. +# endif +#endif +#include /* Define CTAGS to make the program "ctags" compatible with the usual one. Leave it undefined to make the program "etags", which makes emacs-style @@ -157,25 +234,18 @@ char pot_etags_version[] = "@(#) pot revision number is 14.15"; # define CTAGS FALSE #endif -/* Exit codes for success and failure. */ -#ifdef VMS -# define GOOD 1 -# define BAD 0 -#else -# define GOOD 0 -# define BAD 1 -#endif - #define streq(s,t) (assert((s)!=NULL || (t)!=NULL), !strcmp (s, t)) +#define strcaseeq(s,t) (assert((s)!=NULL && (t)!=NULL), !etags_strcasecmp (s, t)) #define strneq(s,t,n) (assert((s)!=NULL || (t)!=NULL), !strncmp (s, t, n)) +#define strncaseeq(s,t,n) (assert((s)!=NULL && (t)!=NULL), !etags_strncasecmp (s, t, n)) #define CHARS 256 /* 2^sizeof(char) */ #define CHAR(x) ((unsigned int)(x) & (CHARS - 1)) -#define iswhite(c) (_wht[CHAR(c)]) /* c is white */ -#define notinname(c) (_nin[CHAR(c)]) /* c is not in a name */ -#define begtoken(c) (_btk[CHAR(c)]) /* c can start token */ -#define intoken(c) (_itk[CHAR(c)]) /* c can be in token */ -#define endtoken(c) (_etk[CHAR(c)]) /* c ends tokens */ +#define iswhite(c) (_wht[CHAR(c)]) /* c is white (see white) */ +#define notinname(c) (_nin[CHAR(c)]) /* c is not in a name (see nonam) */ +#define begtoken(c) (_btk[CHAR(c)]) /* c can start token (see begtk) */ +#define intoken(c) (_itk[CHAR(c)]) /* c can be in token (see midtk) */ +#define endtoken(c) (_etk[CHAR(c)]) /* c ends tokens (see endtk) */ #define ISALNUM(c) isalnum (CHAR(c)) #define ISALPHA(c) isalpha (CHAR(c)) @@ -204,35 +274,51 @@ char pot_etags_version[] = "@(#) pot revision number is 14.15"; (char *) (op), (n) * sizeof (Type))) #endif -typedef int bool; +#define bool int -typedef void Lang_function P_((FILE *)); +typedef void Lang_function __P((FILE *)); typedef struct { - char *suffix; - char *command; /* Takes one arg and decompresses to stdout */ + char *suffix; /* file name suffix for this compressor */ + char *command; /* takes one arg and decompresses to stdout */ } compressor; typedef struct { - char *name; - Lang_function *function; - char **filenames; - char **suffixes; - char **interpreters; + char *name; /* language name */ + char *help; /* detailed help for the language */ + Lang_function *function; /* parse function */ + char **suffixes; /* name suffixes of this language's files */ + char **filenames; /* names of this language's files */ + char **interpreters; /* interpreters for this language */ + bool metasource; /* source used to generate other sources */ } language; +typedef struct fdesc +{ + struct fdesc *next; /* for the linked list */ + char *infname; /* uncompressed input file name */ + char *infabsname; /* absolute uncompressed input file name */ + char *infabsdir; /* absolute dir of input file */ + char *taggedfname; /* file name to write in tagfile */ + language *lang; /* language of file */ + char *prop; /* file properties to write in tagfile */ + bool usecharno; /* etags tags shall contain char number */ + bool written; /* entry written in the tags file */ +} fdesc; + typedef struct node_st -{ /* sorting structure */ - char *name; /* function or type name */ - char *file; /* file name */ - bool is_func; /* use pattern or line no */ - bool been_warned; /* set if noticed dup */ - int lno; /* line number tag is on */ +{ /* sorting structure */ + struct node_st *left, *right; /* left and right sons */ + fdesc *fdp; /* description of file to whom tag belongs */ + char *name; /* tag name */ + char *regex; /* search regexp */ + bool valid; /* write this tag on the tag file */ + bool is_func; /* function tag: use regexp in CTAGS mode */ + bool been_warned; /* warning already given for duplicated tag */ + int lno; /* line number tag is on */ long cno; /* character number line starts on */ - char *pat; /* search pattern */ - struct node_st *left, *right; /* left and right sons */ } node; /* @@ -249,114 +335,153 @@ typedef struct char *buffer; } linebuffer; +/* Used to support mixing of --lang and file names. */ +typedef struct +{ + enum { + at_language, /* a language specification */ + at_regexp, /* a regular expression */ + at_filename, /* a file name */ + at_stdin, /* read from stdin here */ + at_end /* stop parsing the list */ + } arg_type; /* argument type */ + language *lang; /* language associated with the argument */ + char *what; /* the argument itself */ +} argument; + +/* Structure defining a regular expression. */ +typedef struct regexp +{ + struct regexp *p_next; /* pointer to next in list */ + language *lang; /* if set, use only for this language */ + char *pattern; /* the regexp pattern */ + char *name; /* tag name */ + struct re_pattern_buffer *pat; /* the compiled pattern */ + struct re_registers regs; /* re registers */ + bool error_signaled; /* already signaled for this regexp */ + bool force_explicit_name; /* do not allow implict tag name */ + bool ignore_case; /* ignore case when matching */ + bool multi_line; /* do a multi-line match on the whole file */ +} regexp; + + /* Many compilers barf on this: Lang_function Ada_funcs; so let's write it this way */ -static void Ada_funcs P_((FILE *)); -static void Asm_labels P_((FILE *)); -static void C_entries P_((int c_ext, FILE *)); -static void default_C_entries P_((FILE *)); -static void plain_C_entries P_((FILE *)); -static void Cjava_entries P_((FILE *)); -static void Cobol_paragraphs P_((FILE *)); -static void Cplusplus_entries P_((FILE *)); -static void Cstar_entries P_((FILE *)); -static void Erlang_functions P_((FILE *)); -static void Fortran_functions P_((FILE *)); -static void Yacc_entries P_((FILE *)); -static void Lisp_functions P_((FILE *)); -static void Makefile_targets P_((FILE *)); -static void Pascal_functions P_((FILE *)); -static void Perl_functions P_((FILE *)); -static void Postscript_functions P_((FILE *)); -static void Prolog_functions P_((FILE *)); -static void Python_functions P_((FILE *)); -static void Scheme_functions P_((FILE *)); -static void TeX_commands P_((FILE *)); -static void Texinfo_nodes P_((FILE *)); -static void just_read_file P_((FILE *)); - -static void print_language_names P_((void)); -static void print_version P_((void)); -static void print_help P_((void)); -int main P_((int, char **)); -static int number_len P_((long)); - -static compressor *get_compressor_from_suffix P_((char *, char **)); -static language *get_language_from_langname P_((char *)); -static language *get_language_from_interpreter P_((char *)); -static language *get_language_from_filename P_((char *)); -static int total_size_of_entries P_((node *)); -static long readline P_((linebuffer *, FILE *)); -static long readline_internal P_((linebuffer *, FILE *)); -static void get_tag P_((char *)); - -#ifdef ETAGS_REGEXPS -static void analyse_regex P_((char *, bool)); -static void add_regex P_((char *, bool, language *)); -static void free_patterns P_((void)); -#endif /* ETAGS_REGEXPS */ -static void error P_((const char *, const char *)); -static void suggest_asking_for_help P_((void)); -void fatal P_((char *, char *)); -static void pfatal P_((char *)); -static void add_node P_((node *, node **)); - -static void init P_((void)); -static void initbuffer P_((linebuffer *)); -static void find_entries P_((char *, FILE *)); -static void free_tree P_((node *)); -static void pfnote P_((char *, bool, char *, int, int, long)); -static void new_pfnote P_((char *, int, bool, char *, int, int, long)); -static void process_file P_((char *)); -static void put_entries P_((node *)); -static void takeprec P_((void)); - -static char *concat P_((char *, char *, char *)); -static char *skip_spaces P_((char *)); -static char *skip_non_spaces P_((char *)); -static char *savenstr P_((char *, int)); -static char *savestr P_((char *)); -static char *etags_strchr P_((const char *, int)); -static char *etags_strrchr P_((const char *, int)); -static char *etags_getcwd P_((void)); -static char *relative_filename P_((char *, char *)); -static char *absolute_filename P_((char *, char *)); -static char *absolute_dirname P_((char *, char *)); -static bool filename_is_absolute P_((char *f)); -static void canonicalize_filename P_((char *)); -static void linebuffer_setlen P_((linebuffer *, int)); -long *xmalloc P_((unsigned int)); -long *xrealloc P_((char *, unsigned int)); +static void Ada_funcs __P((FILE *)); +static void Asm_labels __P((FILE *)); +static void C_entries __P((int c_ext, FILE *)); +static void default_C_entries __P((FILE *)); +static void plain_C_entries __P((FILE *)); +static void Cjava_entries __P((FILE *)); +static void Cobol_paragraphs __P((FILE *)); +static void Cplusplus_entries __P((FILE *)); +static void Cstar_entries __P((FILE *)); +static void Erlang_functions __P((FILE *)); +static void Forth_words __P((FILE *)); +static void Fortran_functions __P((FILE *)); +static void HTML_labels __P((FILE *)); +static void Lisp_functions __P((FILE *)); +static void Lua_functions __P((FILE *)); +static void Makefile_targets __P((FILE *)); +static void Pascal_functions __P((FILE *)); +static void Perl_functions __P((FILE *)); +static void PHP_functions __P((FILE *)); +static void PS_functions __P((FILE *)); +static void Prolog_functions __P((FILE *)); +static void Python_functions __P((FILE *)); +static void Scheme_functions __P((FILE *)); +static void TeX_commands __P((FILE *)); +static void Texinfo_nodes __P((FILE *)); +static void Yacc_entries __P((FILE *)); +static void just_read_file __P((FILE *)); + +static void print_language_names __P((void)); +static void print_version __P((void)); +static void print_help __P((argument *)); +int main __P((int, char **)); + +static compressor *get_compressor_from_suffix __P((char *, char **)); +static language *get_language_from_langname __P((const char *)); +static language *get_language_from_interpreter __P((char *)); +static language *get_language_from_filename __P((char *, bool)); +static void readline __P((linebuffer *, FILE *)); +static long readline_internal __P((linebuffer *, FILE *)); +static bool nocase_tail __P((char *)); +static void get_tag __P((char *, char **)); + +static void analyse_regex __P((char *)); +static void free_regexps __P((void)); +static void regex_tag_multiline __P((void)); +static void error __P((const char *, const char *)); +static void suggest_asking_for_help __P((void)); +void fatal __P((char *, char *)); +static void pfatal __P((char *)); +static void add_node __P((node *, node **)); + +static void init __P((void)); +static void process_file_name __P((char *, language *)); +static void process_file __P((FILE *, char *, language *)); +static void find_entries __P((FILE *)); +static void free_tree __P((node *)); +static void free_fdesc __P((fdesc *)); +static void pfnote __P((char *, bool, char *, int, int, long)); +static void make_tag __P((char *, int, bool, char *, int, int, long)); +static void invalidate_nodes __P((fdesc *, node **)); +static void put_entries __P((node *)); + +static char *concat __P((char *, char *, char *)); +static char *skip_spaces __P((char *)); +static char *skip_non_spaces __P((char *)); +static char *savenstr __P((char *, int)); +static char *savestr __P((char *)); +static char *etags_strchr __P((const char *, int)); +static char *etags_strrchr __P((const char *, int)); +static int etags_strcasecmp __P((const char *, const char *)); +static int etags_strncasecmp __P((const char *, const char *, int)); +static char *etags_getcwd __P((void)); +static char *relative_filename __P((char *, char *)); +static char *absolute_filename __P((char *, char *)); +static char *absolute_dirname __P((char *, char *)); +static bool filename_is_absolute __P((char *f)); +static void canonicalize_filename __P((char *)); +static void linebuffer_init __P((linebuffer *)); +static void linebuffer_setlen __P((linebuffer *, int)); +static PTR xmalloc __P((unsigned int)); +static PTR xrealloc __P((char *, unsigned int)); -char searchar = '/'; /* use /.../ searches */ +static char searchar = '/'; /* use /.../ searches */ -char *tagfile; /* output file */ -char *progname; /* name this program was invoked with */ -char *cwd; /* current working directory */ -char *tagfiledir; /* directory of tagfile */ -FILE *tagf; /* ioptr for tags file */ +static char *tagfile; /* output file */ +static char *progname; /* name this program was invoked with */ +static char *cwd; /* current working directory */ +static char *tagfiledir; /* directory of tagfile */ +static FILE *tagf; /* ioptr for tags file */ -char *curfile; /* current input file name */ -language *curlang; /* current language */ +static fdesc *fdhead; /* head of file description list */ +static fdesc *curfdp; /* current file description */ +static int lineno; /* line number of current line */ +static long charno; /* current character number */ +static long linecharno; /* charno of start of current line */ +static char *dbp; /* pointer to start of current tag */ -int lineno; /* line number of current line */ -long charno; /* current character number */ -long linecharno; /* charno of start of current line */ -char *dbp; /* pointer to start of current tag */ +static const int invalidcharno = -1; -node *head; /* the head of the binary tree of tags */ +static node *nodehead; /* the head of the binary tree of tags */ +static node *last_node; /* the last node created */ -linebuffer lb; /* the current line */ +static linebuffer lb; /* the current line */ +static linebuffer filebuf; /* a buffer containing the whole file */ +static linebuffer token_name; /* a buffer containing a tag name */ /* boolean "functions" (see init) */ -bool _wht[CHARS], _nin[CHARS], _itk[CHARS], _btk[CHARS], _etk[CHARS]; -char +static bool _wht[CHARS], _nin[CHARS], _itk[CHARS], _btk[CHARS], _etk[CHARS]; +static char /* white chars */ *white = " \f\t\n\r\v", /* not in a name */ - *nonam = " \f\t\n\r(=,[;", + *nonam = " \f\t\n\r()=,;", /* look at make_tag before modifying! */ /* token ending chars */ *endtk = " \t\n\r\"'#()[]{}=-+%*/&|^~!<>;,.:?", /* token starting chars */ @@ -364,86 +489,80 @@ char /* valid in-token chars */ *midtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$0123456789"; -bool append_to_tagfile; /* -a: append to tags */ -/* The following four default to TRUE for etags, but to FALSE for ctags. */ -bool typedefs; /* -t: create tags for C and Ada typedefs */ -bool typedefs_or_cplusplus; /* -T: create tags for C typedefs, level */ +static bool append_to_tagfile; /* -a: append to tags */ +/* The next five default to TRUE for etags, but to FALSE for ctags. */ +static bool typedefs; /* -t: create tags for C and Ada typedefs */ +static bool typedefs_or_cplusplus; /* -T: create tags for C typedefs, level */ /* 0 struct/enum/union decls, and C++ */ /* member functions. */ -bool constantypedefs; /* -d: create tags for C #define, enum */ +static bool constantypedefs; /* -d: create tags for C #define, enum */ /* constants and variables. */ /* -D: opposite of -d. Default under ctags. */ -bool declarations; /* --declarations: tag them and extern in C&Co*/ -bool globals; /* create tags for global variables */ -bool members; /* create tags for C member variables */ -bool update; /* -u: update tags */ -bool vgrind_style; /* -v: create vgrind style index output */ -bool no_warnings; /* -w: suppress warnings */ -bool cxref_style; /* -x: create cxref style output */ -bool cplusplus; /* .[hc] means C++, not C */ -bool noindentypedefs; /* -I: ignore indentation in C */ -bool packages_only; /* --packages-only: in Ada, only tag packages*/ - -#ifdef LONG_OPTIONS -struct option longopts[] = +static bool globals; /* create tags for global variables */ +static bool members; /* create tags for C member variables */ +static bool declarations; /* --declarations: tag them and extern in C&Co*/ +static bool no_line_directive; /* ignore #line directives (undocumented) */ +static bool no_duplicates; /* no duplicate tags for ctags (undocumented) */ +static bool update; /* -u: update tags */ +static bool vgrind_style; /* -v: create vgrind style index output */ +static bool no_warnings; /* -w: suppress warnings (undocumented) */ +static bool cxref_style; /* -x: create cxref style output */ +static bool cplusplus; /* .[hc] means C++, not C */ +static bool ignoreindent; /* -I: ignore indentation in C */ +static bool packages_only; /* --packages-only: in Ada, only tag packages*/ + +/* STDIN is defined in LynxOS system headers */ +#ifdef STDIN +# undef STDIN +#endif + +#define STDIN 0x1001 /* returned by getopt_long on --parse-stdin */ +static bool parsing_stdin; /* --parse-stdin used */ + +static regexp *p_head; /* list of all regexps */ +static bool need_filebuf; /* some regexes are multi-line */ + +static struct option longopts[] = { - { "packages-only", no_argument, &packages_only, TRUE }, - { "append", no_argument, NULL, 'a' }, - { "backward-search", no_argument, NULL, 'B' }, - { "c++", no_argument, NULL, 'C' }, - { "cxref", no_argument, NULL, 'x' }, - { "defines", no_argument, NULL, 'd' }, - { "declarations", no_argument, &declarations, TRUE }, - { "no-defines", no_argument, NULL, 'D' }, - { "globals", no_argument, &globals, TRUE }, - { "no-globals", no_argument, &globals, FALSE }, - { "help", no_argument, NULL, 'h' }, - { "help", no_argument, NULL, 'H' }, - { "ignore-indentation", no_argument, NULL, 'I' }, - { "include", required_argument, NULL, 'i' }, - { "language", required_argument, NULL, 'l' }, - { "members", no_argument, &members, TRUE }, - { "no-members", no_argument, &members, FALSE }, - { "no-warn", no_argument, NULL, 'w' }, - { "output", required_argument, NULL, 'o' }, -#ifdef ETAGS_REGEXPS - { "regex", required_argument, NULL, 'r' }, - { "no-regex", no_argument, NULL, 'R' }, - { "ignore-case-regex", required_argument, NULL, 'c' }, -#endif /* ETAGS_REGEXPS */ - { "typedefs", no_argument, NULL, 't' }, - { "typedefs-and-c++", no_argument, NULL, 'T' }, - { "update", no_argument, NULL, 'u' }, - { "version", no_argument, NULL, 'V' }, - { "vgrind", no_argument, NULL, 'v' }, + { "append", no_argument, NULL, 'a' }, + { "packages-only", no_argument, &packages_only, TRUE }, + { "c++", no_argument, NULL, 'C' }, + { "declarations", no_argument, &declarations, TRUE }, + { "no-line-directive", no_argument, &no_line_directive, TRUE }, + { "no-duplicates", no_argument, &no_duplicates, TRUE }, + { "help", no_argument, NULL, 'h' }, + { "help", no_argument, NULL, 'H' }, + { "ignore-indentation", no_argument, NULL, 'I' }, + { "language", required_argument, NULL, 'l' }, + { "members", no_argument, &members, TRUE }, + { "no-members", no_argument, &members, FALSE }, + { "output", required_argument, NULL, 'o' }, + { "regex", required_argument, NULL, 'r' }, + { "no-regex", no_argument, NULL, 'R' }, + { "ignore-case-regex", required_argument, NULL, 'c' }, + { "parse-stdin", required_argument, NULL, STDIN }, + { "version", no_argument, NULL, 'V' }, + +#if CTAGS /* Ctags options */ + { "backward-search", no_argument, NULL, 'B' }, + { "cxref", no_argument, NULL, 'x' }, + { "defines", no_argument, NULL, 'd' }, + { "globals", no_argument, &globals, TRUE }, + { "typedefs", no_argument, NULL, 't' }, + { "typedefs-and-c++", no_argument, NULL, 'T' }, + { "update", no_argument, NULL, 'u' }, + { "vgrind", no_argument, NULL, 'v' }, + { "no-warn", no_argument, NULL, 'w' }, + +#else /* Etags options */ + { "no-defines", no_argument, NULL, 'D' }, + { "no-globals", no_argument, &globals, FALSE }, + { "include", required_argument, NULL, 'i' }, +#endif { NULL } }; -#endif /* LONG_OPTIONS */ -#ifdef ETAGS_REGEXPS -/* Structure defining a regular expression. Elements are - the compiled pattern, and the name string. */ -typedef struct pattern -{ - struct pattern *p_next; - language *language; - char *regex; - struct re_pattern_buffer *pattern; - struct re_registers regs; - char *name_pattern; - bool error_signaled; -} pattern; - -/* List of all regexps. */ -pattern *p_head = NULL; - -/* How many characters in the character set. (From regex.c.) */ -#define CHAR_SET_SIZE 256 -/* Translation table for case-insensitive matching. */ -char lc_trans[CHAR_SET_SIZE]; -#endif /* ETAGS_REGEXPS */ - -compressor compressors[] = +static compressor compressors[] = { { "z", "gzip -d -c"}, { "Z", "gzip -d -c"}, @@ -457,93 +576,233 @@ compressor compressors[] = * Language stuff. */ -/* Non-NULL if language fixed. */ -language *forced_lang = NULL; - /* Ada code */ -char *Ada_suffixes [] = +static char *Ada_suffixes [] = { "ads", "adb", "ada", NULL }; +static char Ada_help [] = +"In Ada code, functions, procedures, packages, tasks and types are\n\ +tags. Use the `--packages-only' option to create tags for\n\ +packages only.\n\ +Ada tag names have suffixes indicating the type of entity:\n\ + Entity type: Qualifier:\n\ + ------------ ----------\n\ + function /f\n\ + procedure /p\n\ + package spec /s\n\ + package body /b\n\ + type /t\n\ + task /k\n\ +Thus, `M-x find-tag bidule/b ' will go directly to the\n\ +body of the package `bidule', while `M-x find-tag bidule '\n\ +will just search for any tag `bidule'."; /* Assembly code */ -char *Asm_suffixes [] = { "a", /* Unix assembler */ - "asm", /* Microcontroller assembly */ - "def", /* BSO/Tasking definition includes */ - "inc", /* Microcontroller include files */ - "ins", /* Microcontroller include files */ - "s", "sa", /* Unix assembler */ - "S", /* cpp-processed Unix assembler */ - "src", /* BSO/Tasking C compiler output */ - NULL - }; +static char *Asm_suffixes [] = + { "a", /* Unix assembler */ + "asm", /* Microcontroller assembly */ + "def", /* BSO/Tasking definition includes */ + "inc", /* Microcontroller include files */ + "ins", /* Microcontroller include files */ + "s", "sa", /* Unix assembler */ + "S", /* cpp-processed Unix assembler */ + "src", /* BSO/Tasking C compiler output */ + NULL + }; +static char Asm_help [] = +"In assembler code, labels appearing at the beginning of a line,\n\ +followed by a colon, are tags."; + /* Note that .c and .h can be considered C++, if the --c++ flag was - given, or if the `class' keyowrd is met inside the file. + given, or if the `class' or `template' keyowrds are met inside the file. That is why default_C_entries is called for these. */ -char *default_C_suffixes [] = +static char *default_C_suffixes [] = { "c", "h", NULL }; - -char *Cplusplus_suffixes [] = +static char default_C_help [] = +"In C code, any C function or typedef is a tag, and so are\n\ +definitions of `struct', `union' and `enum'. `#define' macro\n\ +definitions and `enum' constants are tags unless you specify\n\ +`--no-defines'. Global variables are tags unless you specify\n\ +`--no-globals' and so are struct members unless you specify\n\ +`--no-members'. Use of `--no-globals', `--no-defines' and\n\ +`--no-members' can make the tags table file much smaller.\n\ +You can tag function declarations and external variables by\n\ +using `--declarations'."; + +static char *Cplusplus_suffixes [] = { "C", "c++", "cc", "cpp", "cxx", "H", "h++", "hh", "hpp", "hxx", "M", /* Objective C++ */ "pdb", /* Postscript with C syntax */ NULL }; - -char *Cjava_suffixes [] = +static char Cplusplus_help [] = +"In C++ code, all the tag constructs of C code are tagged. (Use\n\ +--help --lang=c --lang=c++ for full help.)\n\ +In addition to C tags, member functions are also recognized. Member\n\ +variables are recognized unless you use the `--no-members' option.\n\ +Tags for variables and functions in classes are named `CLASS::VARIABLE'\n\ +and `CLASS::FUNCTION'. `operator' definitions have tag names like\n\ +`operator+'."; + +static char *Cjava_suffixes [] = { "java", NULL }; +static char Cjava_help [] = +"In Java code, all the tags constructs of C and C++ code are\n\ +tagged. (Use --help --lang=c --lang=c++ --lang=java for full help.)"; + -char *Cobol_suffixes [] = +static char *Cobol_suffixes [] = { "COB", "cob", NULL }; +static char Cobol_help [] = +"In Cobol code, tags are paragraph names; that is, any word\n\ +starting in column 8 and followed by a period."; -char *Cstar_suffixes [] = +static char *Cstar_suffixes [] = { "cs", "hs", NULL }; -char *Erlang_suffixes [] = +static char *Erlang_suffixes [] = { "erl", "hrl", NULL }; +static char Erlang_help [] = +"In Erlang code, the tags are the functions, records and macros\n\ +defined in the file."; -char *Fortran_suffixes [] = +char *Forth_suffixes [] = + { "fth", "tok", NULL }; +static char Forth_help [] = +"In Forth code, tags are words defined by `:',\n\ +constant, code, create, defer, value, variable, buffer:, field."; + +static char *Fortran_suffixes [] = { "F", "f", "f90", "for", NULL }; +static char Fortran_help [] = +"In Fortran code, functions, subroutines and block data are tags."; -char *Lisp_suffixes [] = - { "cl", "clisp", "el", "l", "lisp", "LSP", "lsp", "ml", NULL }; +static char *HTML_suffixes [] = + { "htm", "html", "shtml", NULL }; +static char HTML_help [] = +"In HTML input files, the tags are the `title' and the `h1', `h2',\n\ +`h3' headers. Also, tags are `name=' in anchors and all\n\ +occurrences of `id='."; -char *Makefile_filenames [] = +static char *Lisp_suffixes [] = + { "cl", "clisp", "el", "l", "lisp", "LSP", "lsp", "ml", NULL }; +static char Lisp_help [] = +"In Lisp code, any function defined with `defun', any variable\n\ +defined with `defvar' or `defconst', and in general the first\n\ +argument of any expression that starts with `(def' in column zero\n\ +is a tag."; + +static char *Lua_suffixes [] = + { "lua", "LUA", NULL }; +static char Lua_help [] = +"In Lua scripts, all functions are tags."; + +static char *Makefile_filenames [] = { "Makefile", "makefile", "GNUMakefile", "Makefile.in", "Makefile.am", NULL}; +static char Makefile_help [] = +"In makefiles, targets are tags; additionally, variables are tags\n\ +unless you specify `--no-globals'."; + +static char *Objc_suffixes [] = + { "lm", /* Objective lex file */ + "m", /* Objective C file */ + NULL }; +static char Objc_help [] = +"In Objective C code, tags include Objective C definitions for classes,\n\ +class categories, methods and protocols. Tags for variables and\n\ +functions in classes are named `CLASS::VARIABLE' and `CLASS::FUNCTION'.\n\ +(Use --help --lang=c --lang=objc --lang=java for full help.)"; -char *Pascal_suffixes [] = +static char *Pascal_suffixes [] = { "p", "pas", NULL }; +static char Pascal_help [] = +"In Pascal code, the tags are the functions and procedures defined\n\ +in the file."; +/* " // this is for working around an Emacs highlighting bug... */ -char *Perl_suffixes [] = +static char *Perl_suffixes [] = { "pl", "pm", NULL }; -char *Perl_interpreters [] = +static char *Perl_interpreters [] = { "perl", "@PERL@", NULL }; - -char *plain_C_suffixes [] = - { "lm", /* Objective lex file */ - "m", /* Objective C file */ - "pc", /* Pro*C file */ +static char Perl_help [] = +"In Perl code, the tags are the packages, subroutines and variables\n\ +defined by the `package', `sub', `my' and `local' keywords. Use\n\ +`--globals' if you want to tag global variables. Tags for\n\ +subroutines are named `PACKAGE::SUB'. The name for subroutines\n\ +defined in the default package is `main::SUB'."; + +static char *PHP_suffixes [] = + { "php", "php3", "php4", NULL }; +static char PHP_help [] = +"In PHP code, tags are functions, classes and defines. Unless you use\n\ +the `--no-members' option, vars are tags too."; + +static char *plain_C_suffixes [] = + { "pc", /* Pro*C file */ NULL }; -char *Postscript_suffixes [] = +static char *PS_suffixes [] = { "ps", "psw", NULL }; /* .psw is for PSWrap */ +static char PS_help [] = +"In PostScript code, the tags are the functions."; -char *Prolog_suffixes [] = +static char *Prolog_suffixes [] = { "prolog", NULL }; +static char Prolog_help [] = +"In Prolog code, tags are predicates and rules at the beginning of\n\ +line."; -char *Python_suffixes [] = +static char *Python_suffixes [] = { "py", NULL }; +static char Python_help [] = +"In Python code, `def' or `class' at the beginning of a line\n\ +generate a tag."; /* Can't do the `SCM' or `scm' prefix with a version number. */ -char *Scheme_suffixes [] = +static char *Scheme_suffixes [] = { "oak", "sch", "scheme", "SCM", "scm", "SM", "sm", "ss", "t", NULL }; +static char Scheme_help [] = +"In Scheme code, tags include anything defined with `def' or with a\n\ +construct whose name starts with `def'. They also include\n\ +variables set with `set!' at top level in the file."; -char *TeX_suffixes [] = +static char *TeX_suffixes [] = { "bib", "clo", "cls", "ltx", "sty", "TeX", "tex", NULL }; +static char TeX_help [] = +"In LaTeX text, the argument of any of the commands `\\chapter',\n\ +`\\section', `\\subsection', `\\subsubsection', `\\eqno', `\\label',\n\ +`\\ref', `\\cite', `\\bibitem', `\\part', `\\appendix', `\\entry',\n\ +`\\index', `\\def', `\\newcommand', `\\renewcommand',\n\ +`\\newenvironment' or `\\renewenvironment' is a tag.\n\ +\n\ +Other commands can be specified by setting the environment variable\n\ +`TEXTAGS' to a colon-separated list like, for example,\n\ + TEXTAGS=\"mycommand:myothercommand\"."; + -char *Texinfo_suffixes [] = +static char *Texinfo_suffixes [] = { "texi", "texinfo", "txi", NULL }; +static char Texinfo_help [] = +"for texinfo files, lines starting with @node are tagged."; -char *Yacc_suffixes [] = +static char *Yacc_suffixes [] = { "y", "y++", "ym", "yxx", "yy", NULL }; /* .ym is Objective yacc file */ +static char Yacc_help [] = +"In Bison or Yacc input files, each rule defines as a tag the\n\ +nonterminal it constructs. The portions of the file that contain\n\ +C code are parsed as C code (use --help --lang=c --lang=yacc\n\ +for full help)."; + +static char auto_help [] = +"`auto' is not a real language, it indicates to use\n\ +a default language for files base on file name suffix and file contents."; + +static char none_help [] = +"`none' is not a real language, it indicates to only do\n\ +regexp processing on files."; + +static char no_lang_help [] = +"No detailed help available for this language."; + /* * Table of languages. @@ -552,32 +811,37 @@ char *Yacc_suffixes [] = * name. I just didn't. */ -language lang_names [] = +static language lang_names [] = { - { "ada", Ada_funcs, NULL, Ada_suffixes, NULL }, - { "asm", Asm_labels, NULL, Asm_suffixes, NULL }, - { "c", default_C_entries, NULL, default_C_suffixes, NULL }, - { "c++", Cplusplus_entries, NULL, Cplusplus_suffixes, NULL }, - { "c*", Cstar_entries, NULL, Cstar_suffixes, NULL }, - { "cobol", Cobol_paragraphs, NULL, Cobol_suffixes, NULL }, - { "erlang", Erlang_functions, NULL, Erlang_suffixes, NULL }, - { "fortran", Fortran_functions, NULL, Fortran_suffixes, NULL }, - { "java", Cjava_entries, NULL, Cjava_suffixes, NULL }, - { "lisp", Lisp_functions, NULL, Lisp_suffixes, NULL }, - { "makefile", Makefile_targets, Makefile_filenames, NULL, NULL }, - { "pascal", Pascal_functions, NULL, Pascal_suffixes, NULL }, - { "perl", Perl_functions, NULL, Perl_suffixes, Perl_interpreters }, - { "postscript", Postscript_functions, NULL, Postscript_suffixes, NULL }, - { "proc", plain_C_entries, NULL, plain_C_suffixes, NULL }, - { "prolog", Prolog_functions, NULL, Prolog_suffixes, NULL }, - { "python", Python_functions, NULL, Python_suffixes, NULL }, - { "scheme", Scheme_functions, NULL, Scheme_suffixes, NULL }, - { "tex", TeX_commands, NULL, TeX_suffixes, NULL }, - { "texinfo", Texinfo_nodes, NULL, Texinfo_suffixes, NULL }, - { "yacc", Yacc_entries, NULL, Yacc_suffixes, NULL }, - { "auto", NULL }, /* default guessing scheme */ - { "none", just_read_file }, /* regexp matching only */ - { NULL, NULL } /* end of list */ + { "ada", Ada_help, Ada_funcs, Ada_suffixes }, + { "asm", Asm_help, Asm_labels, Asm_suffixes }, + { "c", default_C_help, default_C_entries, default_C_suffixes }, + { "c++", Cplusplus_help, Cplusplus_entries, Cplusplus_suffixes }, + { "c*", no_lang_help, Cstar_entries, Cstar_suffixes }, + { "cobol", Cobol_help, Cobol_paragraphs, Cobol_suffixes }, + { "erlang", Erlang_help, Erlang_functions, Erlang_suffixes }, + { "forth", Forth_help, Forth_words, Forth_suffixes }, + { "fortran", Fortran_help, Fortran_functions, Fortran_suffixes }, + { "html", HTML_help, HTML_labels, HTML_suffixes }, + { "java", Cjava_help, Cjava_entries, Cjava_suffixes }, + { "lisp", Lisp_help, Lisp_functions, Lisp_suffixes }, + { "lua", Lua_help, Lua_functions, Lua_suffixes }, + { "makefile", Makefile_help,Makefile_targets,NULL,Makefile_filenames}, + { "objc", Objc_help, plain_C_entries, Objc_suffixes }, + { "pascal", Pascal_help, Pascal_functions, Pascal_suffixes }, + { "perl",Perl_help,Perl_functions,Perl_suffixes,NULL,Perl_interpreters}, + { "php", PHP_help, PHP_functions, PHP_suffixes }, + { "postscript",PS_help, PS_functions, PS_suffixes }, + { "proc", no_lang_help, plain_C_entries, plain_C_suffixes }, + { "prolog", Prolog_help, Prolog_functions, Prolog_suffixes }, + { "python", Python_help, Python_functions, Python_suffixes }, + { "scheme", Scheme_help, Scheme_functions, Scheme_suffixes }, + { "tex", TeX_help, TeX_commands, TeX_suffixes }, + { "texinfo", Texinfo_help, Texinfo_nodes, Texinfo_suffixes }, + { "yacc", Yacc_help,Yacc_entries,Yacc_suffixes,NULL,NULL,TRUE}, + { "auto", auto_help }, /* default guessing scheme */ + { "none", none_help, just_read_file }, /* regexp matching only */ + { NULL } /* end of list */ }; @@ -600,55 +864,75 @@ default file names and dot suffixes:"); printf (" .%s", *ext); puts (""); } - puts ("Where `auto' means use default language for files based on file\n\ + puts ("where `auto' means use default language for files based on file\n\ name suffix, and `none' means only do regexp processing on files.\n\ If no language is specified and no matching suffix is found,\n\ the first line of the file is read for a sharp-bang (#!) sequence\n\ followed by the name of an interpreter. If no such sequence is found,\n\ Fortran is tried first; if no tags are found, C is tried next.\n\ -When parsing any C file, a \"class\" keyword switches to C++.\n\ -Compressed files are supported using gzip and bzip2."); +When parsing any C file, a \"class\" or \"template\" keyword\n\ +switches to C++."); + puts ("Compressed files are supported using gzip and bzip2.\n\ +\n\ +For detailed help on a given language use, for example,\n\ +etags --help --lang=ada."); } #ifndef EMACS_NAME -# define EMACS_NAME "GNU Emacs" +# define EMACS_NAME "standalone" #endif #ifndef VERSION -# define VERSION "21" +# define VERSION "17.33" #endif static void print_version () { printf ("%s (%s %s)\n", (CTAGS) ? "ctags" : "etags", EMACS_NAME, VERSION); - puts ("Copyright (C) 1999 Free Software Foundation, Inc. and Ken Arnold"); - puts ("This program is distributed under the same terms as Emacs"); + puts ("Copyright (C) 2007 Free Software Foundation, Inc."); + puts ("This program is distributed under the terms in ETAGS.README"); - exit (GOOD); + exit (EXIT_SUCCESS); } +#ifndef PRINT_UNDOCUMENTED_OPTIONS_HELP +# define PRINT_UNDOCUMENTED_OPTIONS_HELP FALSE +#endif + static void -print_help () +print_help (argbuffer) + argument *argbuffer; { + bool help_for_lang = FALSE; + + for (; argbuffer->arg_type != at_end; argbuffer++) + if (argbuffer->arg_type == at_language) + { + if (help_for_lang) + puts (""); + puts (argbuffer->lang->help); + help_for_lang = TRUE; + } + + if (help_for_lang) + exit (EXIT_SUCCESS); + printf ("Usage: %s [options] [[regex-option ...] file-name] ...\n\ \n\ These are the options accepted by %s.\n", progname, progname); -#ifdef LONG_OPTIONS - puts ("You may use unambiguous abbreviations for the long option names."); -#else - puts ("Long option names do not work with this executable, as it is not\n\ -linked with GNU getopt."); -#endif /* LONG_OPTIONS */ - puts ("A - as file name means read names from stdin (one per line)."); - if (!CTAGS) - printf (" Absolute names are stored in the output file as they are.\n\ -Relative ones are stored relative to the output file's directory."); - puts ("\n"); + if (NO_LONG_OPTIONS) + puts ("WARNING: long option names do not work with this executable,\n\ +as it is not linked with GNU getopt."); + else + puts ("You may use unambiguous abbreviations for the long option names."); + puts (" A - as file name means read names from stdin (one per line).\n\ +Absolute names are stored in the output file as they are.\n\ +Relative ones are stored relative to the output file's directory.\n"); puts ("-a, --append\n\ Append tag entries to existing tags file."); puts ("--packages-only\n\ - For Ada files, only generate tags for packages ."); + For Ada files, only generate tags for packages."); if (CTAGS) puts ("-B, --backward-search\n\ @@ -658,7 +942,7 @@ Relative ones are stored relative to the output file's directory."); /* This option is mostly obsolete, because etags can now automatically detect C++. Retained for backward compatibility and for debugging and experimentation. In principle, we could want to tag as C++ even - before any "class" keyword. + before any "class" or "template" keyword. puts ("-C, --c++\n\ Treat files whose name suffix defaults to C language as C++ files."); */ @@ -680,15 +964,14 @@ Relative ones are stored relative to the output file's directory."); This makes the tags file smaller."); if (!CTAGS) - { - puts ("-i FILE, --include=FILE\n\ + puts ("-i FILE, --include=FILE\n\ Include a note in tag file indicating that, when searching for\n\ a tag, one should also consult the tags file FILE after\n\ checking the current file."); - puts ("-l LANG, --language=LANG\n\ + + puts ("-l LANG, --language=LANG\n\ Force the following files to be considered as written in the\n\ named language up to the next --language=LANG option."); - } if (CTAGS) puts ("--globals\n\ @@ -697,30 +980,44 @@ Relative ones are stored relative to the output file's directory."); puts ("--no-globals\n\ Do not create tag entries for global variables in some\n\ languages. This makes the tags file smaller."); - puts ("--members\n\ - Create tag entries for member variables in C and derived languages."); - -#ifdef ETAGS_REGEXPS - puts ("-r /REGEXP/, --regex=/REGEXP/ or --regex=@regexfile\n\ - Make a tag for each line matching pattern REGEXP in the following\n\ - files. {LANGUAGE}/REGEXP/ uses REGEXP for LANGUAGE files only.\n\ - regexfile is a file containing one REGEXP per line.\n\ - REGEXP is anchored (as if preceded by ^).\n\ - The form /REGEXP/NAME/ creates a named tag.\n\ + + if (PRINT_UNDOCUMENTED_OPTIONS_HELP) + puts ("--no-line-directive\n\ + Ignore #line preprocessor directives in C and derived languages."); + + if (CTAGS) + puts ("--members\n\ + Create tag entries for members of structures in some languages."); + else + puts ("--no-members\n\ + Do not create tag entries for members of structures\n\ + in some languages."); + + puts ("-r REGEXP, --regex=REGEXP or --regex=@regexfile\n\ + Make a tag for each line matching a regular expression pattern\n\ + in the following files. {LANGUAGE}REGEXP uses REGEXP for LANGUAGE\n\ + files only. REGEXFILE is a file containing one REGEXP per line.\n\ + REGEXP takes the form /TAGREGEXP/TAGNAME/MODS, where TAGNAME/ is\n\ + optional. The TAGREGEXP pattern is anchored (as if preceded by ^)."); + puts (" If TAGNAME/ is present, the tags created are named.\n\ For example Tcl named tags can be created with:\n\ - --regex=/proc[ \\t]+\\([^ \\t]+\\)/\\1/."); - puts ("-c /REGEXP/, --ignore-case-regex=/REGEXP/ or --ignore-case-regex=@regexfile\n\ - Like -r, --regex but ignore case when matching expressions."); + --regex=\"/proc[ \\t]+\\([^ \\t]+\\)/\\1/.\".\n\ + MODS are optional one-letter modifiers: `i' means to ignore case,\n\ + `m' means to allow multi-line matches, `s' implies `m' and\n\ + causes dot to match any character, including newline."); + puts ("-R, --no-regex\n\ Don't create tags from regexps for the following files."); -#endif /* ETAGS_REGEXPS */ + + puts ("-I, --ignore-indentation\n\ + In C and C++ do not assume that a closing brace in the first\n\ + column is the final brace of a function or structure definition."); + puts ("-o FILE, --output=FILE\n\ Write the tags to FILE."); - puts ("-I, --ignore-indentation\n\ - Don't rely on indentation quite as much as normal. Currently,\n\ - this means not to assume that a closing brace in the first\n\ - column is the final brace of a function or structure\n\ - definition in C and C++."); + + puts ("--parse-stdin=NAME\n\ + Read from standard input and record tags as belonging to file NAME."); if (CTAGS) { @@ -729,20 +1026,33 @@ Relative ones are stored relative to the output file's directory."); puts ("-T, --typedefs-and-c++\n\ Generate tag entries for C typedefs, C struct/enum/union tags,\n\ and C++ member functions."); - puts ("-u, --update\n\ + } + + if (CTAGS) + puts ("-u, --update\n\ Update the tag entries for the given files, leaving tag\n\ entries for other files in place. Currently, this is\n\ implemented by deleting the existing entries for the given\n\ files and then rewriting the new entries at the end of the\n\ tags file. It is often faster to simply rebuild the entire\n\ tag file than to use this."); + + if (CTAGS) + { puts ("-v, --vgrind\n\ - Generates an index of items intended for human consumption,\n\ - similar to the output of vgrind. The index is sorted, and\n\ - gives the page number of each item."); - puts ("-w, --no-warn\n\ - Suppress warning messages about entries defined in multiple\n\ - files."); + Print on the standard output an index of items intended for\n\ + human consumption, similar to the output of vgrind. The index\n\ + is sorted, and gives the page number of each item."); + + if (PRINT_UNDOCUMENTED_OPTIONS_HELP) + puts ("-w, --no-duplicates\n\ + Do not create duplicate tag entries, for compatibility with\n\ + traditional ctags."); + + if (PRINT_UNDOCUMENTED_OPTIONS_HELP) + puts ("-w, --no-warn\n\ + Suppress warning messages about duplicate tag entries."); + puts ("-x, --cxref\n\ Like --vgrind, but in the style of cxref, rather than vgrind.\n\ The output uses line numbers instead of page numbers, but\n\ @@ -753,33 +1063,19 @@ Relative ones are stored relative to the output file's directory."); puts ("-V, --version\n\ Print the version of the program.\n\ -h, --help\n\ - Print this help message."); + Print this help message.\n\ + Followed by one or more `--language' options prints detailed\n\ + help about tag generation for the specified languages."); print_language_names (); puts (""); puts ("Report bugs to bug-gnu-emacs@gnu.org"); - exit (GOOD); + exit (EXIT_SUCCESS); } -enum argument_type -{ - at_language, - at_regexp, - at_filename, - at_icregexp -}; - -/* This structure helps us allow mixing of --lang and file names. */ -typedef struct -{ - enum argument_type arg_type; - char *what; - language *lang; /* language of the regexp */ -} argument; - #ifdef VMS /* VMS specific functions */ #define EOS '\0' @@ -913,13 +1209,16 @@ main (argc, argv) int i; unsigned int nincluded_files; char **included_files; - char *this_file; argument *argbuffer; int current_arg, file_count; linebuffer filename_lb; + bool help_asked = FALSE; #ifdef VMS bool got_err; #endif + char *optstring; + int opt; + #ifdef DOS_NT _fmode = O_BINARY; /* all of files are treated as binary files */ @@ -935,139 +1234,120 @@ main (argc, argv) is small. */ argbuffer = xnew (argc, argument); -#ifdef ETAGS_REGEXPS - /* Set syntax for regular expression routines. */ - re_set_syntax (RE_SYNTAX_EMACS | RE_INTERVALS); - /* Translation table for case-insensitive search. */ - for (i = 0; i < CHAR_SET_SIZE; i++) - lc_trans[i] = lowcase (i); -#endif /* ETAGS_REGEXPS */ - /* * If etags, always find typedefs and structure tags. Why not? - * Also default to find macro constants, enum constants and - * global variables. + * Also default to find macro constants, enum constants, struct + * members and global variables. */ if (!CTAGS) { typedefs = typedefs_or_cplusplus = constantypedefs = TRUE; - globals = TRUE; - declarations = FALSE; - members = FALSE; + globals = members = TRUE; } - while (1) - { - int opt; - char *optstring; + /* When the optstring begins with a '-' getopt_long does not rearrange the + non-options arguments to be at the end, but leaves them alone. */ + optstring = concat (NO_LONG_OPTIONS ? "" : "-", + "ac:Cf:Il:o:r:RSVhH", + (CTAGS) ? "BxdtTuvw" : "Di:"); -#ifdef ETAGS_REGEXPS - optstring = "-aCdDf:Il:o:r:c:RStTi:BuvxwVhH"; -#else - optstring = "-aCdDf:Il:o:StTi:BuvxwVhH"; -#endif /* ETAGS_REGEXPS */ + while ((opt = getopt_long (argc, argv, optstring, longopts, NULL)) != EOF) + switch (opt) + { + case 0: + /* If getopt returns 0, then it has already processed a + long-named option. We should do nothing. */ + break; -#ifndef LONG_OPTIONS - optstring = optstring + 1; -#endif /* LONG_OPTIONS */ + case 1: + /* This means that a file name has been seen. Record it. */ + argbuffer[current_arg].arg_type = at_filename; + argbuffer[current_arg].what = optarg; + ++current_arg; + ++file_count; + break; - opt = getopt_long (argc, argv, optstring, longopts, 0); - if (opt == EOF) + case STDIN: + /* Parse standard input. Idea by Vivek . */ + argbuffer[current_arg].arg_type = at_stdin; + argbuffer[current_arg].what = optarg; + ++current_arg; + ++file_count; + if (parsing_stdin) + fatal ("cannot parse standard input more than once", (char *)NULL); + parsing_stdin = TRUE; break; - switch (opt) + /* Common options. */ + case 'a': append_to_tagfile = TRUE; break; + case 'C': cplusplus = TRUE; break; + case 'f': /* for compatibility with old makefiles */ + case 'o': + if (tagfile) + { + error ("-o option may only be given once.", (char *)NULL); + suggest_asking_for_help (); + /* NOTREACHED */ + } + tagfile = optarg; + break; + case 'I': + case 'S': /* for backward compatibility */ + ignoreindent = TRUE; + break; + case 'l': { - case 0: - /* If getopt returns 0, then it has already processed a - long-named option. We should do nothing. */ - break; - - case 1: - /* This means that a file name has been seen. Record it. */ - argbuffer[current_arg].arg_type = at_filename; - argbuffer[current_arg].what = optarg; - ++current_arg; - ++file_count; - break; - - /* Common options. */ - case 'a': append_to_tagfile = TRUE; break; - case 'C': cplusplus = TRUE; break; - case 'd': constantypedefs = TRUE; break; - case 'D': constantypedefs = FALSE; break; - case 'f': /* for compatibility with old makefiles */ - case 'o': - if (tagfile) + language *lang = get_language_from_langname (optarg); + if (lang != NULL) { - error ("-o option may only be given once.", (char *)NULL); - suggest_asking_for_help (); + argbuffer[current_arg].lang = lang; + argbuffer[current_arg].arg_type = at_language; + ++current_arg; } - tagfile = optarg; - break; - case 'I': - case 'S': /* for backward compatibility */ - noindentypedefs = TRUE; - break; - case 'l': - { - language *lang = get_language_from_langname (optarg); - if (lang != NULL) - { - argbuffer[current_arg].lang = lang; - argbuffer[current_arg].arg_type = at_language; - ++current_arg; - } - } - break; -#ifdef ETAGS_REGEXPS - case 'r': - argbuffer[current_arg].arg_type = at_regexp; - argbuffer[current_arg].what = optarg; - ++current_arg; - break; - case 'R': - argbuffer[current_arg].arg_type = at_regexp; - argbuffer[current_arg].what = NULL; - ++current_arg; - break; - case 'c': - argbuffer[current_arg].arg_type = at_icregexp; - argbuffer[current_arg].what = optarg; - ++current_arg; - break; -#endif /* ETAGS_REGEXPS */ - case 'V': - print_version (); - break; - case 'h': - case 'H': - print_help (); - break; - case 't': - typedefs = TRUE; - break; - case 'T': - typedefs = typedefs_or_cplusplus = TRUE; - break; -#if (!CTAGS) - /* Etags options */ - case 'i': - included_files[nincluded_files++] = optarg; - break; -#else /* CTAGS */ - /* Ctags options. */ - case 'B': searchar = '?'; break; - case 'u': update = TRUE; break; - case 'v': vgrind_style = TRUE; /*FALLTHRU*/ - case 'x': cxref_style = TRUE; break; - case 'w': no_warnings = TRUE; break; -#endif /* CTAGS */ - default: - suggest_asking_for_help (); } - } + break; + case 'c': + /* Backward compatibility: support obsolete --ignore-case-regexp. */ + optarg = concat (optarg, "i", ""); /* memory leak here */ + /* FALLTHRU */ + case 'r': + argbuffer[current_arg].arg_type = at_regexp; + argbuffer[current_arg].what = optarg; + ++current_arg; + break; + case 'R': + argbuffer[current_arg].arg_type = at_regexp; + argbuffer[current_arg].what = NULL; + ++current_arg; + break; + case 'V': + print_version (); + break; + case 'h': + case 'H': + help_asked = TRUE; + break; + + /* Etags options */ + case 'D': constantypedefs = FALSE; break; + case 'i': included_files[nincluded_files++] = optarg; break; + + /* Ctags options. */ + case 'B': searchar = '?'; break; + case 'd': constantypedefs = TRUE; break; + case 't': typedefs = TRUE; break; + case 'T': typedefs = typedefs_or_cplusplus = TRUE; break; + case 'u': update = TRUE; break; + case 'v': vgrind_style = TRUE; /*FALLTHRU*/ + case 'x': cxref_style = TRUE; break; + case 'w': no_warnings = TRUE; break; + default: + suggest_asking_for_help (); + /* NOTREACHED */ + } - for (; optind < argc; ++optind) + /* No more options. Store the rest of arguments. */ + for (; optind < argc; optind++) { argbuffer[current_arg].arg_type = at_filename; argbuffer[current_arg].what = argv[optind]; @@ -1075,10 +1355,17 @@ main (argc, argv) ++file_count; } + argbuffer[current_arg].arg_type = at_end; + + if (help_asked) + print_help (argbuffer); + /* NOTREACHED */ + if (nincluded_files == 0 && file_count == 0) { error ("no input files specified.", (char *)NULL); suggest_asking_for_help (); + /* NOTREACHED */ } if (tagfile == NULL) @@ -1090,15 +1377,19 @@ main (argc, argv) cwd = concat (oldcwd, "/", ""); free (oldcwd); } - if (streq (tagfile, "-")) + /* Relative file names are made relative to the current directory. */ + if (streq (tagfile, "-") + || strneq (tagfile, "/dev/", 5)) tagfiledir = cwd; else tagfiledir = absolute_dirname (tagfile, cwd); init (); /* set up boolean "functions" */ - initbuffer (&lb); - initbuffer (&filename_lb); + linebuffer_init (&lb); + linebuffer_init (&filename_lb); + linebuffer_init (&filebuf); + linebuffer_init (&token_name); if (!CTAGS) { @@ -1121,21 +1412,19 @@ main (argc, argv) /* * Loop through files finding functions. */ - for (i = 0; i < current_arg; ++i) + for (i = 0; i < current_arg; i++) { + static language *lang; /* non-NULL if language is forced */ + char *this_file; + switch (argbuffer[i].arg_type) { case at_language: - forced_lang = argbuffer[i].lang; + lang = argbuffer[i].lang; break; -#ifdef ETAGS_REGEXPS case at_regexp: - analyse_regex (argbuffer[i].what, FALSE); + analyse_regex (argbuffer[i].what); break; - case at_icregexp: - analyse_regex (argbuffer[i].what, TRUE); - break; -#endif case at_filename: #ifdef VMS while ((this_file = gfnames (argbuffer[i].what, &got_err)) != NULL) @@ -1155,38 +1444,54 @@ main (argc, argv) /* Input file named "-" means read file names from stdin (one per line) and use them. */ if (streq (this_file, "-")) - while (readline_internal (&filename_lb, stdin) > 0) - process_file (filename_lb.buffer); + { + if (parsing_stdin) + fatal ("cannot parse standard input AND read file names from it", + (char *)NULL); + while (readline_internal (&filename_lb, stdin) > 0) + process_file_name (filename_lb.buffer, lang); + } else - process_file (this_file); + process_file_name (this_file, lang); #ifdef VMS } #endif break; + case at_stdin: + this_file = argbuffer[i].what; + process_file (stdin, this_file, lang); + break; } } -#ifdef ETAGS_REGEXPS - free_patterns (); -#endif /* ETAGS_REGEXPS */ + free_regexps (); + free (lb.buffer); + free (filebuf.buffer); + free (token_name.buffer); - if (!CTAGS) + if (!CTAGS || cxref_style) { - while (nincluded_files-- > 0) - fprintf (tagf, "\f\n%s,include\n", *included_files++); + /* Write the remaining tags to tagf (ETAGS) or stdout (CXREF). */ + put_entries (nodehead); + free_tree (nodehead); + nodehead = NULL; + if (!CTAGS) + { + fdesc *fdp; - fclose (tagf); - exit (GOOD); - } + /* Output file entries that have no tags. */ + for (fdp = fdhead; fdp != NULL; fdp = fdp->next) + if (!fdp->written) + fprintf (tagf, "\f\n%s,0\n", fdp->taggedfname); - /* If CTAGS, we are here. process_file did not write the tags yet, - because we want them ordered. Let's do it now. */ - if (cxref_style) - { - put_entries (head); - free_tree (head); - head = NULL; - exit (GOOD); + while (nincluded_files-- > 0) + fprintf (tagf, "\f\n%s,include\n", *included_files++); + + if (fclose (tagf) == EOF) + pfatal (tagfile); + } + + exit (EXIT_SUCCESS); } if (update) @@ -1194,12 +1499,18 @@ main (argc, argv) char cmd[BUFSIZ]; for (i = 0; i < current_arg; ++i) { - if (argbuffer[i].arg_type != at_filename) - continue; + switch (argbuffer[i].arg_type) + { + case at_filename: + case at_stdin: + break; + default: + continue; /* the for loop */ + } sprintf (cmd, "mv %s OTAGS;fgrep -v '\t%s\t' OTAGS >%s;rm OTAGS", tagfile, argbuffer[i].what, tagfile); - if (system (cmd) != GOOD) + if (system (cmd) != EXIT_SUCCESS) fatal ("failed to execute shell command", (char *)NULL); } append_to_tagfile = TRUE; @@ -1208,22 +1519,26 @@ main (argc, argv) tagf = fopen (tagfile, append_to_tagfile ? "a" : "w"); if (tagf == NULL) pfatal (tagfile); - put_entries (head); - free_tree (head); - head = NULL; - fclose (tagf); + put_entries (nodehead); /* write all the tags (CTAGS) */ + free_tree (nodehead); + nodehead = NULL; + if (fclose (tagf) == EOF) + pfatal (tagfile); - if (update) - { - char cmd[BUFSIZ]; - sprintf (cmd, "sort %s -o %s", tagfile, tagfile); - exit (system (cmd)); - } - return GOOD; + if (CTAGS) + if (append_to_tagfile || update) + { + char cmd[2*BUFSIZ+20]; + /* Maybe these should be used: + setenv ("LC_COLLATE", "C", 1); + setenv ("LC_ALL", "C", 1); */ + sprintf (cmd, "sort -u -o %.*s %.*s", BUFSIZ, tagfile, BUFSIZ, tagfile); + exit (system (cmd)); + } + return EXIT_SUCCESS; } - /* * Return a compressor given the file name. If EXTPTR is non-zero, * return a pointer into FILE where the compressor-specific @@ -1271,7 +1586,7 @@ get_compressor_from_suffix (file, extptr) */ static language * get_language_from_langname (name) - char *name; + const char *name; { language *lang; @@ -1316,8 +1631,9 @@ get_language_from_interpreter (interpreter) * Return a language given the file name. */ static language * -get_language_from_filename (file) +get_language_from_filename (file, case_sensitive) char *file; + bool case_sensitive; { language *lang; char **name, **ext, *suffix; @@ -1326,7 +1642,9 @@ get_language_from_filename (file) for (lang = lang_names; lang->name != NULL; lang++) if (lang->filenames != NULL) for (name = lang->filenames; *name != NULL; name++) - if (streq (*name, file)) + if ((case_sensitive) + ? streq (*name, file) + : strcaseeq (*name, file)) return lang; /* If not found, try suffix after last dot. */ @@ -1337,26 +1655,29 @@ get_language_from_filename (file) for (lang = lang_names; lang->name != NULL; lang++) if (lang->suffixes != NULL) for (ext = lang->suffixes; *ext != NULL; ext++) - if (streq (*ext, suffix)) + if ((case_sensitive) + ? streq (*ext, suffix) + : strcaseeq (*ext, suffix)) return lang; return NULL; } - - + /* * This routine is called on each file argument. */ static void -process_file (file) +process_file_name (file, lang) char *file; + language *lang; { struct stat stat_buf; FILE *inf; + fdesc *fdp; compressor *compr; char *compressed_name, *uncompressed_name; char *ext, *real_name; - + int retval; canonicalize_filename (file); if (streq (file, tagfile) && !streq (tagfile, "-")) @@ -1375,25 +1696,14 @@ process_file (file) uncompressed_name = savenstr (file, ext - file); } - /* If the canonicalised uncompressed name has already be dealt with, - skip it silently, else add it to the list. */ - { - typedef struct processed_file + /* If the canonicalized uncompressed name + has already been dealt with, skip it silently. */ + for (fdp = fdhead; fdp != NULL; fdp = fdp->next) { - char *filename; - struct processed_file *next; - } processed_file; - static processed_file *pf_head = NULL; - register processed_file *fnp; - - for (fnp = pf_head; fnp != NULL; fnp = fnp->next) - if (streq (uncompressed_name, fnp->filename)) - goto exit; - fnp = pf_head; - pf_head = xnew (1, struct processed_file); - pf_head->filename = savestr (uncompressed_name); - pf_head->next = fnp; - } + assert (fdp->infname != NULL); + if (streq (uncompressed_name, fdp->infname)) + goto cleanup; + } if (stat (real_name, &stat_buf) != 0) { @@ -1440,14 +1750,14 @@ process_file (file) if (real_name == NULL) { perror (file); - goto exit; + goto cleanup; } } /* try with a different name */ if (!S_ISREG (stat_buf.st_mode)) { error ("skipping %s: it is not a regular file.", real_name); - goto exit; + goto cleanup; } if (real_name == compressed_name) { @@ -1460,42 +1770,96 @@ process_file (file) if (inf == NULL) { perror (real_name); - goto exit; + goto cleanup; } - find_entries (uncompressed_name, inf); + process_file (inf, uncompressed_name, lang); if (real_name == compressed_name) - pclose (inf); + retval = pclose (inf); else - fclose (inf); + retval = fclose (inf); + if (retval < 0) + pfatal (file); + + cleanup: + if (compressed_name) free (compressed_name); + if (uncompressed_name) free (uncompressed_name); + last_node = NULL; + curfdp = NULL; + return; +} - if (!CTAGS) +static void +process_file (fh, fn, lang) + FILE *fh; + char *fn; + language *lang; +{ + static const fdesc emptyfdesc; + fdesc *fdp; + + /* Create a new input file description entry. */ + fdp = xnew (1, fdesc); + *fdp = emptyfdesc; + fdp->next = fdhead; + fdp->infname = savestr (fn); + fdp->lang = lang; + fdp->infabsname = absolute_filename (fn, cwd); + fdp->infabsdir = absolute_dirname (fn, cwd); + if (filename_is_absolute (fn)) + { + /* An absolute file name. Canonicalize it. */ + fdp->taggedfname = absolute_filename (fn, NULL); + } + else { - char *filename; + /* A file name relative to cwd. Make it relative + to the directory of the tags file. */ + fdp->taggedfname = relative_filename (fn, tagfiledir); + } + fdp->usecharno = TRUE; /* use char position when making tags */ + fdp->prop = NULL; + fdp->written = FALSE; /* not written on tags file yet */ - if (filename_is_absolute (uncompressed_name)) - { - /* file is an absolute file name. Canonicalise it. */ - filename = absolute_filename (uncompressed_name, cwd); - } - else + fdhead = fdp; + curfdp = fdhead; /* the current file description */ + + find_entries (fh); + + /* If not Ctags, and if this is not metasource and if it contained no #line + directives, we can write the tags and free all nodes pointing to + curfdp. */ + if (!CTAGS + && curfdp->usecharno /* no #line directives in this file */ + && !curfdp->lang->metasource) + { + node *np, *prev; + + /* Look for the head of the sublist relative to this file. See add_node + for the structure of the node tree. */ + prev = NULL; + for (np = nodehead; np != NULL; prev = np, np = np->left) + if (np->fdp == curfdp) + break; + + /* If we generated tags for this file, write and delete them. */ + if (np != NULL) { - /* file is a file name relative to cwd. Make it relative - to the directory of the tags file. */ - filename = relative_filename (uncompressed_name, tagfiledir); + /* This is the head of the last sublist, if any. The following + instructions depend on this being true. */ + assert (np->left == NULL); + + assert (fdhead == curfdp); + assert (last_node->fdp == curfdp); + put_entries (np); /* write tags for file curfdp->taggedfname */ + free_tree (np); /* remove the written nodes */ + if (prev == NULL) + nodehead = NULL; /* no nodes left */ + else + prev->left = NULL; /* delete the pointer to the sublist */ } - fprintf (tagf, "\f\n%s,%d\n", filename, total_size_of_entries (head)); - free (filename); - put_entries (head); - free_tree (head); - head = NULL; } - - exit: - if (compressed_name) free(compressed_name); - if (uncompressed_name) free(uncompressed_name); - return; } /* @@ -1529,44 +1893,34 @@ init () * This routine opens the specified file and calls the function * which finds the function and type definitions. */ -node *last_node = NULL; - static void -find_entries (file, inf) - char *file; +find_entries (inf) FILE *inf; { char *cp; - language *lang; - node *old_last_node; - - /* Memory leakage here: the string pointed by curfile is - never released, because curfile is copied into np->file - for each node, to be used in CTAGS mode. The amount of - memory leaked here is the sum of the lengths of the - file names. */ - curfile = savestr (file); + language *lang = curfdp->lang; + Lang_function *parser = NULL; /* If user specified a language, use it. */ - lang = forced_lang; if (lang != NULL && lang->function != NULL) { - curlang = lang; - lang->function (inf); - return; + parser = lang->function; } - /* Try to guess the language given the file name. */ - lang = get_language_from_filename (file); - if (lang != NULL && lang->function != NULL) + /* Else try to guess the language given the file name. */ + if (parser == NULL) { - curlang = lang; - lang->function (inf); - return; + lang = get_language_from_filename (curfdp->infname, TRUE); + if (lang != NULL && lang->function != NULL) + { + curfdp->lang = lang; + parser = lang->function; + } } - /* Look for sharp-bang as the first two characters. */ - if (readline_internal (&lb, inf) > 0 + /* Else look for sharp-bang as the first two characters. */ + if (parser == NULL + && readline_internal (&lb, inf) > 0 && lb.len >= 2 && lb.buffer[0] == '#' && lb.buffer[1] == '!') @@ -1589,141 +1943,212 @@ find_entries (file, inf) lang = get_language_from_interpreter (lp); if (lang != NULL && lang->function != NULL) { - curlang = lang; - lang->function (inf); - return; + curfdp->lang = lang; + parser = lang->function; } } } + /* We rewind here, even if inf may be a pipe. We fail if the length of the first line is longer than the pipe block size, which is unlikely. */ rewind (inf); - /* Try Fortran. */ - old_last_node = last_node; - curlang = get_language_from_langname ("fortran"); - Fortran_functions (inf); + /* Else try to guess the language given the case insensitive file name. */ + if (parser == NULL) + { + lang = get_language_from_filename (curfdp->infname, FALSE); + if (lang != NULL && lang->function != NULL) + { + curfdp->lang = lang; + parser = lang->function; + } + } + + /* Else try Fortran or C. */ + if (parser == NULL) + { + node *old_last_node = last_node; + + curfdp->lang = get_language_from_langname ("fortran"); + find_entries (inf); + + if (old_last_node == last_node) + /* No Fortran entries found. Try C. */ + { + /* We do not tag if rewind fails. + Only the file name will be recorded in the tags file. */ + rewind (inf); + curfdp->lang = get_language_from_langname (cplusplus ? "c++" : "c"); + find_entries (inf); + } + return; + } - /* No Fortran entries found. Try C. */ - if (old_last_node == last_node) + if (!no_line_directive + && curfdp->lang != NULL && curfdp->lang->metasource) + /* It may be that this is a bingo.y file, and we already parsed a bingo.c + file, or anyway we parsed a file that is automatically generated from + this one. If this is the case, the bingo.c file contained #line + directives that generated tags pointing to this file. Let's delete + them all before parsing this file, which is the real source. */ { - /* We do not tag if rewind fails. - Only the file name will be recorded in the tags file. */ - rewind (inf); - curlang = get_language_from_langname (cplusplus ? "c++" : "c"); - default_C_entries (inf); + fdesc **fdpp = &fdhead; + while (*fdpp != NULL) + if (*fdpp != curfdp + && streq ((*fdpp)->taggedfname, curfdp->taggedfname)) + /* We found one of those! We must delete both the file description + and all tags referring to it. */ + { + fdesc *badfdp = *fdpp; + + /* Delete the tags referring to badfdp->taggedfname + that were obtained from badfdp->infname. */ + invalidate_nodes (badfdp, &nodehead); + + *fdpp = badfdp->next; /* remove the bad description from the list */ + free_fdesc (badfdp); + } + else + fdpp = &(*fdpp)->next; /* advance the list pointer */ } - return; + + assert (parser != NULL); + + /* Generic initialisations before reading from file. */ + linebuffer_setlen (&filebuf, 0); /* reset the file buffer */ + + /* Generic initialisations before parsing file with readline. */ + lineno = 0; /* reset global line number */ + charno = 0; /* reset global char number */ + linecharno = 0; /* reset global char number of line start */ + + parser (inf); + + regex_tag_multiline (); } -/* Record a tag. */ +/* + * Check whether an implicitly named tag should be created, + * then call `pfnote'. + * NAME is a string that is internally copied by this function. + * + * TAGS format specification + * Idea by Sam Kendall (1997) + * The following is explained in some more detail in etc/ETAGS.EBNF. + * + * make_tag creates tags with "implicit tag names" (unnamed tags) + * if the following are all true, assuming NONAM=" \f\t\n\r()=,;": + * 1. NAME does not contain any of the characters in NONAM; + * 2. LINESTART contains name as either a rightmost, or rightmost but + * one character, substring; + * 3. the character, if any, immediately before NAME in LINESTART must + * be a character in NONAM; + * 4. the character, if any, immediately after NAME in LINESTART must + * also be a character in NONAM. + * + * The implementation uses the notinname() macro, which recognises the + * characters stored in the string `nonam'. + * etags.el needs to use the same characters that are in NONAM. + */ static void -pfnote (name, is_func, linestart, linelen, lno, cno) +make_tag (name, namelen, is_func, linestart, linelen, lno, cno) char *name; /* tag name, or NULL if unnamed */ + int namelen; /* tag length */ bool is_func; /* tag is a function */ char *linestart; /* start of the line where tag is */ int linelen; /* length of the line where tag is */ int lno; /* line number */ long cno; /* character number */ { - register node *np; + bool named = (name != NULL && namelen > 0); - if (CTAGS && name == NULL) - return; + if (!CTAGS && named) /* maybe set named to false */ + /* Let's try to make an implicit tag name, that is, create an unnamed tag + such that etags.el can guess a name from it. */ + { + int i; + register char *cp = name; - np = xnew (1, node); + for (i = 0; i < namelen; i++) + if (notinname (*cp++)) + break; + if (i == namelen) /* rule #1 */ + { + cp = linestart + linelen - namelen; + if (notinname (linestart[linelen-1])) + cp -= 1; /* rule #4 */ + if (cp >= linestart /* rule #2 */ + && (cp == linestart + || notinname (cp[-1])) /* rule #3 */ + && strneq (name, cp, namelen)) /* rule #2 */ + named = FALSE; /* use implicit tag name */ + } + } + + if (named) + name = savenstr (name, namelen); + else + name = NULL; + pfnote (name, is_func, linestart, linelen, lno, cno); +} + +/* Record a tag. */ +static void +pfnote (name, is_func, linestart, linelen, lno, cno) + char *name; /* tag name, or NULL if unnamed */ + bool is_func; /* tag is a function */ + char *linestart; /* start of the line where tag is */ + int linelen; /* length of the line where tag is */ + int lno; /* line number */ + long cno; /* character number */ +{ + register node *np; + + assert (name == NULL || name[0] != '\0'); + if (CTAGS && name == NULL) + return; + + np = xnew (1, node); /* If ctags mode, change name "main" to M. */ if (CTAGS && !cxref_style && streq (name, "main")) { - register char *fp = etags_strrchr (curfile, '/'); - np->name = concat ("M", fp == NULL ? curfile : fp + 1, ""); + register char *fp = etags_strrchr (curfdp->taggedfname, '/'); + np->name = concat ("M", fp == NULL ? curfdp->taggedfname : fp + 1, ""); fp = etags_strrchr (np->name, '.'); if (fp != NULL && fp[1] != '\0' && fp[2] == '\0') fp[0] = '\0'; } else np->name = name; + np->valid = TRUE; np->been_warned = FALSE; - np->file = curfile; + np->fdp = curfdp; np->is_func = is_func; np->lno = lno; - /* Our char numbers are 0-base, because of C language tradition? - ctags compatibility? old versions compatibility? I don't know. - Anyway, since emacs's are 1-base we expect etags.el to take care - of the difference. If we wanted to have 1-based numbers, we would - uncomment the +1 below. */ - np->cno = cno /* + 1 */ ; + if (np->fdp->usecharno) + /* Our char numbers are 0-base, because of C language tradition? + ctags compatibility? old versions compatibility? I don't know. + Anyway, since emacs's are 1-base we expect etags.el to take care + of the difference. If we wanted to have 1-based numbers, we would + uncomment the +1 below. */ + np->cno = cno /* + 1 */ ; + else + np->cno = invalidcharno; np->left = np->right = NULL; if (CTAGS && !cxref_style) { if (strlen (linestart) < 50) - np->pat = concat (linestart, "$", ""); + np->regex = concat (linestart, "$", ""); else - np->pat = savenstr (linestart, 50); + np->regex = savenstr (linestart, 50); } else - np->pat = savenstr (linestart, linelen); + np->regex = savenstr (linestart, linelen); - add_node (np, &head); -} - -/* - * TAGS format specification - * Idea by Sam Kendall (1997) - * - * pfnote should emit the optimized form [unnamed tag] only if: - * 1. name does not contain any of the characters " \t\r\n(),;"; - * 2. linestart contains name as either a rightmost, or rightmost but - * one character, substring; - * 3. the character, if any, immediately before name in linestart must - * be one of the characters " \t(),;"; - * 4. the character, if any, immediately after name in linestart must - * also be one of the characters " \t(),;". - * - * The real implementation uses the notinname() macro, which recognises - * characters slightly different form " \t\r\n(),;". See the variable - * `nonam'. - */ -#define traditional_tag_style TRUE -static void -new_pfnote (name, namelen, is_func, linestart, linelen, lno, cno) - char *name; /* tag name, or NULL if unnamed */ - int namelen; /* tag length */ - bool is_func; /* tag is a function */ - char *linestart; /* start of the line where tag is */ - int linelen; /* length of the line where tag is */ - int lno; /* line number */ - long cno; /* character number */ -{ - register char *cp; - bool named; - - named = TRUE; - if (!CTAGS) - { - for (cp = name; !notinname (*cp); cp++) - continue; - if (*cp == '\0') /* rule #1 */ - { - cp = linestart + linelen - namelen; - if (notinname (linestart[linelen-1])) - cp -= 1; /* rule #4 */ - if (cp >= linestart /* rule #2 */ - && (cp == linestart - || notinname (cp[-1])) /* rule #3 */ - && strneq (name, cp, namelen)) /* rule #2 */ - named = FALSE; /* use unnamed tag */ - } - } - - if (named) - name = savenstr (name, namelen); - else - name = NULL; - pfnote (name, is_func, linestart, linelen, lno, cno); + add_node (np, &nodehead); } /* @@ -1740,17 +2165,33 @@ free_tree (np) free_tree (np->left); if (np->name != NULL) free (np->name); - free (np->pat); + free (np->regex); free (np); np = node_right; } } /* + * free_fdesc () + * delete a file description + */ +static void +free_fdesc (fdp) + register fdesc *fdp; +{ + if (fdp->infname != NULL) free (fdp->infname); + if (fdp->infabsname != NULL) free (fdp->infabsname); + if (fdp->infabsdir != NULL) free (fdp->infabsdir); + if (fdp->taggedfname != NULL) free (fdp->taggedfname); + if (fdp->prop != NULL) free (fdp->prop); + free (fdp); +} + +/* * add_node () - * Adds a node to the tree of nodes. In etags mode, we don't keep - * it sorted; we just keep a linear list. In ctags mode, maintain - * an ordered tree, with no attempt at balancing. + * Adds a node to the tree of nodes. In etags mode, sort by file + * name. In ctags mode, sort by tag name. Make no attempt at + * balancing. * * add_node is the only function allowed to add nodes, so it can * maintain state. @@ -1770,13 +2211,31 @@ add_node (np, cur_node_p) } if (!CTAGS) + /* Etags Mode */ { - /* Etags Mode */ - if (last_node == NULL) - fatal ("internal error in add_node", (char *)NULL); - last_node->right = np; - last_node = np; - } + /* For each file name, tags are in a linked sublist on the right + pointer. The first tags of different files are a linked list + on the left pointer. last_node points to the end of the last + used sublist. */ + if (last_node != NULL && last_node->fdp == np->fdp) + { + /* Let's use the same sublist as the last added node. */ + assert (last_node->right == NULL); + last_node->right = np; + last_node = np; + } + else if (cur_node->fdp == np->fdp) + { + /* Scanning the list we found the head of a sublist which is + good for us. Let's scan this sublist. */ + add_node (np, &cur_node->right); + } + else + /* The head of this sublist is not good for us. Let's try the + next one. */ + add_node (np, &cur_node->left); + } /* if ETAGS mode */ + else { /* Ctags Mode */ @@ -1786,14 +2245,14 @@ add_node (np, cur_node_p) * If this tag name matches an existing one, then * do not add the node, but maybe print a warning. */ - if (!dif) + if (no_duplicates && !dif) { - if (streq (np->file, cur_node->file)) + if (np->fdp == cur_node->fdp) { if (!no_warnings) { fprintf (stderr, "Duplicate entry in file %s, line %d: %s\n", - np->file, lineno, np->name); + np->fdp->infname, lineno, np->name); fprintf (stderr, "Second entry ignored\n"); } } @@ -1802,7 +2261,7 @@ add_node (np, cur_node_p) fprintf (stderr, "Duplicate entry in files %s and %s: %s (Warning only)\n", - np->file, cur_node->file, np->name); + np->fdp->infname, cur_node->fdp->infname, np->name); cur_node->been_warned = TRUE; } return; @@ -1810,77 +2269,53 @@ add_node (np, cur_node_p) /* Actually add the node */ add_node (np, dif < 0 ? &cur_node->left : &cur_node->right); - } + } /* if CTAGS mode */ } - +/* + * invalidate_nodes () + * Scan the node tree and invalidate all nodes pointing to the + * given file description (CTAGS case) or free them (ETAGS case). + */ static void -put_entries (np) - register node *np; +invalidate_nodes (badfdp, npp) + fdesc *badfdp; + node **npp; { - register char *sp; + node *np = *npp; if (np == NULL) return; - /* Output subentries that precede this one */ - put_entries (np->left); - - /* Output this entry */ - - if (!CTAGS) + if (CTAGS) { - if (np->name != NULL) - fprintf (tagf, "%s\177%s\001%d,%ld\n", - np->pat, np->name, np->lno, np->cno); - else - fprintf (tagf, "%s\177%d,%ld\n", - np->pat, np->lno, np->cno); + if (np->left != NULL) + invalidate_nodes (badfdp, &np->left); + if (np->fdp == badfdp) + np->valid = FALSE; + if (np->right != NULL) + invalidate_nodes (badfdp, &np->right); } else { - if (np->name == NULL) - error ("internal error: NULL name in ctags mode.", (char *)NULL); - - if (cxref_style) + assert (np->fdp != NULL); + if (np->fdp == badfdp) { - if (vgrind_style) - fprintf (stdout, "%s %s %d\n", - np->name, np->file, (np->lno + 63) / 64); - else - fprintf (stdout, "%-16s %3d %-16s %s\n", - np->name, np->lno, np->file, np->pat); + *npp = np->left; /* detach the sublist from the list */ + np->left = NULL; /* isolate it */ + free_tree (np); /* free it */ + invalidate_nodes (badfdp, npp); } else - { - fprintf (tagf, "%s\t%s\t", np->name, np->file); - - if (np->is_func) - { /* a function */ - putc (searchar, tagf); - putc ('^', tagf); - - for (sp = np->pat; *sp; sp++) - { - if (*sp == '\\' || *sp == searchar) - putc ('\\', tagf); - putc (*sp, tagf); - } - putc (searchar, tagf); - } - else - { /* a typedef; text pattern inadequate */ - fprintf (tagf, "%d", np->lno); - } - putc ('\n', tagf); - } + invalidate_nodes (badfdp, &np->left); } - - /* Output subentries that follow this one */ - put_entries (np->right); } -/* Length of a number's decimal representation. */ + +static int total_size_of_entries __P((node *)); +static int number_len __P((long)); + +/* Length of a non-negative number's decimal representation. */ static int number_len (num) long num; @@ -1893,33 +2328,115 @@ number_len (num) /* * Return total number of characters that put_entries will output for - * the nodes in the subtree of the specified node. Works only if - * we are not ctags, but called only in that case. This count - * is irrelevant with the new tags.el, but is still supplied for - * backward compatibility. + * the nodes in the linked list at the right of the specified node. + * This count is irrelevant with etags.el since emacs 19.34 at least, + * but is still supplied for backward compatibility. */ static int total_size_of_entries (np) register node *np; { - register int total; + register int total = 0; + + for (; np != NULL; np = np->right) + if (np->valid) + { + total += strlen (np->regex) + 1; /* pat\177 */ + if (np->name != NULL) + total += strlen (np->name) + 1; /* name\001 */ + total += number_len ((long) np->lno) + 1; /* lno, */ + if (np->cno != invalidcharno) /* cno */ + total += number_len (np->cno); + total += 1; /* newline */ + } + + return total; +} + +static void +put_entries (np) + register node *np; +{ + register char *sp; + static fdesc *fdp = NULL; if (np == NULL) - return 0; + return; + + /* Output subentries that precede this one */ + if (CTAGS) + put_entries (np->left); - for (total = 0; np != NULL; np = np->right) + /* Output this entry */ + if (np->valid) { - /* Count left subentries. */ - total += total_size_of_entries (np->left); + if (!CTAGS) + { + /* Etags mode */ + if (fdp != np->fdp) + { + fdp = np->fdp; + fprintf (tagf, "\f\n%s,%d\n", + fdp->taggedfname, total_size_of_entries (np)); + fdp->written = TRUE; + } + fputs (np->regex, tagf); + fputc ('\177', tagf); + if (np->name != NULL) + { + fputs (np->name, tagf); + fputc ('\001', tagf); + } + fprintf (tagf, "%d,", np->lno); + if (np->cno != invalidcharno) + fprintf (tagf, "%ld", np->cno); + fputs ("\n", tagf); + } + else + { + /* Ctags mode */ + if (np->name == NULL) + error ("internal error: NULL name in ctags mode.", (char *)NULL); - /* Count this entry */ - total += strlen (np->pat) + 1; - total += number_len ((long) np->lno) + 1 + number_len (np->cno) + 1; - if (np->name != NULL) - total += 1 + strlen (np->name); /* \001name */ - } + if (cxref_style) + { + if (vgrind_style) + fprintf (stdout, "%s %s %d\n", + np->name, np->fdp->taggedfname, (np->lno + 63) / 64); + else + fprintf (stdout, "%-16s %3d %-16s %s\n", + np->name, np->lno, np->fdp->taggedfname, np->regex); + } + else + { + fprintf (tagf, "%s\t%s\t", np->name, np->fdp->taggedfname); - return total; + if (np->is_func) + { /* function or #define macro with args */ + putc (searchar, tagf); + putc ('^', tagf); + + for (sp = np->regex; *sp; sp++) + { + if (*sp == '\\' || *sp == searchar) + putc ('\\', tagf); + putc (*sp, tagf); + } + putc (searchar, tagf); + } + else + { /* anything else; text pattern inadequate */ + fprintf (tagf, "%d", np->lno); + } + putc ('\n', tagf); + } + } + } /* if this node contains a valid tag */ + + /* Output subentries that follow this one */ + put_entries (np->right); + if (!CTAGS) + put_entries (np->left); } @@ -1940,91 +2457,80 @@ enum sym_type st_none, st_C_objprot, st_C_objimpl, st_C_objend, st_C_gnumacro, - st_C_ignore, + st_C_ignore, st_C_attribute, st_C_javastruct, st_C_operator, - st_C_class, - st_C_struct, st_C_extern, st_C_enum, st_C_define, st_C_typedef, st_C_typespec + st_C_class, st_C_template, + st_C_struct, st_C_extern, st_C_enum, st_C_define, st_C_typedef }; -static unsigned int hash P_((const char *, unsigned int)); -static struct C_stab_entry * in_word_set P_((const char *, unsigned int)); -static enum sym_type C_symtype P_((char *, int, int)); +static unsigned int hash __P((const char *, unsigned int)); +static struct C_stab_entry * in_word_set __P((const char *, unsigned int)); +static enum sym_type C_symtype __P((char *, int, int)); /* Feed stuff between (but not including) %[ and %] lines to: - gperf -c -k 1,3 -o -p -r -t - then put a `static' keyword in front of the in_word_set function. + gperf -m 5 %[ +%compare-strncmp +%enum +%struct-type struct C_stab_entry { char *name; int c_ext; enum sym_type type; } %% -if, 0, st_C_ignore -for, 0, st_C_ignore -while, 0, st_C_ignore -switch, 0, st_C_ignore -return, 0, st_C_ignore -@interface, 0, st_C_objprot -@protocol, 0, st_C_objprot -@implementation,0, st_C_objimpl -@end, 0, st_C_objend -import, C_JAVA, st_C_ignore -package, C_JAVA, st_C_ignore -friend, C_PLPL, st_C_ignore -extends, C_JAVA, st_C_javastruct -implements, C_JAVA, st_C_javastruct -interface, C_JAVA, st_C_struct -class, 0, st_C_class -namespace, C_PLPL, st_C_struct -domain, C_STAR, st_C_struct -union, 0, st_C_struct -struct, 0, st_C_struct -extern, 0, st_C_extern -enum, 0, st_C_enum -typedef, 0, st_C_typedef -define, 0, st_C_define -operator, C_PLPL, st_C_operator -bool, C_PLPL, st_C_typespec -long, 0, st_C_typespec -short, 0, st_C_typespec -int, 0, st_C_typespec -char, 0, st_C_typespec -float, 0, st_C_typespec -double, 0, st_C_typespec -signed, 0, st_C_typespec -unsigned, 0, st_C_typespec -auto, 0, st_C_typespec -void, 0, st_C_typespec -static, 0, st_C_typespec -const, 0, st_C_typespec -volatile, 0, st_C_typespec -explicit, C_PLPL, st_C_typespec -mutable, C_PLPL, st_C_typespec -typename, C_PLPL, st_C_typespec +if, 0, st_C_ignore +for, 0, st_C_ignore +while, 0, st_C_ignore +switch, 0, st_C_ignore +return, 0, st_C_ignore +__attribute__, 0, st_C_attribute +@interface, 0, st_C_objprot +@protocol, 0, st_C_objprot +@implementation,0, st_C_objimpl +@end, 0, st_C_objend +import, (C_JAVA & ~C_PLPL), st_C_ignore +package, (C_JAVA & ~C_PLPL), st_C_ignore +friend, C_PLPL, st_C_ignore +extends, (C_JAVA & ~C_PLPL), st_C_javastruct +implements, (C_JAVA & ~C_PLPL), st_C_javastruct +interface, (C_JAVA & ~C_PLPL), st_C_struct +class, 0, st_C_class +namespace, C_PLPL, st_C_struct +domain, C_STAR, st_C_struct +union, 0, st_C_struct +struct, 0, st_C_struct +extern, 0, st_C_extern +enum, 0, st_C_enum +typedef, 0, st_C_typedef +define, 0, st_C_define +undef, 0, st_C_define +operator, C_PLPL, st_C_operator +template, 0, st_C_template # DEFUN used in emacs, the next three used in glibc (SYSCALL only for mach). -DEFUN, 0, st_C_gnumacro -SYSCALL, 0, st_C_gnumacro -ENTRY, 0, st_C_gnumacro -PSEUDO, 0, st_C_gnumacro +DEFUN, 0, st_C_gnumacro +SYSCALL, 0, st_C_gnumacro +ENTRY, 0, st_C_gnumacro +PSEUDO, 0, st_C_gnumacro # These are defined inside C functions, so currently they are not met. # EXFUN used in glibc, DEFVAR_* in emacs. -#EXFUN, 0, st_C_gnumacro -#DEFVAR_, 0, st_C_gnumacro +#EXFUN, 0, st_C_gnumacro +#DEFVAR_, 0, st_C_gnumacro %] -and replace lines between %< and %> with its output, -then make in_word_set static. */ +and replace lines between %< and %> with its output, then: + - remove the #if characterset check + - make in_word_set static and not inline. */ /*%<*/ -/* C code produced by gperf version 2.7.1 (19981006 egcs) */ -/* Command-line: gperf -c -k 1,3 -o -p -r -t */ -struct C_stab_entry { char *name; int c_ext; enum sym_type type; }; +/* C code produced by gperf version 3.0.1 */ +/* Command-line: gperf -m 5 */ +/* Computed positions: -k'2-3' */ -#define TOTAL_KEYWORDS 46 -#define MIN_WORD_LENGTH 2 -#define MAX_WORD_LENGTH 15 -#define MIN_HASH_VALUE 13 -#define MAX_HASH_VALUE 121 -/* maximum key range = 109, duplicates = 0 */ +struct C_stab_entry { char *name; int c_ext; enum sym_type type; }; +/* maximum key range = 33, duplicates = 0 */ #ifdef __GNUC__ __inline +#else +#ifdef __cplusplus +inline +#endif #endif static unsigned int hash (str, len) @@ -2033,130 +2539,97 @@ hash (str, len) { static unsigned char asso_values[] = { - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 57, 122, 122, 122, 55, 6, - 60, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 51, 122, 122, 10, 2, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 2, 52, 59, - 49, 38, 56, 41, 122, 22, 122, 122, 9, 32, - 33, 60, 26, 122, 1, 28, 46, 59, 44, 51, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122 + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 15, + 14, 35, 35, 35, 35, 35, 35, 35, 14, 35, + 35, 35, 35, 12, 13, 35, 35, 35, 35, 12, + 35, 35, 35, 35, 35, 1, 35, 16, 35, 6, + 23, 0, 0, 35, 22, 0, 35, 35, 5, 0, + 0, 15, 1, 35, 6, 35, 8, 19, 35, 16, + 4, 5, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35 }; register int hval = len; switch (hval) { default: - case 3: hval += asso_values[(unsigned char)str[2]]; + /*FALLTHROUGH*/ case 2: - case 1: - hval += asso_values[(unsigned char)str[0]]; + hval += asso_values[(unsigned char)str[1]]; break; } return hval; } -#ifdef __GNUC__ -__inline -#endif static struct C_stab_entry * in_word_set (str, len) register const char *str; register unsigned int len; { + enum + { + TOTAL_KEYWORDS = 32, + MIN_WORD_LENGTH = 2, + MAX_WORD_LENGTH = 15, + MIN_HASH_VALUE = 2, + MAX_HASH_VALUE = 34 + }; + static struct C_stab_entry wordlist[] = { - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, - {"ENTRY", 0, st_C_gnumacro}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, - {"if", 0, st_C_ignore}, {""}, {""}, - {"SYSCALL", 0, st_C_gnumacro}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {"struct", 0, st_C_struct}, - {"static", 0, st_C_typespec}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {"long", 0, st_C_typespec}, - {""}, {""}, {""}, {""}, {""}, - {"auto", 0, st_C_typespec}, - {"return", 0, st_C_ignore}, - {"import", C_JAVA, st_C_ignore}, - {""}, - {"switch", 0, st_C_ignore}, - {""}, - {"implements", C_JAVA, st_C_javastruct}, - {""}, - {"for", 0, st_C_ignore}, - {"volatile", 0, st_C_typespec}, - {""}, - {"PSEUDO", 0, st_C_gnumacro}, + {"if", 0, st_C_ignore}, {""}, - {"char", 0, st_C_typespec}, - {"class", 0, st_C_class}, - {"@protocol", 0, st_C_objprot}, - {""}, {""}, - {"void", 0, st_C_typespec}, - {"int", 0, st_C_typespec}, - {"explicit", C_PLPL, st_C_typespec}, - {""}, - {"namespace", C_PLPL, st_C_struct}, - {"signed", 0, st_C_typespec}, - {""}, - {"interface", C_JAVA, st_C_struct}, - {"while", 0, st_C_ignore}, - {"typedef", 0, st_C_typedef}, - {"typename", C_PLPL, st_C_typespec}, - {""}, {""}, {""}, - {"friend", C_PLPL, st_C_ignore}, - {"mutable", C_PLPL, st_C_typespec}, - {"union", 0, st_C_struct}, - {"domain", C_STAR, st_C_struct}, - {""}, {""}, - {"extern", 0, st_C_extern}, - {"extends", C_JAVA, st_C_javastruct}, - {"package", C_JAVA, st_C_ignore}, - {"short", 0, st_C_typespec}, - {"@end", 0, st_C_objend}, - {"unsigned", 0, st_C_typespec}, - {""}, - {"const", 0, st_C_typespec}, - {""}, {""}, - {"@interface", 0, st_C_objprot}, - {"enum", 0, st_C_enum}, - {""}, {""}, - {"@implementation",0, st_C_objimpl}, - {""}, - {"operator", C_PLPL, st_C_operator}, - {""}, {""}, {""}, {""}, - {"define", 0, st_C_define}, - {""}, {""}, - {"double", 0, st_C_typespec}, - {""}, - {"bool", C_PLPL, st_C_typespec}, - {""}, {""}, {""}, - {"DEFUN", 0, st_C_gnumacro}, - {"float", 0, st_C_typespec} + {"@end", 0, st_C_objend}, + {"union", 0, st_C_struct}, + {"define", 0, st_C_define}, + {"import", (C_JAVA & ~C_PLPL), st_C_ignore}, + {"template", 0, st_C_template}, + {"operator", C_PLPL, st_C_operator}, + {"@interface", 0, st_C_objprot}, + {"implements", (C_JAVA & ~C_PLPL), st_C_javastruct}, + {"friend", C_PLPL, st_C_ignore}, + {"typedef", 0, st_C_typedef}, + {"return", 0, st_C_ignore}, + {"@implementation",0, st_C_objimpl}, + {"@protocol", 0, st_C_objprot}, + {"interface", (C_JAVA & ~C_PLPL), st_C_struct}, + {"extern", 0, st_C_extern}, + {"extends", (C_JAVA & ~C_PLPL), st_C_javastruct}, + {"struct", 0, st_C_struct}, + {"domain", C_STAR, st_C_struct}, + {"switch", 0, st_C_ignore}, + {"enum", 0, st_C_enum}, + {"for", 0, st_C_ignore}, + {"namespace", C_PLPL, st_C_struct}, + {"class", 0, st_C_class}, + {"while", 0, st_C_ignore}, + {"undef", 0, st_C_define}, + {"package", (C_JAVA & ~C_PLPL), st_C_ignore}, + {"__attribute__", 0, st_C_attribute}, + {"SYSCALL", 0, st_C_gnumacro}, + {"ENTRY", 0, st_C_gnumacro}, + {"PSEUDO", 0, st_C_gnumacro}, + {"DEFUN", 0, st_C_gnumacro} }; if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) @@ -2167,7 +2640,7 @@ in_word_set (str, len) { register const char *s = wordlist[key].name; - if (*str == *s && !strncmp (str + 1, s + 1, len - 1)) + if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0') return &wordlist[key]; } } @@ -2190,10 +2663,15 @@ C_symtype (str, len, c_ext) /* + * Ignoring __attribute__ ((list)) + */ +static bool inattribute; /* looking at an __attribute__ construct */ + +/* * C functions and variables are recognized using a simple * finite automaton. fvdef is its state variable. */ -enum +static enum { fvnone, /* nothing seen */ fdefunkey, /* Emacs DEFUN keyword seen */ @@ -2207,13 +2685,13 @@ enum vignore /* var-like: ignore until ';' */ } fvdef; -bool fvextern; /* func or var: extern keyword seen; */ +static bool fvextern; /* func or var: extern keyword seen; */ /* * typedefs are recognized using a simple finite automaton. * typdef is its state variable. */ -enum +static enum { tnone, /* nothing seen */ tkeyseen, /* typedef keyword seen */ @@ -2228,25 +2706,24 @@ enum * using another simple finite automaton. `structdef' is its state * variable. */ -enum +static enum { snone, /* nothing seen yet, - or in struct body if cblev > 0 */ + or in struct body if bracelev > 0 */ skeyseen, /* struct-like keyword seen */ stagseen, /* struct-like tag seen */ - sintemplate, /* inside template (ignore) */ scolonseen /* colon seen after struct-like tag */ } structdef; /* * When objdef is different from onone, objtag is the name of the class. */ -char *objtag = ""; +static char *objtag = ""; /* * Yet another little state machine to deal with preprocessor lines. */ -enum +static enum { dnone, /* nothing seen */ dsharpseen, /* '#' seen as first char on line */ @@ -2258,7 +2735,7 @@ enum * State machine for Objective C protocols and implementations. * Idea by Tom R.Hageman (1995) */ -enum +static enum { onone, /* nothing seen */ oprotocol, /* @interface or @protocol seen */ @@ -2279,68 +2756,75 @@ enum * Use this structure to keep info about the token read, and how it * should be tagged. Used by the make_C_tag function to build a tag. */ -struct tok +static struct tok { - bool valid; - bool named; - int offset; - int length; - int lineno; - long linepos; - char *line; + char *line; /* string containing the token */ + int offset; /* where the token starts in LINE */ + int length; /* token length */ + /* + The previous members can be used to pass strings around for generic + purposes. The following ones specifically refer to creating tags. In this + case the token contained here is the pattern that will be used to create a + tag. + */ + bool valid; /* do not create a tag; the token should be + invalidated whenever a state machine is + reset prematurely */ + bool named; /* create a named tag */ + int lineno; /* source line number of tag */ + long linepos; /* source char number of tag */ } token; /* latest token read */ -linebuffer token_name; /* its name */ /* * Variables and functions for dealing with nested structures. * Idea by Mykola Dzyuba (2001) */ -static void pushclass_above P_((int, char *, int)); -static void popclass_above P_((int)); -static void write_classname P_((linebuffer *, char *qualifier)); +static void pushclass_above __P((int, char *, int)); +static void popclass_above __P((int)); +static void write_classname __P((linebuffer *, char *qualifier)); -struct { +static struct { char **cname; /* nested class names */ - int *cblev; /* nested class curly brace level */ + int *bracelev; /* nested class brace level */ int nl; /* class nesting level (elements used) */ int size; /* length of the array */ } cstack; /* stack for nested declaration tags */ /* Current struct nesting depth (namespace, class, struct, union, enum). */ #define nestlev (cstack.nl) -/* After struct keyword or in struct body, not inside an nested function. */ +/* After struct keyword or in struct body, not inside a nested function. */ #define instruct (structdef == snone && nestlev > 0 \ - && cblev == cstack.cblev[nestlev-1] + 1) + && bracelev == cstack.bracelev[nestlev-1] + 1) static void -pushclass_above (cblev, str, len) - int cblev; +pushclass_above (bracelev, str, len) + int bracelev; char *str; int len; { int nl; - popclass_above (cblev); + popclass_above (bracelev); nl = cstack.nl; if (nl >= cstack.size) { int size = cstack.size *= 2; xrnew (cstack.cname, size, char *); - xrnew (cstack.cblev, size, int); + xrnew (cstack.bracelev, size, int); } - assert (nl == 0 || cstack.cblev[nl-1] < cblev); + assert (nl == 0 || cstack.bracelev[nl-1] < bracelev); cstack.cname[nl] = (str == NULL) ? NULL : savenstr (str, len); - cstack.cblev[nl] = cblev; + cstack.bracelev[nl] = bracelev; cstack.nl = nl + 1; } static void -popclass_above (cblev) - int cblev; +popclass_above (bracelev) + int bracelev; { int nl; for (nl = cstack.nl - 1; - nl >= 0 && cstack.cblev[nl] >= cblev; + nl >= 0 && cstack.bracelev[nl] >= bracelev; nl--) { if (cstack.cname[nl] != NULL) @@ -2386,8 +2870,8 @@ write_classname (cn, qualifier) } -static bool consider_token P_((char *, int, int, int *, int, int, bool *)); -static void make_C_tag P_((bool)); +static bool consider_token __P((char *, int, int, int *, int, int, bool *)); +static void make_C_tag __P((bool)); /* * consider_token () @@ -2407,265 +2891,295 @@ static void make_C_tag P_((bool)); */ static bool -consider_token (str, len, c, c_extp, cblev, parlev, is_func_or_var) +consider_token (str, len, c, c_extp, bracelev, parlev, is_func_or_var) register char *str; /* IN: token pointer */ register int len; /* IN: token length */ register int c; /* IN: first char after the token */ int *c_extp; /* IN, OUT: C extensions mask */ - int cblev; /* IN: curly brace level */ + int bracelev; /* IN: brace level */ int parlev; /* IN: parenthesis level */ bool *is_func_or_var; /* OUT: function or variable found */ { - /* When structdef is stagseen, scolonseen, or snone with cblev > 0, + /* When structdef is stagseen, scolonseen, or snone with bracelev > 0, structtype is the type of the preceding struct-like keyword, and - structcblev is the curly brace level where it has been seen. */ + structbracelev is the brace level where it has been seen. */ static enum sym_type structtype; - static int structcblev; + static int structbracelev; static enum sym_type toktype; toktype = C_symtype (str, len, *c_extp); /* - * Advance the definedef state machine. + * Skip __attribute__ */ - switch (definedef) + if (toktype == st_C_attribute) { - case dnone: - /* We're not on a preprocessor line. */ - if (toktype == st_C_gnumacro) - { - fvdef = fdefunkey; - return FALSE; - } - break; - case dsharpseen: - if (toktype == st_C_define) - { - definedef = ddefineseen; - } - else - { - definedef = dignorerest; - } - return FALSE; - case ddefineseen: - /* - * Make a tag for any macro, unless it is a constant - * and constantypedefs is FALSE. - */ - definedef = dignorerest; - *is_func_or_var = (c == '('); - if (!*is_func_or_var && !constantypedefs) - return FALSE; - else - return TRUE; - case dignorerest: + inattribute = TRUE; return FALSE; - default: - error ("internal error: definedef value.", (char *)NULL); - } - - /* - * Now typedefs - */ - switch (typdef) - { - case tnone: - if (toktype == st_C_typedef) - { - if (typedefs) - typdef = tkeyseen; - fvextern = FALSE; - fvdef = fvnone; - return FALSE; - } - break; - case tkeyseen: - switch (toktype) - { - case st_none: - case st_C_typespec: - case st_C_class: - case st_C_struct: - case st_C_enum: - typdef = ttypeseen; - break; - } - break; - case ttypeseen: - if (structdef == snone && fvdef == fvnone) - { - fvdef = fvnameseen; - return TRUE; - } - break; - case tend: - switch (toktype) - { - case st_C_typespec: - case st_C_class: - case st_C_struct: - case st_C_enum: - return FALSE; - } - return TRUE; - } - - /* - * This structdef business is NOT invoked when we are ctags and the - * file is plain C. This is because a struct tag may have the same - * name as another tag, and this loses with ctags. - */ - switch (toktype) - { - case st_C_javastruct: - if (structdef == stagseen) - structdef = scolonseen; - return FALSE; - case st_C_class: - if (cblev == 0 - && (*c_extp & C_AUTO) /* automatic detection of C++ language */ - && definedef == dnone && structdef == snone - && typdef == tnone && fvdef == fvnone) - *c_extp = (*c_extp | C_PLPL) & ~C_AUTO; - /* FALLTHRU */ - case st_C_struct: - case st_C_enum: - if (parlev == 0 - && fvdef != vignore - && (typdef == tkeyseen - || (typedefs_or_cplusplus && structdef == snone))) - { - structdef = skeyseen; - structtype = toktype; - structcblev = cblev; - } - return FALSE; - } - - if (structdef == skeyseen) - { - structdef = stagseen; - return TRUE; - } - - if (typdef != tnone) - definedef = dnone; - - /* Detect Objective C constructs. */ - switch (objdef) - { - case onone: - switch (toktype) - { - case st_C_objprot: - objdef = oprotocol; - return FALSE; - case st_C_objimpl: - objdef = oimplementation; - return FALSE; - } - break; - case oimplementation: - /* Save the class tag for functions or variables defined inside. */ - objtag = savenstr (str, len); - objdef = oinbody; - return FALSE; - case oprotocol: - /* Save the class tag for categories. */ - objtag = savenstr (str, len); - objdef = otagseen; - *is_func_or_var = TRUE; - return TRUE; - case oparenseen: - objdef = ocatseen; - *is_func_or_var = TRUE; - return TRUE; - case oinbody: - break; - case omethodsign: - if (parlev == 0) - { - objdef = omethodtag; - linebuffer_setlen (&token_name, len); - strncpy (token_name.buffer, str, len); - token_name.buffer[len] = '\0'; - return TRUE; - } - return FALSE; - case omethodcolon: - if (parlev == 0) - objdef = omethodparm; - return FALSE; - case omethodparm: - if (parlev == 0) - { - objdef = omethodtag; - linebuffer_setlen (&token_name, token_name.len + len); - strncat (token_name.buffer, str, len); - return TRUE; - } - return FALSE; - case oignore: - if (toktype == st_C_objend) - { - /* Memory leakage here: the string pointed by objtag is - never released, because many tests would be needed to - avoid breaking on incorrect input code. The amount of - memory leaked here is the sum of the lengths of the - class tags. - free (objtag); */ - objdef = onone; - } - return FALSE; - } - - /* A function, variable or enum constant? */ - switch (toktype) - { - case st_C_extern: - fvextern = TRUE; - /* FALLTHRU */ - case st_C_typespec: - if (fvdef != finlist && fvdef != fignore && fvdef != vignore) - fvdef = fvnone; /* should be useless */ - return FALSE; - case st_C_ignore: - fvextern = FALSE; - fvdef = vignore; - return FALSE; - case st_C_operator: - fvdef = foperator; - *is_func_or_var = TRUE; - return TRUE; - case st_none: - if (constantypedefs - && structdef == snone - && structtype == st_C_enum && cblev > structcblev) - return TRUE; /* enum constant */ - switch (fvdef) - { - case fdefunkey: - if (cblev > 0) - break; - fvdef = fdefunname; /* GNU macro */ - *is_func_or_var = TRUE; - return TRUE; - case fvnone: - if ((strneq (str, "asm", 3) && endtoken (str[3])) - || (strneq (str, "__asm__", 7) && endtoken (str[7]))) - { - fvdef = vignore; - return FALSE; - } - if ((*c_extp & C_PLPL) && strneq (str+len-10, "::operator", 10)) + } + + /* + * Advance the definedef state machine. + */ + switch (definedef) + { + case dnone: + /* We're not on a preprocessor line. */ + if (toktype == st_C_gnumacro) + { + fvdef = fdefunkey; + return FALSE; + } + break; + case dsharpseen: + if (toktype == st_C_define) + { + definedef = ddefineseen; + } + else + { + definedef = dignorerest; + } + return FALSE; + case ddefineseen: + /* + * Make a tag for any macro, unless it is a constant + * and constantypedefs is FALSE. + */ + definedef = dignorerest; + *is_func_or_var = (c == '('); + if (!*is_func_or_var && !constantypedefs) + return FALSE; + else + return TRUE; + case dignorerest: + return FALSE; + default: + error ("internal error: definedef value.", (char *)NULL); + } + + /* + * Now typedefs + */ + switch (typdef) + { + case tnone: + if (toktype == st_C_typedef) + { + if (typedefs) + typdef = tkeyseen; + fvextern = FALSE; + fvdef = fvnone; + return FALSE; + } + break; + case tkeyseen: + switch (toktype) + { + case st_none: + case st_C_class: + case st_C_struct: + case st_C_enum: + typdef = ttypeseen; + } + break; + case ttypeseen: + if (structdef == snone && fvdef == fvnone) + { + fvdef = fvnameseen; + return TRUE; + } + break; + case tend: + switch (toktype) + { + case st_C_class: + case st_C_struct: + case st_C_enum: + return FALSE; + } + return TRUE; + } + + /* + * This structdef business is NOT invoked when we are ctags and the + * file is plain C. This is because a struct tag may have the same + * name as another tag, and this loses with ctags. + */ + switch (toktype) + { + case st_C_javastruct: + if (structdef == stagseen) + structdef = scolonseen; + return FALSE; + case st_C_template: + case st_C_class: + if ((*c_extp & C_AUTO) /* automatic detection of C++ language */ + && bracelev == 0 + && definedef == dnone && structdef == snone + && typdef == tnone && fvdef == fvnone) + *c_extp = (*c_extp | C_PLPL) & ~C_AUTO; + if (toktype == st_C_template) + break; + /* FALLTHRU */ + case st_C_struct: + case st_C_enum: + if (parlev == 0 + && fvdef != vignore + && (typdef == tkeyseen + || (typedefs_or_cplusplus && structdef == snone))) + { + structdef = skeyseen; + structtype = toktype; + structbracelev = bracelev; + if (fvdef == fvnameseen) + fvdef = fvnone; + } + return FALSE; + } + + if (structdef == skeyseen) + { + structdef = stagseen; + return TRUE; + } + + if (typdef != tnone) + definedef = dnone; + + /* Detect Objective C constructs. */ + switch (objdef) + { + case onone: + switch (toktype) + { + case st_C_objprot: + objdef = oprotocol; + return FALSE; + case st_C_objimpl: + objdef = oimplementation; + return FALSE; + } + break; + case oimplementation: + /* Save the class tag for functions or variables defined inside. */ + objtag = savenstr (str, len); + objdef = oinbody; + return FALSE; + case oprotocol: + /* Save the class tag for categories. */ + objtag = savenstr (str, len); + objdef = otagseen; + *is_func_or_var = TRUE; + return TRUE; + case oparenseen: + objdef = ocatseen; + *is_func_or_var = TRUE; + return TRUE; + case oinbody: + break; + case omethodsign: + if (parlev == 0) + { + fvdef = fvnone; + objdef = omethodtag; + linebuffer_setlen (&token_name, len); + strncpy (token_name.buffer, str, len); + token_name.buffer[len] = '\0'; + return TRUE; + } + return FALSE; + case omethodcolon: + if (parlev == 0) + objdef = omethodparm; + return FALSE; + case omethodparm: + if (parlev == 0) + { + fvdef = fvnone; + objdef = omethodtag; + linebuffer_setlen (&token_name, token_name.len + len); + strncat (token_name.buffer, str, len); + return TRUE; + } + return FALSE; + case oignore: + if (toktype == st_C_objend) + { + /* Memory leakage here: the string pointed by objtag is + never released, because many tests would be needed to + avoid breaking on incorrect input code. The amount of + memory leaked here is the sum of the lengths of the + class tags. + free (objtag); */ + objdef = onone; + } + return FALSE; + } + + /* A function, variable or enum constant? */ + switch (toktype) + { + case st_C_extern: + fvextern = TRUE; + switch (fvdef) + { + case finlist: + case flistseen: + case fignore: + case vignore: + break; + default: + fvdef = fvnone; + } + return FALSE; + case st_C_ignore: + fvextern = FALSE; + fvdef = vignore; + return FALSE; + case st_C_operator: + fvdef = foperator; + *is_func_or_var = TRUE; + return TRUE; + case st_none: + if (constantypedefs + && structdef == snone + && structtype == st_C_enum && bracelev > structbracelev) + return TRUE; /* enum constant */ + switch (fvdef) + { + case fdefunkey: + if (bracelev > 0) + break; + fvdef = fdefunname; /* GNU macro */ + *is_func_or_var = TRUE; + return TRUE; + case fvnone: + switch (typdef) + { + case ttypeseen: + return FALSE; + case tnone: + if ((strneq (str, "asm", 3) && endtoken (str[3])) + || (strneq (str, "__asm__", 7) && endtoken (str[7]))) + { + fvdef = vignore; + return FALSE; + } + break; + } + /* FALLTHRU */ + case fvnameseen: + if (len >= 10 && strneq (str+len-10, "::operator", 10)) { + if (*c_extp & C_AUTO) /* automatic detection of C++ */ + *c_extp = (*c_extp | C_PLPL) & ~C_AUTO; fvdef = foperator; *is_func_or_var = TRUE; return TRUE; } - if (cblev > 0 && !instruct) + if (bracelev > 0 && !instruct) break; fvdef = fvnameseen; /* function or variable */ *is_func_or_var = TRUE; @@ -2683,7 +3197,7 @@ consider_token (str, len, c, c_extp, cblev, parlev, is_func_or_var) * the line currently read. By keeping two line buffers, and switching * them at end of line, it is possible to use those pointers. */ -struct +static struct { long linepos; linebuffer lb; @@ -2697,12 +3211,14 @@ struct #define curlinepos (lbs[curndx].linepos) #define newlinepos (lbs[newndx].linepos) +#define plainc ((c_ext & C_EXT) == C_PLAIN) +#define cplpl (c_ext & C_PLPL) +#define cjava ((c_ext & C_JAVA) == C_JAVA) + #define CNL_SAVE_DEFINEDEF() \ do { \ curlinepos = charno; \ - lineno++; \ - linecharno = charno; \ - charno += readline (&curlb, inf); \ + readline (&curlb, inf); \ lp = curlb.buffer; \ quotednl = FALSE; \ newndx = curndx; \ @@ -2724,33 +3240,20 @@ static void make_C_tag (isfun) bool isfun; { - /* This function should never be called when token.valid is FALSE, but + /* This function is never called when token.valid is FALSE, but we must protect against invalid input or internal errors. */ - if (DEBUG || token.valid) - { - if (traditional_tag_style) - { - /* This was the original code. Now we call new_pfnote instead, - which uses the new method for naming tags (see new_pfnote). */ - char *name = NULL; + if (!DEBUG && !token.valid) + return; - if (CTAGS || token.named) - name = savestr (token_name.buffer); - if (DEBUG && !token.valid) - { - if (token.named) - name = concat (name, "##invalid##", ""); - else - name = savestr ("##invalid##"); - } - pfnote (name, isfun, token.line, - token.offset+token.length+1, token.lineno, token.linepos); - } - else - new_pfnote (token_name.buffer, token_name.len, isfun, token.line, - token.offset+token.length+1, token.lineno, token.linepos); - token.valid = FALSE; - } + if (token.valid) + make_tag (token_name.buffer, token_name.len, isfun, token.line, + token.offset+token.length+1, token.lineno, token.linepos); + else /* this case is optimised away if !DEBUG */ + make_tag (concat ("INVALID TOKEN:-->", token_name.buffer, ""), + token_name.len + 17, isfun, token.line, + token.offset+token.length+1, token.lineno, token.linepos); + + token.valid = FALSE; } @@ -2772,30 +3275,29 @@ C_entries (c_ext, inf) register int toklen; /* length of current token */ char *qualifier; /* string used to qualify names */ int qlen; /* length of qualifier */ - int cblev; /* current curly brace level */ + int bracelev; /* current brace level */ + int bracketlev; /* current bracket level */ int parlev; /* current parenthesis level */ - int typdefcblev; /* cblev where a typedef struct body begun */ + int attrparlev; /* __attribute__ parenthesis level */ + int templatelev; /* current template level */ + int typdefbracelev; /* bracelev where a typedef struct body begun */ bool incomm, inquote, inchar, quotednl, midtoken; - bool cplpl, cjava; bool yacc_rules; /* in the rules part of a yacc file */ - struct tok savetoken; /* token saved during preprocessor handling */ + struct tok savetoken = {0}; /* token saved during preprocessor handling */ - initbuffer (&token_name); - initbuffer (&lbs[0].lb); - initbuffer (&lbs[1].lb); + linebuffer_init (&lbs[0].lb); + linebuffer_init (&lbs[1].lb); if (cstack.size == 0) { cstack.size = (DEBUG) ? 1 : 4; cstack.nl = 0; cstack.cname = xnew (cstack.size, char *); - cstack.cblev = xnew (cstack.size, int); + cstack.bracelev = xnew (cstack.size, int); } - tokoff = toklen = 0; /* keep compiler quiet */ + tokoff = toklen = typdefbracelev = 0; /* keep compiler quiet */ curndx = newndx = 0; - lineno = 0; - charno = 0; lp = curlb.buffer; *lp = 0; @@ -2804,11 +3306,7 @@ C_entries (c_ext, inf) yacc_rules = FALSE; midtoken = inquote = inchar = incomm = quotednl = FALSE; token.valid = savetoken.valid = FALSE; - cblev = 0; - typdefcblev = 0; - parlev = 0; - cplpl = (c_ext & C_PLPL) == C_PLPL; - cjava = (c_ext & C_JAVA) == C_JAVA; + bracelev = bracketlev = parlev = attrparlev = templatelev = 0; if (cjava) { qualifier = "."; qlen = 1; } else @@ -2820,8 +3318,8 @@ C_entries (c_ext, inf) c = *lp++; if (c == '\\') { - /* If we're at the end of the line, the next character is a - '\0'; don't skip it, because it's the thing that tells us + /* If we are at the end of the line, the next character is a + '\0'; do not skip it, because it is what tells us to read the next line. */ if (*lp == '\0') { @@ -2880,107 +3378,125 @@ C_entries (c_ext, inf) } continue; } - else - switch (c) - { - case '"': - inquote = TRUE; - switch (fvdef) - { - case fdefunkey: - case fstartlist: - case finlist: - case fignore: - case vignore: - break; - default: - fvextern = FALSE; - fvdef = fvnone; - } - continue; - case '\'': - inchar = TRUE; - if (fvdef != finlist && fvdef != fignore && fvdef !=vignore) - { - fvextern = FALSE; - fvdef = fvnone; - } - continue; - case '/': - if (*lp == '*') - { - lp++; - incomm = TRUE; + else if (bracketlev > 0) + { + switch (c) + { + case ']': + if (--bracketlev > 0) continue; - } - else if (/* cplpl && */ *lp == '/') - { - c = '\0'; - break; - } - else break; - case '%': - if ((c_ext & YACC) && *lp == '%') - { - /* Entering or exiting rules section in yacc file. */ - lp++; - definedef = dnone; fvdef = fvnone; fvextern = FALSE; - typdef = tnone; structdef = snone; - midtoken = inquote = inchar = incomm = quotednl = FALSE; - cblev = 0; - yacc_rules = !yacc_rules; - continue; - } - else + case '\0': + CNL_SAVE_DEFINEDEF (); break; - case '#': - if (definedef == dnone) - { - char *cp; - bool cpptoken = TRUE; - - /* Look back on this line. If all blanks, or nonblanks - followed by an end of comment, this is a preprocessor - token. */ - for (cp = newlb.buffer; cp < lp-1; cp++) - if (!iswhite (*cp)) - { - if (*cp == '*' && *(cp+1) == '/') - { - cp++; - cpptoken = TRUE; - } - else - cpptoken = FALSE; - } - if (cpptoken) - definedef = dsharpseen; - } /* if (definedef == dnone) */ - + } + continue; + } + else switch (c) + { + case '"': + inquote = TRUE; + if (inattribute) + break; + switch (fvdef) + { + case fdefunkey: + case fstartlist: + case finlist: + case fignore: + case vignore: + break; + default: + fvextern = FALSE; + fvdef = fvnone; + } + continue; + case '\'': + inchar = TRUE; + if (inattribute) + break; + if (fvdef != finlist && fvdef != fignore && fvdef !=vignore) + { + fvextern = FALSE; + fvdef = fvnone; + } + continue; + case '/': + if (*lp == '*') + { + incomm = TRUE; + lp++; + c = ' '; + } + else if (/* cplpl && */ *lp == '/') + { + c = '\0'; + } + break; + case '%': + if ((c_ext & YACC) && *lp == '%') + { + /* Entering or exiting rules section in yacc file. */ + lp++; + definedef = dnone; fvdef = fvnone; fvextern = FALSE; + typdef = tnone; structdef = snone; + midtoken = inquote = inchar = incomm = quotednl = FALSE; + bracelev = 0; + yacc_rules = !yacc_rules; + continue; + } + else + break; + case '#': + if (definedef == dnone) + { + char *cp; + bool cpptoken = TRUE; + + /* Look back on this line. If all blanks, or nonblanks + followed by an end of comment, this is a preprocessor + token. */ + for (cp = newlb.buffer; cp < lp-1; cp++) + if (!iswhite (*cp)) + { + if (*cp == '*' && *(cp+1) == '/') + { + cp++; + cpptoken = TRUE; + } + else + cpptoken = FALSE; + } + if (cpptoken) + definedef = dsharpseen; + } /* if (definedef == dnone) */ + continue; + case '[': + bracketlev++; continue; - } /* switch (c) */ + } /* switch (c) */ /* Consider token only if some involved conditions are satisfied. */ if (typdef != tignore && definedef != dignorerest && fvdef != finlist - && structdef != sintemplate + && templatelev == 0 && (definedef != dnone - || structdef != scolonseen)) + || structdef != scolonseen) + && !inattribute) { if (midtoken) { if (endtoken (c)) { - if (c == ':' && cplpl && *lp == ':' && begtoken (lp[1])) + if (c == ':' && *lp == ':' && begtoken (lp[1])) + /* This handles :: in the middle, + but not at the beginning of an identifier. + Also, space-separated :: is not recognised. */ { - /* - * This handles :: in the middle, but not at the - * beginning of an identifier. Also, space-separated - * :: is not recognised. - */ + if (c_ext & C_AUTO) /* automatic detection of C++ */ + c_ext = (c_ext | C_PLPL) & ~C_AUTO; lp += 2; toklen += 2; c = lp[-1]; @@ -2992,7 +3508,8 @@ C_entries (c_ext, inf) if (yacc_rules || consider_token (newlb.buffer + tokoff, toklen, c, - &c_ext, cblev, parlev, &funorvar)) + &c_ext, bracelev, parlev, + &funorvar)) { if (fvdef == foperator) { @@ -3007,7 +3524,7 @@ C_entries (c_ext, inf) toklen += lp - oldlp; } token.named = FALSE; - if ((c_ext & C_EXT) /* not pure C */ + if (!plainc && nestlev > 0 && definedef == dnone) /* in struct body */ { @@ -3051,7 +3568,6 @@ C_entries (c_ext, inf) off += 1; len -= 1; } - len = toklen; linebuffer_setlen (&token_name, len); strncpy (token_name.buffer, newlb.buffer + off, len); @@ -3077,7 +3593,7 @@ C_entries (c_ext, inf) || (funorvar && definedef == dnone && structdef == snone - && cblev > 0)); + && bracelev > 0)); } token.lineno = lineno; token.offset = tokoff; @@ -3102,6 +3618,16 @@ C_entries (c_ext, inf) || instruct) make_C_tag (funorvar); } + else /* not yacc and consider_token failed */ + { + if (inattribute && fvdef == fignore) + { + /* We have just met __attribute__ after a + function parameter list: do not tag the + function again. */ + fvdef = fvnone; + } + } midtoken = FALSE; } } /* if (endtoken (c)) */ @@ -3120,24 +3646,28 @@ C_entries (c_ext, inf) switch (fvdef) { case fstartlist: + /* This prevents tagging fb in + void (__attribute__((noreturn)) *fb) (void); + Fixing this is not easy and not very important. */ fvdef = finlist; continue; case flistseen: - make_C_tag (TRUE); /* a function */ - fvdef = fignore; - break; - case fvnameseen: - fvdef = fvnone; + if (plainc || declarations) + { + make_C_tag (TRUE); /* a function */ + fvdef = fignore; + } break; } if (structdef == stagseen && !cjava) { - popclass_above (cblev); + popclass_above (bracelev); structdef = snone; } break; case dsharpseen: savetoken = token; + break; } if (!yacc_rules || lp == newlb.buffer + 1) { @@ -3155,6 +3685,8 @@ C_entries (c_ext, inf) switch (c) { case ':': + if (inattribute) + break; if (yacc_rules && token.offset == 0 && token.valid) { make_C_tag (FALSE); /* a yacc function */ @@ -3176,10 +3708,20 @@ C_entries (c_ext, inf) break; } if (structdef == stagseen) - structdef = scolonseen; + { + structdef = scolonseen; + break; + } + /* Should be useless, but may be work as a safety net. */ + if (cplpl && fvdef == flistseen) + { + make_C_tag (TRUE); /* a function */ + fvdef = fignore; + break; + } break; case ';': - if (definedef != dnone) + if (definedef != dnone || inattribute) break; switch (typdef) { @@ -3195,11 +3737,11 @@ C_entries (c_ext, inf) switch (fvdef) { case fignore: - if (typdef == tignore) + if (typdef == tignore || cplpl) fvdef = fvnone; break; case fvnameseen: - if ((globals && cblev == 0 && (!fvextern || declarations)) + if ((globals && bracelev == 0 && (!fvextern || declarations)) || (members && instruct)) make_C_tag (FALSE); /* a variable */ fvextern = FALSE; @@ -3207,20 +3749,20 @@ C_entries (c_ext, inf) token.valid = FALSE; break; case flistseen: - if ((declarations && typdef == tnone && !instruct) - || (members && typdef != tignore && instruct)) - make_C_tag (TRUE); /* a function declaration */ + if ((declarations + && (cplpl || !instruct) + && (typdef == tnone || (typdef != tignore && instruct))) + || (members + && plainc && instruct)) + make_C_tag (TRUE); /* a function */ /* FALLTHRU */ default: fvextern = FALSE; fvdef = fvnone; if (declarations - && structdef == stagseen && (c_ext & C_PLPL)) + && cplpl && structdef == stagseen) make_C_tag (FALSE); /* forward declaration */ else - /* The following instruction invalidates the token. - Probably the token should be invalidated in all other - cases where some state machine is reset prematurely. */ token.valid = FALSE; } /* switch (fvdef) */ /* FALLTHRU */ @@ -3232,7 +3774,7 @@ C_entries (c_ext, inf) structdef = snone; break; case ',': - if (definedef != dnone) + if (definedef != dnone || inattribute) break; switch (objdef) { @@ -3254,16 +3796,20 @@ C_entries (c_ext, inf) case fdefunname: fvdef = fignore; break; - case fvnameseen: /* a variable */ - if ((globals && cblev == 0 && (!fvextern || declarations)) - || (members && instruct)) - make_C_tag (FALSE); + case fvnameseen: + if (parlev == 0 + && ((globals + && bracelev == 0 + && templatelev == 0 + && (!fvextern || declarations)) + || (members && instruct))) + make_C_tag (FALSE); /* a variable */ break; - case flistseen: /* a function */ + case flistseen: if ((declarations && typdef == tnone && !instruct) || (members && typdef != tignore && instruct)) { - make_C_tag (TRUE); /* a function declaration */ + make_C_tag (TRUE); /* a function */ fvdef = fvnameseen; } else if (!declarations) @@ -3276,8 +3822,8 @@ C_entries (c_ext, inf) if (structdef == stagseen) structdef = snone; break; - case '[': - if (definedef != dnone) + case ']': + if (definedef != dnone || inattribute) break; if (structdef == stagseen) structdef = snone; @@ -3298,8 +3844,8 @@ C_entries (c_ext, inf) case vignore: break; case fvnameseen: - if ((members && cblev == 1) - || (globals && cblev == 0 + if ((members && bracelev == 1) + || (globals && bracelev == 0 && (!fvextern || declarations))) make_C_tag (FALSE); /* a variable */ /* FALLTHRU */ @@ -3310,6 +3856,11 @@ C_entries (c_ext, inf) } break; case '(': + if (inattribute) + { + attrparlev++; + break; + } if (definedef != dnone) break; if (objdef == otagseen && parlev == 0) @@ -3339,6 +3890,12 @@ C_entries (c_ext, inf) parlev++; break; case ')': + if (inattribute) + { + if (--attrparlev == 0) + inattribute = FALSE; + break; + } if (definedef != dnone) break; if (objdef == ocatseen && parlev == 1) @@ -3371,8 +3928,10 @@ C_entries (c_ext, inf) break; if (typdef == ttypeseen) { - typdefcblev = cblev; + /* Whenever typdef is set to tinbody (currently only + here), typdefbracelev should be set to bracelev. */ typdef = tinbody; + typdefbracelev = bracelev; } switch (fvdef) { @@ -3396,47 +3955,56 @@ C_entries (c_ext, inf) break; default: /* Neutralize `extern "C" {' grot. */ - if (cblev == 0 && structdef == snone && nestlev == 0 + if (bracelev == 0 && structdef == snone && nestlev == 0 && typdef == tnone) - cblev = -1; + bracelev = -1; } + break; } switch (structdef) { case skeyseen: /* unnamed struct */ - pushclass_above (cblev, NULL, 0); + pushclass_above (bracelev, NULL, 0); structdef = snone; break; case stagseen: /* named struct or enum */ case scolonseen: /* a class */ - pushclass_above (cblev, token.line+token.offset, token.length); + pushclass_above (bracelev,token.line+token.offset, token.length); structdef = snone; make_C_tag (FALSE); /* a struct or enum */ break; } - cblev++; + bracelev++; break; case '*': if (definedef != dnone) break; if (fvdef == fstartlist) - fvdef = fvnone; /* avoid tagging `foo' in `foo (*bar()) ()' */ + { + fvdef = fvnone; /* avoid tagging `foo' in `foo (*bar()) ()' */ + token.valid = FALSE; + } break; case '}': if (definedef != dnone) break; - if (!noindentypedefs && lp == newlb.buffer + 1) + if (!ignoreindent && lp == newlb.buffer + 1) { - cblev = 0; /* reset curly brace level if first column */ + if (bracelev != 0) + token.valid = FALSE; + bracelev = 0; /* reset brace level if first column */ parlev = 0; /* also reset paren level, just in case... */ } - else if (cblev > 0) - cblev--; - popclass_above (cblev); + else if (bracelev > 0) + bracelev--; + else + token.valid = FALSE; /* something gone amiss, token unreliable */ + popclass_above (bracelev); structdef = snone; - if (typdef == tinbody && cblev <= typdefcblev) + /* Only if typdef == tinbody is typdefbracelev significant. */ + if (typdef == tinbody && bracelev <= typdefbracelev) { - assert (cblev == typdefcblev); + assert (bracelev == typdefbracelev); typdef = tend; } break; @@ -3451,8 +4019,8 @@ C_entries (c_ext, inf) case vignore: break; case fvnameseen: - if ((members && cblev == 1) - || (globals && cblev == 0 && (!fvextern || declarations))) + if ((members && bracelev == 1) + || (globals && bracelev == 0 && (!fvextern || declarations))) make_C_tag (FALSE); /* a variable */ /* FALLTHRU */ default: @@ -3460,30 +4028,31 @@ C_entries (c_ext, inf) } break; case '<': - if (cplpl && structdef == stagseen) + if (cplpl + && (structdef == stagseen || fvdef == fvnameseen)) { - structdef = sintemplate; + templatelev++; break; } goto resetfvdef; case '>': - if (structdef == sintemplate) + if (templatelev > 0) { - structdef = stagseen; + templatelev--; break; } goto resetfvdef; case '+': case '-': - if (objdef == oinbody && cblev == 0) + if (objdef == oinbody && bracelev == 0) { objdef = omethodsign; break; } /* FALLTHRU */ resetfvdef: - case '#': case '~': case '&': case '%': case '/': case '|': - case '^': case '!': case '.': case '?': case ']': + case '#': case '~': case '&': case '%': case '/': + case '|': case '^': case '!': case '.': case '?': if (definedef != dnone) break; /* These surely cannot follow a function tag in C. */ @@ -3514,7 +4083,6 @@ C_entries (c_ext, inf) } /* while not eof */ - free (token_name.buffer); free (lbs[0].lb.buffer); free (lbs[1].lb.buffer); } @@ -3571,17 +4139,27 @@ Yacc_entries (inf) } -/* A useful macro. */ +/* Useful macros. */ #define LOOP_ON_INPUT_LINES(file_pointer, line_buffer, char_pointer) \ - for (lineno = charno = 0; /* loop initialization */ \ + for (; /* loop initialization */ \ !feof (file_pointer) /* loop test */ \ - && (lineno++, /* instructions at start of loop */ \ - linecharno = charno, \ - charno += readline (&line_buffer, file_pointer), \ - char_pointer = lb.buffer, \ + && /* instructions at start of loop */ \ + (readline (&line_buffer, file_pointer), \ + char_pointer = line_buffer.buffer, \ TRUE); \ ) +#define LOOKING_AT(cp, kw) /* kw is the keyword, a literal string */ \ + ((assert("" kw), TRUE) /* syntax error if not a literal string */ \ + && strneq ((cp), kw, sizeof(kw)-1) /* cp points at kw */ \ + && notinname ((cp)[sizeof(kw)-1]) /* end of kw */ \ + && ((cp) = skip_spaces((cp)+sizeof(kw)-1))) /* skip spaces */ + +/* Similar to LOOKING_AT but does not use notinname, does not skip */ +#define LOOKING_AT_NOCASE(cp, kw) /* the keyword is a literal string */ \ + ((assert("" kw), TRUE) /* syntax error if not a literal string */ \ + && strncaseeq ((cp), kw, sizeof(kw)-1) /* cp points at kw */ \ + && ((cp) += sizeof(kw)-1)) /* skip spaces */ /* * Read a file, but do no processing. This is used to do regexp @@ -3600,28 +4178,11 @@ just_read_file (inf) /* Fortran parsing */ -static bool tail P_((char *)); -static void takeprec P_((void)); -static void getit P_((FILE *)); - -static bool -tail (cp) - char *cp; -{ - register int len = 0; - - while (*cp != '\0' && lowcase (*cp) == lowcase (dbp[len])) - cp++, len++; - if (*cp == '\0' && !intoken (dbp[len])) - { - dbp += len; - return TRUE; - } - return FALSE; -} +static void F_takeprec __P((void)); +static void F_getit __P((FILE *)); static void -takeprec () +F_takeprec () { dbp = skip_spaces (dbp); if (*dbp != '*') @@ -3644,7 +4205,7 @@ takeprec () } static void -getit (inf) +F_getit (inf) FILE *inf; { register char *cp; @@ -3652,9 +4213,7 @@ getit (inf) dbp = skip_spaces (dbp); if (*dbp == '\0') { - lineno++; - linecharno = charno; - charno += readline (&lb, inf); + readline (&lb, inf); dbp = lb.buffer; if (dbp[5] != '&') return; @@ -3665,8 +4224,8 @@ getit (inf) return; for (cp = dbp + 1; *cp != '\0' && intoken (*cp); cp++) continue; - pfnote (savenstr (dbp, cp-dbp), TRUE, - lb.buffer, cp - lb.buffer + 1, lineno, linecharno); + make_tag (dbp, cp-dbp, TRUE, + lb.buffer, cp - lb.buffer + 1, lineno, linecharno); } @@ -3684,28 +4243,28 @@ Fortran_functions (inf) switch (lowcase (*dbp)) { case 'i': - if (tail ("integer")) - takeprec (); + if (nocase_tail ("integer")) + F_takeprec (); break; case 'r': - if (tail ("real")) - takeprec (); + if (nocase_tail ("real")) + F_takeprec (); break; case 'l': - if (tail ("logical")) - takeprec (); + if (nocase_tail ("logical")) + F_takeprec (); break; case 'c': - if (tail ("complex") || tail ("character")) - takeprec (); + if (nocase_tail ("complex") || nocase_tail ("character")) + F_takeprec (); break; case 'd': - if (tail ("double")) + if (nocase_tail ("double")) { dbp = skip_spaces (dbp); if (*dbp == '\0') continue; - if (tail ("precision")) + if (nocase_tail ("precision")) break; continue; } @@ -3717,26 +4276,26 @@ Fortran_functions (inf) switch (lowcase (*dbp)) { case 'f': - if (tail ("function")) - getit (inf); + if (nocase_tail ("function")) + F_getit (inf); continue; case 's': - if (tail ("subroutine")) - getit (inf); + if (nocase_tail ("subroutine")) + F_getit (inf); continue; case 'e': - if (tail ("entry")) - getit (inf); + if (nocase_tail ("entry")) + F_getit (inf); continue; case 'b': - if (tail ("blockdata") || tail ("block data")) + if (nocase_tail ("blockdata") || nocase_tail ("block data")) { dbp = skip_spaces (dbp); if (*dbp == '\0') /* assume un-named */ - pfnote (savestr ("blockdata"), TRUE, - lb.buffer, dbp - lb.buffer, lineno, linecharno); + make_tag ("blockdata", 9, TRUE, + lb.buffer, dbp - lb.buffer, lineno, linecharno); else - getit (inf); /* look for name */ + F_getit (inf); /* look for name */ } continue; } @@ -3746,15 +4305,16 @@ Fortran_functions (inf) /* * Ada parsing - * Philippe Waroquiers (1998) + * Original code by + * Philippe Waroquiers (1998) */ -static void adagetit P_((FILE *, char *)); +static void Ada_getit __P((FILE *, char *)); /* Once we are positioned after an "interesting" keyword, let's get the real tag value necessary. */ static void -adagetit (inf, name_qualifier) +Ada_getit (inf, name_qualifier) FILE *inf; char *name_qualifier; { @@ -3768,16 +4328,13 @@ adagetit (inf, name_qualifier) if (*dbp == '\0' || (dbp[0] == '-' && dbp[1] == '-')) { - lineno++; - linecharno = charno; - charno += readline (&lb, inf); + readline (&lb, inf); dbp = lb.buffer; } - switch (*dbp) + switch (lowcase(*dbp)) { case 'b': - case 'B': - if (tail ("body")) + if (nocase_tail ("body")) { /* Skipping body of procedure body or package body or .... resetting qualifier to body instead of spec. */ @@ -3786,9 +4343,8 @@ adagetit (inf, name_qualifier) } break; case 't': - case 'T': /* Skipping type of task type or protected type ... */ - if (tail ("type")) + if (nocase_tail ("type")) continue; break; } @@ -3813,7 +4369,9 @@ adagetit (inf, name_qualifier) *cp = '\0'; name = concat (dbp, name_qualifier, ""); *cp = c; - pfnote (name, TRUE, lb.buffer, cp - lb.buffer + 1, lineno, linecharno); + make_tag (name, strlen (name), TRUE, + lb.buffer, cp - lb.buffer + 1, lineno, linecharno); + free (name); if (c == '"') dbp = cp + 1; return; @@ -3825,6 +4383,7 @@ Ada_funcs (inf) FILE *inf; { bool inquote = FALSE; + bool skip_till_semicolumn = FALSE; LOOP_ON_INPUT_LINES (inf, lb, dbp) { @@ -3861,6 +4420,14 @@ Ada_funcs (inf) continue; } + if (skip_till_semicolumn) + { + if (*dbp == ';') + skip_till_semicolumn = FALSE; + dbp++; + continue; /* advance char */ + } + /* Search for beginning of a token. */ if (!begtoken (*dbp)) { @@ -3869,33 +4436,40 @@ Ada_funcs (inf) } /* We are at the beginning of a token. */ - switch (*dbp) + switch (lowcase(*dbp)) { case 'f': - case 'F': - if (!packages_only && tail ("function")) - adagetit (inf, "/f"); + if (!packages_only && nocase_tail ("function")) + Ada_getit (inf, "/f"); else break; /* from switch */ continue; /* advance char */ case 'p': - case 'P': - if (!packages_only && tail ("procedure")) - adagetit (inf, "/p"); - else if (tail ("package")) - adagetit (inf, "/s"); - else if (tail ("protected")) /* protected type */ - adagetit (inf, "/t"); + if (!packages_only && nocase_tail ("procedure")) + Ada_getit (inf, "/p"); + else if (nocase_tail ("package")) + Ada_getit (inf, "/s"); + else if (nocase_tail ("protected")) /* protected type */ + Ada_getit (inf, "/t"); else break; /* from switch */ continue; /* advance char */ + + case 'u': + if (typedefs && !packages_only && nocase_tail ("use")) + { + /* when tagging types, avoid tagging use type Pack.Typename; + for this, we will skip everything till a ; */ + skip_till_semicolumn = TRUE; + continue; /* advance char */ + } + case 't': - case 'T': - if (!packages_only && tail ("task")) - adagetit (inf, "/k"); - else if (typedefs && !packages_only && tail ("type")) + if (!packages_only && nocase_tail ("task")) + Ada_getit (inf, "/k"); + else if (typedefs && !packages_only && nocase_tail ("type")) { - adagetit (inf, "/t"); + Ada_getit (inf, "/t"); while (*dbp != '\0') dbp += 1; } @@ -3914,9 +4488,9 @@ Ada_funcs (inf) /* - * Bob Weiner, Motorola Inc., 4/3/94 * Unix and microcontroller assembly tag handling - * look for '^[a-zA-Z_.$][a-zA_Z0-9_.$]*[: ^I^J]' + * Labels: /^[a-zA-Z_.$][a-zA_Z0-9_.$]*[: ^I^J]/ + * Idea by Bob Weiner, Motorola Inc. (1994) */ static void Asm_labels (inf) @@ -3935,11 +4509,9 @@ Asm_labels (inf) while (ISALNUM (*cp) || *cp == '_' || *cp == '.' || *cp == '$') cp++; if (*cp == ':' || iswhite (*cp)) - { - /* Found end of label, so copy it and add it to the table. */ - pfnote (savenstr(lb.buffer, cp-lb.buffer), TRUE, + /* Found end of label, so copy it and add it to the table. */ + make_tag (lb.buffer, cp - lb.buffer, TRUE, lb.buffer, cp - lb.buffer + 1, lineno, linecharno); - } } } } @@ -3947,79 +4519,94 @@ Asm_labels (inf) /* * Perl support - * Perl sub names: look for /^sub[ \t\n]+[^ \t\n{]+/ + * Perl sub names: /^sub[ \t\n]+[^ \t\n{]+/ * Perl variable names: /^(my|local).../ - * Bart Robinson (1995) - * Michael Ernst (1997) + * Original code by Bart Robinson (1995) + * Additions by Michael Ernst (1997) + * Ideas by Kai Großjohann (2001) */ static void Perl_functions (inf) FILE *inf; { + char *package = savestr ("main"); /* current package name */ register char *cp; LOOP_ON_INPUT_LINES (inf, lb, cp) { - if (*cp++ == 's' - && *cp++ == 'u' - && *cp++ == 'b' && iswhite (*cp++)) + skip_spaces(cp); + + if (LOOKING_AT (cp, "package")) { - cp = skip_spaces (cp); - if (*cp != '\0') - { - char *sp = cp; - while (*cp != '\0' - && !iswhite (*cp) && *cp != '{' && *cp != '(') - cp++; - pfnote (savenstr (sp, cp-sp), TRUE, - lb.buffer, cp - lb.buffer + 1, lineno, linecharno); - } + free (package); + get_tag (cp, &package); + } + else if (LOOKING_AT (cp, "sub")) + { + char *pos; + char *sp = cp; + + while (!notinname (*cp)) + cp++; + if (cp == sp) + continue; /* nothing found */ + if ((pos = etags_strchr (sp, ':')) != NULL + && pos < cp && pos[1] == ':') + /* The name is already qualified. */ + make_tag (sp, cp - sp, TRUE, + lb.buffer, cp - lb.buffer + 1, lineno, linecharno); + else + /* Qualify it. */ + { + char savechar, *name; + + savechar = *cp; + *cp = '\0'; + name = concat (package, "::", sp); + *cp = savechar; + make_tag (name, strlen(name), TRUE, + lb.buffer, cp - lb.buffer + 1, lineno, linecharno); + free (name); + } } - else if (globals /* only if tagging global vars is enabled */ - && ((cp = lb.buffer, - *cp++ == 'm' - && *cp++ == 'y') - || (cp = lb.buffer, - *cp++ == 'l' - && *cp++ == 'o' - && *cp++ == 'c' - && *cp++ == 'a' - && *cp++ == 'l')) - && (*cp == '(' || iswhite (*cp))) + else if (globals) /* only if we are tagging global vars */ { + /* Skip a qualifier, if any. */ + bool qual = LOOKING_AT (cp, "my") || LOOKING_AT (cp, "local"); /* After "my" or "local", but before any following paren or space. */ - char *varname = NULL; + char *varstart = cp; - cp = skip_spaces (cp); - if (*cp == '$' || *cp == '@' || *cp == '%') + if (qual /* should this be removed? If yes, how? */ + && (*cp == '$' || *cp == '@' || *cp == '%')) { - char* varstart = ++cp; - while (ISALNUM (*cp) || *cp == '_') + varstart += 1; + do cp++; - varname = savenstr (varstart, cp-varstart); + while (ISALNUM (*cp) || *cp == '_'); } - else + else if (qual) { /* Should be examining a variable list at this point; could insist on seeing an open parenthesis. */ while (*cp != '\0' && *cp != ';' && *cp != '=' && *cp != ')') cp++; } + else + continue; - /* Perhaps I should back cp up one character, so the TAGS table - doesn't mention (and so depend upon) the following char. */ - pfnote ((CTAGS) ? savenstr (lb.buffer, cp-lb.buffer) : varname, - FALSE, lb.buffer, cp - lb.buffer + 1, lineno, linecharno); + make_tag (varstart, cp - varstart, FALSE, + lb.buffer, cp - lb.buffer + 1, lineno, linecharno); } } + free (package); } - + /* * Python support - * Look for /^[ \t\n]*def[ \t\n]+[^ \t\n(:]+/ or /^class[ \t\n]+[^ \t\n(:]+/ - * Eric S. Raymond (1997) - * Sean Legassick (2004) + * Look for /^[\t]*def[ \t\n]+[^ \t\n(:]+/ or /^class[ \t\n]+[^ \t\n(:]+/ + * Idea by Eric S. Raymond (1997) + * More ideas by seb bacon (2002) */ static void Python_functions (inf) @@ -4030,38 +4617,107 @@ Python_functions (inf) LOOP_ON_INPUT_LINES (inf, lb, cp) { cp = skip_spaces (cp); - if (*cp++ == 'd' - && *cp++ == 'e' - && *cp++ == 'f' && iswhite (*cp++)) + if (LOOKING_AT (cp, "def") || LOOKING_AT (cp, "class")) { - cp = skip_spaces (cp); - while (*cp != '\0' && !iswhite (*cp) && *cp != '(' && *cp != ':') + char *name = cp; + while (!notinname (*cp) && *cp != ':') cp++; - pfnote (NULL, TRUE, - lb.buffer, cp - lb.buffer + 1, lineno, linecharno); + make_tag (name, cp - name, TRUE, + lb.buffer, cp - lb.buffer + 1, lineno, linecharno); } + } +} + + +/* + * PHP support + * Look for: + * - /^[ \t]*function[ \t\n]+[^ \t\n(]+/ + * - /^[ \t]*class[ \t\n]+[^ \t\n]+/ + * - /^[ \t]*define\(\"[^\"]+/ + * Only with --members: + * - /^[ \t]*var[ \t\n]+\$[^ \t\n=;]/ + * Idea by Diez B. Roggisch (2001) + */ +static void +PHP_functions (inf) + FILE *inf; +{ + register char *cp, *name; + bool search_identifier = FALSE; - cp = lb.buffer; - if (*cp++ == 'c' - && *cp++ == 'l' - && *cp++ == 'a' - && *cp++ == 's' - && *cp++ == 's' && iswhite (*cp++)) + LOOP_ON_INPUT_LINES (inf, lb, cp) + { + cp = skip_spaces (cp); + name = cp; + if (search_identifier + && *cp != '\0') { - cp = skip_spaces (cp); - while (*cp != '\0' && !iswhite (*cp) && *cp != '(' && *cp != ':') + while (!notinname (*cp)) cp++; - pfnote (NULL, TRUE, - lb.buffer, cp - lb.buffer + 1, lineno, linecharno); + make_tag (name, cp - name, TRUE, + lb.buffer, cp - lb.buffer + 1, lineno, linecharno); + search_identifier = FALSE; + } + else if (LOOKING_AT (cp, "function")) + { + if(*cp == '&') + cp = skip_spaces (cp+1); + if(*cp != '\0') + { + name = cp; + while (!notinname (*cp)) + cp++; + make_tag (name, cp - name, TRUE, + lb.buffer, cp - lb.buffer + 1, lineno, linecharno); + } + else + search_identifier = TRUE; + } + else if (LOOKING_AT (cp, "class")) + { + if (*cp != '\0') + { + name = cp; + while (*cp != '\0' && !iswhite (*cp)) + cp++; + make_tag (name, cp - name, FALSE, + lb.buffer, cp - lb.buffer + 1, lineno, linecharno); + } + else + search_identifier = TRUE; + } + else if (strneq (cp, "define", 6) + && (cp = skip_spaces (cp+6)) + && *cp++ == '(' + && (*cp == '"' || *cp == '\'')) + { + char quote = *cp++; + name = cp; + while (*cp != quote && *cp != '\0') + cp++; + make_tag (name, cp - name, FALSE, + lb.buffer, cp - lb.buffer + 1, lineno, linecharno); + } + else if (members + && LOOKING_AT (cp, "var") + && *cp == '$') + { + name = cp; + while (!notinname(*cp)) + cp++; + make_tag (name, cp - name, FALSE, + lb.buffer, cp - lb.buffer + 1, lineno, linecharno); } } } -/* Idea by Corny de Souza +/* * Cobol tag functions * We could look for anything that could be a paragraph name. * i.e. anything that starts in column 8 is one word and ends in a full stop. + * Idea by Corny de Souza (1993) */ static void Cobol_paragraphs (inf) @@ -4082,15 +4738,15 @@ Cobol_paragraphs (inf) for (ep = bp; ISALNUM (*ep) || *ep == '-'; ep++) continue; if (*ep++ == '.') - pfnote (savenstr (bp, ep-bp), TRUE, - lb.buffer, ep - lb.buffer + 1, lineno, linecharno); + make_tag (bp, ep - bp, TRUE, + lb.buffer, ep - lb.buffer + 1, lineno, linecharno); } } /* * Makefile support - * Idea by Assar Westerlund (2001) + * Ideas by Assar Westerlund (2001) */ static void Makefile_targets (inf) @@ -4104,17 +4760,25 @@ Makefile_targets (inf) continue; while (*bp != '\0' && *bp != '=' && *bp != ':') bp++; - if (*bp == ':') - pfnote (savenstr (lb.buffer, bp - lb.buffer), TRUE, - lb.buffer, bp - lb.buffer + 1, lineno, linecharno); + if (*bp == ':' || (globals && *bp == '=')) + { + /* We should detect if there is more than one tag, but we do not. + We just skip initial and final spaces. */ + char * namestart = skip_spaces (lb.buffer); + while (--bp > namestart) + if (!notinname (*bp)) + break; + make_tag (namestart, bp - namestart + 1, TRUE, + lb.buffer, bp - lb.buffer + 2, lineno, linecharno); + } } } -/* Added by Mosur Mohan, 4/22/88 */ -/* Pascal parsing */ - /* + * Pascal parsing + * Original code by Mosur K. Mohan (1989) + * * Locates tags for procedures & functions. Doesn't do any type- or * var-definitions. It does look for the keyword "extern" or * "forward" immediately following the procedure statement; if found, @@ -4126,8 +4790,8 @@ Pascal_functions (inf) { linebuffer tline; /* mostly copied from C_entries */ long save_lcno; - int save_lineno, save_len; - char c, *cp, *namebuf; + int save_lineno, namelen, taglen; + char c, *name; bool /* each of these flags is TRUE iff: */ incomment, /* point is inside a comment */ @@ -4141,17 +4805,15 @@ Pascal_functions (inf) is a FORWARD/EXTERN to be ignored, or whether it is a real tag */ - save_lcno = save_lineno = save_len = 0; /* keep compiler quiet */ - namebuf = NULL; /* keep compiler quiet */ - lineno = 0; - charno = 0; + save_lcno = save_lineno = namelen = taglen = 0; /* keep compiler quiet */ + name = NULL; /* keep compiler quiet */ dbp = lb.buffer; *dbp = '\0'; - initbuffer (&tline); + linebuffer_init (&tline); incomment = inquote = FALSE; found_tag = FALSE; /* have a proc name; check if extern */ - get_tagname = FALSE; /* have found "procedure" keyword */ + get_tagname = FALSE; /* found "procedure" keyword */ inparms = FALSE; /* found '(' after "proc" */ verify_tag = FALSE; /* check if "extern" is ahead */ @@ -4161,9 +4823,7 @@ Pascal_functions (inf) c = *dbp++; if (c == '\0') /* if end of line */ { - lineno++; - linecharno = charno; - charno += readline (&lb, inf); + readline (&lb, inf); dbp = lb.buffer; if (*dbp == '\0') continue; @@ -4222,12 +4882,12 @@ Pascal_functions (inf) } if (found_tag && verify_tag && (*dbp != ' ')) { - /* check if this is an "extern" declaration */ + /* Check if this is an "extern" declaration. */ if (*dbp == '\0') continue; if (lowcase (*dbp == 'e')) { - if (tail ("extern")) /* superfluous, really! */ + if (nocase_tail ("extern")) /* superfluous, really! */ { found_tag = FALSE; verify_tag = FALSE; @@ -4235,7 +4895,7 @@ Pascal_functions (inf) } else if (lowcase (*dbp) == 'f') { - if (tail ("forward")) /* check for forward reference */ + if (nocase_tail ("forward")) /* check for forward reference */ { found_tag = FALSE; verify_tag = FALSE; @@ -4245,50 +4905,54 @@ Pascal_functions (inf) { found_tag = FALSE; verify_tag = FALSE; - pfnote (namebuf, TRUE, - tline.buffer, save_len, save_lineno, save_lcno); + make_tag (name, namelen, TRUE, + tline.buffer, taglen, save_lineno, save_lcno); continue; } } if (get_tagname) /* grab name of proc or fn */ { + char *cp; + if (*dbp == '\0') continue; - /* save all values for later tagging */ + /* Find block name. */ + for (cp = dbp + 1; *cp != '\0' && !endtoken (*cp); cp++) + continue; + + /* Save all values for later tagging. */ linebuffer_setlen (&tline, lb.len); strcpy (tline.buffer, lb.buffer); save_lineno = lineno; save_lcno = linecharno; + name = tline.buffer + (dbp - lb.buffer); + namelen = cp - dbp; + taglen = cp - lb.buffer + 1; - /* grab block name */ - for (cp = dbp + 1; *cp != '\0' && !endtoken (*cp); cp++) - continue; - namebuf = savenstr (dbp, cp-dbp); dbp = cp; /* set dbp to e-o-token */ - save_len = dbp - lb.buffer + 1; get_tagname = FALSE; found_tag = TRUE; continue; - /* and proceed to check for "extern" */ + /* And proceed to check for "extern". */ } else if (!incomment && !inquote && !found_tag) { - /* check for proc/fn keywords */ + /* Check for proc/fn keywords. */ switch (lowcase (c)) { case 'p': - if (tail ("rocedure")) /* c = 'p', dbp has advanced */ + if (nocase_tail ("rocedure")) /* c = 'p', dbp has advanced */ get_tagname = TRUE; continue; case 'f': - if (tail ("unction")) + if (nocase_tail ("unction")) get_tagname = TRUE; continue; } } - } /* while not eof */ + } /* while not eof */ free (tline.buffer); } @@ -4299,56 +4963,22 @@ Pascal_functions (inf) * look for (def or (DEF, quote or QUOTE */ -static int L_isdef P_((char *)); -static int L_isquote P_((char *)); -static void L_getit P_((void)); - -static int -L_isdef (strp) - register char *strp; -{ - return ((strp[1] == 'd' || strp[1] == 'D') - && (strp[2] == 'e' || strp[2] == 'E') - && (strp[3] == 'f' || strp[3] == 'F')); -} - -static int -L_isquote (strp) - register char *strp; -{ - return ((*++strp == 'q' || *strp == 'Q') - && (*++strp == 'u' || *strp == 'U') - && (*++strp == 'o' || *strp == 'O') - && (*++strp == 't' || *strp == 'T') - && (*++strp == 'e' || *strp == 'E') - && iswhite (*++strp)); -} +static void L_getit __P((void)); static void L_getit () { - register char *cp; - if (*dbp == '\'') /* Skip prefix quote */ dbp++; else if (*dbp == '(') { - if (L_isquote (dbp)) - dbp += 7; /* Skip "(quote " */ - else - dbp += 1; /* Skip "(" before name in (defstruct (foo)) */ - dbp = skip_spaces (dbp); + dbp++; + /* Try to skip "(quote " */ + if (!LOOKING_AT (dbp, "quote") && !LOOKING_AT (dbp, "QUOTE")) + /* Ok, then skip "(" before name in (defstruct (foo)) */ + dbp = skip_spaces (dbp); } - - for (cp = dbp /*+1*/; - *cp != '\0' && *cp != '(' && !iswhite(*cp) && *cp != ')'; - cp++) - continue; - if (cp == dbp) - return; - - pfnote (savenstr (dbp, cp-dbp), TRUE, - lb.buffer, cp - lb.buffer + 1, lineno, linecharno); + get_tag (dbp, NULL); } static void @@ -4357,33 +4987,32 @@ Lisp_functions (inf) { LOOP_ON_INPUT_LINES (inf, lb, dbp) { - if (dbp[0] == '(') + if (dbp[0] != '(') + continue; + + if (strneq (dbp+1, "def", 3) || strneq (dbp+1, "DEF", 3)) { - if (L_isdef (dbp)) - { - dbp = skip_non_spaces (dbp); - dbp = skip_spaces (dbp); - L_getit (); - } - else + dbp = skip_non_spaces (dbp); + dbp = skip_spaces (dbp); + L_getit (); + } + else + { + /* Check for (foo::defmumble name-defined ... */ + do + dbp++; + while (!notinname (*dbp) && *dbp != ':'); + if (*dbp == ':') { - /* Check for (foo::defmumble name-defined ... */ do dbp++; - while (*dbp != '\0' && !iswhite (*dbp) - && *dbp != ':' && *dbp != '(' && *dbp != ')'); - if (*dbp == ':') - { - do - dbp++; - while (*dbp == ':'); + while (*dbp == ':'); - if (L_isdef (dbp - 1)) - { - dbp = skip_non_spaces (dbp); - dbp = skip_spaces (dbp); - L_getit (); - } + if (strneq (dbp, "def", 3) || strneq (dbp, "DEF", 3)) + { + dbp = skip_non_spaces (dbp); + dbp = skip_spaces (dbp); + L_getit (); } } } @@ -4392,14 +5021,40 @@ Lisp_functions (inf) /* - * Postscript tag functions + * Lua script language parsing + * Original code by David A. Capello (2004) + * + * "function" and "local function" are tags if they start at column 1. + */ +static void +Lua_functions (inf) + FILE *inf; +{ + register char *bp; + + LOOP_ON_INPUT_LINES (inf, lb, bp) + { + if (bp[0] != 'f' && bp[0] != 'l') + continue; + + (void)LOOKING_AT (bp, "local"); /* skip possible "local" */ + + if (LOOKING_AT (bp, "function")) + get_tag (bp, NULL); + } +} + + +/* + * Postscript tags * Just look for lines where the first character is '/' * Also look at "defineps" for PSWrap - * Richard Mlynarik (1997) - * Ideas by Masatake Yamato (1999) + * Ideas by: + * Richard Mlynarik (1997) + * Masatake Yamato (1999) */ static void -Postscript_functions (inf) +PS_functions (inf) FILE *inf; { register char *bp, *ep; @@ -4412,27 +5067,60 @@ Postscript_functions (inf) *ep != '\0' && *ep != ' ' && *ep != '{'; ep++) continue; - pfnote (savenstr (bp, ep-bp), TRUE, - lb.buffer, ep - lb.buffer + 1, lineno, linecharno); - } - else if (strneq (bp, "defineps", 8)) - { - bp = skip_non_spaces (bp); - bp = skip_spaces (bp); - get_tag (bp); + make_tag (bp, ep - bp, TRUE, + lb.buffer, ep - lb.buffer + 1, lineno, linecharno); } + else if (LOOKING_AT (bp, "defineps")) + get_tag (bp, NULL); } } /* + * Forth tags + * Ignore anything after \ followed by space or in ( ) + * Look for words defined by : + * Look for constant, code, create, defer, value, and variable + * OBP extensions: Look for buffer:, field, + * Ideas by Eduardo Horvath (2004) + */ +static void +Forth_words (inf) + FILE *inf; +{ + register char *bp; + + LOOP_ON_INPUT_LINES (inf, lb, bp) + while ((bp = skip_spaces (bp))[0] != '\0') + if (bp[0] == '\\' && iswhite(bp[1])) + break; /* read next line */ + else if (bp[0] == '(' && iswhite(bp[1])) + do /* skip to ) or eol */ + bp++; + while (*bp != ')' && *bp != '\0'); + else if ((bp[0] == ':' && iswhite(bp[1]) && bp++) + || LOOKING_AT_NOCASE (bp, "constant") + || LOOKING_AT_NOCASE (bp, "code") + || LOOKING_AT_NOCASE (bp, "create") + || LOOKING_AT_NOCASE (bp, "defer") + || LOOKING_AT_NOCASE (bp, "value") + || LOOKING_AT_NOCASE (bp, "variable") + || LOOKING_AT_NOCASE (bp, "buffer:") + || LOOKING_AT_NOCASE (bp, "field")) + get_tag (skip_spaces (bp), NULL); /* Yay! A definition! */ + else + bp = skip_non_spaces (bp); +} + + +/* * Scheme tag functions * look for (def... xyzzy - * look for (def... (xyzzy - * look for (def ... ((...(xyzzy .... - * look for (set! xyzzy + * (def... (xyzzy + * (def ... ((...(xyzzy .... + * (set! xyzzy + * Original code by Ken Haase (1985?) */ - static void Scheme_functions (inf) FILE *inf; @@ -4441,28 +5129,16 @@ Scheme_functions (inf) LOOP_ON_INPUT_LINES (inf, lb, bp) { - if (bp[0] == '(' - && (bp[1] == 'D' || bp[1] == 'd') - && (bp[2] == 'E' || bp[2] == 'e') - && (bp[3] == 'F' || bp[3] == 'f')) + if (strneq (bp, "(def", 4) || strneq (bp, "(DEF", 4)) { - bp = skip_non_spaces (bp); + bp = skip_non_spaces (bp+4); /* Skip over open parens and white space */ - while (iswhite (*bp) || *bp == '(') + while (notinname (*bp)) bp++; - get_tag (bp); - } - if (bp[0] == '(' - && (bp[1] == 'S' || bp[1] == 's') - && (bp[2] == 'E' || bp[2] == 'e') - && (bp[3] == 'T' || bp[3] == 't') - && (bp[4] == '!' || bp[4] == '!') - && (iswhite (bp[5]))) - { - bp = skip_non_spaces (bp); - bp = skip_spaces (bp); - get_tag (bp); + get_tag (bp, NULL); } + if (LOOKING_AT (bp, "(SET!") || LOOKING_AT (bp, "(set!")) + get_tag (bp, NULL); } } @@ -4470,30 +5146,28 @@ Scheme_functions (inf) /* Find tags in TeX and LaTeX input files. */ /* TEX_toktab is a table of TeX control sequences that define tags. - Each TEX_tabent records one such control sequence. - CONVERT THIS TO USE THE Stab TYPE!! */ -struct TEX_tabent -{ - char *name; - int len; -}; + * Each entry records one such control sequence. + * + * Original code from who knows whom. + * Ideas by: + * Stefan Monnier (2002) + */ -struct TEX_tabent *TEX_toktab = NULL; /* Table with tag tokens */ +static linebuffer *TEX_toktab = NULL; /* Table with tag tokens */ /* Default set of control sequences to put into TEX_toktab. The value of environment var TEXTAGS is prepended to this. */ - -char *TEX_defenv = "\ +static char *TEX_defenv = "\ :chapter:section:subsection:subsubsection:eqno:label:ref:cite:bibitem\ -:part:appendix:entry:index"; +:part:appendix:entry:index:def\ +:newcommand:renewcommand:newenvironment:renewenvironment"; -static void TEX_mode P_((FILE *)); -static struct TEX_tabent *TEX_decode_env P_((char *, char *)); -static int TEX_Token P_((char *)); +static void TEX_mode __P((FILE *)); +static void TEX_decode_env __P((char *, char *)); -char TEX_esc = '\\'; -char TEX_opgrp = '{'; -char TEX_clgrp = '}'; +static char TEX_esc = '\\'; +static char TEX_opgrp = '{'; +static char TEX_clgrp = '}'; /* * TeX/LaTeX scanning loop. @@ -4502,46 +5176,64 @@ static void TeX_commands (inf) FILE *inf; { - char *cp, *lasthit; - register int i; + char *cp; + linebuffer *key; /* Select either \ or ! as escape character. */ TEX_mode (inf); /* Initialize token table once from environment. */ - if (!TEX_toktab) - TEX_toktab = TEX_decode_env ("TEXTAGS", TEX_defenv); + if (TEX_toktab == NULL) + TEX_decode_env ("TEXTAGS", TEX_defenv); LOOP_ON_INPUT_LINES (inf, lb, cp) { - lasthit = cp; - /* Look at each esc in line. */ - while ((cp = etags_strchr (cp, TEX_esc)) != NULL) + /* Look at each TEX keyword in line. */ + for (;;) { - if (*++cp == '\0') - break; - linecharno += cp - lasthit; - lasthit = cp; - i = TEX_Token (lasthit); - if (i >= 0) - { - /* We seem to include the TeX command in the tag name. - register char *p; - for (p = lasthit + TEX_toktab[i].len; - *p != '\0' && *p != TEX_clgrp; - p++) - continue; */ - pfnote (/*savenstr (lasthit, p-lasthit)*/ (char *)NULL, TRUE, - lb.buffer, lb.len, lineno, linecharno); - break; /* We only tag a line once */ - } + /* Look for a TEX escape. */ + while (*cp++ != TEX_esc) + if (cp[-1] == '\0' || cp[-1] == '%') + goto tex_next_line; + + for (key = TEX_toktab; key->buffer != NULL; key++) + if (strneq (cp, key->buffer, key->len)) + { + register char *p; + int namelen, linelen; + bool opgrp = FALSE; + + cp = skip_spaces (cp + key->len); + if (*cp == TEX_opgrp) + { + opgrp = TRUE; + cp++; + } + for (p = cp; + (!iswhite (*p) && *p != '#' && + *p != TEX_opgrp && *p != TEX_clgrp); + p++) + continue; + namelen = p - cp; + linelen = lb.len; + if (!opgrp || *p == TEX_clgrp) + { + while (*p != '\0' && *p != TEX_opgrp && *p != TEX_clgrp) + p++; + linelen = p - lb.buffer + 1; + } + make_tag (cp, namelen, TRUE, + lb.buffer, linelen, lineno, linecharno); + goto tex_next_line; /* We only tag a line once */ + } } + tex_next_line: + ; } } #define TEX_LESC '\\' #define TEX_SESC '!' -#define TEX_cmt '%' /* Figure out whether TeX's escapechar is '\\' or '!' and set grouping chars accordingly. */ @@ -4554,8 +5246,8 @@ TEX_mode (inf) while ((c = getc (inf)) != EOF) { /* Skip to next line if we hit the TeX comment char. */ - if (c == TEX_cmt) - while (c != '\n') + if (c == '%') + while (c != '\n' && c != EOF) c = getc (inf); else if (c == TEX_LESC || c == TEX_SESC ) break; @@ -4580,15 +5272,13 @@ TEX_mode (inf) /* Read environment and prepend it to the default string. Build token table. */ -static struct TEX_tabent * +static void TEX_decode_env (evarname, defenv) char *evarname; char *defenv; { register char *env, *p; - - struct TEX_tabent *tab; - int size, i; + int i, len; /* Append default string to environment. */ env = getenv (evarname); @@ -4601,52 +5291,33 @@ TEX_decode_env (evarname, defenv) } /* Allocate a token table */ - for (size = 1, p = env; p;) + for (len = 1, p = env; p;) if ((p = etags_strchr (p, ':')) && *++p != '\0') - size++; - /* Add 1 to leave room for null terminator. */ - tab = xnew (size + 1, struct TEX_tabent); + len++; + TEX_toktab = xnew (len, linebuffer); /* Unpack environment string into token table. Be careful about */ /* zero-length strings (leading ':', "::" and trailing ':') */ - for (i = 0; *env;) + for (i = 0; *env != '\0';) { p = etags_strchr (env, ':'); if (!p) /* End of environment string. */ p = env + strlen (env); if (p - env > 0) { /* Only non-zero strings. */ - tab[i].name = savenstr (env, p - env); - tab[i].len = strlen (tab[i].name); + TEX_toktab[i].buffer = savenstr (env, p - env); + TEX_toktab[i].len = p - env; i++; } if (*p) env = p + 1; else { - tab[i].name = NULL; /* Mark end of table. */ - tab[i].len = 0; + TEX_toktab[i].buffer = NULL; /* Mark end of table. */ + TEX_toktab[i].len = 0; break; } } - return tab; -} - -/* If the text at CP matches one of the tag-defining TeX command names, - return the pointer to the first occurrence of that command in TEX_toktab. - Otherwise return -1. - Keep the capital `T' in `token' for dumb truncating compilers - (this distinguishes it from `TEX_toktab' */ -static int -TEX_Token (cp) - char *cp; -{ - int i; - - for (i = 0; TEX_toktab[i].len > 0; i++) - if (strneq (TEX_toktab[i].name, cp, TEX_toktab[i].len)) - return i; - return -1; } @@ -4657,32 +5328,149 @@ Texinfo_nodes (inf) { char *cp, *start; LOOP_ON_INPUT_LINES (inf, lb, cp) - { - if ((*cp++ == '@' - && *cp++ == 'n' - && *cp++ == 'o' - && *cp++ == 'd' - && *cp++ == 'e' && iswhite (*cp++))) - { - start = cp = skip_spaces(cp); - while (*cp != '\0' && *cp != ',') - cp++; - pfnote (savenstr (start, cp - start), TRUE, + if (LOOKING_AT (cp, "@node")) + { + start = cp; + while (*cp != '\0' && *cp != ',') + cp++; + make_tag (start, cp - start, TRUE, lb.buffer, cp - lb.buffer + 1, lineno, linecharno); - } - } + } +} + + +/* + * HTML support. + * Contents of , <h1>, <h2>, <h3> are tags. + * Contents of <a name=xxx> are tags with name xxx. + * + * Francesco Potortì, 2002. + */ +static void +HTML_labels (inf) + FILE * inf; +{ + bool getnext = FALSE; /* next text outside of HTML tags is a tag */ + bool skiptag = FALSE; /* skip to the end of the current HTML tag */ + bool intag = FALSE; /* inside an html tag, looking for ID= */ + bool inanchor = FALSE; /* when INTAG, is an anchor, look for NAME= */ + char *end; + + + linebuffer_setlen (&token_name, 0); /* no name in buffer */ + + LOOP_ON_INPUT_LINES (inf, lb, dbp) + for (;;) /* loop on the same line */ + { + if (skiptag) /* skip HTML tag */ + { + while (*dbp != '\0' && *dbp != '>') + dbp++; + if (*dbp == '>') + { + dbp += 1; + skiptag = FALSE; + continue; /* look on the same line */ + } + break; /* go to next line */ + } + + else if (intag) /* look for "name=" or "id=" */ + { + while (*dbp != '\0' && *dbp != '>' + && lowcase (*dbp) != 'n' && lowcase (*dbp) != 'i') + dbp++; + if (*dbp == '\0') + break; /* go to next line */ + if (*dbp == '>') + { + dbp += 1; + intag = FALSE; + continue; /* look on the same line */ + } + if ((inanchor && LOOKING_AT_NOCASE (dbp, "name=")) + || LOOKING_AT_NOCASE (dbp, "id=")) + { + bool quoted = (dbp[0] == '"'); + + if (quoted) + for (end = ++dbp; *end != '\0' && *end != '"'; end++) + continue; + else + for (end = dbp; *end != '\0' && intoken (*end); end++) + continue; + linebuffer_setlen (&token_name, end - dbp); + strncpy (token_name.buffer, dbp, end - dbp); + token_name.buffer[end - dbp] = '\0'; + + dbp = end; + intag = FALSE; /* we found what we looked for */ + skiptag = TRUE; /* skip to the end of the tag */ + getnext = TRUE; /* then grab the text */ + continue; /* look on the same line */ + } + dbp += 1; + } + + else if (getnext) /* grab next tokens and tag them */ + { + dbp = skip_spaces (dbp); + if (*dbp == '\0') + break; /* go to next line */ + if (*dbp == '<') + { + intag = TRUE; + inanchor = (lowcase (dbp[1]) == 'a' && !intoken (dbp[2])); + continue; /* look on the same line */ + } + + for (end = dbp + 1; *end != '\0' && *end != '<'; end++) + continue; + make_tag (token_name.buffer, token_name.len, TRUE, + dbp, end - dbp, lineno, linecharno); + linebuffer_setlen (&token_name, 0); /* no name in buffer */ + getnext = FALSE; + break; /* go to next line */ + } + + else /* look for an interesting HTML tag */ + { + while (*dbp != '\0' && *dbp != '<') + dbp++; + if (*dbp == '\0') + break; /* go to next line */ + intag = TRUE; + if (lowcase (dbp[1]) == 'a' && !intoken (dbp[2])) + { + inanchor = TRUE; + continue; /* look on the same line */ + } + else if (LOOKING_AT_NOCASE (dbp, "<title>") + || LOOKING_AT_NOCASE (dbp, "<h1>") + || LOOKING_AT_NOCASE (dbp, "<h2>") + || LOOKING_AT_NOCASE (dbp, "<h3>")) + { + intag = FALSE; + getnext = TRUE; + continue; /* look on the same line */ + } + dbp += 1; + } + } } /* - * Prolog support (rewritten) by Anders Lindgren, Mar. 96 + * Prolog support * - * Assumes that the predicate starts at column 0. - * Only the first clause of a predicate is added. + * Assumes that the predicate or rule starts at column 0. + * Only the first clause of a predicate or rule is added. + * Original code by Sunichirou Sugou (1989) + * Rewritten by Anders Lindgren (1996) */ -static int prolog_pred P_((char *, char *)); -static void prolog_skip_comment P_((linebuffer *, FILE *)); -static int prolog_atom P_((char *, int)); +static int prolog_pr __P((char *, char *)); +static void prolog_skip_comment __P((linebuffer *, FILE *)); +static int prolog_atom __P((char *, int)); static void Prolog_functions (inf) @@ -4704,10 +5492,10 @@ Prolog_functions (inf) continue; else if (cp[0] == '/' && cp[1] == '*') /* comment. */ prolog_skip_comment (&lb, inf); - else if ((len = prolog_pred (cp, last)) > 0) + else if ((len = prolog_pr (cp, last)) > 0) { - /* Predicate. Store the function name so that we only - generate a tag for the first clause. */ + /* Predicate or rule. Store the function name so that we + only generate a tag for the first clause. */ if (last == NULL) last = xnew(len + 1, char); else if (len + 1 > allocated) @@ -4717,6 +5505,8 @@ Prolog_functions (inf) last[len] = '\0'; } } + if (last != NULL) + free (last); } @@ -4732,24 +5522,24 @@ prolog_skip_comment (plb, inf) for (cp = plb->buffer; *cp != '\0'; cp++) if (cp[0] == '*' && cp[1] == '/') return; - lineno++; - linecharno += readline (plb, inf); + readline (plb, inf); } while (!feof(inf)); } /* - * A predicate definition is added if it matches: + * A predicate or rule definition is added if it matches: * <beginning of line><Prolog Atom><whitespace>( + * or <beginning of line><Prolog Atom><whitespace>:- * * It is added to the tags database if it doesn't match the * name of the previous clause header. * - * Return the size of the name of the predicate, or 0 if no header - * was found. + * Return the size of the name of the predicate or rule, or 0 if no + * header was found. */ static int -prolog_pred (s, last) +prolog_pr (s, last) char *s; char *last; /* Name of last clause. */ { @@ -4763,21 +5553,18 @@ prolog_pred (s, last) len = pos; pos = skip_spaces (s + pos) - s; - if ((s[pos] == '(') || (s[pos] == '.')) - { - if (s[pos] == '(') - pos++; - - /* Save only the first clause. */ - if (last == NULL + if ((s[pos] == '.' + || (s[pos] == '(' && (pos += 1)) + || (s[pos] == ':' && s[pos + 1] == '-' && (pos += 2))) + && (last == NULL /* save only the first clause */ || len != (int)strlen (last) - || !strneq (s, last, len)) + || !strneq (s, last, len))) { - pfnote (savenstr (s, len), TRUE, s, pos, lineno, linecharno); + make_tag (s, len, TRUE, s, pos, lineno, linecharno); return len; } - } - return 0; + else + return 0; } /* @@ -4812,7 +5599,7 @@ prolog_atom (s, pos) { pos++; - while (1) + for (;;) { if (s[pos] == '\'') { @@ -4841,15 +5628,15 @@ prolog_atom (s, pos) /* - * Support for Erlang -- Anders Lindgren, Feb 1996. + * Support for Erlang * * Generates tags for functions, defines, and records. - * * Assumes that Erlang functions start at column 0. + * Original code by Anders Lindgren (1996) */ -static int erlang_func P_((char *, char *)); -static void erlang_attribute P_((char *)); -static int erlang_atom P_((char *, int)); +static int erlang_func __P((char *, char *)); +static void erlang_attribute __P((char *)); +static int erlang_atom __P((char *)); static void Erlang_functions (inf) @@ -4876,7 +5663,11 @@ Erlang_functions (inf) else if (cp[0] == '-') /* attribute, e.g. "-define" */ { erlang_attribute (cp); - last = NULL; + if (last != NULL) + { + free (last); + last = NULL; + } } else if ((len = erlang_func (cp, last)) > 0) { @@ -4893,6 +5684,8 @@ Erlang_functions (inf) last[len] = '\0'; } } + if (last != NULL) + free (last); } @@ -4914,7 +5707,7 @@ erlang_func (s, last) int pos; int len; - pos = erlang_atom (s, 0); + pos = erlang_atom (s); if (pos < 1) return 0; @@ -4927,7 +5720,7 @@ erlang_func (s, last) || len != (int)strlen (last) || !strneq (s, last, len))) { - pfnote (savenstr (s, len), TRUE, s, pos, lineno, linecharno); + make_tag (s, len, TRUE, s, pos, lineno, linecharno); return len; } @@ -4948,20 +5741,14 @@ static void erlang_attribute (s) char *s; { - int pos; - int len; + char *cp = s; - if (strneq (s, "-define", 7) || strneq (s, "-record", 7)) + if ((LOOKING_AT (cp, "-define") || LOOKING_AT (cp, "-record")) + && *cp++ == '(') { - pos = skip_spaces (s + 7) - s; - if (s[pos++] == '(') - { - pos = skip_spaces (s + pos) - s; - len = erlang_atom (s, pos); - if (len != 0) - pfnote (savenstr (& s[pos], len), TRUE, - s, pos + len, lineno, linecharno); - } + int len = erlang_atom (skip_spaces (cp)); + if (len > 0) + make_tag (cp, len, TRUE, s, cp + len - s, lineno, linecharno); } return; } @@ -4972,65 +5759,44 @@ erlang_attribute (s) * Return the number of bytes consumed, or -1 if there was an error. */ static int -erlang_atom (s, pos) +erlang_atom (s) char *s; - int pos; { - int origpos; - - origpos = pos; + int pos = 0; if (ISALPHA (s[pos]) || s[pos] == '_') { /* The atom is unquoted. */ - pos++; - while (ISALNUM (s[pos]) || s[pos] == '_') + do pos++; - return pos - origpos; + while (ISALNUM (s[pos]) || s[pos] == '_'); } else if (s[pos] == '\'') { + for (pos++; s[pos] != '\''; pos++) + if (s[pos] == '\0' /* multiline quoted atoms are ignored */ + || (s[pos] == '\\' && s[++pos] == '\0')) + return 0; pos++; - - while (1) - { - if (s[pos] == '\'') - { - pos++; - break; - } - else if (s[pos] == '\0') - /* Multiline quoted atoms are ignored. */ - return -1; - else if (s[pos] == '\\') - { - if (s[pos+1] == '\0') - return -1; - pos += 2; - } - else - pos++; - } - return pos - origpos; } - else - return -1; + + return pos; } -#ifdef ETAGS_REGEXPS - -static char *scan_separators P_((char *)); -static void analyse_regex P_((char *, bool)); -static void add_regex P_((char *, bool, language *)); -static char *substitute P_((char *, char *, struct re_registers *)); - -/* Take a string like "/blah/" and turn it into "blah", making sure - that the first and last characters are the same, and handling - quoted separator characters. Actually, stops on the occurrence of - an unquoted separator. Also turns "\t" into a Tab character. - Returns pointer to terminating separator. Works in place. Null - terminates name string. */ +static char *scan_separators __P((char *)); +static void add_regex __P((char *, language *)); +static char *substitute __P((char *, char *, struct re_registers *)); + +/* + * Take a string like "/blah/" and turn it into "blah", verifying + * that the first and last characters are the same, and handling + * quoted separator characters. Actually, stops on the occurrence of + * an unquoted separator. Also process \t, \n, etc. and turn into + * appropriate characters. Works in place. Null terminates name string. + * Returns pointer to terminating separator, or NULL for + * unterminated regexps. + */ static char * scan_separators (name) char *name; @@ -5043,15 +5809,27 @@ scan_separators (name) { if (quoted) { - if (*name == 't') - *copyto++ = '\t'; - else if (*name == sep) - *copyto++ = sep; - else + switch (*name) { - /* Something else is quoted, so preserve the quote. */ - *copyto++ = '\\'; - *copyto++ = *name; + case 'a': *copyto++ = '\007'; break; /* BEL (bell) */ + case 'b': *copyto++ = '\b'; break; /* BS (back space) */ + case 'd': *copyto++ = 0177; break; /* DEL (delete) */ + case 'e': *copyto++ = 033; break; /* ESC (delete) */ + case 'f': *copyto++ = '\f'; break; /* FF (form feed) */ + case 'n': *copyto++ = '\n'; break; /* NL (new line) */ + case 'r': *copyto++ = '\r'; break; /* CR (carriage return) */ + case 't': *copyto++ = '\t'; break; /* TAB (horizontal tab) */ + case 'v': *copyto++ = '\v'; break; /* VT (vertical tab) */ + default: + if (*name == sep) + *copyto++ = sep; + else + { + /* Something else is quoted, so preserve the quote. */ + *copyto++ = '\\'; + *copyto++ = *name; + } + break; } quoted = FALSE; } @@ -5062,6 +5840,8 @@ scan_separators (name) else *copyto++ = *name; } + if (*name != sep) + name = NULL; /* signal unterminated regexp */ /* Terminate copied string. */ *copyto = '\0'; @@ -5071,12 +5851,14 @@ scan_separators (name) /* Look at the argument of --regex or --no-regex and do the right thing. Same for each line of a regexp file. */ static void -analyse_regex (regex_arg, ignore_case) +analyse_regex (regex_arg) char *regex_arg; - bool ignore_case; { if (regex_arg == NULL) - free_patterns (); /* --no-regex: remove existing regexps */ + { + free_regexps (); /* --no-regex: remove existing regexps */ + return; + } /* A real --regexp option or a line in a regexp file. */ switch (regex_arg[0]) @@ -5102,9 +5884,9 @@ analyse_regex (regex_arg, ignore_case) pfatal (regexfile); return; } - initbuffer (®exbuf); + linebuffer_init (®exbuf); while (readline_internal (®exbuf, regexfp) > 0) - analyse_regex (regexbuf.buffer, ignore_case); + analyse_regex (regexbuf.buffer); free (regexbuf.buffer); fclose (regexfp); } @@ -5123,69 +5905,136 @@ analyse_regex (regex_arg, ignore_case) error ("unterminated language name in regex: %s", regex_arg); return; } - *cp = '\0'; + *cp++ = '\0'; lang = get_language_from_langname (lang_name); if (lang == NULL) return; - add_regex (cp + 1, ignore_case, lang); + add_regex (cp, lang); } break; /* Regexp to be used for any language. */ default: - add_regex (regex_arg, ignore_case, NULL); + add_regex (regex_arg, NULL); break; } } -/* Turn a name, which is an ed-style (but Emacs syntax) regular - expression, into a real regular expression by compiling it. */ +/* Separate the regexp pattern, compile it, + and care for optional name and modifiers. */ static void -add_regex (regexp_pattern, ignore_case, lang) +add_regex (regexp_pattern, lang) char *regexp_pattern; - bool ignore_case; language *lang; { static struct re_pattern_buffer zeropattern; - char *name; + char sep, *pat, *name, *modifiers; const char *err; struct re_pattern_buffer *patbuf; - pattern *pp; + regexp *rp; + bool + force_explicit_name = TRUE, /* do not use implicit tag names */ + ignore_case = FALSE, /* case is significant */ + multi_line = FALSE, /* matches are done one line at a time */ + single_line = FALSE; /* dot does not match newline */ - if (regexp_pattern[strlen(regexp_pattern)-1] != regexp_pattern[0]) + if (strlen(regexp_pattern) < 3) { - error ("%s: unterminated regexp", regexp_pattern); + error ("null regexp", (char *)NULL); return; } + sep = regexp_pattern[0]; name = scan_separators (regexp_pattern); - if (regexp_pattern[0] == '\0') + if (name == NULL) { - error ("null regexp", (char *)NULL); + error ("%s: unterminated regexp", regexp_pattern); + return; + } + if (name[1] == sep) + { + error ("null name for regexp \"%s\"", regexp_pattern); return; } - (void) scan_separators (name); + modifiers = scan_separators (name); + if (modifiers == NULL) /* no terminating separator --> no name */ + { + modifiers = name; + name = ""; + } + else + modifiers += 1; /* skip separator */ + + /* Parse regex modifiers. */ + for (; modifiers[0] != '\0'; modifiers++) + switch (modifiers[0]) + { + case 'N': + if (modifiers == name) + error ("forcing explicit tag name but no name, ignoring", NULL); + force_explicit_name = TRUE; + break; + case 'i': + ignore_case = TRUE; + break; + case 's': + single_line = TRUE; + /* FALLTHRU */ + case 'm': + multi_line = TRUE; + need_filebuf = TRUE; + break; + default: + { + char wrongmod [2]; + wrongmod[0] = modifiers[0]; + wrongmod[1] = '\0'; + error ("invalid regexp modifier `%s', ignoring", wrongmod); + } + break; + } patbuf = xnew (1, struct re_pattern_buffer); *patbuf = zeropattern; - /* Translation table to fold case if appropriate. */ - patbuf->translate = (ignore_case) ? lc_trans : NULL; + if (ignore_case) + { + static char lc_trans[CHARS]; + int i; + for (i = 0; i < CHARS; i++) + lc_trans[i] = lowcase (i); + patbuf->translate = lc_trans; /* translation table to fold case */ + } + + if (multi_line) + pat = concat ("^", regexp_pattern, ""); /* anchor to beginning of line */ + else + pat = regexp_pattern; + + if (single_line) + re_set_syntax (RE_SYNTAX_EMACS | RE_DOT_NEWLINE); + else + re_set_syntax (RE_SYNTAX_EMACS); - err = re_compile_pattern (regexp_pattern, strlen (regexp_pattern), patbuf); + err = re_compile_pattern (pat, strlen (regexp_pattern), patbuf); + if (multi_line) + free (pat); if (err != NULL) { error ("%s while compiling pattern", err); return; } - pp = p_head; - p_head = xnew (1, pattern); - p_head->regex = savestr (regexp_pattern); - p_head->p_next = pp; - p_head->language = lang; - p_head->pattern = patbuf; - p_head->name_pattern = savestr (name); + rp = p_head; + p_head = xnew (1, regexp); + p_head->pattern = savestr (regexp_pattern); + p_head->p_next = rp; + p_head->lang = lang; + p_head->pat = patbuf; + p_head->name = savestr (name); p_head->error_signaled = FALSE; + p_head->force_explicit_name = force_explicit_name; + p_head->ignore_case = ignore_case; + p_head->multi_line = multi_line; } /* @@ -5219,6 +6068,7 @@ substitute (in, out, regs) size -= 1; /* Allocate space and do the substitutions. */ + assert (size >= 0); result = xnew (size + 1, char); for (t = result; *out != '\0'; out++) @@ -5233,55 +6083,146 @@ substitute (in, out, regs) *t++ = *out; *t = '\0'; - assert (t <= result + size && t - result == (int)strlen (result)); + assert (t <= result + size); + assert (t - result == (int)strlen (result)); return result; } -/* Deallocate all patterns. */ +/* Deallocate all regexps. */ static void -free_patterns () +free_regexps () { - pattern *pp; + regexp *rp; while (p_head != NULL) { - pp = p_head->p_next; - free (p_head->regex); - free (p_head->name_pattern); + rp = p_head->p_next; + free (p_head->pattern); + free (p_head->name); free (p_head); - p_head = pp; + p_head = rp; } return; } -#endif /* ETAGS_REGEXPS */ - +/* + * Reads the whole file as a single string from `filebuf' and looks for + * multi-line regular expressions, creating tags on matches. + * readline already dealt with normal regexps. + * + * Idea by Ben Wing <ben@666.com> (2002). + */ static void -get_tag (bp) - register char *bp; +regex_tag_multiline () { - register char *cp; + char *buffer = filebuf.buffer; + regexp *rp; + char *name; - if (*bp == '\0') - return; - /* Go till you get to white space or a syntactic break */ - for (cp = bp + 1; - *cp != '\0' && *cp != '(' && *cp != ')' && !iswhite (*cp); - cp++) - continue; - pfnote (savenstr (bp, cp-bp), TRUE, - lb.buffer, cp - lb.buffer + 1, lineno, linecharno); + for (rp = p_head; rp != NULL; rp = rp->p_next) + { + int match = 0; + + if (!rp->multi_line) + continue; /* skip normal regexps */ + + /* Generic initialisations before parsing file from memory. */ + lineno = 1; /* reset global line number */ + charno = 0; /* reset global char number */ + linecharno = 0; /* reset global char number of line start */ + + /* Only use generic regexps or those for the current language. */ + if (rp->lang != NULL && rp->lang != curfdp->lang) + continue; + + while (match >= 0 && match < filebuf.len) + { + match = re_search (rp->pat, buffer, filebuf.len, charno, + filebuf.len - match, &rp->regs); + switch (match) + { + case -2: + /* Some error. */ + if (!rp->error_signaled) + { + error ("regexp stack overflow while matching \"%s\"", + rp->pattern); + rp->error_signaled = TRUE; + } + break; + case -1: + /* No match. */ + break; + default: + if (match == rp->regs.end[0]) + { + if (!rp->error_signaled) + { + error ("regexp matches the empty string: \"%s\"", + rp->pattern); + rp->error_signaled = TRUE; + } + match = -3; /* exit from while loop */ + break; + } + + /* Match occurred. Construct a tag. */ + while (charno < rp->regs.end[0]) + if (buffer[charno++] == '\n') + lineno++, linecharno = charno; + name = rp->name; + if (name[0] == '\0') + name = NULL; + else /* make a named tag */ + name = substitute (buffer, rp->name, &rp->regs); + if (rp->force_explicit_name) + /* Force explicit tag name, if a name is there. */ + pfnote (name, TRUE, buffer + linecharno, + charno - linecharno + 1, lineno, linecharno); + else + make_tag (name, strlen (name), TRUE, buffer + linecharno, + charno - linecharno + 1, lineno, linecharno); + break; + } + } + } +} + + +static bool +nocase_tail (cp) + char *cp; +{ + register int len = 0; + + while (*cp != '\0' && lowcase (*cp) == lowcase (dbp[len])) + cp++, len++; + if (*cp == '\0' && !intoken (dbp[len])) + { + dbp += len; + return TRUE; + } + return FALSE; } -/* Initialize a linebuffer for use */ static void -initbuffer (lbp) - linebuffer *lbp; +get_tag (bp, namepp) + register char *bp; + char **namepp; { - lbp->size = (DEBUG) ? 3 : 200; - lbp->buffer = xnew (lbp->size, char); - lbp->buffer[0] = '\0'; - lbp->len = 0; + register char *cp = bp; + + if (*bp != '\0') + { + /* Go till you get to white space or a syntactic break */ + for (cp = bp + 1; !notinname (*cp); cp++) + continue; + make_tag (bp, cp - bp, TRUE, + lb.buffer, cp - lb.buffer + 1, lineno, linecharno); + } + + if (namepp != NULL) + *namepp = savenstr (bp, cp - bp); } /* @@ -5289,10 +6230,13 @@ initbuffer (lbp) * newline or CR-NL, if any. Return the number of characters read from * `stream', which is the length of the line including the newline. * - * On DOS or Windows we do not count the CR character, if any, before the - * NL, in the returned length; this mirrors the behavior of emacs on those + * On DOS or Windows we do not count the CR character, if any before the + * NL, in the returned length; this mirrors the behavior of Emacs on those * platforms (for text files, it translates CR-NL to NL as it reads in the * file). + * + * If multi-line regular expressions are requested, each line read is + * appended to `filebuf'. */ static long readline_internal (lbp, stream) @@ -5306,7 +6250,7 @@ readline_internal (lbp, stream) pend = p + lbp->size; /* Separate to avoid 386/IX compiler bug. */ - while (1) + for (;;) { register int c = getc (stream); if (p == pend) @@ -5351,68 +6295,217 @@ readline_internal (lbp, stream) } lbp->len = p - buffer; + if (need_filebuf /* we need filebuf for multi-line regexps */ + && chars_deleted > 0) /* not at EOF */ + { + while (filebuf.size <= filebuf.len + lbp->len + 1) /* +1 for \n */ + { + /* Expand filebuf. */ + filebuf.size *= 2; + xrnew (filebuf.buffer, filebuf.size, char); + } + strncpy (filebuf.buffer + filebuf.len, lbp->buffer, lbp->len); + filebuf.len += lbp->len; + filebuf.buffer[filebuf.len++] = '\n'; + filebuf.buffer[filebuf.len] = '\0'; + } + return lbp->len + chars_deleted; } /* * Like readline_internal, above, but in addition try to match the - * input line against relevant regular expressions. + * input line against relevant regular expressions and manage #line + * directives. */ -static long +static void readline (lbp, stream) linebuffer *lbp; FILE *stream; { - /* Read new line. */ - long result = readline_internal (lbp, stream); -#ifdef ETAGS_REGEXPS - int match; - pattern *pp; - - /* Match against relevant patterns. */ - if (lbp->len > 0) - for (pp = p_head; pp != NULL; pp = pp->p_next) - { - /* Only use generic regexps or those for the current language. */ - if (pp->language != NULL && pp->language != curlang) - continue; + long result; - match = re_match (pp->pattern, lbp->buffer, lbp->len, 0, &pp->regs); - switch (match) - { - case -2: - /* Some error. */ - if (!pp->error_signaled) - { - error ("error while matching \"%s\"", pp->regex); - pp->error_signaled = TRUE; - } - break; - case -1: - /* No match. */ - break; - default: - /* Match occurred. Construct a tag. */ - if (pp->name_pattern[0] != '\0') - { - /* Make a named tag. */ - char *name = substitute (lbp->buffer, - pp->name_pattern, &pp->regs); - if (name != NULL) - pfnote (name, TRUE, lbp->buffer, match, lineno, linecharno); - } - else - { - /* Make an unnamed tag. */ - pfnote ((char *)NULL, TRUE, - lbp->buffer, match, lineno, linecharno); - } - break; - } - } -#endif /* ETAGS_REGEXPS */ + linecharno = charno; /* update global char number of line start */ + result = readline_internal (lbp, stream); /* read line */ + lineno += 1; /* increment global line number */ + charno += result; /* increment global char number */ - return result; + /* Honour #line directives. */ + if (!no_line_directive) + { + static bool discard_until_line_directive; + + /* Check whether this is a #line directive. */ + if (result > 12 && strneq (lbp->buffer, "#line ", 6)) + { + unsigned int lno; + int start = 0; + + if (sscanf (lbp->buffer, "#line %u \"%n", &lno, &start) >= 1 + && start > 0) /* double quote character found */ + { + char *endp = lbp->buffer + start; + + while ((endp = etags_strchr (endp, '"')) != NULL + && endp[-1] == '\\') + endp++; + if (endp != NULL) + /* Ok, this is a real #line directive. Let's deal with it. */ + { + char *taggedabsname; /* absolute name of original file */ + char *taggedfname; /* name of original file as given */ + char *name; /* temp var */ + + discard_until_line_directive = FALSE; /* found it */ + name = lbp->buffer + start; + *endp = '\0'; + canonicalize_filename (name); /* for DOS */ + taggedabsname = absolute_filename (name, tagfiledir); + if (filename_is_absolute (name) + || filename_is_absolute (curfdp->infname)) + taggedfname = savestr (taggedabsname); + else + taggedfname = relative_filename (taggedabsname,tagfiledir); + + if (streq (curfdp->taggedfname, taggedfname)) + /* The #line directive is only a line number change. We + deal with this afterwards. */ + free (taggedfname); + else + /* The tags following this #line directive should be + attributed to taggedfname. In order to do this, set + curfdp accordingly. */ + { + fdesc *fdp; /* file description pointer */ + + /* Go look for a file description already set up for the + file indicated in the #line directive. If there is + one, use it from now until the next #line + directive. */ + for (fdp = fdhead; fdp != NULL; fdp = fdp->next) + if (streq (fdp->infname, curfdp->infname) + && streq (fdp->taggedfname, taggedfname)) + /* If we remove the second test above (after the &&) + then all entries pertaining to the same file are + coalesced in the tags file. If we use it, then + entries pertaining to the same file but generated + from different files (via #line directives) will + go into separate sections in the tags file. These + alternatives look equivalent. The first one + destroys some apparently useless information. */ + { + curfdp = fdp; + free (taggedfname); + break; + } + /* Else, if we already tagged the real file, skip all + input lines until the next #line directive. */ + if (fdp == NULL) /* not found */ + for (fdp = fdhead; fdp != NULL; fdp = fdp->next) + if (streq (fdp->infabsname, taggedabsname)) + { + discard_until_line_directive = TRUE; + free (taggedfname); + break; + } + /* Else create a new file description and use that from + now on, until the next #line directive. */ + if (fdp == NULL) /* not found */ + { + fdp = fdhead; + fdhead = xnew (1, fdesc); + *fdhead = *curfdp; /* copy curr. file description */ + fdhead->next = fdp; + fdhead->infname = savestr (curfdp->infname); + fdhead->infabsname = savestr (curfdp->infabsname); + fdhead->infabsdir = savestr (curfdp->infabsdir); + fdhead->taggedfname = taggedfname; + fdhead->usecharno = FALSE; + fdhead->prop = NULL; + fdhead->written = FALSE; + curfdp = fdhead; + } + } + free (taggedabsname); + lineno = lno - 1; + readline (lbp, stream); + return; + } /* if a real #line directive */ + } /* if #line is followed by a a number */ + } /* if line begins with "#line " */ + + /* If we are here, no #line directive was found. */ + if (discard_until_line_directive) + { + if (result > 0) + { + /* Do a tail recursion on ourselves, thus discarding the contents + of the line buffer. */ + readline (lbp, stream); + return; + } + /* End of file. */ + discard_until_line_directive = FALSE; + return; + } + } /* if #line directives should be considered */ + + { + int match; + regexp *rp; + char *name; + + /* Match against relevant regexps. */ + if (lbp->len > 0) + for (rp = p_head; rp != NULL; rp = rp->p_next) + { + /* Only use generic regexps or those for the current language. + Also do not use multiline regexps, which is the job of + regex_tag_multiline. */ + if ((rp->lang != NULL && rp->lang != fdhead->lang) + || rp->multi_line) + continue; + + match = re_match (rp->pat, lbp->buffer, lbp->len, 0, &rp->regs); + switch (match) + { + case -2: + /* Some error. */ + if (!rp->error_signaled) + { + error ("regexp stack overflow while matching \"%s\"", + rp->pattern); + rp->error_signaled = TRUE; + } + break; + case -1: + /* No match. */ + break; + case 0: + /* Empty string matched. */ + if (!rp->error_signaled) + { + error ("regexp matches the empty string: \"%s\"", rp->pattern); + rp->error_signaled = TRUE; + } + break; + default: + /* Match occurred. Construct a tag. */ + name = rp->name; + if (name[0] == '\0') + name = NULL; + else /* make a named tag */ + name = substitute (lbp->buffer, rp->name, &rp->regs); + if (rp->force_explicit_name) + /* Force explicit tag name, if a name is there. */ + pfnote (name, TRUE, lbp->buffer, match, lineno, linecharno); + else + make_tag (name, strlen (name), TRUE, + lbp->buffer, match, lineno, linecharno); + break; + } + } + } } @@ -5466,7 +6559,6 @@ etags_strrchr (sp, c) return (char *)r; } - /* * Return the ptr in sp at which the character c first * appears; NULL if not found @@ -5486,7 +6578,54 @@ etags_strchr (sp, c) return NULL; } -/* Skip spaces, return new pointer. */ +/* + * Compare two strings, ignoring case for alphabetic characters. + * + * Same as BSD's strcasecmp, included for portability. + */ +static int +etags_strcasecmp (s1, s2) + register const char *s1; + register const char *s2; +{ + while (*s1 != '\0' + && (ISALPHA (*s1) && ISALPHA (*s2) + ? lowcase (*s1) == lowcase (*s2) + : *s1 == *s2)) + s1++, s2++; + + return (ISALPHA (*s1) && ISALPHA (*s2) + ? lowcase (*s1) - lowcase (*s2) + : *s1 - *s2); +} + +/* + * Compare two strings, ignoring case for alphabetic characters. + * Stop after a given number of characters + * + * Same as BSD's strncasecmp, included for portability. + */ +static int +etags_strncasecmp (s1, s2, n) + register const char *s1; + register const char *s2; + register int n; +{ + while (*s1 != '\0' && n-- > 0 + && (ISALPHA (*s1) && ISALPHA (*s2) + ? lowcase (*s1) == lowcase (*s2) + : *s1 == *s2)) + s1++, s2++; + + if (n < 0) + return 0; + else + return (ISALPHA (*s1) && ISALPHA (*s2) + ? lowcase (*s1) - lowcase (*s2) + : *s1 - *s2); +} + +/* Skip spaces (end of string is not space), return new pointer. */ static char * skip_spaces (cp) char *cp; @@ -5496,7 +6635,7 @@ skip_spaces (cp) return cp; } -/* Skip non spaces, return new pointer. */ +/* Skip non spaces, except end of string, return new pointer. */ static char * skip_non_spaces (cp) char *cp; @@ -5512,7 +6651,7 @@ fatal (s1, s2) char *s1, *s2; { error (s1, s2); - exit (BAD); + exit (EXIT_FAILURE); } static void @@ -5520,21 +6659,15 @@ pfatal (s1) char *s1; { perror (s1); - exit (BAD); + exit (EXIT_FAILURE); } static void suggest_asking_for_help () { fprintf (stderr, "\tTry `%s %s' for a complete list of options.\n", - progname, -#ifdef LONG_OPTIONS - "--help" -#else - "-h" -#endif - ); - exit (BAD); + progname, NO_LONG_OPTIONS ? "-h" : "--help"); + exit (EXIT_FAILURE); } /* Print error message. `s1' is printf control string, `s2' is arg for it. */ @@ -5604,7 +6737,7 @@ etags_getcwd () linebuffer path; FILE *pipe; - initbuffer (&path); + linebuffer_init (&path); pipe = (FILE *) popen ("pwd 2>/dev/null", "r"); if (pipe == NULL || readline_internal (&path, pipe) == 0) pfatal ("pwd"); @@ -5710,8 +6843,11 @@ absolute_filename (file, dir) slashp = etags_strchr (slashp + 1, '/'); } - if (res[0] == '\0') - return savestr ("/"); + if (res[0] == '\0') /* just a safety net: should never happen */ + { + free (res); + return savestr ("/"); + } else return res; } @@ -5770,6 +6906,18 @@ canonicalize_filename (fn) #endif } + +/* Initialize a linebuffer for use */ +static void +linebuffer_init (lbp) + linebuffer *lbp; +{ + lbp->size = (DEBUG) ? 3 : 200; + lbp->buffer = xnew (lbp->size, char); + lbp->buffer[0] = '\0'; + lbp->len = 0; +} + /* Set the minimum size of a string contained in a linebuffer. */ static void linebuffer_setlen (lbp, toksize) @@ -5784,24 +6932,39 @@ linebuffer_setlen (lbp, toksize) lbp->len = toksize; } -/* Like malloc but get fatal error if memory is exhausted. */ -long * +/* Like malloc but get fatal error if memory is exhausted. */ +static PTR xmalloc (size) unsigned int size; { - long *result = (long *) malloc (size); + PTR result = (PTR) malloc (size); if (result == NULL) fatal ("virtual memory exhausted", (char *)NULL); return result; } -long * +static PTR xrealloc (ptr, size) char *ptr; unsigned int size; { - long *result = (long *) realloc (ptr, size); + PTR result = (PTR) realloc (ptr, size); if (result == NULL) fatal ("virtual memory exhausted", (char *)NULL); return result; } + +/* + * Local Variables: + * indent-tabs-mode: t + * tab-width: 8 + * fill-column: 79 + * c-font-lock-extra-types: ("FILE" "bool" "language" "linebuffer" "fdesc" "node" "regexp") + * c-file-style: "gnu" + * End: + */ + +/* arch-tag: 8a9b748d-390c-4922-99db-2eeefa921051 + (do not change this comment) */ + +/* etags.c ends here */ diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d89637d..aaa3047 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,60 @@ +2007-10-07 Vin Shelton <acs@xemacs.org> + + * XEmacs 21.4.21 is released + +2007-09-19 Didier Verna <didier@xemacs.org> + + Update my personal info. + * about.el (xemacs-hackers): Use 'didier instead of 'dv. + * about.el (about-other-current-hackers): Ditto. + * about.el (about-url-alist): Add my musical website. + * about.el (about-personal-info): Update my entry. + * about.el (about-hacker-contribution): Ditto. + +2007-08-21 Adrian Aichner <adrian@xemacs.org> + + * package-get.el (package-get-download-sites): Update download + sites in Japan. + * package-get.el (package-get-pre-release-download-sites): Ditto. + +2007-08-18 Vin Shelton <acs@xemacs.org> + + * package-get.el (package-get-pre-release-download-sites): Sync + mirror sites with 21.5. (Thanks, Adrian) + +2007-08-09 Mike Sperber <mike@xemacs.org> + + * startup.el (migrate-user-init-file): Create backup of + `user-init-file' before migrating. + * startup.el (maybe-migrate-user-init-file): Print + information about backup file. + (maybe-create-compatibility-dot-emacs): Follow above change. + +2006-11-02 Adrian Aichner <adrian@xemacs.org> + + * font-lock.el: Sync font-lock-add-keywords and + font-lock-remove-keywords from GNU Emacs. + * font-lock.el (font-lock-keywords-alist): New. + * font-lock.el (font-lock-removed-keywords-alist): New. + * font-lock.el (font-lock-add-keywords): New. + * font-lock.el (font-lock-update-removed-keyword-alist): New. + * font-lock.el (font-lock-remove-keywords): New. + +2007-08-16 Vin Shelton <acs@xemacs.org> + + * font-lock.el: Add defvar for font-lock-warning-face. Original + patch from Hans de Graaff. + +2007-07-28 Adrian Aichner <adrian@xemacs.org> + + * package-get.el (package-get-download-sites): Document Chile and + update Denmark download site. + * package-get.el (package-get-pre-release-download-sites): Ditto. + +2007-05-20 Stephen J. Turnbull <stephen@xemacs.org> + + * gutter-items.el (progress-feedback-with-label): Clarify docstring. + 2006-12-09 Vin Shelton <acs@xemacs.org> * XEmacs 21.4.20 is released diff --git a/lisp/about.el b/lisp/about.el index e6e7d58..ef91a55 100644 --- a/lisp/about.el +++ b/lisp/about.el @@ -111,7 +111,7 @@ (devin "Matthieu Devin" "devin@xemacs.org") (dkindred "Darrell Kindred" "dkindred@xemacs.org") (dmoore "David Moore" "dmoore@xemacs.org") - (dv "Didier Verna" "didier@xemacs.org") + (didier "Didier Verna" "didier@xemacs.org") (eb "Eric Benson" "eb@xemacs.org") (fabrice "Fabrice Popineau" "fabrice@xemacs.org") (golubev "Ilya Golubev" "golubev@xemacs.org") @@ -173,7 +173,7 @@ (defvar about-other-current-hackers ;; to sort this list or the one below, use: ;; M-x sort-regexp-fields RET [a-z]+ RET \(.*\) RET - '(aj alastair cgw craig daiki dan dv fabrice golubev gunnar hisashi hniksic + '(aj alastair cgw craig daiki dan didier fabrice golubev gunnar hisashi hniksic jan jareth jmiller jason jonathan kazz kirill larsi morioka mta ograf olivier oscar pittman tomonori tuck wmperry yoshiki)) @@ -199,7 +199,8 @@ (daiki . "http://deisui.bug.org/diary/servlet/view") (dkindred . "http://www.cs.cmu.edu/People/dkindred/me.html") (dmoore . "http://oj.egbt.org/dmoore/") - (dv . "http://www.lrde.epita.fr/~didier/") + (didier . "http://didier.lrde.org/") + (dvljazz . "http://www.didierverna.com/") (fabrice . "http://www.ese-metz.fr/~popineau/") (fptex . "http://www.fptex.org/") (jas . "http://josefsson.org/") @@ -931,24 +932,30 @@ hours of the day. He has a page at ") (about-url-link 'dmoore nil "Visit David's home page") (widget-insert ".\n")) - (dv - (widget-insert "\ -I graduated at ENST (an engineering school in Paris) and have a Ph.D. -in computer science. I'm currently a teacher at EPITA (another -engineering school, still in Paris) and a researcher at LRDE (EPITA's -research and development laboratory). Our research topics include -generic programming and distributed virtual reality. - -Apart from XEmacs, I'm also involved in other free software projects, -including Gnus, BBDB, and the GNU \"autotools\". I also wrote some -LaTeX packages (ugh :-). - -All of this, actually, is only 60% true. Two days per week, I'm also a -semi-professional Jazz guitar player (and singer), which means that it -is not the way I earn my crust, but things may very well reverse in -the future ...\n\n") - (widget-insert "Visit Didier's home page: ") - (about-url-link 'dv nil "Visit Didier's home page") + (didier + (widget-insert "\ +Didier has a Ph.D. in Computer Science and is currently working as an +assistant professor for an engineering school in Paris). He gives +lectures on Operating Systems, Computer Graphics, Functional Programming +and Typesetting. His research interests include Genericity, Object +Orientation and Functional Programming, all in one language: + +... Common Lisp. + + +Apart from the world of XEmacs and Emacs Lisp, Didier is also the author +of several LaTeX packages (FiNK, FiXme, QCM and CurVe) and an occasional +contributor to other Free Software projects (the GNU Autotools most +notably; he was one of the technical reviewers for the \"Goat Book\"). + +But all of this is only 60% true... Two days per week, Didier is indeed +a semi-professional Jazz guitar player (and singer), which means that he +doesn't quite earn his crust with it, but things may very well reverse in +the future...\n") + (widget-insert "\nVisit Didier's scientific website: ") + (about-url-link 'didier nil "Visit Didier's scientific website") + (widget-insert "\nVisit Didier's musical website: ") + (about-url-link 'dvljazz nil "Visit Didier's musical website") (widget-insert "\n")) (eb (widget-insert @@ -1540,18 +1547,17 @@ annoy him. He hopes he's spared you from a core dump or two.\n")) (dmoore (widget-insert "\ David has contributed greatly to the quest to speed up XEmacs.\n")) - (dv - (widget-insert "\ -I joined the development of XEmacs in 1996, and have been one of the -core maintainers since 1998. Although I'm mostly interested in the -GUI, ergonomics, redisplay and autoconf issues, it's probably simpler -to describe what I'm *not* involved in: I've never touched the Lisp -implementation, and I probably never will... - -I'm the author of the multicast support, I wrote and maintain some -external Emacs Lisp packages (including mchat) and I'm also -responsible for some of the core Lisp code (including the rectangle -library which I rewrote for both XEmacs and GNU Emacs).\n")) + (didier + (widget-insert "\ +Didier joined the development of XEmacs in 1996, and has been one of +the core maintainers since 1998. His very first contribution was the +translation of the tutorial to French. Since then, he has contributed +various bug fixes and enhancements in fields as diverse as the GUI, +redisplay engine and autoconf support. + +Didier is the official maintainer of some core libraries (rect, cus-edit, +wid-edit) and the author of the multicast support. He is also the author +of several packages, including mchat and Patcher.\n")) (eb (widget-insert "\ Also part of the original Lucid Emacs development team. Eric played a diff --git a/lisp/auto-autoloads.el b/lisp/auto-autoloads.el index 4410de6..835ba1f 100644 --- a/lisp/auto-autoloads.el +++ b/lisp/auto-autoloads.el @@ -1506,9 +1506,9 @@ one version of a package available.") (defcustom package-get-install-to-user-init-directory nil "*If non-nil install packages under `user-init-directory'." :type 'boolean :group 'package-get) -(defcustom package-get-download-sites '(("US (Main XEmacs Site)" "ftp.xemacs.org" "pub/xemacs/packages") ("Argentina (xmundo.net)" "xemacs.xmundo.net" "pub/mirrors/xemacs/packages") ("Australia (aarnet.edu.au)" "mirror.aarnet.edu.au" "pub/xemacs/packages") ("Australia (au.xemacs.org)" "ftp.au.xemacs.org" "pub/xemacs/packages") ("Austria (at.xemacs.org)" "ftp.at.xemacs.org" "editors/xemacs/packages") ("Belgium (be.xemacs.org)" "ftp.be.xemacs.org" "xemacs/packages") ("Brazil (br.xemacs.org)" "ftp.br.xemacs.org" "pub/xemacs/packages") ("Canada (ca.xemacs.org)" "ftp.ca.xemacs.org" "pub/Mirror/xemacs/packages") ("Canada (crc.ca)" "ftp.crc.ca" "pub/packages/editors/xemacs/packages") ("Canada (nrc.ca)" "ftp.nrc.ca" "pub/packages/editors/xemacs/packages") ("Czech Republic (cz.xemacs.org)" "ftp.cz.xemacs.org" "MIRRORS/ftp.xemacs.org/pub/xemacs/packages") ("Denmark (dk.xemacs.org)" "ftp.dk.xemacs.org" "pub/emacs/xemacs/packages") ("Finland (fi.xemacs.org)" "ftp.fi.xemacs.org" "pub/mirrors/ftp.xemacs.org/pub/tux/xemacs/packages") ("France (fr.xemacs.org)" "ftp.fr.xemacs.org" "pub/xemacs/packages") ("France (mirror.cict.fr)" "mirror.cict.fr" "xemacs/packages") ("France (pasteur.fr)" "ftp.pasteur.fr" "pub/computing/xemacs/packages") ("Germany (de.xemacs.org)" "ftp.de.xemacs.org" "pub/ftp.xemacs.org/tux/xemacs/packages") ("Hong Kong (hk.xemacs.org)" "ftp.hk.xemacs.org" "pub/xemacsftp/packages") ("Iceland (is.xemacs.org)" "ftp.is.xemacs.org" "pub/xemacs/packages") ("Ireland (ie.xemacs.org)" "ftp.ie.xemacs.org" "mirrors/ftp.xemacs.org/pub/xemacs/packages") ("Ireland (heanet.ie)" "ftp.heanet.ie" "mirrors/ftp.xemacs.org/packages") ("Italy (it.xemacs.org)" "ftp.it.xemacs.org" "unix/packages/XEMACS/packages") ("Japan (aist.go.jp)" "ring.aist.go.jp" "pub/text/xemacs/packages") ("Japan (asahi-net.or.jp)" "ring.asahi-net.or.jp" "pub/text/xemacs/packages") ("Japan (dti.ad.jp)" "ftp.dti.ad.jp" "pub/unix/editor/xemacs/packages") ("Japan (sut.ac.jp)" "sunsite.sut.ac.jp" "pub/archives/packages/xemacs/packages") ("Korea (kr.xemacs.org)" "ftp.kr.xemacs.org" "pub/tools/emacs/xemacs/packages") ("Netherlands (nl.xemacs.org)" "ftp.nl.xemacs.org" "pub/xemacs/ftp/packages") ("New Zealand (nz.xemacs.org)" "ftp.nz.xemacs.org" "mirror/ftp.xemacs.org/packages") ("Norway (no.xemacs.org)" "ftp.no.xemacs.org" "pub/xemacs/packages") ("Poland (pl.xemacs.org)" "ftp.pl.xemacs.org" "pub/unix/editors/xemacs/packages") ("Portugal (pt.xemacs.org)" "ftp.pt.xemacs.org" "pub/MIRRORS/ftp.xemacs.org/packages") ("Russia (ru.xemacs.org)" "ftp.ru.xemacs.org" "pub/emacs/xemacs/packages") ("Sweden (se.xemacs.org)" "ftp.se.xemacs.org" "pub/gnu/xemacs/packages") ("Switzerland (ch.xemacs.org)" "ftp.ch.xemacs.org" "mirror/xemacs/packages") ("Taiwan (ftp.tw.xemacs.org)" "ftp.tw.xemacs.org" "Unix/Editors/XEmacs/packages") ("UK (uk.xemacs.org)" "ftp.uk.xemacs.org" "sites/ftp.xemacs.org/pub/xemacs/packages") ("US (ibiblio.org)" "mirrors.ibiblio.org" "pub/mirrors/xemacs/packages") ("US (stealth.net)" "ftp.stealth.net" "pub/mirrors/ftp.xemacs.org/pub/xemacs/packages") ("US (unc.edu)" "metalab.unc.edu" "pub/packages/editors/xemacs/packages") ("US (us.xemacs.org)" "ftp.us.xemacs.org" "pub/xemacs/packages")) "*List of remote sites available for downloading packages.\nList format is '(site-description site-name directory-on-site).\nSITE-DESCRIPTION is a textual description of the site. SITE-NAME\nis the internet address of the download site. DIRECTORY-ON-SITE\nis the directory on the site in which packages may be found.\nThis variable is used to initialize `package-get-remote', the\nvariable actually used to specify package download sites." :tag "Package download sites" :type '(repeat (list (string :tag "Name") host-name directory)) :group 'package-get) +(defcustom package-get-download-sites '(("US (Main XEmacs Site)" "ftp.xemacs.org" "pub/xemacs/packages") ("Argentina (xmundo.net)" "xemacs.xmundo.net" "pub/mirrors/xemacs/packages") ("Australia (aarnet.edu.au)" "mirror.aarnet.edu.au" "pub/xemacs/packages") ("Australia (au.xemacs.org)" "ftp.au.xemacs.org" "pub/xemacs/packages") ("Austria (at.xemacs.org)" "ftp.at.xemacs.org" "editors/xemacs/packages") ("Belgium (be.xemacs.org)" "ftp.be.xemacs.org" "xemacs/packages") ("Brazil (br.xemacs.org)" "ftp.br.xemacs.org" "pub/xemacs/packages") ("Canada (ca.xemacs.org)" "ftp.ca.xemacs.org" "pub/Mirror/xemacs/packages") ("Canada (crc.ca)" "ftp.crc.ca" "pub/packages/editors/xemacs/packages") ("Canada (nrc.ca)" "ftp.nrc.ca" "pub/packages/editors/xemacs/packages") ("Czech Republic (cz.xemacs.org)" "ftp.cz.xemacs.org" "MIRRORS/ftp.xemacs.org/pub/xemacs/packages") ("Denmark (dk.xemacs.org)" "ftp.dk.xemacs.org" "xemacs/packages") ("Finland (fi.xemacs.org)" "ftp.fi.xemacs.org" "pub/mirrors/ftp.xemacs.org/pub/tux/xemacs/packages") ("France (fr.xemacs.org)" "ftp.fr.xemacs.org" "pub/xemacs/packages") ("France (mirror.cict.fr)" "mirror.cict.fr" "xemacs/packages") ("France (pasteur.fr)" "ftp.pasteur.fr" "pub/computing/xemacs/packages") ("Germany (de.xemacs.org)" "ftp.de.xemacs.org" "pub/ftp.xemacs.org/tux/xemacs/packages") ("Greece (gr.xemacs.org)" "ftp.gr.xemacs.org" "mirrors/XEmacs/ftp/packages") ("Hong Kong (hk.xemacs.org)" "ftp.hk.xemacs.org" "pub/xemacsftp/packages") ("Ireland (ie.xemacs.org)" "ftp.ie.xemacs.org" "mirrors/ftp.xemacs.org/pub/xemacs/packages") ("Ireland (heanet.ie)" "ftp.heanet.ie" "mirrors/ftp.xemacs.org/packages") ("Italy (it.xemacs.org)" "ftp.it.xemacs.org" "unix/packages/XEMACS/packages") ("Japan (dti.ad.jp)" "ftp.dti.ad.jp" "pub/unix/editor/xemacs/packages") ("Japan (jp.xemacs.org)" "ftp.jp.xemacs.org" "pub/text/xemacs/packages") ("Korea (kr.xemacs.org)" "ftp.kr.xemacs.org" "pub/tools/emacs/xemacs/packages") ("Netherlands (nl.xemacs.org)" "ftp.nl.xemacs.org" "pub/xemacs/ftp/packages") ("Norway (no.xemacs.org)" "ftp.no.xemacs.org" "pub/xemacs/packages") ("Portugal (pt.xemacs.org)" "ftp.pt.xemacs.org" "pub/MIRRORS/ftp.xemacs.org/packages") ("Russia (ru.xemacs.org)" "ftp.ru.xemacs.org" "pub/emacs/xemacs/packages") ("Saudi Arabia (sa.xemacs.org)" "ftp.sa.xemacs.org" "pub/xemacs.org/packages") ("Sweden (se.xemacs.org)" "ftp.se.xemacs.org" "pub/gnu/xemacs/packages") ("Switzerland (ch.xemacs.org)" "ftp.ch.xemacs.org" "mirror/xemacs/packages") ("Taiwan (ftp.tw.xemacs.org)" "ftp.tw.xemacs.org" "Unix/Editors/XEmacs/packages") ("UK (uk.xemacs.org)" "ftp.uk.xemacs.org" "sites/ftp.xemacs.org/pub/xemacs/packages") ("US (ibiblio.org)" "mirrors.ibiblio.org" "pub/mirrors/xemacs/packages") ("US (us.xemacs.org)" "ftp.us.xemacs.org" "pub/mirrors/xemacs/packages")) "*List of remote sites available for downloading packages.\nList format is '(site-description site-name directory-on-site).\nSITE-DESCRIPTION is a textual description of the site. SITE-NAME\nis the internet address of the download site. DIRECTORY-ON-SITE\nis the directory on the site in which packages may be found.\nThis variable is used to initialize `package-get-remote', the\nvariable actually used to specify package download sites." :tag "Package download sites" :type '(repeat (list (string :tag "Name") host-name directory)) :group 'package-get) -(defcustom package-get-pre-release-download-sites '(("US Pre-Releases (Main XEmacs Site)" "ftp.xemacs.org" "pub/xemacs/beta/experimental/packages") ("Argentina Pre-Releases (xmundo.net)" "xemacs.xmundo.net" "pub/mirrors/xemacs/beta/experimental/packages") ("Australia Pre-Releases (aarnet.edu.au)" "mirror.aarnet.edu.au" "pub/xemacs/beta/experimental/packages") ("Australia Pre-Releases (au.xemacs.org)" "ftp.au.xemacs.org" "pub/xemacs/beta/experimental/packages") ("Austria Pre-Releases (at.xemacs.org)" "ftp.at.xemacs.org" "editors/xemacs/beta/experimental/packages") ("Belgium (be.xemacs.org)" "ftp.be.xemacs.org" "xemacs/beta/experimental/packages") ("Brazil Pre-Releases (br.xemacs.org)" "ftp.br.xemacs.org" "pub/xemacs/xemacs-21.5/experimental/packages") ("Canada Pre-Releases (ca.xemacs.org)" "ftp.ca.xemacs.org" "pub/Mirror/xemacs/beta/experimental/packages") ("Canada Pre-Releases (crc.ca)" "ftp.crc.ca" "pub/packages/editors/xemacs/beta/experimental/packages") ("Canada Pre-Releases (nrc.ca)" "ftp.nrc.ca" "pub/packages/editors/xemacs/beta/experimental/packages") ("Czech Republic Pre-Releases (cz.xemacs.org)" "ftp.cz.xemacs.org" "MIRRORS/ftp.xemacs.org/pub/xemacs/xemacs-21.5/experimental/packages") ("Denmark Pre-Releases (dk.xemacs.org)" "ftp.dk.xemacs.org" "pub/emacs/xemacs/beta/experimental/packages") ("Finland Pre-Releases (fi.xemacs.org)" "ftp.fi.xemacs.org" "pub/mirrors/ftp.xemacs.org/pub/tux/xemacs/beta/experimental/packages") ("France Pre-Releases (fr.xemacs.org)" "ftp.fr.xemacs.org" "pub/xemacs/beta/experimental/packages") ("France Pre-Releases (mirror.cict.fr)" "mirror.cict.fr" "xemacs/beta/experimental/packages") ("France Pre-Releases (pasteur.fr)" "ftp.pasteur.fr" "pub/computing/xemacs/beta/experimental/packages") ("Germany Pre-Releases (de.xemacs.org)" "ftp.de.xemacs.org" "pub/ftp.xemacs.org/tux/xemacs/beta/experimental/packages") ("Hong Kong Pre-Releases (hk.xemacs.org)" "ftp.hk.xemacs.org" "pub/xemacsftp/beta/experimental/packages") ("Iceland Pre-Releases (is.xemacs.org)" "ftp.is.xemacs.org" "pub/xemacs/beta/experimental/packages") ("Ireland Pre-Releases (ie.xemacs.org)" "ftp.ie.xemacs.org" "mirrors/ftp.xemacs.org/pub/xemacs/beta/experimental/packages") ("Ireland Pre-Releases (heanet.ie)" "ftp.heanet.ie" "mirrors/ftp.xemacs.org/beta/experimental/packages") ("Italy Pre-Releases (it.xemacs.org)" "ftp.it.xemacs.org" "unix/packages/XEMACS/beta/experimental/packages") ("Japan Pre-Releases (aist.go.jp)" "ring.aist.go.jp" "pub/text/xemacs/beta/experimental/packages") ("Japan Pre-Releases (asahi-net.or.jp)" "ring.asahi-net.or.jp" "pub/text/xemacs/beta/experimental/packages") ("Japan Pre-Releases (dti.ad.jp)" "ftp.dti.ad.jp" "pub/unix/editor/xemacs/beta/experimental/packages") ("Japan Pre-Releases (sut.ac.jp)" "sunsite.sut.ac.jp" "pub/archives/packages/xemacs/xemacs-21.5/experimental/packages") ("Korea (kr.xemacs.org)" "ftp.kr.xemacs.org" "pub/tools/emacs/xemacs/beta/experimental/packages") ("Netherlands (nl.xemacs.org)" "ftp.nl.xemacs.org" "pub/xemacs/ftp/beta/experimental/packages") ("New Zealand Pre-Releases (nz.xemacs.org)" "ftp.nz.xemacs.org" "mirror/ftp.xemacs.org/packages") ("Norway Pre-Releases (no.xemacs.org)" "ftp.no.xemacs.org" "pub/xemacs/beta/experimental/packages") ("Poland Pre-Releases (pl.xemacs.org)" "ftp.pl.xemacs.org" "pub/unix/editors/xemacs/beta/experimental/packages") ("Portugal Pre-Releases (pt.xemacs.org)" "ftp.pt.xemacs.org" "pub/MIRRORS/ftp.xemacs.org/beta/experimental/packages") ("Russia Pre-Releases (ru.xemacs.org)" "ftp.ru.xemacs.org" "pub/emacs/xemacs/beta/experimental/packages") ("Sweden Pre-Releases (se.xemacs.org)" "ftp.se.xemacs.org" "pub/gnu/xemacs/beta/experimental/packages") ("Switzerland Pre-Releases (ch.xemacs.org)" "ftp.ch.xemacs.org" "mirror/xemacs/beta/experimental/packages") ("Taiwan Pre-Releases (ftp.tw.xemacs.org)" "ftp.tw.xemacs.org" "Unix/Editors/XEmacs/beta/experimental/packages") ("UK Pre-Releases (uk.xemacs.org)" "ftp.uk.xemacs.org" "sites/ftp.xemacs.org/pub/xemacs/beta/experimental/packages") ("US Pre-Releases (ibiblio.org)" "mirrors.ibiblio.org" "pub/mirrors/xemacs/beta/experimental/packages") ("US Pre-Releases (stealth.net)" "ftp.stealth.net" "pub/mirrors/ftp.xemacs.org/pub/xemacs/beta/experimental/packages") ("US Pre-Releases (unc.edu)" "metalab.unc.edu" "pub/packages/editors/xemacs/beta/experimental/packages") ("US Pre-Releases (us.xemacs.org)" "ftp.us.xemacs.org" "pub/xemacs/beta/experimental/packages")) "*List of remote sites available for downloading \"Pre-Release\" packages.\nList format is '(site-description site-name directory-on-site).\nSITE-DESCRIPTION is a textual description of the site. SITE-NAME\nis the internet address of the download site. DIRECTORY-ON-SITE\nis the directory on the site in which packages may be found.\nThis variable is used to initialize `package-get-remote', the\nvariable actually used to specify package download sites." :tag "Pre-Release Package download sites" :type '(repeat (list (string :tag "Name") host-name directory)) :group 'package-get) +(defcustom package-get-pre-release-download-sites '(("US Pre-Releases (Main XEmacs Site)" "ftp.xemacs.org" "pub/xemacs/beta/experimental/packages") ("Argentina Pre-Releases (xmundo.net)" "xemacs.xmundo.net" "pub/mirrors/xemacs/beta/experimental/packages") ("Australia Pre-Releases (aarnet.edu.au)" "mirror.aarnet.edu.au" "pub/xemacs/beta/experimental/packages") ("Australia Pre-Releases (au.xemacs.org)" "ftp.au.xemacs.org" "pub/xemacs/beta/experimental/packages") ("Austria Pre-Releases (at.xemacs.org)" "ftp.at.xemacs.org" "editors/xemacs/beta/experimental/packages") ("Belgium (be.xemacs.org)" "ftp.be.xemacs.org" "xemacs/beta/experimental/packages") ("Brazil Pre-Releases (br.xemacs.org)" "ftp.br.xemacs.org" "pub/xemacs/xemacs-21.5/experimental/packages") ("Canada Pre-Releases (ca.xemacs.org)" "ftp.ca.xemacs.org" "pub/Mirror/xemacs/beta/experimental/packages") ("Canada Pre-Releases (nrc.ca)" "ftp.nrc.ca" "pub/packages/editors/xemacs/beta/experimental/packages") ("Czech Republic Pre-Releases (cz.xemacs.org)" "ftp.cz.xemacs.org" "MIRRORS/ftp.xemacs.org/pub/xemacs/xemacs-21.5/experimental/packages") ("Denmark Pre-Releases (dk.xemacs.org)" "ftp.dk.xemacs.org" "xemacs/beta/experimental/packages") ("Finland Pre-Releases (fi.xemacs.org)" "ftp.fi.xemacs.org" "pub/mirrors/ftp.xemacs.org/pub/tux/xemacs/beta/experimental/packages") ("France Pre-Releases (fr.xemacs.org)" "ftp.fr.xemacs.org" "pub/xemacs/beta/experimental/packages") ("France Pre-Releases (mirror.cict.fr)" "mirror.cict.fr" "xemacs/beta/experimental/packages") ("France Pre-Releases (pasteur.fr)" "ftp.pasteur.fr" "pub/computing/xemacs/beta/experimental/packages") ("Germany Pre-Releases (de.xemacs.org)" "ftp.de.xemacs.org" "pub/ftp.xemacs.org/tux/xemacs/beta/experimental/packages") ("Greece Pre-Releases (gr.xemacs.org)" "ftp.gr.xemacs.org" "mirrors/XEmacs/ftp/beta/experimental/packages") ("Hong Kong Pre-Releases (hk.xemacs.org)" "ftp.hk.xemacs.org" "pub/xemacsftp/beta/experimental/packages") ("Ireland Pre-Releases (ie.xemacs.org)" "ftp.ie.xemacs.org" "mirrors/ftp.xemacs.org/pub/xemacs/beta/experimental/packages") ("Ireland Pre-Releases (heanet.ie)" "ftp.heanet.ie" "mirrors/ftp.xemacs.org/beta/experimental/packages") ("Italy Pre-Releases (it.xemacs.org)" "ftp.it.xemacs.org" "unix/packages/XEMACS/beta/experimental/packages") ("Japan Pre-Releases (dti.ad.jp)" "ftp.dti.ad.jp" "pub/unix/editor/xemacs/beta/experimental/packages") ("Japan Pre-Releases (jp.xemacs.org)" "ftp.jp.xemacs.org" "pub/text/xemacs/beta/experimental/packages") ("Korea (kr.xemacs.org)" "ftp.kr.xemacs.org" "pub/tools/emacs/xemacs/beta/experimental/packages") ("Netherlands (nl.xemacs.org)" "ftp.nl.xemacs.org" "pub/xemacs/ftp/beta/experimental/packages") ("Norway Pre-Releases (no.xemacs.org)" "ftp.no.xemacs.org" "pub/xemacs/beta/experimental/packages") ("Portugal Pre-Releases (pt.xemacs.org)" "ftp.pt.xemacs.org" "pub/MIRRORS/ftp.xemacs.org/beta/experimental/packages") ("Russia Pre-Releases (ru.xemacs.org)" "ftp.ru.xemacs.org" "pub/emacs/xemacs/beta/experimental/packages") ("Saudi Arabia (sa.xemacs.org)" "ftp.sa.xemacs.org" "pub/xemacs.org/beta/experimental/packages") ("Sweden Pre-Releases (se.xemacs.org)" "ftp.se.xemacs.org" "pub/gnu/xemacs/beta/experimental/packages") ("Switzerland Pre-Releases (ch.xemacs.org)" "ftp.ch.xemacs.org" "mirror/xemacs/beta/experimental/packages") ("Taiwan Pre-Releases (ftp.tw.xemacs.org)" "ftp.tw.xemacs.org" "Unix/Editors/XEmacs/beta/experimental/packages") ("UK Pre-Releases (uk.xemacs.org)" "ftp.uk.xemacs.org" "sites/ftp.xemacs.org/pub/xemacs/beta/experimental/packages") ("US Pre-Releases (ibiblio.org)" "mirrors.ibiblio.org" "pub/mirrors/xemacs/beta/experimental/packages") ("US Pre-Releases (us.xemacs.org)" "ftp.us.xemacs.org" "pub/mirrors/xemacs/beta/experimental/packages")) "*List of remote sites available for downloading \"Pre-Release\" packages.\nList format is '(site-description site-name directory-on-site).\nSITE-DESCRIPTION is a textual description of the site. SITE-NAME\nis the internet address of the download site. DIRECTORY-ON-SITE\nis the directory on the site in which packages may be found.\nThis variable is used to initialize `package-get-remote', the\nvariable actually used to specify package download sites." :tag "Pre-Release Package download sites" :type '(repeat (list (string :tag "Name") host-name directory)) :group 'package-get) (defcustom package-get-site-release-download-sites nil "*List of remote sites available for downloading \"Site Release\" packages.\nList format is '(site-description site-name directory-on-site).\nSITE-DESCRIPTION is a textual description of the site. SITE-NAME\nis the internet address of the download site. DIRECTORY-ON-SITE\nis the directory on the site in which packages may be found.\nThis variable is used to initialize `package-get-remote', the\nvariable actually used to specify package download sites." :tag "Site Release Package download sites" :type '(repeat (list (string :tag "Name") host-name directory)) :group 'package-get) diff --git a/lisp/font-lock.el b/lisp/font-lock.el index e2ed681..d72aeeb 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el @@ -441,6 +441,32 @@ edit the buffer does not, since it considers text one line at a time. Be very careful composing regexps for this list; the wrong pattern can dramatically slow things down! ") + +(defvar font-lock-keywords-alist nil + "Alist of additional `font-lock-keywords' elements for major modes. + +Each element has the form (MODE KEYWORDS . HOW). +`font-lock-set-defaults' adds the elements in the list KEYWORDS to +`font-lock-keywords' when Font Lock is turned on in major mode MODE. + +If HOW is nil, KEYWORDS are added at the beginning of +`font-lock-keywords'. If it is `set', they are used to replace the +value of `font-lock-keywords'. If HOW is any other non-nil value, +they are added at the end. + +This is normally set via `font-lock-add-keywords' and +`font-lock-remove-keywords'.") + +(defvar font-lock-removed-keywords-alist nil + "Alist of `font-lock-keywords' elements to be removed for major modes. + +Each element has the form (MODE . KEYWORDS). `font-lock-set-defaults' +removes the elements in the list KEYWORDS from `font-lock-keywords' +when Font Lock is turned on in major mode MODE. + +This is normally set via `font-lock-add-keywords' and +`font-lock-remove-keywords'.") + ;;;###autoload (make-variable-buffer-local 'font-lock-keywords) @@ -687,6 +713,11 @@ The corresponding face should be set using `edit-faces' or the It is present only for horrid FSF compatibility reasons. The corresponding face should be set using `edit-faces' or the `set-face-*' functions.") +(defvar font-lock-warning-face 'font-lock-warning-face + "This variable should not be set. +It is present only for horrid FSF compatibility reasons. +The corresponding face should be set using `edit-faces' or the +`set-face-*' functions.") (defconst font-lock-face-list '(font-lock-comment-face @@ -860,6 +891,188 @@ on the major mode's symbol." (setq font-lock-maximum-decoration t) (font-lock-recompute-variables))) +(defun font-lock-add-keywords (mode keywords &optional how) + "Add highlighting KEYWORDS for MODE. + +MODE should be a symbol, the major mode command name, such as `c-mode' +or nil. If nil, highlighting keywords are added for the current buffer. +KEYWORDS should be a list; see the variable `font-lock-keywords'. +By default they are added at the beginning of the current highlighting list. +If optional argument HOW is `set', they are used to replace the current +highlighting list. If HOW is any other non-nil value, they are added at the +end of the current highlighting list. + +For example: + + (font-lock-add-keywords 'c-mode + '((\"\\\\\\=<\\\\(FIXME\\\\):\" 1 font-lock-warning-face prepend) + (\"\\\\\\=<\\\\(and\\\\|or\\\\|not\\\\)\\\\\\=>\" . font-lock-keyword-face))) + +adds two fontification patterns for C mode, to fontify `FIXME:' words, even in +comments, and to fontify `and', `or' and `not' words as keywords. + +The above procedure will only add the keywords for C mode, not +for modes derived from C mode. To add them for derived modes too, +pass nil for MODE and add the call to c-mode-hook. + +For example: + + (add-hook 'c-mode-hook + (lambda () + (font-lock-add-keywords nil + '((\"\\\\\\=<\\\\(FIXME\\\\):\" 1 font-lock-warning-face prepend) + (\"\\\\\\=<\\\\(and\\\\|or\\\\|not\\\\)\\\\\\=>\" . + font-lock-keyword-face))))) + +The above procedure may fail to add keywords to derived modes if +some involved major mode does not follow the standard conventions. +File a bug report if this happens, so the major mode can be corrected. + +Note that some modes have specialized support for additional patterns, e.g., +see the variables `c-font-lock-extra-types', `c++-font-lock-extra-types', +`objc-font-lock-extra-types' and `java-font-lock-extra-types'." + (cond (mode + ;; If MODE is non-nil, add the KEYWORDS and HOW spec to + ;; `font-lock-keywords-alist' so `font-lock-set-defaults' uses them. + (let ((spec (cons keywords how)) cell) + (if (setq cell (assq mode font-lock-keywords-alist)) + (if (eq how 'set) + (setcdr cell (list spec)) + (setcdr cell (append (cdr cell) (list spec)))) + (push (list mode spec) font-lock-keywords-alist))) + ;; Make sure that `font-lock-removed-keywords-alist' does not + ;; contain the new keywords. + (font-lock-update-removed-keyword-alist mode keywords how)) + (t + ;; Otherwise set or add the keywords now. + ;; This is a no-op if it has been done already in this buffer + ;; for the correct major mode. + (font-lock-set-defaults) + (let ((was-compiled (eq (car font-lock-keywords) t))) + ;; Bring back the user-level (uncompiled) keywords. + (if was-compiled + (setq font-lock-keywords (cadr font-lock-keywords))) + ;; Now modify or replace them. + (if (eq how 'set) + (setq font-lock-keywords keywords) + (font-lock-remove-keywords nil keywords) ;to avoid duplicates + (let ((old (if (eq (car-safe font-lock-keywords) t) + (cdr font-lock-keywords) + font-lock-keywords))) + (setq font-lock-keywords (if how + (append old keywords) + (append keywords old))))) + ;; If the keywords were compiled before, compile them again. + (if was-compiled + (setq font-lock-keywords + (font-lock-compile-keywords font-lock-keywords))))))) + +(defun font-lock-update-removed-keyword-alist (mode keywords how) + "Update `font-lock-removed-keywords-alist' when adding new KEYWORDS to MODE." + ;; When font-lock is enabled first all keywords in the list + ;; `font-lock-keywords-alist' are added, then all keywords in the + ;; list `font-lock-removed-keywords-alist' are removed. If a + ;; keyword was once added, removed, and then added again it must be + ;; removed from the removed-keywords list. Otherwise the second add + ;; will not take effect. + (let ((cell (assq mode font-lock-removed-keywords-alist))) + (if cell + (if (eq how 'set) + ;; A new set of keywords is defined. Forget all about + ;; our old keywords that should be removed. + (setq font-lock-removed-keywords-alist + (delq cell font-lock-removed-keywords-alist)) + ;; Delete all previously removed keywords. + (dolist (kword keywords) + (setcdr cell (delete kword (cdr cell)))) + ;; Delete the mode cell if empty. + (if (null (cdr cell)) + (setq font-lock-removed-keywords-alist + (delq cell font-lock-removed-keywords-alist))))))) + +;; Written by Anders Lindgren <andersl@andersl.com>. +;; +;; Case study: +;; (I) The keywords are removed from a major mode. +;; In this case the keyword could be local (i.e. added earlier by +;; `font-lock-add-keywords'), global, or both. +;; +;; (a) In the local case we remove the keywords from the variable +;; `font-lock-keywords-alist'. +;; +;; (b) The actual global keywords are not known at this time. +;; All keywords are added to `font-lock-removed-keywords-alist', +;; when font-lock is enabled those keywords are removed. +;; +;; Note that added keywords are taken out of the list of removed +;; keywords. This ensure correct operation when the same keyword +;; is added and removed several times. +;; +;; (II) The keywords are removed from the current buffer. +(defun font-lock-remove-keywords (mode keywords) + "Remove highlighting KEYWORDS for MODE. + +MODE should be a symbol, the major mode command name, such as `c-mode' +or nil. If nil, highlighting keywords are removed for the current buffer. + +To make the removal apply to modes derived from MODE as well, +pass nil for MODE and add the call to MODE-hook. This may fail +for some derived modes if some involved major mode does not +follow the standard conventions. File a bug report if this +happens, so the major mode can be corrected." + (cond (mode + ;; Remove one keyword at the time. + (dolist (keyword keywords) + (let ((top-cell (assq mode font-lock-keywords-alist))) + ;; If MODE is non-nil, remove the KEYWORD from + ;; `font-lock-keywords-alist'. + (when top-cell + (dolist (keyword-list-how-pair (cdr top-cell)) + ;; `keywords-list-how-pair' is a cons with a list of + ;; keywords in the car top-cell and the original how + ;; argument in the cdr top-cell. + (setcar keyword-list-how-pair + (delete keyword (car keyword-list-how-pair)))) + ;; Remove keyword list/how pair when the keyword list + ;; is empty and how doesn't specify `set'. (If it + ;; should be deleted then previously deleted keywords + ;; would appear again.) + (let ((cell top-cell)) + (while (cdr cell) + (if (and (null (car (car (cdr cell)))) + (not (eq (cdr (car (cdr cell))) 'set))) + (setcdr cell (cdr (cdr cell))) + (setq cell (cdr cell))))) + ;; Final cleanup, remove major mode cell if last keyword + ;; was deleted. + (if (null (cdr top-cell)) + (setq font-lock-keywords-alist + (delq top-cell font-lock-keywords-alist)))) + ;; Remember the keyword in case it is not local. + (let ((cell (assq mode font-lock-removed-keywords-alist))) + (if cell + (unless (member keyword (cdr cell)) + (nconc cell (list keyword))) + (push (cons mode (list keyword)) + font-lock-removed-keywords-alist)))))) + (t + ;; Otherwise remove it immediately. + (font-lock-set-defaults) + (let ((was-compiled (eq (car font-lock-keywords) t))) + ;; Bring back the user-level (uncompiled) keywords. + (if was-compiled + (setq font-lock-keywords (cadr font-lock-keywords))) + + ;; Edit them. + (setq font-lock-keywords (copy-sequence font-lock-keywords)) + (dolist (keyword keywords) + (setq font-lock-keywords + (delete keyword font-lock-keywords))) + + ;; If the keywords were compiled before, compile them again. + (if was-compiled + (setq font-lock-keywords + (font-lock-compile-keywords font-lock-keywords))))))) ;;;;;;;;;;;;;;;;;;;;;; actual code ;;;;;;;;;;;;;;;;;;;;;; diff --git a/lisp/gutter-items.el b/lisp/gutter-items.el index c71a172..8ac62f6 100644 --- a/lisp/gutter-items.el +++ b/lisp/gutter-items.el @@ -670,8 +670,10 @@ If the only argument is nil, clear any existing progress gauge." (defun progress-feedback-with-label (label fmt &optional value &rest args) "Print a progress gauge and message in the bottom gutter area of the frame. -First argument LABEL is an identifier for this progress gauge. The rest of the -arguments are the same as to `format'." +LABEL is an identifier for this progress gauge. +FMT is a format string to be passed to `format' along with ARGS. +Optional VALUE is the current degree of progress, an integer 0-100. +The remaining ARGS are passed with FMT `(apply #'format FMT ARGS)'." ;; #### sometimes the buffer gets changed temporarily. I don't know ;; why this is, so protect against it. (save-excursion diff --git a/lisp/package-get.el b/lisp/package-get.el index 0d97982..1ca37a6 100644 --- a/lisp/package-get.el +++ b/lisp/package-get.el @@ -213,42 +213,36 @@ directory." ("Canada (ca.xemacs.org)" "ftp.ca.xemacs.org" "pub/Mirror/xemacs/packages") ("Canada (crc.ca)" "ftp.crc.ca" "pub/packages/editors/xemacs/packages") ("Canada (nrc.ca)" "ftp.nrc.ca" "pub/packages/editors/xemacs/packages") +; ;; no anonymous ftp available: +; ("Chile (cl.xemacs.org)" "ftp.cl.xemacs.org" "packages") ("Czech Republic (cz.xemacs.org)" "ftp.cz.xemacs.org" "MIRRORS/ftp.xemacs.org/pub/xemacs/packages") - ("Denmark (dk.xemacs.org)" "ftp.dk.xemacs.org" "pub/emacs/xemacs/packages") + ("Denmark (dk.xemacs.org)" "ftp.dk.xemacs.org" "xemacs/packages") ("Finland (fi.xemacs.org)" "ftp.fi.xemacs.org" "pub/mirrors/ftp.xemacs.org/pub/tux/xemacs/packages") ("France (fr.xemacs.org)" "ftp.fr.xemacs.org" "pub/xemacs/packages") ("France (mirror.cict.fr)" "mirror.cict.fr" "xemacs/packages") ("France (pasteur.fr)" "ftp.pasteur.fr" "pub/computing/xemacs/packages") ("Germany (de.xemacs.org)" "ftp.de.xemacs.org" "pub/ftp.xemacs.org/tux/xemacs/packages") + ("Greece (gr.xemacs.org)" "ftp.gr.xemacs.org" "mirrors/XEmacs/ftp/packages") ("Hong Kong (hk.xemacs.org)" "ftp.hk.xemacs.org" "pub/xemacsftp/packages") - ("Iceland (is.xemacs.org)" "ftp.is.xemacs.org" "pub/xemacs/packages") ("Ireland (ie.xemacs.org)" "ftp.ie.xemacs.org" "mirrors/ftp.xemacs.org/pub/xemacs/packages") ("Ireland (heanet.ie)" "ftp.heanet.ie" "mirrors/ftp.xemacs.org/packages") ("Italy (it.xemacs.org)" "ftp.it.xemacs.org" "unix/packages/XEMACS/packages") - ("Japan (aist.go.jp)" "ring.aist.go.jp" "pub/text/xemacs/packages") - ("Japan (asahi-net.or.jp)" "ring.asahi-net.or.jp" "pub/text/xemacs/packages") ("Japan (dti.ad.jp)" "ftp.dti.ad.jp" "pub/unix/editor/xemacs/packages") ; ("Japan (jaist.ac.jp)" "ftp.jaist.ac.jp" "pub/GNU/xemacs/packages") -; ("Japan (jp.xemacs.org)" "ftp.jp.xemacs.org" "pub/GNU/xemacs/packages") + ("Japan (jp.xemacs.org)" "ftp.jp.xemacs.org" "pub/text/xemacs/packages") ; ("Japan (nucba.ac.jp)" "mirror.nucba.ac.jp" "mirror/xemacs/packages") - ("Japan (sut.ac.jp)" "sunsite.sut.ac.jp" "pub/archives/packages/xemacs/packages") ("Korea (kr.xemacs.org)" "ftp.kr.xemacs.org" "pub/tools/emacs/xemacs/packages") ("Netherlands (nl.xemacs.org)" "ftp.nl.xemacs.org" "pub/xemacs/ftp/packages") - ("New Zealand (nz.xemacs.org)" "ftp.nz.xemacs.org" "mirror/ftp.xemacs.org/packages") ("Norway (no.xemacs.org)" "ftp.no.xemacs.org" "pub/xemacs/packages") - ("Poland (pl.xemacs.org)" "ftp.pl.xemacs.org" "pub/unix/editors/xemacs/packages") ("Portugal (pt.xemacs.org)" "ftp.pt.xemacs.org" "pub/MIRRORS/ftp.xemacs.org/packages") ("Russia (ru.xemacs.org)" "ftp.ru.xemacs.org" "pub/emacs/xemacs/packages") -; ("South Africa (za.xemacs.org)" "ftp.za.xemacs.org" "mirrorsites/ftp.xemacs.org/packages") + ("Saudi Arabia (sa.xemacs.org)" "ftp.sa.xemacs.org" "pub/xemacs.org/packages") ("Sweden (se.xemacs.org)" "ftp.se.xemacs.org" "pub/gnu/xemacs/packages") ("Switzerland (ch.xemacs.org)" "ftp.ch.xemacs.org" "mirror/xemacs/packages") ("Taiwan (ftp.tw.xemacs.org)" "ftp.tw.xemacs.org" "Unix/Editors/XEmacs/packages") ("UK (uk.xemacs.org)" "ftp.uk.xemacs.org" "sites/ftp.xemacs.org/pub/xemacs/packages") ("US (ibiblio.org)" "mirrors.ibiblio.org" "pub/mirrors/xemacs/packages") - ("US (stealth.net)" "ftp.stealth.net" "pub/mirrors/ftp.xemacs.org/pub/xemacs/packages") - ("US (unc.edu)" "metalab.unc.edu" "pub/packages/editors/xemacs/packages") - ("US (us.xemacs.org)" "ftp.us.xemacs.org" "pub/xemacs/packages") -; ("US (utk.edu)" "ftp.sunsite.utk.edu" "pub/xemacs/packages") + ("US (us.xemacs.org)" "ftp.us.xemacs.org" "pub/mirrors/xemacs/packages") ) "*List of remote sites available for downloading packages. List format is '(site-description site-name directory-on-site). @@ -282,14 +276,15 @@ variable actually used to specify package download sites." "pub/xemacs/xemacs-21.5/experimental/packages") ("Canada Pre-Releases (ca.xemacs.org)" "ftp.ca.xemacs.org" "pub/Mirror/xemacs/beta/experimental/packages") - ("Canada Pre-Releases (crc.ca)" "ftp.crc.ca" - "pub/packages/editors/xemacs/beta/experimental/packages") ("Canada Pre-Releases (nrc.ca)" "ftp.nrc.ca" "pub/packages/editors/xemacs/beta/experimental/packages") +; ;; no anonymous ftp available: +; ("Chile Pre-Releases (cl.xemacs.org)" "ftp.cl.xemacs.org" +; "beta/experimental/packages") ("Czech Republic Pre-Releases (cz.xemacs.org)" "ftp.cz.xemacs.org" "MIRRORS/ftp.xemacs.org/pub/xemacs/xemacs-21.5/experimental/packages") ("Denmark Pre-Releases (dk.xemacs.org)" "ftp.dk.xemacs.org" - "pub/emacs/xemacs/beta/experimental/packages") + "xemacs/beta/experimental/packages") ("Finland Pre-Releases (fi.xemacs.org)" "ftp.fi.xemacs.org" "pub/mirrors/ftp.xemacs.org/pub/tux/xemacs/beta/experimental/packages") ("France Pre-Releases (fr.xemacs.org)" "ftp.fr.xemacs.org" @@ -300,44 +295,34 @@ variable actually used to specify package download sites." "pub/computing/xemacs/beta/experimental/packages") ("Germany Pre-Releases (de.xemacs.org)" "ftp.de.xemacs.org" "pub/ftp.xemacs.org/tux/xemacs/beta/experimental/packages") + ("Greece Pre-Releases (gr.xemacs.org)" "ftp.gr.xemacs.org" + "mirrors/XEmacs/ftp/beta/experimental/packages") ("Hong Kong Pre-Releases (hk.xemacs.org)" "ftp.hk.xemacs.org" "pub/xemacsftp/beta/experimental/packages") - ("Iceland Pre-Releases (is.xemacs.org)" "ftp.is.xemacs.org" - "pub/xemacs/beta/experimental/packages") ("Ireland Pre-Releases (ie.xemacs.org)" "ftp.ie.xemacs.org" "mirrors/ftp.xemacs.org/pub/xemacs/beta/experimental/packages") ("Ireland Pre-Releases (heanet.ie)" "ftp.heanet.ie" "mirrors/ftp.xemacs.org/beta/experimental/packages") ("Italy Pre-Releases (it.xemacs.org)" "ftp.it.xemacs.org" "unix/packages/XEMACS/beta/experimental/packages") - ("Japan Pre-Releases (aist.go.jp)" "ring.aist.go.jp" - "pub/text/xemacs/beta/experimental/packages") - ("Japan Pre-Releases (asahi-net.or.jp)" "ring.asahi-net.or.jp" - "pub/text/xemacs/beta/experimental/packages") ("Japan Pre-Releases (dti.ad.jp)" "ftp.dti.ad.jp" "pub/unix/editor/xemacs/beta/experimental/packages") ; ("Japan Pre-Releases (jaist.ac.jp)" "ftp.jaist.ac.jp" ; "pub/GNU/xemacs/beta/experimental/packages") -; ("Japan Pre-Releases (jp.xemacs.org)" "ftp.jp.xemacs.org" -; "pub/GNU/xemacs/beta/experimental/packages") - ("Japan Pre-Releases (sut.ac.jp)" "sunsite.sut.ac.jp" - "pub/archives/packages/xemacs/xemacs-21.5/experimental/packages") + ("Japan Pre-Releases (jp.xemacs.org)" "ftp.jp.xemacs.org" + "pub/text/xemacs/beta/experimental/packages") ("Korea (kr.xemacs.org)" "ftp.kr.xemacs.org" "pub/tools/emacs/xemacs/beta/experimental/packages") ("Netherlands (nl.xemacs.org)" "ftp.nl.xemacs.org" "pub/xemacs/ftp/beta/experimental/packages") - ("New Zealand Pre-Releases (nz.xemacs.org)" "ftp.nz.xemacs.org" - "mirror/ftp.xemacs.org/packages") ("Norway Pre-Releases (no.xemacs.org)" "ftp.no.xemacs.org" "pub/xemacs/beta/experimental/packages") - ("Poland Pre-Releases (pl.xemacs.org)" "ftp.pl.xemacs.org" - "pub/unix/editors/xemacs/beta/experimental/packages") ("Portugal Pre-Releases (pt.xemacs.org)" "ftp.pt.xemacs.org" "pub/MIRRORS/ftp.xemacs.org/beta/experimental/packages") ("Russia Pre-Releases (ru.xemacs.org)" "ftp.ru.xemacs.org" "pub/emacs/xemacs/beta/experimental/packages") -; ("South Africa Pre-Releases (za.xemacs.org)" "ftp.za.xemacs.org" -; "mirrorsites/ftp.xemacs.org/beta/experimental/packages") + ("Saudi Arabia (sa.xemacs.org)" "ftp.sa.xemacs.org" + "pub/xemacs.org/beta/experimental/packages") ("Sweden Pre-Releases (se.xemacs.org)" "ftp.se.xemacs.org" "pub/gnu/xemacs/beta/experimental/packages") ("Switzerland Pre-Releases (ch.xemacs.org)" "ftp.ch.xemacs.org" @@ -348,14 +333,8 @@ variable actually used to specify package download sites." "sites/ftp.xemacs.org/pub/xemacs/beta/experimental/packages") ("US Pre-Releases (ibiblio.org)" "mirrors.ibiblio.org" "pub/mirrors/xemacs/beta/experimental/packages") - ("US Pre-Releases (stealth.net)" "ftp.stealth.net" - "pub/mirrors/ftp.xemacs.org/pub/xemacs/beta/experimental/packages") - ("US Pre-Releases (unc.edu)" "metalab.unc.edu" - "pub/packages/editors/xemacs/beta/experimental/packages") ("US Pre-Releases (us.xemacs.org)" "ftp.us.xemacs.org" - "pub/xemacs/beta/experimental/packages") -; ("US Pre-Releases (utk.edu)" "ftp.sunsite.utk.edu" -; "pub/xemacs/beta/experimental/packages") + "pub/mirrors/xemacs/beta/experimental/packages") ) "*List of remote sites available for downloading \"Pre-Release\" packages. List format is '(site-description site-name directory-on-site). diff --git a/lisp/startup.el b/lisp/startup.el index 937dcdf..44ab5c5 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -710,43 +710,56 @@ perform the migration at any time with M-x migrate-user-init-file.") (yes-or-no-p-minibuf (concat "Migrate init file to " user-init-directory "? ")))) - (progn - (migrate-user-init-file) - (maybe-create-compatibility-dot-emacs)) - (customize-save-variable 'load-home-init-file t)))) -(defun maybe-create-compatibility-dot-emacs () - "Ask user if she wants to create a .emacs compatibility file." - (if (with-output-to-temp-buffer (help-buffer-name nil) - (progn - (princ "The initialization code has now been migrated to the ") - (princ user-init-directory) - (princ "directory. + (let ((backup (migrate-user-init-file))) + (with-output-to-temp-buffer (help-buffer-name nil) + (progn + (princ "The initialization code has now been migrated to the ") + (princ user-init-directory) + (princ "directory. For backwards compatibility with, for example, older versions of XEmacs, XEmacs can create a special old-style .emacs file in your home directory which will load the relocated initialization code.") - (show-temp-buffer-in-current-frame standard-output) - (yes-or-no-p-minibuf "Create compatibility .emacs? "))) + (if backup + (progn + (princ "\nMoreover, a backup of your old .emacs file was created as\n") + (princ backup) + (princ ".\n"))) + (show-temp-buffer-in-current-frame standard-output) + (maybe-create-compatibility-dot-emacs)))) + (customize-save-variable 'load-home-init-file t)))) + +(defun maybe-create-compatibility-dot-emacs () + "Ask user if she wants to create a .emacs compatibility file." + (if (yes-or-no-p-minibuf "Create compatibility .emacs? ") (create-compatibility-dot-emacs))) (defun migrate-user-init-file () - "Migrate the init file from the home directory." + "Migrate the init file from the home directory. +Return the name of backup file, if one was created." (interactive) (if (not (file-exists-p user-init-directory)) (progn (message "Creating %s directory..." user-init-directory) (make-directory user-init-directory))) (message "Migrating custom file...") - (customize-set-value 'load-home-init-file nil) - (custom-migrate-custom-file (make-custom-file-name user-init-file - 'force-new)) - (message "Moving init file...") - (let ((new-user-init-file (expand-file-name user-init-file-base - user-init-directory))) - (rename-file user-init-file new-user-init-file) - (setq user-init-file new-user-init-file)) - (message "Migration done.")) + (let* ((backup (concat user-init-file ".backup")) + (backup-p + (and (not (file-exists-p backup)) + (progn + (copy-file user-init-file backup) + t)))) + (customize-set-value 'load-home-init-file nil) + (custom-migrate-custom-file (make-custom-file-name user-init-file + 'force-new)) + (message "Moving init file...") + (let ((new-user-init-file (expand-file-name user-init-file-base + user-init-directory))) + (rename-file user-init-file new-user-init-file) + (setq user-init-file new-user-init-file)) + (message "Migration done.") + (and backup-p backup))) (defun create-compatibility-dot-emacs () "Create .emacs compatibility file for migrated setup." diff --git a/lwlib/ChangeLog b/lwlib/ChangeLog index 43763b1..df27f9e 100644 --- a/lwlib/ChangeLog +++ b/lwlib/ChangeLog @@ -1,3 +1,25 @@ +2007-10-07 Vin Shelton <acs@xemacs.org> + + * XEmacs 21.4.21 is released + +2007-05-20 Stephen J. Turnbull <stephen@xemacs.org> + + Gauge values are signed integers (ints). + (XawGaugeGetValue): Declare return value as int. + (XawGaugeSetValue): Declare value as int. + + * xlwgauge.h: Get rid of references to Cardinal in comment. + + * xlwgauge.c (GaugeGetValue): Declare value as int. + (GaugeMercury): Declare val0 and val1 as int. Remove redundant casts. + (XawGaugeGetValue): Declare return value as int. + (XawGaugeSetValue): Declare value as int. + +2007-05-17 Stephen J. Turnbull <stephen@xemacs.org> + + * lwlib-Xaw.c (wm_delete_window): Iterate over children of shell + (there may be more than one) to find our widget. + 2006-12-09 Vin Shelton <acs@xemacs.org> * XEmacs 21.4.20 is released diff --git a/lwlib/lwlib-Xaw.c b/lwlib/lwlib-Xaw.c index a52b231..2fe4dc9 100644 --- a/lwlib/lwlib-Xaw.c +++ b/lwlib/lwlib-Xaw.c @@ -597,11 +597,14 @@ wm_delete_window (Widget shell, XtPointer closure, XtPointer call_data) abort (); XtSetArg (al [0], XtNchildren, &kids); XtGetValues (shell, al, 1); - if (!kids || !*kids) - abort (); - widget = kids [0]; - if (! XtIsSubclass (widget, dialogWidgetClass)) - abort (); + if (!kids || !*kids) abort (); + + for (widget = *kids; + widget && ! XtIsSubclass (widget, dialogWidgetClass); + widget = *++kids) + ; + if (!widget) abort (); + id = lw_get_widget_id (widget); if (! id) abort (); diff --git a/lwlib/xlwgauge.c b/lwlib/xlwgauge.c index 074a6c7..7364fd1 100644 --- a/lwlib/xlwgauge.c +++ b/lwlib/xlwgauge.c @@ -132,7 +132,7 @@ static void EnableUpdate (GaugeWidget); static void DisableUpdate (GaugeWidget); static void GaugeGetValue (XtPointer, XtIntervalId *); -static void GaugeMercury (Display *, Window, GC, GaugeWidget, Cardinal, Cardinal); +static void GaugeMercury (Display *, Window, GC, GaugeWidget, int, int); static Boolean GaugeConvert (Widget, Atom *, Atom *, Atom *, XtPointer *, unsigned long *, int *); @@ -819,8 +819,7 @@ GaugeGetSelCB (Widget w, */ void -XawGaugeSetValue (Widget w, - Cardinal value) +XawGaugeSetValue (Widget w, int value) { GaugeWidget gw = (GaugeWidget)w ; int oldvalue ; @@ -852,7 +851,7 @@ XawGaugeSetValue (Widget w, } -Cardinal +int XawGaugeGetValue (Widget w) { GaugeWidget gw = (GaugeWidget)w ; @@ -875,8 +874,8 @@ GaugeMercury (Display *dpy, Window win, GC gc, GaugeWidget gw, - Cardinal val0, - Cardinal val1) + int val0, + int val1) { int v0 = gw->gauge.v0 ; int v1 = gw->gauge.v1 ; @@ -1110,7 +1109,7 @@ GaugeGetValue (XtPointer clientData, XtIntervalId *intervalId) { GaugeWidget gw = (GaugeWidget)clientData ; - Cardinal value ; + int value ; if( gw->gauge.update > 0 ) EnableUpdate(gw) ; diff --git a/lwlib/xlwgauge.h b/lwlib/xlwgauge.h index ceb21ef..8141384 100644 --- a/lwlib/xlwgauge.h +++ b/lwlib/xlwgauge.h @@ -48,9 +48,9 @@ Boston, MA 02111-1307, USA. */ Name Class RepType Default Value ---- ----- ------- ------------- - value Value Cardinal 0 - minValue MinValue Cardinal 0 - maxValue MaxValue Cardinal 100 + value Value Int 0 + minValue Int Cardinal 0 + maxValue Int Cardinal 100 ntics NTics Cardinal 0 + nlabels NLabels Cardinal 0 ++ labels Labels String * NULL +++ @@ -100,7 +100,7 @@ Boston, MA 02111-1307, USA. */ XtPointer client ; XtPointer rval ; { - *(Cardinal *)rval = value ; + *(int *)rval = value ; } */ @@ -169,11 +169,11 @@ _XFUNCPROTOBEGIN extern void XawGaugeSetValue( #if NeedFunctionPrototypes Widget gauge, - Cardinal value + int value #endif ); -extern Cardinal XawGaugeGetValue( +extern int XawGaugeGetValue( #if NeedFunctionPrototypes Widget gauge #endif diff --git a/man/ChangeLog b/man/ChangeLog index 4342f7f..28c171a 100644 --- a/man/ChangeLog +++ b/man/ChangeLog @@ -1,3 +1,7 @@ +2007-10-07 Vin Shelton <acs@xemacs.org> + + * XEmacs 21.4.21 is released + 2006-12-09 Vin Shelton <acs@xemacs.org> * XEmacs 21.4.20 is released diff --git a/modules/ldap/eldap.c b/modules/ldap/eldap.c index e9bdf0c..4e89cb4 100644 --- a/modules/ldap/eldap.c +++ b/modules/ldap/eldap.c @@ -35,6 +35,13 @@ Boston, MA 02111-1307, USA. */ #include "eldap.h" #include <lber.h> +/* #### NEEDS REWRITE! + Thanks to Mats Lidell <matsl@xemacs.org> for the report & patch: + <871wgnqunm.fsf@spencer.lidell.homelinux.net> + "See http://www.openldap.org/faq/data/cache/1278.html. + Temporary workaround would be use the deprecated interface. Long term + solution is a rewrite." */ +#define LDAP_DEPRECATED 1 #include <ldap.h> #ifdef HAVE_NS_LDAP diff --git a/netinstall/ChangeLog b/netinstall/ChangeLog index bed827a..33afe7b 100644 --- a/netinstall/ChangeLog +++ b/netinstall/ChangeLog @@ -1,3 +1,7 @@ +2007-10-07 Vin Shelton <acs@xemacs.org> + + * XEmacs 21.4.21 is released + 2006-12-09 Vin Shelton <acs@xemacs.org> * XEmacs 21.4.20 is released diff --git a/nt/ChangeLog b/nt/ChangeLog index 833f1fa..a527cd3 100644 --- a/nt/ChangeLog +++ b/nt/ChangeLog @@ -1,3 +1,21 @@ +2007-10-07 Vin Shelton <acs@xemacs.org> + + * XEmacs 21.4.21 is released + +2007-09-27 Vin Shelton <acs@xemacs.org> + + * XEmacs.iss: Don't set package-get-always-update. + +2007-09-25 Vin Shelton <acs@xemacs.org> + + * XEmacs.iss: Put comment wrapper around site-start.el changes and + remove those changes on uninstall. Enable ftp.xemacs.org for + package retrieval and set the ftp path. + +2007-09-19 Vin Shelton <acs@xemacs.org> + + * XEmacs.iss: Various updates: Add support for 21.5; add easypg. + 2006-12-09 Vin Shelton <acs@xemacs.org> * XEmacs 21.4.20 is released diff --git a/nt/XEmacs.iss b/nt/XEmacs.iss index 8862b66..b31c915 100644 --- a/nt/XEmacs.iss +++ b/nt/XEmacs.iss @@ -1,105 +1,420 @@ -; This script generates an installation kit for a Windows-native XEmacs, version 21.4. +; This script generates an installation kit for a Windows-native XEmacs, 21.4 and 21.5. ; This script runs with Inno Setup version 5.1.6, see http://www.jrsoftware.org/ for more info. +; This script requires the Inno Setup pre-processor. ; ; Version History +; 2007-09-26 Vin Shelton <acs@xemacs.org> Remove setting of package-get-always-update and miscellaneous cleanup. +; 2007-09-25 Vin Shelton <acs@xemacs.org> Put comment wrapper around site-start.el changes and remove them on uninstall. +; Enable ftp.xemacs.org for packages and set path to ftp.exe in site-start.el. +; 2007-09-06 Vin Shelton <acs@xemacs.org> Added easypg. +; 2006-04-06 Vin Shelton <acs@xemacs.org> Changed defaults for ExecSrc and PkgSrc. +; Don't set 'Start in' property. +; 2006-04-02 Vin Shelton <acs@xemacs.org> Set 'Start in' property for shortcuts to 'My Documents' directory. +; 2006-03-03 Vin Shelton <acs@xemacs.org> Support for 21.5. Added packages as separate components. +; 2006-01-28 Vin Shelton <acs@xemacs.org> Erase unused registry code. ; 2006-01-26 Vin Shelton <acs@xemacs.org> Don't append XEmacs binary directory to system path. ; 2006-01-21 Vin Shelton <acs@xemacs.org> Append XEmacs binary directory to system path; this is not currently deleted on uninstall. ; Get built kit from C:\XEmacs-built. ; 2005-12-26 Vin Shelton <acs@xemacs.org> Packages are now installed directly into {app}\xemacs-packages, etc. As of 21.4.19, the package root is found automatically, so EMACSPACKAGEPATH is no longer necessary. -; 2005-12-17 Vin Shelton <acs@xemacs.org> Move packages out of the version-specific tree +; 2005-12-17 Vin Shelton <acs@xemacs.org> Move packages out of the version-specific tree. ; 2005-12-13 Vin Shelton <acs@xemacs.org> Created. +; Allow undefined identifiers, e.g. 'KitName' +#pragma parseroption -u+ + +;#define QUICKIE_TEST + +#ifndef XEmacsVersion + #define XEmacsVersion "21.4.20" +#endif +;#define KitName "-2" +#ifndef ExecSrc + #define ExecSrc "installed" +#endif +#ifndef PkgSrc + #define PkgSrc "packages" +#endif + [Setup] +AllowNoIcons=yes AppName=XEmacs -AppVersion={code:XEmacsVersion} -AppVerName=XEmacs {code:XEmacsVersion} -AppPublisher=The XEmacs Development Team +AppVerName=XEmacs {#XEmacsVersion} +AppPublisher=XEmacs Development Team AppPublisherURL=http://www.xemacs.org AppSupportURL=http://www.xemacs.org AppUpdatesURL=http://www.xemacs.org +Compression=lzma DefaultDirName={pf}\XEmacs DefaultGroupName=XEmacs -AllowNoIcons=yes +InfoBeforeFile=ReadMe-{#XEmacsVersion} OutputDir=. -OutputBaseFilename=XEmacs Setup 21.4.19 -Compression=lzma +OutputBaseFilename=XEmacs_Setup_{#XEmacsVersion}{#KitName} SolidCompression=yes -InfoAfterFile=README +UninstallFilesDir={app}/XEmacs-{#XEmacsVersion} [Languages] Name: "english"; MessagesFile: "compiler:Default.isl" +[Messages] +StatusRunProgram=Unpacking selected packages... + [Tasks] Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked [Files] -; Before you run this script, XEmacs-21.4 must be installed in C:\XEmacs-built\XEmacs-21.4.xx -; and any packages you want to include must be installed in C:\XEmacs-built\{xemacs,mule,site}-packages -Source: "C:\XEmacs-built\*"; Excludes: "C:\XEmacs-built\XEmacs-21.5*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs -; NOTE: Don't use "Flags: ignoreversion" on any shared system files +; Always installed +Source: "{#ExecSrc}\XEmacs-{#XEmacsVersion}\*"; DestDir: "{app}\XEmacs-{#XEmacsVersion}"; Flags: ignoreversion recursesubdirs +Source: "{#PkgSrc}\efs-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Flags: ignoreversion +Source: "{#PkgSrc}\xemacs-base-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Flags: ignoreversion +; minitar.exe and unpack.cmd are used to unpack the packages +Source: "{#ExecSrc}\XEmacs-{#XEmacsVersion}\i586-pc-win32\minitar.exe"; DestDir: "{app}\xemacs-packages"; Flags: ignoreversion +Source: "unpack.cmd"; DestDir: "{app}\xemacs-packages"; Flags: ignoreversion +Source: "{#PkgSrc}\package-index.LATEST.gpg"; DestDir: "{app}"; +#ifndef QUICKIE_TEST +; Recommended +Source: "{#PkgSrc}\c-support-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: c_support; Flags: ignoreversion +Source: "{#PkgSrc}\cc-mode-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: cc_mode; Flags: ignoreversion +Source: "{#PkgSrc}\debug-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: debug; Flags: ignoreversion +Source: "{#PkgSrc}\dired-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: dired; Flags: ignoreversion +Source: "{#PkgSrc}\ecb-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: ecb; Flags: ignoreversion +Source: "{#PkgSrc}\edebug-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: edebug; Flags: ignoreversion +Source: "{#PkgSrc}\ediff-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: ediff; Flags: ignoreversion +Source: "{#PkgSrc}\edit-utils-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: edit_utils; Flags: ignoreversion +Source: "{#PkgSrc}\eieio-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: eieio; Flags: ignoreversion +Source: "{#PkgSrc}\fsf-compat-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: fsf_compat; Flags: ignoreversion +Source: "{#PkgSrc}\mail-lib-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: mail_lib; Flags: ignoreversion +Source: "{#PkgSrc}\net-utils-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: net_utils; Flags: ignoreversion +Source: "{#PkgSrc}\os-utils-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: os_utils; Flags: ignoreversion +Source: "{#PkgSrc}\pc-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: pc; Flags: ignoreversion +Source: "{#PkgSrc}\perl-modes-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: perl_modes; Flags: ignoreversion +Source: "{#PkgSrc}\prog-modes-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: prog_modes; Flags: ignoreversion +Source: "{#PkgSrc}\semantic-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: semantic; Flags: ignoreversion +Source: "{#PkgSrc}\sh-script-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: sh_script; Flags: ignoreversion +Source: "{#PkgSrc}\sounds-wav-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: sounds_wav; Flags: ignoreversion +Source: "{#PkgSrc}\speedbar-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: speedbar; Flags: ignoreversion +Source: "{#PkgSrc}\texinfo-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: texinfo; Flags: ignoreversion +Source: "{#PkgSrc}\text-modes-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: text_modes; Flags: ignoreversion +Source: "{#PkgSrc}\time-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: time; Flags: ignoreversion +Source: "{#PkgSrc}\xemacs-devel-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: xemacs_devel; Flags: ignoreversion +; Optional +Source: "{#PkgSrc}\auctex-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: auctex; Flags: ignoreversion +Source: "{#PkgSrc}\bbdb-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: bbdb; Flags: ignoreversion +Source: "{#PkgSrc}\calc-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: calc; Flags: ignoreversion +Source: "{#PkgSrc}\easypg-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: easypg; Flags: ignoreversion +Source: "{#PkgSrc}\ecrypto-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: ecrypto; Flags: ignoreversion +Source: "{#PkgSrc}\elib-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: elib; Flags: ignoreversion +Source: "{#PkgSrc}\emerge-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: emerge; Flags: ignoreversion +Source: "{#PkgSrc}\eshell-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: eshell; Flags: ignoreversion +Source: "{#PkgSrc}\footnote-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: footnote; Flags: ignoreversion +Source: "{#PkgSrc}\fortran-modes-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: fortran_modes; Flags: ignoreversion +Source: "{#PkgSrc}\gnus-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: gnus; Flags: ignoreversion +Source: "{#PkgSrc}\hm--html-menus-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: hm__html_menus; Flags: ignoreversion +Source: "{#PkgSrc}\ibuffer-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: ibuffer; Flags: ignoreversion +Source: "{#PkgSrc}\igrep-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: igrep; Flags: ignoreversion +Source: "{#PkgSrc}\ispell-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: ispell; Flags: ignoreversion +Source: "{#PkgSrc}\jde-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: jde; Flags: ignoreversion +Source: "{#PkgSrc}\mailcrypt-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: mailcrypt; Flags: ignoreversion +Source: "{#PkgSrc}\mh-e-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: mh_e; Flags: ignoreversion +Source: "{#PkgSrc}\mmm-mode-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: mmm_mode; Flags: ignoreversion +Source: "{#PkgSrc}\pcl-cvs-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: pcl_cvs; Flags: ignoreversion +Source: "{#PkgSrc}\pcomplete-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: pcomplete; Flags: ignoreversion +Source: "{#PkgSrc}\ps-print-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: ps_print; Flags: ignoreversion +Source: "{#PkgSrc}\psgml-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: psgml; Flags: ignoreversion +Source: "{#PkgSrc}\python-modes-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: python_modes; Flags: ignoreversion +Source: "{#PkgSrc}\re-builder-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: re_builder; Flags: ignoreversion +Source: "{#PkgSrc}\reftex-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: reftex; Flags: ignoreversion +Source: "{#PkgSrc}\ruby-modes-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: ruby_modes; Flags: ignoreversion +Source: "{#PkgSrc}\sasl-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: sasl; Flags: ignoreversion +Source: "{#PkgSrc}\scheme-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: scheme; Flags: ignoreversion +Source: "{#PkgSrc}\sgml-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: sgml; Flags: ignoreversion +Source: "{#PkgSrc}\sieve-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: sieve; Flags: ignoreversion +Source: "{#PkgSrc}\supercite-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: supercite; Flags: ignoreversion +Source: "{#PkgSrc}\textools-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: textools; Flags: ignoreversion +Source: "{#PkgSrc}\tramp-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: tramp; Flags: ignoreversion +Source: "{#PkgSrc}\vc-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: vc; Flags: ignoreversion +Source: "{#PkgSrc}\vhdl-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: vhdl; Flags: ignoreversion +Source: "{#PkgSrc}\viper-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: viper; Flags: ignoreversion +Source: "{#PkgSrc}\vm-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: vm; Flags: ignoreversion +Source: "{#PkgSrc}\w3-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: w3; Flags: ignoreversion +Source: "{#PkgSrc}\x-symbol-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: x_symbol; Flags: ignoreversion +Source: "{#PkgSrc}\xetla-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: xetla; Flags: ignoreversion +Source: "{#PkgSrc}\xslide-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: xslide; Flags: ignoreversion +Source: "{#PkgSrc}\xslt-process-*-pkg.tar"; DestDir: "{app}\xemacs-packages"; Components: xslt_process; Flags: ignoreversion +#endif // ifndef QUICKIE_TEST +#ifdef MULE +Source: "{#PkgSrc}\latin-euro-standards-*-pkg.tar"; DestDir: "{app}\mule-packages"; Components: latin_euro_standards; Flags: ignoreversion +Source: "{#PkgSrc}\latin-unity-*-pkg.tar"; DestDir: "{app}\mule-packages"; Components: latin_unity; Flags: ignoreversion +Source: "{#PkgSrc}\locale-*-pkg.tar"; DestDir: "{app}\mule-packages"; Components: locale; Flags: ignoreversion +Source: "{#PkgSrc}\lookup-*-pkg.tar"; DestDir: "{app}\mule-packages"; Components: lookup; Flags: ignoreversion +Source: "{#PkgSrc}\mule-base-*-pkg.tar"; DestDir: "{app}\mule-packages"; Components: mule_base; Flags: ignoreversion +#endif -[INI] -Filename: "{app}\xemacs.url"; Section: "InternetShortcut"; Key: "URL"; String: "http://www.xemacs.org" +[Types] +Name: "recommended"; Description: "Recommended installation" +Name: "complete"; Description: "Install XEmacs {#XEmacsVersion} and all packages" +Name: "minimal"; Description: "Minimalist installation" +Name: "custom"; Description: "Custom installation"; Flags: iscustom -[Icons] -Name: "{group}\XEmacs"; Filename: "{app}\XEmacs-{code:XEmacsVersion}\i586-pc-win32\xemacs.exe" -Name: "{group}\{cm:ProgramOnTheWeb,XEmacs}"; Filename: "{app}\xemacs.url" -Name: "{group}\{cm:UninstallProgram,XEmacs}"; Filename: "{uninstallexe}" -Name: "{userdesktop}\XEmacs"; Filename: "{app}\XEmacs-{code:XEmacsVersion}\i586-pc-win32\xemacs.exe"; Tasks: desktopicon -Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\XEmacs"; Filename: "{app}\XEmacs-{code:XEmacsVersion}\i586-pc-win32\xemacs.exe"; Tasks: quicklaunchicon +[Components] +Name: "base"; Description: "XEmacs {#XEmacsVersion} executable and essential support files"; Types: complete minimal recommended custom; Flags: fixed +Name: "auctex"; Description: "auctex: Basic TeX/LaTeX support"; Types: complete custom +Name: "bbdb"; Description: "bbdb: The Big Brother Data Base"; Types: complete custom +Name: "c_support"; Description: "c-support: Basic single-file add-ons for editing C code"; Types: complete recommended custom +Name: "calc"; Description: "calc: Emacs calculator"; Types: complete custom +Name: "cc_mode"; Description: "cc-mode: C, C++, etc language support"; Types: complete recommended custom +Name: "debug"; Description: "debug: GUD, gdb, dbx debugging support"; Types: complete recommended custom +Name: "dired"; Description: "dired: Manage file systems"; Types: complete recommended custom +Name: "ecb"; Description: "ecb: Emacs source code browser"; Types: complete recommended custom +Name: "easypg"; Description: "easypg: GnuPG interface for Emacs"; Types: complete custom +Name: "ecrypto"; Description: "ecrypto: Crypto functionality in Emacs Lisp"; Types: complete custom +Name: "edebug"; Description: "edebug: An Emacs Lisp debugger"; Types: complete recommended custom +Name: "ediff"; Description: "ediff: Interface over GNU patch"; Types: complete recommended custom +Name: "edit_utils"; Description: "edit-utils: Miscellaneous editor extensions, you probably need this"; Types: complete minimal recommended custom +Name: "efs"; Description: "efs: Edit files on other computers"; Types: complete minimal recommended custom; Flags: fixed +Name: "eieio"; Description: "eieio: Enhanced Implementation of Emacs Interpreted Objects"; Types: complete recommended custom +Name: "elib"; Description: "elib: Portable Emacs Lisp utilities library"; Types: complete custom +Name: "emerge"; Description: "emerge: Another interface over GNU patch"; Types: complete custom +Name: "eshell"; Description: "eshell: Command shell implemented in Emacs Lisp"; Types: complete custom +Name: "footnote"; Description: "footnote: Footnoting in mail message editing modes"; Types: complete custom +Name: "fortran_modes"; Description: "fortran-modes: Fortran support"; Types: complete custom +Name: "fsf_compat"; Description: "fsf-compat: FSF Emacs compatibility files"; Types: complete recommended custom +Name: "gnus"; Description: "gnus: The Gnus Newsreader and Mailreader"; Types: complete custom +Name: "hm__html_menus"; Description: "hm--html-menus: HTML editing"; Types: complete custom +Name: "ibuffer"; Description: "ibuffer: Advanced replacement for buffer-menu"; Types: complete custom +Name: "igrep"; Description: "igrep: Enhanced front-end for Grep"; Types: complete custom +Name: "ispell"; Description: "ispell: Spell-checking with GNU ispell"; Types: complete custom +Name: "jde"; Description: "jde: Integrated Development Environment for Java"; Types: complete custom +#ifdef MULE +Name: "latin_euro_standards"; Description: "latin-euro-standards: Support for the Latin character sets (MULE)"; Types: complete recommended custom +Name: "latin_unity"; Description: "latin-unity: Find single ISO 8859 character set to encode a buffer (MULE)"; Types: complete recommended custom +Name: "locale"; Description: "locale: Localized menubars and localized splash screens (MULE)"; Types: complete recommended custom +Name: "lookup"; Description: "lookup: Dictionary support (MULE)"; Types: complete recommended custom +#endif +Name: "mail_lib"; Description: "mail-lib: Fundamental lisp files for providing email support"; Types: complete recommended custom +Name: "mailcrypt"; Description: "mailcrypt: Support for messaging encryption with PGP"; Types: complete custom +Name: "mh_e"; Description: "mh-e: Interface to the MH Mail System"; Types: complete custom +Name: "mmm_mode"; Description: "mmm-mode: Multiple major modes in a single buffer"; Types: complete custom +#ifdef MULE +Name: "mule_base"; Description: "mule-base: Basic MULE support"; Types: complete recommended custom +#endif +Name: "net_utils"; Description: "net-utils: Miscellaneous Networking Utilities"; Types: complete recommended custom +Name: "os_utils"; Description: "os-utils: Miscellaneous O/S utilities"; Types: complete recommended custom +Name: "pc"; Description: "pc: PC style interface emulation"; Types: complete recommended custom +Name: "pcl_cvs"; Description: "pcl-cvs: CVS frontend"; Types: complete custom +Name: "pcomplete"; Description: "pcomplete: Provides programmatic completion"; Types: complete custom +Name: "perl_modes"; Description: "perl-modes: Perl support"; Types: complete recommended custom +Name: "prog_modes"; Description: "prog-modes: Support for various programming languages"; Types: complete recommended custom +Name: "ps_print"; Description: "ps-print: Printing functions and utilities"; Types: complete custom +Name: "psgml"; Description: "psgml: Validated HTML/SGML editing"; Types: complete custom +Name: "python_modes"; Description: "python-modes: Python support"; Types: complete custom +Name: "re_builder"; Description: "re-builder: Build regular expressions"; Types: complete custom +Name: "reftex"; Description: "reftex: LaTeX cross-references and citations"; Types: complete custom +Name: "ruby_modes"; Description: "ruby-modes: Ruby support"; Types: complete custom +Name: "sasl"; Description: "sasl: Simple Authentication and Security Layer (SASL) library"; Types: complete custom +Name: "scheme"; Description: "scheme: Front-end support for Inferior Scheme"; Types: complete custom +Name: "semantic"; Description: "semantic: Semantic bovinator (Yacc/Lex for XEmacs)"; Types: complete recommended custom +Name: "sgml"; Description: "sgml: SGML/Linuxdoc-SGML editing"; Types: complete custom +Name: "sh_script"; Description: "sh-script: Support for editing shell scripts"; Types: complete recommended custom +Name: "sieve"; Description: "sieve: Manage Sieve email filtering scripts"; Types: complete custom +Name: "sounds_wav"; Description: "sounds-wav: XEmacs Microsoft sound files"; Types: complete recommended custom +Name: "speedbar"; Description: "speedbar: Provides a separate frame with convenient references"; Types: complete recommended custom +Name: "supercite"; Description: "supercite: Citation tool for news & mail messages"; Types: complete custom +Name: "texinfo"; Description: "texinfo: XEmacs TeXinfo support"; Types: complete minimal recommended custom +Name: "text_modes"; Description: "text-modes: Miscellaneous support for editing text files"; Types: complete recommended custom +Name: "textools"; Description: "textools: Miscellaneous TeX support"; Types: complete custom +Name: "time"; Description: "time: Display time & date on the modeline"; Types: complete recommended custom +Name: "tramp"; Description: "tramp: Remote shell-based file editing"; Types: complete custom +Name: "vc"; Description: "vc: Version Control for Free systems"; Types: complete custom +Name: "vhdl"; Description: "vhdl: Support for VHDL"; Types: complete custom +Name: "viper"; Description: "viper: VI emulation support"; Types: complete custom +Name: "vm"; Description: "vm: An Emacs mailer"; Types: complete custom +Name: "w3"; Description: "w3: A Web browser"; Types: complete custom +Name: "x_symbol"; Description: "x-symbol: Semi WYSIWYG for LaTeX and HTML"; Types: complete custom +Name: "xemacs_base"; Description: "xemacs-base: Basic XEmacs support"; Types: complete minimal recommended custom; Flags: fixed +Name: "xemacs_devel"; Description: "xemacs-devel: Emacs Lisp developer support"; Types: complete recommended custom +Name: "xetla"; Description: "xetla: XEmacs support for GNU/arch (tla)"; Types: complete custom +Name: "xslide"; Description: "xslide: XSL editing support"; Types: complete custom +Name: "xslt_process"; Description: "xslt-process: XSLT processing support"; Types: complete custom -[Registry] -; Set a registry key to point to the packages so they can be shared between multiple installed versions of XEmacs -; This is no longer necessary as of version 21.4.19. -;Root: HKLM; Subkey: "Software\XEmacs\XEmacs"; ValueType: string; ValueName: "EMACSPACKAGEPATH"; ValueData: "{app}\Packages"; Flags: uninsdeletekey -; Don't fiddle with the system path -;Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}\XEmacs-{code:XEmacsVersion}\i586-pc-win32" +[INI] +[Icons] +Name: "{group}\XEmacs-{#XEmacsVersion}"; Filename: "{app}\XEmacs-{#XEmacsVersion}\i586-pc-win32\xemacs.exe" +Name: "{group}\{cm:UninstallProgram,XEmacs-{#XEmacsVersion}}"; Filename: "{uninstallexe}" +; WorkingDir corresponds to the 'Start in' property. +Name: "{userdesktop}\XEmacs-{#XEmacsVersion}"; Filename: "{app}\XEmacs-{#XEmacsVersion}\i586-pc-win32\xemacs.exe"; Tasks: desktopicon +Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\XEmacs-{#XEmacsVersion}"; Filename: "{app}\XEmacs-{#XEmacsVersion}\i586-pc-win32\xemacs.exe"; Tasks: quicklaunchicon [Run] -Filename: "{app}\XEmacs-{code:XEmacsVersion}\i586-pc-win32\xemacs.exe"; Description: "{cm:LaunchProgram,XEmacs}"; Flags: nowait postinstall skipifsilent +; Unpack and delete the package tarballs +Filename: "{app}\xemacs-packages\unpack.cmd"; WorkingDir: "{app}\xemacs-packages"; Flags: runhidden; AfterInstall: AfterInstall [UninstallDelete] -Type: files; Name: "{app}\xemacs.url" [Code] -function XEmacsVersion(Param: String): String; +Const + SiteStartFooter = ';;; End of XEmacs_Setup addition' + #10; + SiteStartHeader = #10 + ';;; Lines added by XEmacs_Setup' + #10; + SubKeyName = 'Software\XEmacs\XEmacs'; + ValueName = 'EMACSPACKAGEPATH'; + +// Internal Declarations +procedure AfterInstall(); forward; +procedure CleanupPackagePath(); forward; +procedure CreateSiteStart(); forward; +procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); forward; +procedure RemovePackagePathSetting(RootKey: Integer); forward; +procedure RemoveSiteStartModifications(); forward; + + +procedure AfterInstall(); begin - Result := '21.4.19'; + CreateSiteStart; + CleanupPackagePath; end; -procedure CurStepChanged(CurStep: TSetupStep); +procedure CleanupPackagePath(); +begin + RemovePackagePathSetting(HKEY_CURRENT_USER); + RemovePackagePathSetting(HKEY_LOCAL_MACHINE); +end; + +// Create a site-start.el file to allow easy package downloading +procedure CreateSiteStart(); var - BinDir: String; - EtcDir: String; + Contents: String; + FtpExe: String; + HeaderRequired, FooterRequired: Boolean; + InsertPos: Integer; InstallBase: String; + Payload: String; SiteStart: String; begin - // Create a site-start.el file to allow easy package downloading in the future and to add the binary directory to exec-path. - // E.g, here's what we're going to add to lisp\site-start.el: - // (setq package-get-package-index-file-location "C:\\Program Files\XEmacs\\XEmacs-21.4.98\\etc") - // ; Uncomment the next line to select the primary XEmacs package download site - // ;(setq package-get-remote '("ftp.xemacs.org" "pub/xemacs/packages")) - if CurStep = ssPostInstall then begin - - // Convert directory names to lisp format by doubling each backslash - InstallBase := WizardDirValue + '\XEmacs-' + XEmacsVersion(''); - StringChange(InstallBase, '\', '\\'); - EtcDir := InstallBase + '\\etc'; - //BinDir := InstallBase + '\\i586-pc-win32\\'; - - SiteStart := WizardDirValue + '\site-packages\lisp'; - CreateDir(SiteStart); - SiteStart := SiteStart + '\site-start.el'; - - SaveStringToFile(SiteStart, #13#10 + '(setq package-get-package-index-file-location "' + EtcDir + '")' + #13#10, True); - SaveStringToFile(SiteStart, '; Uncomment the next line to select the primary XEmacs package download site' + #13#10, True); - SaveStringToFile(SiteStart, ';(setq package-get-remote ' + Chr(39) + '("ftp.xemacs.org" "pub/xemacs/packages"))' + #13#10, True); - - //SaveStringToFile(SiteStart, '(pushnew "' + BinDir + '" exec-path)' + #13#10, True); + // Here's what we're going to add to lisp\site-start.el: + // ;;; Lines added by XEmacs_Setup + // (setq package-get-package-index-file-location "C:/Program Files/XEmacs") + // (setq package-get-remote '("ftp.xemacs.org" "pub/xemacs/packages")) + // (setq efs-ftp-program-name "C:/WINDOWS/system32/ftp.exe") + // ;;; End of XEmacs_Setup addition + + SiteStart := ExpandConstant('{app}') + '\site-packages'; + CreateDir(SiteStart); + SiteStart := SiteStart + '\lisp'; + CreateDir(SiteStart); + SiteStart := SiteStart + '\site-start.el'; + + // Optimize for the most common cases: either site-start.el does not contain anything related to XEmacs setup + // or site-start.el contains the entire text verbatim. + + // Convert separators from backslash to slash + InstallBase := ExpandConstant('{app}'); + StringChange(InstallBase, '\', '/'); + FtpExe := ExpandConstant('{syswow64}') + '\ftp.exe'; + StringChange(FtpExe, '\', '/'); + Payload := '(setq package-get-package-index-file-location "' + InstallBase + '")' + #10 + + '(setq package-get-remote ' + Chr(39) + '("ftp.xemacs.org" "pub/xemacs/packages"))' + #10 + '(setq efs-ftp-program-name "' + FtpExe + '")' + #10; + + // File is non-existant - write header, payload and footer + if NOT LoadStringFromFile(SiteStart, Contents) then + begin + SaveStringToFile(SiteStart, SiteStartHeader + Payload + SiteStartFooter, False); + end else + begin + + // Pos > 0 indicates that the full text already appears verbatim in the site-start.el file, so do nothing in that case + if Pos(SiteStartHeader + Payload + SiteStartFooter, Contents) = 0 then + begin + FooterRequired := True; + HeaderRequired := True; + InsertPos := Pos(SiteStartHeader, Contents); + if InsertPos > 0 then + begin + HeaderRequired := False + InsertPos := Pos(SiteStartFooter, Contents); + if InsertPos > 0 then + begin + FooterRequired := False; + end else + begin + InsertPos := Length(Contents); + end; + end; + + if InsertPos = 0 then InsertPos := 1; + + if HeaderRequired then + begin + Insert(SiteStartHeader, Contents, InsertPos); + InsertPos := InsertPos + Length(SiteStartHeader); + end; + Insert(Payload, Contents, InsertPos); + InsertPos := InsertPos + Length(Payload); + + if FooterRequired then + Insert(SiteStartFooter, Contents, InsertPos); + + SaveStringToFile(SiteStart, Contents, False); + end; end; end; +procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); +begin + case CurUninstallStep of + usUninstall: + begin + RemoveSiteStartModifications; + end; + end; +end; + +procedure RemovePackagePathSetting(RootKey: Integer); +var + RootKeyName: String; + Value: String; +begin + RootKeyName := 'Unknown Root'; + case RootKey of + HKEY_CURRENT_USER: + RootKeyName := 'HKEY_CURRENT_USER'; + HKEY_LOCAL_MACHINE: + RootKeyName := 'HKEY_LOCAL_MACHINE'; + end; + // Check to see if the key exists in the specified registry root + if RegQueryStringValue(RootKey, SubKeyName, ValueName, Value) then + begin + // Allow the user to delete it + if MsgBox('Do you want to delete the registry key ' + RootKeyName + '\' + SubKeyName + '\' + ValueName + '?' #13 'Currently this key has the value "' + Value + '".' #13#13 'If you do not delete this registry key, then the packages installed from this setup kit will not be found when XEmacs runs.' #13, mbConfirmation, MB_YESNO) = IDYES then + begin + RegDeleteValue(RootKey, SubKeyName, ValueName); + end; + end; +end; + + +procedure RemoveSiteStartModifications(); +var + Contents: String; + Footer, Header: Integer; + SiteStart: String; +begin + SiteStart := ExpandConstant('{app}') + '\site-packages\lisp\site-start.el'; + if LoadStringFromFile(SiteStart, Contents) then + begin + Header := Pos(SiteStartHeader, Contents); + if Header > 0 then + begin + Footer := Pos(SiteStartFooter, Contents); + if (Footer > 0) AND (Footer > Header) then + begin + Footer := Footer + Length(SiteStartFooter); + Delete(Contents, Header, Footer-Header); + SaveStringToFile(SiteStart, Contents, False); + end; + end; + end; +end; diff --git a/src/ChangeLog b/src/ChangeLog index de3bf94..d9b6740 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,64 @@ +2007-10-07 Vin Shelton <acs@xemacs.org> + + * XEmacs 21.4.21 is released + +2007-08-14 Marcus Crestani <crestani@xemacs.org> + + * s/sol2.h: Fix for GCC lossage not needed with SunOS 5.10. + +2007-02-17 Stephen J. Turnbull <stephen@xemacs.org> + + * glyphs-eimage.c (png_instantiate_unwind): Avoid recursion. + (png_instantiate): Initialize setjmp_buffer early, and avoid + recursive entry to error handler. + +2007-06-23 Stephen J. Turnbull <stephen@xemacs.org> + + * linuxplay.c (linux_play_data_or_file): More 64-bit tweaking, and + a typo fix. + +2007-05-12 Aidan Kehoe <kehoea@parhasard.net> + + * event-Xt.c (x_reset_modifier_mapping): + * event-gtk.c (gtk_reset_modifier_mapping): + Zero out the device's modifier map once we've freed it, to prevent + a double free on a re-entrant call. + +2007-05-17 Vin Shelton <acs@xemacs.org> + + * linuxplay.c (linux_play_data_or_file): Fix playing sound on + 64-bit linux. Patch from Hans de Graaff. + +2007-05-02 Vin Shelton <acs@xemacs.org> + + * dumper.c (pdump): Don't close pdump_fd (already closed by + fclose() call. Patch from Steve Higham. + * callproc.c (Fold_call_process_internal): Don't close fd1 if it's + already closed. Patch inspired by Steve Higham. + +2007-05-01 Vin Shelton <acs@xemacs.org> + + * nt.c (mswindows_stat): Tie _S_IEXEC permission to read access. + (mswindows_fstat): Ditto. + * sysfile.h: Under Windows, define X_OK to be the same as R_OK. + +2007-02-08 Adrian Aichner <adrian@xemacs.org> + + * postgresql.c: Update Steve Baur's email address by his request. + * postgresql.h: Ditto. + +2007-01-04 Vin Shelton <acs@xemacs.org> + + * fileio.c (check_writable): Check old-style readonly bit only for + non-directories. + +2006-12-25 Benson I. Margulies <benson@dchbk.us> + + * src/fileio.c (check_writable): + Cope with the fact that the read-only attribute trumps Windows NTFS + ACLS. + + 2006-12-09 Vin Shelton <acs@xemacs.org> * XEmacs 21.4.20 is released diff --git a/src/callproc.c b/src/callproc.c index 5c90e9e..8272ca9 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -399,9 +399,6 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you } #endif } - /* Close STDERR into the parent process. We no longer need it. */ - if (fd_error >= 0) - close (fd_error); #else /* not WIN32_NATIVE */ pid = fork (); @@ -420,17 +417,18 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you child_setup (filefd, fd1, fd_error, new_argv, (char *) XSTRING_DATA (current_dir)); } - if (fd_error >= 0) - close (fd_error); - #endif /* not WIN32_NATIVE */ environ = save_environ; + /* Close STDERR into the parent process. We no longer need it. */ + if (fd_error >= 0) + close (fd_error); + /* Close most of our fd's, but not fd[0] since we will use that to read input from. */ close (filefd); - if (fd1 >= 0) + if ((fd1 >= 0) && (fd1 != fd_error)) close (fd1); } diff --git a/src/dumper.c b/src/dumper.c index 1531367..872a0d1 100644 --- a/src/dumper.c +++ b/src/dumper.c @@ -1067,7 +1067,8 @@ pdump (void) pdump_dump_root_objects (); fclose (pdump_out); - close (pdump_fd); + /* pdump_fd is already closed by the preceding fclose call + close (pdump_fd); */ free (pdump_buf); diff --git a/src/event-Xt.c b/src/event-Xt.c index 31dd6c6..ccfde91 100644 --- a/src/event-Xt.c +++ b/src/event-Xt.c @@ -461,7 +461,14 @@ x_reset_modifier_mapping (struct device *d) xd->lock_interpretation = 0; if (xd->x_modifier_keymap) - XFreeModifiermap (xd->x_modifier_keymap); + { + XFreeModifiermap (xd->x_modifier_keymap); + /* Set it to NULL in case we receive two MappingModifier events in a + row, and the second is processed during some CHECK_QUITs within + x_reset_key_mapping. If that happens, XFreeModifierMap will be + called twice on the same map, and we crash. */ + xd->x_modifier_keymap = NULL; + } x_reset_key_mapping (d); diff --git a/src/fileio.c b/src/fileio.c index c9bc2ae..64adf94 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -2307,6 +2307,11 @@ check_writable (const char *filename) filename = filename_buffer; #endif + // First check for a normal file with the old-style readonly bit + attributes = GetFileAttributes(filename); + if (FILE_ATTRIBUTE_READONLY == (attributes & (FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_READONLY))) + return 0; + /* Win32 prototype lacks const. */ error = GetNamedSecurityInfo((LPTSTR)filename, SE_FILE_OBJECT, DACL_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|OWNER_SECURITY_INFORMATION, diff --git a/src/glyphs-eimage.c b/src/glyphs-eimage.c index 3974bc0..c786271 100644 --- a/src/glyphs-eimage.c +++ b/src/glyphs-eimage.c @@ -847,7 +847,13 @@ png_instantiate_unwind (Lisp_Object unwind_obj) free_opaque_ptr (unwind_obj); if (data->png_ptr) - png_destroy_read_struct (&(data->png_ptr), &(data->info_ptr), (png_infopp)NULL); + { + /* ensure we can't get here again */ + png_structp tmp = data->png_ptr; + data->png_ptr = NULL; + png_destroy_read_struct (&tmp, &(data->info_ptr), (png_infopp)NULL); + } + if (data->instream) fclose (data->instream); @@ -871,24 +877,36 @@ png_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, png_structp png_ptr; png_infop info_ptr; + xzero (unwind); + record_unwind_protect (png_instantiate_unwind, make_opaque_ptr (&unwind)); + + if (setjmp (png_err_stct.setjmp_buffer)) + { + /* Something blew up: + just display the error (cleanup happens in the unwind) */ + signal_image_error_2 ("Error decoding PNG", + build_string(png_err_stct.err_str), + instantiator); + } + /* Initialize all PNG structures */ - png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, (void*)&png_err_stct, + png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, + (void *) &png_err_stct, png_error_func, png_warning_func); if (!png_ptr) signal_image_error ("Error obtaining memory for png_read", instantiator); + unwind.png_ptr = png_ptr; + info_ptr = png_create_info_struct (png_ptr); if (!info_ptr) { + unwind.png_ptr = NULL; /* avoid re-calling png_destroy_read_struct + when unwinding */ png_destroy_read_struct (&png_ptr, (png_infopp)NULL, (png_infopp)NULL); signal_image_error ("Error obtaining memory for png_read", instantiator); } - - xzero (unwind); - unwind.png_ptr = png_ptr; unwind.info_ptr = info_ptr; - record_unwind_protect (png_instantiate_unwind, make_opaque_ptr (&unwind)); - /* This code is a mixture of stuff from Ben's GIF/JPEG stuff from this file, example.c from the libpng 0.81 distribution, and the pngtopnm sources. -WMP- @@ -897,16 +915,6 @@ png_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, and is no longer usable for previous versions. jh */ - /* Set the jmp_buf return context for png_error ... if this returns !0, then - we ran into a problem somewhere, and need to clean up after ourselves. */ - if (setjmp (png_err_stct.setjmp_buffer)) - { - /* Something blew up: just display the error (cleanup happens in the unwind) */ - signal_image_error_2 ("Error decoding PNG", - build_string(png_err_stct.err_str), - instantiator); - } - /* Initialize the IO layer and read in header information */ { Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); diff --git a/src/linuxplay.c b/src/linuxplay.c index 9b702a0..4108a19 100644 --- a/src/linuxplay.c +++ b/src/linuxplay.c @@ -290,8 +290,9 @@ static int linux_play_data_or_file(int fd,unsigned char *data, fmtType ffmt; int fmt,speed,tracks; unsigned char *pptr,*optr,*cptr,*sptr; - int wrtn,rrtn,crtn,prtn; - unsigned char sndbuf[SNDBUFSZ]; + int wrtn, crtn; + size_t prtn, rrtn; + unsigned char sndbuf[SNDBUFSZ]; /* We need to read at least the header information before we can start doing anything */ @@ -338,9 +339,9 @@ static int linux_play_data_or_file(int fd,unsigned char *data, device; repeat until all data has been processed */ rrtn = length; do { - for (pptr = data; (prtn = parsesndfile((void **)&pptr,(size_t *)&rrtn, + for (pptr = data; (prtn = parsesndfile((void **)&pptr, &rrtn, (void **)&optr)) > 0; ) - for (cptr = optr; (crtn = sndcnv((void **)&cptr,(size_t *) &prtn, + for (cptr = optr; (crtn = sndcnv((void **)&cptr, &prtn, (void **)&sptr)) > 0; ) { for (;;) { if ((wrtn = write(audio_fd,sptr,crtn)) < 0) { diff --git a/src/nt.c b/src/nt.c index 566f4f0..1e26fbb 100644 --- a/src/nt.c +++ b/src/nt.c @@ -1449,9 +1449,9 @@ mswindows_fstat (int desc, struct stat * buf) /* determine rwx permissions */ if (info.dwFileAttributes & FILE_ATTRIBUTE_READONLY) - permission = _S_IREAD; + permission = _S_IREAD | _S_IEXEC; else - permission = _S_IREAD | _S_IWRITE; + permission = _S_IREAD | _S_IEXEC |_S_IWRITE; if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) permission |= _S_IEXEC; @@ -1638,22 +1638,12 @@ mswindows_stat (const char * path, struct stat * buf) /* determine rwx permissions */ if (wfd.dwFileAttributes & FILE_ATTRIBUTE_READONLY) - permission = _S_IREAD; + permission = _S_IREAD | _S_IEXEC; else - permission = _S_IREAD | _S_IWRITE; + permission = _S_IREAD | _S_IEXEC |_S_IWRITE; if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) permission |= _S_IEXEC; - else - { - char * p = strrchr (name, '.'); - if (p != NULL && - (stricmp (p, ".exe") == 0 || - stricmp (p, ".com") == 0 || - stricmp (p, ".bat") == 0 || - stricmp (p, ".cmd") == 0)) - permission |= _S_IEXEC; - } buf->st_mode |= permission | (permission >> 3) | (permission >> 6); diff --git a/src/postgresql.c b/src/postgresql.c index 66807a3..34b608e 100644 --- a/src/postgresql.c +++ b/src/postgresql.c @@ -3,8 +3,8 @@ Copyright (C) 2000 Electrotechnical Laboratory, JAPAN. Licensed to the Free Software Foundation. - Author: SL Baur <steve@beopen.com> - Maintainer: SL Baur <steve@beopen.com> + Author: SL Baur <steve@xemacs.org> + Maintainer: SL Baur <steve@xemacs.org> Please send patches to this file to me first before submitting them to xemacs-patches. diff --git a/src/postgresql.h b/src/postgresql.h index acfda83..79e99b5 100644 --- a/src/postgresql.h +++ b/src/postgresql.h @@ -3,8 +3,8 @@ Copyright (C) 2000 Electrotechnical Laboratory, JAPAN. Licensed to the Free Software Foundation. - Author: SL Baur <steve@beopen.com> - Maintainer: SL Baur <steve@beopen.com> + Author: SL Baur <steve@xemacs.org> + Maintainer: SL Baur <steve@xemacs.org> Please send patches to this file to me first before submitting them to xemacs-patches. diff --git a/src/s/sol2.h b/src/s/sol2.h index be814d7..aa9e4e4 100644 --- a/src/s/sol2.h +++ b/src/s/sol2.h @@ -11,7 +11,7 @@ #endif /* Fix understandable GCC lossage on Solaris 2.6 */ -#if defined(__GNUC__) && OS_RELEASE >= 506 && !defined(NOT_C_CODE) +#if defined(__GNUC__) && OS_RELEASE >= 506 && OS_RELEASE < 510 && !defined(NOT_C_CODE) /* GCC va_list munging is a little messed up */ #define __GNUC_VA_LIST diff --git a/src/sysfile.h b/src/sysfile.h index 25c009d..d9d3deb 100644 --- a/src/sysfile.h +++ b/src/sysfile.h @@ -261,14 +261,20 @@ Boston, MA 02111-1307, USA. */ #endif /* The following definitions are needed under Windows, at least */ -#ifndef X_OK -# define X_OK 1 -#endif - #ifndef R_OK # define R_OK 4 #endif +/* Under native Windows, there is no concept of execute permission, + so redefine execute permissions to be the same as read permission */ +#ifndef X_OK +# ifdef WIN32_NATIVE +# define X_OK R_OK +# else +# define X_OK 1 +# endif +#endif + #ifndef W_OK # define W_OK 2 #endif diff --git a/tests/ChangeLog b/tests/ChangeLog index 9ea1717..380e70e 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,11 @@ +2007-10-07 Vin Shelton <acs@xemacs.org> + + * XEmacs 21.4.21 is released + +2007-06-22 Stephen J. Turnbull <stephen@xemacs.org> + + * automated/mule-tests.el (buffer-modified-p): Test after revert. + 2006-12-09 Vin Shelton <acs@xemacs.org> * XEmacs 21.4.20 is released diff --git a/tests/automated/mule-tests.el b/tests/automated/mule-tests.el index a89690b..4001f1b 100644 --- a/tests/automated/mule-tests.el +++ b/tests/automated/mule-tests.el @@ -78,6 +78,35 @@ the Assert macro checks for correctness." ;; once compiled, for no good reason. (test-chars t) +;;---------------------------------------------------------------- +;; Test that revert-buffer resets the modiff +;; Bug reported 2007-06-20 <200706201902.32191.scop@xemacs.org>. +;; Fixed 2007-06-22 <18043.2793.611745.734215@parhasard.net>. +;;---------------------------------------------------------------- + +;; #### need a temp file name but this will do for now +(let ((test-file-name (expand-file-name "~/test-revert-buffer-resets-modiff")) + revert-buffer-function + kill-buffer-hook) ; paranoia + (find-file test-file-name) + (erase-buffer) + (insert "a string\n") + (save-buffer 0) + (insert "more text\n") + (revert-buffer t t) + ;; Just "find-file" with autodetect coding didn't fail for me, but it does + ;; fail under test harness. Still we'll redo the test with an explicit + ;; coding system just in case. + (Assert (not (buffer-modified-p))) + (kill-buffer nil) + (when (find-coding-system 'utf-8) + (find-file test-file-name 'utf-8) + (insert "more text\n") + (revert-buffer t t) + (Assert (not (buffer-modified-p))) + (kill-buffer nil)) + (delete-file test-file-name)) + ;;----------------------------------------------------------------- ;; Test string modification functions that modify the length of a char. ;;----------------------------------------------------------------- diff --git a/version.sh b/version.sh index 22fd490..8e1fc9a 100644 --- a/version.sh +++ b/version.sh @@ -2,8 +2,8 @@ emacs_is_beta= emacs_major_version=21 emacs_minor_version=4 -emacs_beta_version=20 -xemacs_codename="Double Solitaire" +emacs_beta_version=21 +xemacs_codename="Educational Television" emacs_kit_version= infodock_major_version=4 infodock_minor_version=0