From: Francesco Potortì Date: Tue, 27 Sep 2005 13:26:54 +0000 (+0000) Subject: Preliminary Forth support. X-Git-Tag: emacs-pretest-22.0.90~6933 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=55102b5d3100b6dcb45832f9c0b9e1f13f5bdad6;p=emacs.git 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. (longopts, print_help, main): The -a (--append) option can be used in ctags also; for one, the Linux make file uses it. --- diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 7d22972794f..e8bda4e21b9 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog @@ -1,3 +1,15 @@ +2005-09-27 Francesco Potort,Al(B + + * 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. + +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. + 2005-09-20 Chong Yidong * ebrowse.c (add_sym): Compare namespace names instead of diff --git a/lib-src/etags.c b/lib-src/etags.c index fe4fa84f4c5..357470b4fde 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c @@ -41,7 +41,7 @@ * configuration file containing regexp definitions for etags. */ -char pot_etags_version[] = "@(#) pot revision number is 17.5"; +char pot_etags_version[] = "@(#) pot revision number is 17.13"; #define TRUE 1 #define FALSE 0 @@ -343,6 +343,7 @@ 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 *)); @@ -489,6 +490,7 @@ static bool need_filebuf; /* some regexes are multi-line */ #if LONG_OPTIONS static struct option longopts[] = { + { "append", no_argument, NULL, 'a' }, { "packages-only", no_argument, &packages_only, TRUE }, { "c++", no_argument, NULL, 'C' }, { "declarations", no_argument, &declarations, TRUE }, @@ -508,7 +510,7 @@ static struct option longopts[] = { "parse-stdin", required_argument, NULL, STDIN }, { "version", no_argument, NULL, 'V' }, -#if CTAGS /* Etags options */ +#if CTAGS /* Ctags options */ { "backward-search", no_argument, NULL, 'B' }, { "cxref", no_argument, NULL, 'x' }, { "defines", no_argument, NULL, 'd' }, @@ -519,8 +521,7 @@ static struct option longopts[] = { "vgrind", no_argument, NULL, 'v' }, { "no-warn", no_argument, NULL, 'w' }, -#else /* Ctags options */ - { "append", no_argument, NULL, 'a' }, +#else /* Etags options */ { "no-defines", no_argument, NULL, 'D' }, { "no-globals", no_argument, &globals, FALSE }, { "include", required_argument, NULL, 'i' }, @@ -631,6 +632,12 @@ static char Erlang_help [] = "In Erlang code, the tags are the functions, records and macros\n\ defined in the file."; +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 [] = @@ -778,6 +785,7 @@ static language lang_names [] = { "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 }, @@ -881,8 +889,7 @@ linked with GNU getopt."); Absolute names are stored in the output file as they are.\n\ Relative ones are stored relative to the output file's directory.\n"); - if (!CTAGS) - puts ("-a, --append\n\ + puts ("-a, --append\n\ Append tag entries to existing tags file."); puts ("--packages-only\n\ @@ -1180,17 +1187,19 @@ main (argc, argv) globals = TRUE; } + /* 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 = "-"; #ifdef ETAGS_REGEXPS optstring = "-r:Rc:"; #endif /* ETAGS_REGEXPS */ if (!LONG_OPTIONS) - optstring += 1; + optstring += 1; /* remove the initial '-' */ optstring = concat (optstring, - "Cf:Il:o:SVhH", - (CTAGS) ? "BxdtTuvw" : "aDi:"); + "aCf:Il:o:SVhH", + (CTAGS) ? "BxdtTuvw" : "Di:"); - while ((opt = getopt_long (argc, argv, optstring, longopts, 0)) != EOF) + while ((opt = getopt_long (argc, argv, optstring, longopts, NULL)) != EOF) switch (opt) { case 0: @@ -1218,6 +1227,7 @@ main (argc, argv) break; /* Common options. */ + case 'a': append_to_tagfile = TRUE; break; case 'C': cplusplus = TRUE; break; case 'f': /* for compatibility with old makefiles */ case 'o': @@ -1267,7 +1277,6 @@ main (argc, argv) break; /* Etags options */ - case 'a': append_to_tagfile = TRUE; break; case 'D': constantypedefs = FALSE; break; case 'i': included_files[nincluded_files++] = optarg; break; @@ -1285,6 +1294,7 @@ main (argc, argv) /* NOTREACHED */ } + /* No more options. Store the rest of arguments. */ for (; optind < argc; optind++) { argbuffer[current_arg].arg_type = at_filename; @@ -1413,7 +1423,7 @@ main (argc, argv) if (!CTAGS || cxref_style) { - put_entries (nodehead); /* write the remainig tags (ETAGS) */ + put_entries (nodehead); /* write the remaining tags (ETAGS) */ free_tree (nodehead); nodehead = NULL; if (!CTAGS) @@ -4075,10 +4085,18 @@ Yacc_entries (inf) char_pointer = line_buffer.buffer, \ TRUE); \ ) -#define LOOKING_AT(cp, keyword) /* keyword is a constant string */ \ - (strneq ((cp), keyword, sizeof(keyword)-1) /* cp points at keyword */ \ - && notinname ((cp)[sizeof(keyword)-1]) /* end of keyword */ \ - && ((cp) = skip_spaces((cp)+sizeof(keyword)-1))) /* skip spaces */ + +#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 @@ -4956,7 +4974,7 @@ Lua_functions (inf) /* - * Postscript tag functions + * Postscript tags * Just look for lines where the first character is '/' * Also look at "defineps" for PSWrap * Ideas by: @@ -4985,6 +5003,43 @@ PS_functions (inf) } } + +/* + * 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 @@ -4994,7 +5049,6 @@ PS_functions (inf) * (set! xyzzy * Original code by Ken Haase (1985?) */ - static void Scheme_functions (inf) FILE *inf; @@ -5213,11 +5267,6 @@ Texinfo_nodes (inf) } -/* Similar to LOOKING_AT but does not use notinname, does not skip */ -#define LOOKING_AT_NOCASE(cp, kw) /* kw is a constant string */ \ - (strncaseeq ((cp), kw, sizeof(kw)-1) /* cp points at kw */ \ - && ((cp) += sizeof(kw)-1)) /* skip spaces */ - /* * HTML support. * Contents of , <h1>, <h2>, <h3> are tags. @@ -5434,7 +5483,7 @@ prolog_pr (s, last) || (s[pos] == '(' && (pos += 1)) || (s[pos] == ':' && s[pos + 1] == '-' && (pos += 2))) && (last == NULL /* save only the first clause */ - || len != strlen (last) + || len != (int)strlen (last) || !strneq (s, last, len))) { make_tag (s, len, TRUE, s, pos, lineno, linecharno); @@ -6502,7 +6551,7 @@ etags_strncasecmp (s1, s2, n) : *s1 - *s2); } -/* Skip spaces, return new pointer. */ +/* Skip spaces (end of string is not space), return new pointer. */ static char * skip_spaces (cp) char *cp; @@ -6512,7 +6561,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;