diff options
| author | Francesco Potortì | 2005-09-27 13:26:54 +0000 |
|---|---|---|
| committer | Francesco Potortì | 2005-09-27 13:26:54 +0000 |
| commit | 55102b5d3100b6dcb45832f9c0b9e1f13f5bdad6 (patch) | |
| tree | 62bf328b35b9c45ad0183e5769417cb822b6a1dd /lib-src | |
| parent | cd0899ab44277c0d532973cf7c7a386e549c9ea0 (diff) | |
| download | emacs-55102b5d3100b6dcb45832f9c0b9e1f13f5bdad6.tar.gz emacs-55102b5d3100b6dcb45832f9c0b9e1f13f5bdad6.zip | |
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.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/ChangeLog | 12 | ||||
| -rw-r--r-- | lib-src/etags.c | 101 |
2 files changed, 87 insertions, 26 deletions
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 @@ | |||
| 1 | 2005-09-27 Francesco Potort,Al(B <pot@gnu.org> | ||
| 2 | |||
| 3 | * etags.c: Preliminary Forth support. | ||
| 4 | (prolog_pr): Cast strlen to int before comparison. | ||
| 5 | (LOOKING_AT, LOOKING_AT_NOCASE): Let the preprocessor check that | ||
| 6 | the second argument is indeed a literal string. | ||
| 7 | |||
| 8 | 2005-09-27 Emanuele Giaquinta <emanuele.giaquinta@gmail.com> (tiny change) | ||
| 9 | |||
| 10 | * etags.c (longopts, print_help, main): The -a (--append) option | ||
| 11 | can be used in ctags also; for one, the Linux make file uses it. | ||
| 12 | |||
| 1 | 2005-09-20 Chong Yidong <cyd@stupidchicken.com> | 13 | 2005-09-20 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 14 | ||
| 3 | * ebrowse.c (add_sym): Compare namespace names instead of | 15 | * 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 @@ | |||
| 41 | * configuration file containing regexp definitions for etags. | 41 | * configuration file containing regexp definitions for etags. |
| 42 | */ | 42 | */ |
| 43 | 43 | ||
| 44 | char pot_etags_version[] = "@(#) pot revision number is 17.5"; | 44 | char pot_etags_version[] = "@(#) pot revision number is 17.13"; |
| 45 | 45 | ||
| 46 | #define TRUE 1 | 46 | #define TRUE 1 |
| 47 | #define FALSE 0 | 47 | #define FALSE 0 |
| @@ -343,6 +343,7 @@ static void Cobol_paragraphs __P((FILE *)); | |||
| 343 | static void Cplusplus_entries __P((FILE *)); | 343 | static void Cplusplus_entries __P((FILE *)); |
| 344 | static void Cstar_entries __P((FILE *)); | 344 | static void Cstar_entries __P((FILE *)); |
| 345 | static void Erlang_functions __P((FILE *)); | 345 | static void Erlang_functions __P((FILE *)); |
| 346 | static void Forth_words __P((FILE *)); | ||
| 346 | static void Fortran_functions __P((FILE *)); | 347 | static void Fortran_functions __P((FILE *)); |
| 347 | static void HTML_labels __P((FILE *)); | 348 | static void HTML_labels __P((FILE *)); |
| 348 | static void Lisp_functions __P((FILE *)); | 349 | static void Lisp_functions __P((FILE *)); |
| @@ -489,6 +490,7 @@ static bool need_filebuf; /* some regexes are multi-line */ | |||
| 489 | #if LONG_OPTIONS | 490 | #if LONG_OPTIONS |
| 490 | static struct option longopts[] = | 491 | static struct option longopts[] = |
| 491 | { | 492 | { |
| 493 | { "append", no_argument, NULL, 'a' }, | ||
| 492 | { "packages-only", no_argument, &packages_only, TRUE }, | 494 | { "packages-only", no_argument, &packages_only, TRUE }, |
| 493 | { "c++", no_argument, NULL, 'C' }, | 495 | { "c++", no_argument, NULL, 'C' }, |
| 494 | { "declarations", no_argument, &declarations, TRUE }, | 496 | { "declarations", no_argument, &declarations, TRUE }, |
| @@ -508,7 +510,7 @@ static struct option longopts[] = | |||
| 508 | { "parse-stdin", required_argument, NULL, STDIN }, | 510 | { "parse-stdin", required_argument, NULL, STDIN }, |
| 509 | { "version", no_argument, NULL, 'V' }, | 511 | { "version", no_argument, NULL, 'V' }, |
| 510 | 512 | ||
| 511 | #if CTAGS /* Etags options */ | 513 | #if CTAGS /* Ctags options */ |
| 512 | { "backward-search", no_argument, NULL, 'B' }, | 514 | { "backward-search", no_argument, NULL, 'B' }, |
| 513 | { "cxref", no_argument, NULL, 'x' }, | 515 | { "cxref", no_argument, NULL, 'x' }, |
| 514 | { "defines", no_argument, NULL, 'd' }, | 516 | { "defines", no_argument, NULL, 'd' }, |
| @@ -519,8 +521,7 @@ static struct option longopts[] = | |||
| 519 | { "vgrind", no_argument, NULL, 'v' }, | 521 | { "vgrind", no_argument, NULL, 'v' }, |
| 520 | { "no-warn", no_argument, NULL, 'w' }, | 522 | { "no-warn", no_argument, NULL, 'w' }, |
| 521 | 523 | ||
| 522 | #else /* Ctags options */ | 524 | #else /* Etags options */ |
| 523 | { "append", no_argument, NULL, 'a' }, | ||
| 524 | { "no-defines", no_argument, NULL, 'D' }, | 525 | { "no-defines", no_argument, NULL, 'D' }, |
| 525 | { "no-globals", no_argument, &globals, FALSE }, | 526 | { "no-globals", no_argument, &globals, FALSE }, |
| 526 | { "include", required_argument, NULL, 'i' }, | 527 | { "include", required_argument, NULL, 'i' }, |
| @@ -631,6 +632,12 @@ static char Erlang_help [] = | |||
| 631 | "In Erlang code, the tags are the functions, records and macros\n\ | 632 | "In Erlang code, the tags are the functions, records and macros\n\ |
| 632 | defined in the file."; | 633 | defined in the file."; |
| 633 | 634 | ||
| 635 | char *Forth_suffixes [] = | ||
| 636 | { "fth", "tok", NULL }; | ||
| 637 | static char Forth_help [] = | ||
| 638 | "In Forth code, tags are words defined by `:',\n\ | ||
| 639 | constant, code, create, defer, value, variable, buffer:, field."; | ||
| 640 | |||
| 634 | static char *Fortran_suffixes [] = | 641 | static char *Fortran_suffixes [] = |
| 635 | { "F", "f", "f90", "for", NULL }; | 642 | { "F", "f", "f90", "for", NULL }; |
| 636 | static char Fortran_help [] = | 643 | static char Fortran_help [] = |
| @@ -778,6 +785,7 @@ static language lang_names [] = | |||
| 778 | { "c*", no_lang_help, Cstar_entries, Cstar_suffixes }, | 785 | { "c*", no_lang_help, Cstar_entries, Cstar_suffixes }, |
| 779 | { "cobol", Cobol_help, Cobol_paragraphs, Cobol_suffixes }, | 786 | { "cobol", Cobol_help, Cobol_paragraphs, Cobol_suffixes }, |
| 780 | { "erlang", Erlang_help, Erlang_functions, Erlang_suffixes }, | 787 | { "erlang", Erlang_help, Erlang_functions, Erlang_suffixes }, |
| 788 | { "forth", Forth_help, Forth_words, Forth_suffixes }, | ||
| 781 | { "fortran", Fortran_help, Fortran_functions, Fortran_suffixes }, | 789 | { "fortran", Fortran_help, Fortran_functions, Fortran_suffixes }, |
| 782 | { "html", HTML_help, HTML_labels, HTML_suffixes }, | 790 | { "html", HTML_help, HTML_labels, HTML_suffixes }, |
| 783 | { "java", Cjava_help, Cjava_entries, Cjava_suffixes }, | 791 | { "java", Cjava_help, Cjava_entries, Cjava_suffixes }, |
| @@ -881,8 +889,7 @@ linked with GNU getopt."); | |||
| 881 | Absolute names are stored in the output file as they are.\n\ | 889 | Absolute names are stored in the output file as they are.\n\ |
| 882 | Relative ones are stored relative to the output file's directory.\n"); | 890 | Relative ones are stored relative to the output file's directory.\n"); |
| 883 | 891 | ||
| 884 | if (!CTAGS) | 892 | puts ("-a, --append\n\ |
| 885 | puts ("-a, --append\n\ | ||
| 886 | Append tag entries to existing tags file."); | 893 | Append tag entries to existing tags file."); |
| 887 | 894 | ||
| 888 | puts ("--packages-only\n\ | 895 | puts ("--packages-only\n\ |
| @@ -1180,17 +1187,19 @@ main (argc, argv) | |||
| 1180 | globals = TRUE; | 1187 | globals = TRUE; |
| 1181 | } | 1188 | } |
| 1182 | 1189 | ||
| 1190 | /* When the optstring begins with a '-' getopt_long does not rearrange the | ||
| 1191 | non-options arguments to be at the end, but leaves them alone. */ | ||
| 1183 | optstring = "-"; | 1192 | optstring = "-"; |
| 1184 | #ifdef ETAGS_REGEXPS | 1193 | #ifdef ETAGS_REGEXPS |
| 1185 | optstring = "-r:Rc:"; | 1194 | optstring = "-r:Rc:"; |
| 1186 | #endif /* ETAGS_REGEXPS */ | 1195 | #endif /* ETAGS_REGEXPS */ |
| 1187 | if (!LONG_OPTIONS) | 1196 | if (!LONG_OPTIONS) |
| 1188 | optstring += 1; | 1197 | optstring += 1; /* remove the initial '-' */ |
| 1189 | optstring = concat (optstring, | 1198 | optstring = concat (optstring, |
| 1190 | "Cf:Il:o:SVhH", | 1199 | "aCf:Il:o:SVhH", |
| 1191 | (CTAGS) ? "BxdtTuvw" : "aDi:"); | 1200 | (CTAGS) ? "BxdtTuvw" : "Di:"); |
| 1192 | 1201 | ||
| 1193 | while ((opt = getopt_long (argc, argv, optstring, longopts, 0)) != EOF) | 1202 | while ((opt = getopt_long (argc, argv, optstring, longopts, NULL)) != EOF) |
| 1194 | switch (opt) | 1203 | switch (opt) |
| 1195 | { | 1204 | { |
| 1196 | case 0: | 1205 | case 0: |
| @@ -1218,6 +1227,7 @@ main (argc, argv) | |||
| 1218 | break; | 1227 | break; |
| 1219 | 1228 | ||
| 1220 | /* Common options. */ | 1229 | /* Common options. */ |
| 1230 | case 'a': append_to_tagfile = TRUE; break; | ||
| 1221 | case 'C': cplusplus = TRUE; break; | 1231 | case 'C': cplusplus = TRUE; break; |
| 1222 | case 'f': /* for compatibility with old makefiles */ | 1232 | case 'f': /* for compatibility with old makefiles */ |
| 1223 | case 'o': | 1233 | case 'o': |
| @@ -1267,7 +1277,6 @@ main (argc, argv) | |||
| 1267 | break; | 1277 | break; |
| 1268 | 1278 | ||
| 1269 | /* Etags options */ | 1279 | /* Etags options */ |
| 1270 | case 'a': append_to_tagfile = TRUE; break; | ||
| 1271 | case 'D': constantypedefs = FALSE; break; | 1280 | case 'D': constantypedefs = FALSE; break; |
| 1272 | case 'i': included_files[nincluded_files++] = optarg; break; | 1281 | case 'i': included_files[nincluded_files++] = optarg; break; |
| 1273 | 1282 | ||
| @@ -1285,6 +1294,7 @@ main (argc, argv) | |||
| 1285 | /* NOTREACHED */ | 1294 | /* NOTREACHED */ |
| 1286 | } | 1295 | } |
| 1287 | 1296 | ||
| 1297 | /* No more options. Store the rest of arguments. */ | ||
| 1288 | for (; optind < argc; optind++) | 1298 | for (; optind < argc; optind++) |
| 1289 | { | 1299 | { |
| 1290 | argbuffer[current_arg].arg_type = at_filename; | 1300 | argbuffer[current_arg].arg_type = at_filename; |
| @@ -1413,7 +1423,7 @@ main (argc, argv) | |||
| 1413 | 1423 | ||
| 1414 | if (!CTAGS || cxref_style) | 1424 | if (!CTAGS || cxref_style) |
| 1415 | { | 1425 | { |
| 1416 | put_entries (nodehead); /* write the remainig tags (ETAGS) */ | 1426 | put_entries (nodehead); /* write the remaining tags (ETAGS) */ |
| 1417 | free_tree (nodehead); | 1427 | free_tree (nodehead); |
| 1418 | nodehead = NULL; | 1428 | nodehead = NULL; |
| 1419 | if (!CTAGS) | 1429 | if (!CTAGS) |
| @@ -4075,10 +4085,18 @@ Yacc_entries (inf) | |||
| 4075 | char_pointer = line_buffer.buffer, \ | 4085 | char_pointer = line_buffer.buffer, \ |
| 4076 | TRUE); \ | 4086 | TRUE); \ |
| 4077 | ) | 4087 | ) |
| 4078 | #define LOOKING_AT(cp, keyword) /* keyword is a constant string */ \ | 4088 | |
| 4079 | (strneq ((cp), keyword, sizeof(keyword)-1) /* cp points at keyword */ \ | 4089 | #define LOOKING_AT(cp, kw) /* kw is the keyword, a literal string */ \ |
| 4080 | && notinname ((cp)[sizeof(keyword)-1]) /* end of keyword */ \ | 4090 | ((assert("" kw), TRUE) /* syntax error if not a literal string */ \ |
| 4081 | && ((cp) = skip_spaces((cp)+sizeof(keyword)-1))) /* skip spaces */ | 4091 | && strneq ((cp), kw, sizeof(kw)-1) /* cp points at kw */ \ |
| 4092 | && notinname ((cp)[sizeof(kw)-1]) /* end of kw */ \ | ||
| 4093 | && ((cp) = skip_spaces((cp)+sizeof(kw)-1))) /* skip spaces */ | ||
| 4094 | |||
| 4095 | /* Similar to LOOKING_AT but does not use notinname, does not skip */ | ||
| 4096 | #define LOOKING_AT_NOCASE(cp, kw) /* the keyword is a literal string */ \ | ||
| 4097 | ((assert("" kw), TRUE) /* syntax error if not a literal string */ \ | ||
| 4098 | && strncaseeq ((cp), kw, sizeof(kw)-1) /* cp points at kw */ \ | ||
| 4099 | && ((cp) += sizeof(kw)-1)) /* skip spaces */ | ||
| 4082 | 4100 | ||
| 4083 | /* | 4101 | /* |
| 4084 | * Read a file, but do no processing. This is used to do regexp | 4102 | * Read a file, but do no processing. This is used to do regexp |
| @@ -4956,7 +4974,7 @@ Lua_functions (inf) | |||
| 4956 | 4974 | ||
| 4957 | 4975 | ||
| 4958 | /* | 4976 | /* |
| 4959 | * Postscript tag functions | 4977 | * Postscript tags |
| 4960 | * Just look for lines where the first character is '/' | 4978 | * Just look for lines where the first character is '/' |
| 4961 | * Also look at "defineps" for PSWrap | 4979 | * Also look at "defineps" for PSWrap |
| 4962 | * Ideas by: | 4980 | * Ideas by: |
| @@ -4987,6 +5005,43 @@ PS_functions (inf) | |||
| 4987 | 5005 | ||
| 4988 | 5006 | ||
| 4989 | /* | 5007 | /* |
| 5008 | * Forth tags | ||
| 5009 | * Ignore anything after \ followed by space or in ( ) | ||
| 5010 | * Look for words defined by : | ||
| 5011 | * Look for constant, code, create, defer, value, and variable | ||
| 5012 | * OBP extensions: Look for buffer:, field, | ||
| 5013 | * Ideas by Eduardo Horvath <eeh@netbsd.org> (2004) | ||
| 5014 | */ | ||
| 5015 | static void | ||
| 5016 | Forth_words (inf) | ||
| 5017 | FILE *inf; | ||
| 5018 | { | ||
| 5019 | register char *bp; | ||
| 5020 | |||
| 5021 | LOOP_ON_INPUT_LINES (inf, lb, bp) | ||
| 5022 | while ((bp = skip_spaces (bp))[0] != '\0') | ||
| 5023 | if (bp[0] == '\\' && iswhite(bp[1])) | ||
| 5024 | break; /* read next line */ | ||
| 5025 | else if (bp[0] == '(' && iswhite(bp[1])) | ||
| 5026 | do /* skip to ) or eol */ | ||
| 5027 | bp++; | ||
| 5028 | while (*bp != ')' && *bp != '\0'); | ||
| 5029 | else if ((bp[0] == ':' && iswhite(bp[1]) && bp++) | ||
| 5030 | || LOOKING_AT_NOCASE (bp, "constant") | ||
| 5031 | || LOOKING_AT_NOCASE (bp, "code") | ||
| 5032 | || LOOKING_AT_NOCASE (bp, "create") | ||
| 5033 | || LOOKING_AT_NOCASE (bp, "defer") | ||
| 5034 | || LOOKING_AT_NOCASE (bp, "value") | ||
| 5035 | || LOOKING_AT_NOCASE (bp, "variable") | ||
| 5036 | || LOOKING_AT_NOCASE (bp, "buffer:") | ||
| 5037 | || LOOKING_AT_NOCASE (bp, "field")) | ||
| 5038 | get_tag (skip_spaces (bp), NULL); /* Yay! A definition! */ | ||
| 5039 | else | ||
| 5040 | bp = skip_non_spaces (bp); | ||
| 5041 | } | ||
| 5042 | |||
| 5043 | |||
| 5044 | /* | ||
| 4990 | * Scheme tag functions | 5045 | * Scheme tag functions |
| 4991 | * look for (def... xyzzy | 5046 | * look for (def... xyzzy |
| 4992 | * (def... (xyzzy | 5047 | * (def... (xyzzy |
| @@ -4994,7 +5049,6 @@ PS_functions (inf) | |||
| 4994 | * (set! xyzzy | 5049 | * (set! xyzzy |
| 4995 | * Original code by Ken Haase (1985?) | 5050 | * Original code by Ken Haase (1985?) |
| 4996 | */ | 5051 | */ |
| 4997 | |||
| 4998 | static void | 5052 | static void |
| 4999 | Scheme_functions (inf) | 5053 | Scheme_functions (inf) |
| 5000 | FILE *inf; | 5054 | FILE *inf; |
| @@ -5213,11 +5267,6 @@ Texinfo_nodes (inf) | |||
| 5213 | } | 5267 | } |
| 5214 | 5268 | ||
| 5215 | 5269 | ||
| 5216 | /* Similar to LOOKING_AT but does not use notinname, does not skip */ | ||
| 5217 | #define LOOKING_AT_NOCASE(cp, kw) /* kw is a constant string */ \ | ||
| 5218 | (strncaseeq ((cp), kw, sizeof(kw)-1) /* cp points at kw */ \ | ||
| 5219 | && ((cp) += sizeof(kw)-1)) /* skip spaces */ | ||
| 5220 | |||
| 5221 | /* | 5270 | /* |
| 5222 | * HTML support. | 5271 | * HTML support. |
| 5223 | * Contents of <title>, <h1>, <h2>, <h3> are tags. | 5272 | * Contents of <title>, <h1>, <h2>, <h3> are tags. |
| @@ -5434,7 +5483,7 @@ prolog_pr (s, last) | |||
| 5434 | || (s[pos] == '(' && (pos += 1)) | 5483 | || (s[pos] == '(' && (pos += 1)) |
| 5435 | || (s[pos] == ':' && s[pos + 1] == '-' && (pos += 2))) | 5484 | || (s[pos] == ':' && s[pos + 1] == '-' && (pos += 2))) |
| 5436 | && (last == NULL /* save only the first clause */ | 5485 | && (last == NULL /* save only the first clause */ |
| 5437 | || len != strlen (last) | 5486 | || len != (int)strlen (last) |
| 5438 | || !strneq (s, last, len))) | 5487 | || !strneq (s, last, len))) |
| 5439 | { | 5488 | { |
| 5440 | make_tag (s, len, TRUE, s, pos, lineno, linecharno); | 5489 | make_tag (s, len, TRUE, s, pos, lineno, linecharno); |
| @@ -6502,7 +6551,7 @@ etags_strncasecmp (s1, s2, n) | |||
| 6502 | : *s1 - *s2); | 6551 | : *s1 - *s2); |
| 6503 | } | 6552 | } |
| 6504 | 6553 | ||
| 6505 | /* Skip spaces, return new pointer. */ | 6554 | /* Skip spaces (end of string is not space), return new pointer. */ |
| 6506 | static char * | 6555 | static char * |
| 6507 | skip_spaces (cp) | 6556 | skip_spaces (cp) |
| 6508 | char *cp; | 6557 | char *cp; |
| @@ -6512,7 +6561,7 @@ skip_spaces (cp) | |||
| 6512 | return cp; | 6561 | return cp; |
| 6513 | } | 6562 | } |
| 6514 | 6563 | ||
| 6515 | /* Skip non spaces, return new pointer. */ | 6564 | /* Skip non spaces, except end of string, return new pointer. */ |
| 6516 | static char * | 6565 | static char * |
| 6517 | skip_non_spaces (cp) | 6566 | skip_non_spaces (cp) |
| 6518 | char *cp; | 6567 | char *cp; |