/[emacs]/emacs/lib-src/etags.c
ViewVC logotype

Diff of /emacs/lib-src/etags.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3.46 by ttn, Sun Aug 7 10:44:16 2005 UTC revision 3.47 by pot, Tue Sep 27 13:23:47 2005 UTC
# Line 41  Line 41 
41   * configuration file containing regexp definitions for etags.   * configuration file containing regexp definitions for etags.
42   */   */
43    
44  char pot_etags_version[] = "@(#) pot revision number is 17.5";  char pot_etags_version[] = "@(#) pot revision number is 17.13";
45    
46  #define TRUE    1  #define TRUE    1
47  #define FALSE   0  #define FALSE   0
# Line 343  static void Cobol_paragraphs __P((FILE * Line 343  static void Cobol_paragraphs __P((FILE *
343  static void Cplusplus_entries __P((FILE *));  static void Cplusplus_entries __P((FILE *));
344  static void Cstar_entries __P((FILE *));  static void Cstar_entries __P((FILE *));
345  static void Erlang_functions __P((FILE *));  static void Erlang_functions __P((FILE *));
346    static void Forth_words __P((FILE *));
347  static void Fortran_functions __P((FILE *));  static void Fortran_functions __P((FILE *));
348  static void HTML_labels __P((FILE *));  static void HTML_labels __P((FILE *));
349  static void Lisp_functions __P((FILE *));  static void Lisp_functions __P((FILE *));
# Line 489  static bool need_filebuf;      /* some regexe Line 490  static bool need_filebuf;      /* some regexe
490  #if LONG_OPTIONS  #if LONG_OPTIONS
491  static struct option longopts[] =  static struct option longopts[] =
492  {  {
493      { "append",             no_argument,       NULL,               'a'   },
494    { "packages-only",      no_argument,       &packages_only,     TRUE  },    { "packages-only",      no_argument,       &packages_only,     TRUE  },
495    { "c++",                no_argument,       NULL,               'C'   },    { "c++",                no_argument,       NULL,               'C'   },
496    { "declarations",       no_argument,       &declarations,      TRUE  },    { "declarations",       no_argument,       &declarations,      TRUE  },
# Line 508  static struct option longopts[] = Line 510  static struct option longopts[] =
510    { "parse-stdin",        required_argument, NULL,               STDIN },    { "parse-stdin",        required_argument, NULL,               STDIN },
511    { "version",            no_argument,       NULL,               'V'   },    { "version",            no_argument,       NULL,               'V'   },
512    
513  #if CTAGS /* Etags options */  #if CTAGS /* Ctags options */
514    { "backward-search",    no_argument,       NULL,               'B'   },    { "backward-search",    no_argument,       NULL,               'B'   },
515    { "cxref",              no_argument,       NULL,               'x'   },    { "cxref",              no_argument,       NULL,               'x'   },
516    { "defines",            no_argument,       NULL,               'd'   },    { "defines",            no_argument,       NULL,               'd'   },
# Line 519  static struct option longopts[] = Line 521  static struct option longopts[] =
521    { "vgrind",             no_argument,       NULL,               'v'   },    { "vgrind",             no_argument,       NULL,               'v'   },
522    { "no-warn",            no_argument,       NULL,               'w'   },    { "no-warn",            no_argument,       NULL,               'w'   },
523    
524  #else /* Ctags options */  #else /* Etags options */
   { "append",             no_argument,       NULL,               'a'   },  
525    { "no-defines",         no_argument,       NULL,               'D'   },    { "no-defines",         no_argument,       NULL,               'D'   },
526    { "no-globals",         no_argument,       &globals,           FALSE },    { "no-globals",         no_argument,       &globals,           FALSE },
527    { "include",            required_argument, NULL,               'i'   },    { "include",            required_argument, NULL,               'i'   },
# Line 631  static char Erlang_help [] = Line 632  static char Erlang_help [] =
632  "In Erlang code, the tags are the functions, records and macros\n\  "In Erlang code, the tags are the functions, records and macros\n\
633  defined in the file.";  defined in the file.";
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    
641  static char *Fortran_suffixes [] =  static char *Fortran_suffixes [] =
642    { "F", "f", "f90", "for", NULL };    { "F", "f", "f90", "for", NULL };
643  static char Fortran_help [] =  static char Fortran_help [] =
# Line 778  static language lang_names [] = Line 785  static language lang_names [] =
785    { "c*",        no_lang_help,   Cstar_entries,     Cstar_suffixes     },    { "c*",        no_lang_help,   Cstar_entries,     Cstar_suffixes     },
786    { "cobol",     Cobol_help,     Cobol_paragraphs,  Cobol_suffixes     },    { "cobol",     Cobol_help,     Cobol_paragraphs,  Cobol_suffixes     },
787    { "erlang",    Erlang_help,    Erlang_functions,  Erlang_suffixes    },    { "erlang",    Erlang_help,    Erlang_functions,  Erlang_suffixes    },
788      { "forth",     Forth_help,     Forth_words,       Forth_suffixes     },
789    { "fortran",   Fortran_help,   Fortran_functions, Fortran_suffixes   },    { "fortran",   Fortran_help,   Fortran_functions, Fortran_suffixes   },
790    { "html",      HTML_help,      HTML_labels,       HTML_suffixes      },    { "html",      HTML_help,      HTML_labels,       HTML_suffixes      },
791    { "java",      Cjava_help,     Cjava_entries,     Cjava_suffixes     },    { "java",      Cjava_help,     Cjava_entries,     Cjava_suffixes     },
# Line 881  linked with GNU getopt."); Line 889  linked with GNU getopt.");
889  Absolute names are stored in the output file as they are.\n\  Absolute names are stored in the output file as they are.\n\
890  Relative ones are stored relative to the output file's directory.\n");  Relative ones are stored relative to the output file's directory.\n");
891    
892    if (!CTAGS)    puts ("-a, --append\n\
     puts ("-a, --append\n\  
893          Append tag entries to existing tags file.");          Append tag entries to existing tags file.");
894    
895    puts ("--packages-only\n\    puts ("--packages-only\n\
# Line 1180  main (argc, argv) Line 1187  main (argc, argv)
1187        globals = TRUE;        globals = TRUE;
1188      }      }
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. */
1192    optstring = "-";    optstring = "-";
1193  #ifdef ETAGS_REGEXPS  #ifdef ETAGS_REGEXPS
1194    optstring = "-r:Rc:";    optstring = "-r:Rc:";
1195  #endif /* ETAGS_REGEXPS */  #endif /* ETAGS_REGEXPS */
1196    if (!LONG_OPTIONS)    if (!LONG_OPTIONS)
1197      optstring += 1;      optstring += 1;             /* remove the initial '-' */
1198    optstring = concat (optstring,    optstring = concat (optstring,
1199                        "Cf:Il:o:SVhH",                        "aCf:Il:o:SVhH",
1200                        (CTAGS) ? "BxdtTuvw" : "aDi:");                        (CTAGS) ? "BxdtTuvw" : "Di:");
1201    
1202    while ((opt = getopt_long (argc, argv, optstring, longopts, 0)) != EOF)    while ((opt = getopt_long (argc, argv, optstring, longopts, NULL)) != EOF)
1203      switch (opt)      switch (opt)
1204        {        {
1205        case 0:        case 0:
# Line 1218  main (argc, argv) Line 1227  main (argc, argv)
1227          break;          break;
1228    
1229          /* Common options. */          /* Common options. */
1230          case 'a': append_to_tagfile = TRUE;       break;
1231        case 'C': cplusplus = TRUE;               break;        case 'C': cplusplus = TRUE;               break;
1232        case 'f':         /* for compatibility with old makefiles */        case 'f':         /* for compatibility with old makefiles */
1233        case 'o':        case 'o':
# Line 1267  main (argc, argv) Line 1277  main (argc, argv)
1277          break;          break;
1278    
1279          /* Etags options */          /* Etags options */
       case 'a': append_to_tagfile = TRUE;                       break;  
1280        case 'D': constantypedefs = FALSE;                        break;        case 'D': constantypedefs = FALSE;                        break;
1281        case 'i': included_files[nincluded_files++] = optarg;     break;        case 'i': included_files[nincluded_files++] = optarg;     break;
1282    
# Line 1285  main (argc, argv) Line 1294  main (argc, argv)
1294          /* NOTREACHED */          /* NOTREACHED */
1295        }        }
1296    
1297      /* No more options.  Store the rest of arguments. */
1298    for (; optind < argc; optind++)    for (; optind < argc; optind++)
1299      {      {
1300        argbuffer[current_arg].arg_type = at_filename;        argbuffer[current_arg].arg_type = at_filename;
# Line 1413  main (argc, argv) Line 1423  main (argc, argv)
1423    
1424    if (!CTAGS || cxref_style)    if (!CTAGS || cxref_style)
1425      {      {
1426        put_entries (nodehead);   /* write the remainig tags (ETAGS) */        put_entries (nodehead);   /* write the remaining tags (ETAGS) */
1427        free_tree (nodehead);        free_tree (nodehead);
1428        nodehead = NULL;        nodehead = NULL;
1429        if (!CTAGS)        if (!CTAGS)
# Line 4075  Yacc_entries (inf) Line 4085  Yacc_entries (inf)
4085             char_pointer = line_buffer.buffer,                           \             char_pointer = line_buffer.buffer,                           \
4086             TRUE);                                                       \             TRUE);                                                       \
4087        )        )
4088  #define LOOKING_AT(cp, keyword) /* keyword is a constant string */      \  
4089    (strneq ((cp), keyword, sizeof(keyword)-1) /* cp points at keyword */ \  #define LOOKING_AT(cp, kw)  /* kw is the keyword, a literal string */   \
4090     && notinname ((cp)[sizeof(keyword)-1])       /* end of keyword */    \    ((assert("" kw), TRUE)   /* syntax error if not a literal string */   \
4091     && ((cp) = skip_spaces((cp)+sizeof(keyword)-1))) /* skip spaces */     && 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 */
4100    
4101  /*  /*
4102   * Read a file, but do no processing.  This is used to do regexp   * Read a file, but do no processing.  This is used to do regexp
# Line 4956  Lua_functions (inf) Line 4974  Lua_functions (inf)
4974    
4975    
4976  /*  /*
4977   * Postscript tag functions   * Postscript tags
4978   * Just look for lines where the first character is '/'   * Just look for lines where the first character is '/'
4979   * Also look at "defineps" for PSWrap   * Also look at "defineps" for PSWrap
4980   * Ideas by:   * Ideas by:
# Line 4987  PS_functions (inf) Line 5005  PS_functions (inf)
5005    
5006    
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    /*
5045   * Scheme tag functions   * Scheme tag functions
5046   * look for (def... xyzzy   * look for (def... xyzzy
5047   *          (def... (xyzzy   *          (def... (xyzzy
# Line 4994  PS_functions (inf) Line 5049  PS_functions (inf)
5049   *          (set! xyzzy   *          (set! xyzzy
5050   * Original code by Ken Haase (1985?)   * Original code by Ken Haase (1985?)
5051   */   */
   
5052  static void  static void
5053  Scheme_functions (inf)  Scheme_functions (inf)
5054       FILE *inf;       FILE *inf;
# Line 5213  Texinfo_nodes (inf) Line 5267  Texinfo_nodes (inf)
5267  }  }
5268    
5269    
 /* 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 */  
   
5270  /*  /*
5271   * HTML support.   * HTML support.
5272   * Contents of <title>, <h1>, <h2>, <h3> are tags.   * Contents of <title>, <h1>, <h2>, <h3> are tags.
# Line 5434  prolog_pr (s, last) Line 5483  prolog_pr (s, last)
5483         || (s[pos] == '(' && (pos += 1))         || (s[pos] == '(' && (pos += 1))
5484         || (s[pos] == ':' && s[pos + 1] == '-' && (pos += 2)))         || (s[pos] == ':' && s[pos + 1] == '-' && (pos += 2)))
5485        && (last == NULL          /* save only the first clause */        && (last == NULL          /* save only the first clause */
5486            || len != strlen (last)            || len != (int)strlen (last)
5487            || !strneq (s, last, len)))            || !strneq (s, last, len)))
5488          {          {
5489            make_tag (s, len, TRUE, s, pos, lineno, linecharno);            make_tag (s, len, TRUE, s, pos, lineno, linecharno);
# Line 6502  etags_strncasecmp (s1, s2, n) Line 6551  etags_strncasecmp (s1, s2, n)
6551              : *s1 - *s2);              : *s1 - *s2);
6552  }  }
6553    
6554  /* Skip spaces, return new pointer. */  /* Skip spaces (end of string is not space), return new pointer. */
6555  static char *  static char *
6556  skip_spaces (cp)  skip_spaces (cp)
6557       char *cp;       char *cp;
# Line 6512  skip_spaces (cp) Line 6561  skip_spaces (cp)
6561    return cp;    return cp;
6562  }  }
6563    
6564  /* Skip non spaces, return new pointer. */  /* Skip non spaces, except end of string, return new pointer. */
6565  static char *  static char *
6566  skip_non_spaces (cp)  skip_non_spaces (cp)
6567       char *cp;       char *cp;

Legend:
Removed from v.3.46  
changed lines
  Added in v.3.47

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26