Show
Ignore:
Timestamp:
10/02/05 09:47:43 (3 years ago)
Author:
miyoshi
Message:

Sync up with Emacs CVS HEAD.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib-src/etags.c

    r3809 r3894  
    4242 */ 
    4343 
    44 char pot_etags_version[] = "@(#) pot revision number is 17.5"; 
     44char pot_etags_version[] = "@(#) pot revision number is 17.14"; 
    4545 
    4646#define TRUE    1 
     
    344344static void Cstar_entries __P((FILE *)); 
    345345static void Erlang_functions __P((FILE *)); 
     346static void Forth_words __P((FILE *)); 
    346347static void Fortran_functions __P((FILE *)); 
    347348static void HTML_labels __P((FILE *)); 
     
    490491static struct option longopts[] = 
    491492{ 
     493  { "append",             no_argument,       NULL,               'a'   }, 
    492494  { "packages-only",      no_argument,       &packages_only,     TRUE  }, 
    493495  { "c++",                no_argument,       NULL,               'C'   }, 
     
    509511  { "version",            no_argument,       NULL,               'V'   }, 
    510512 
    511 #if CTAGS /* Etags options */ 
     513#if CTAGS /* Ctags options */ 
    512514  { "backward-search",    no_argument,       NULL,               'B'   }, 
    513515  { "cxref",              no_argument,       NULL,               'x'   }, 
     
    520522  { "no-warn",            no_argument,       NULL,               'w'   }, 
    521523 
    522 #else /* Ctags options */ 
    523   { "append",             no_argument,       NULL,               'a'   }, 
     524#else /* Etags options */ 
    524525  { "no-defines",         no_argument,       NULL,               'D'   }, 
    525526  { "no-globals",         no_argument,       &globals,           FALSE }, 
     
    632633defined in the file."; 
    633634 
     635char *Forth_suffixes [] = 
     636  { "fth", "tok", NULL }; 
     637static char Forth_help [] = 
     638"In Forth code, tags are words defined by `:',\n\ 
     639constant, code, create, defer, value, variable, buffer:, field."; 
     640 
    634641static char *Fortran_suffixes [] = 
    635642  { "F", "f", "f90", "for", NULL }; 
     
    779786  { "cobol",     Cobol_help,     Cobol_paragraphs,  Cobol_suffixes     }, 
    780787  { "erlang",    Erlang_help,    Erlang_functions,  Erlang_suffixes    }, 
     788  { "forth",     Forth_help,     Forth_words,       Forth_suffixes     }, 
    781789  { "fortran",   Fortran_help,   Fortran_functions, Fortran_suffixes   }, 
    782790  { "html",      HTML_help,      HTML_labels,       HTML_suffixes      }, 
     
    882890Relative ones are stored relative to the output file's directory.\n"); 
    883891 
    884   if (!CTAGS) 
    885     puts ("-a, --append\n\ 
     892  puts ("-a, --append\n\ 
    886893        Append tag entries to existing tags file."); 
    887894 
     
    11811188    } 
    11821189 
     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. */ 
    11831192  optstring = "-"; 
    11841193#ifdef ETAGS_REGEXPS 
     
    11861195#endif /* ETAGS_REGEXPS */ 
    11871196  if (!LONG_OPTIONS) 
    1188     optstring += 1; 
     1197    optstring += 1;            /* remove the initial '-' */ 
    11891198  optstring = concat (optstring, 
    1190                       "Cf:Il:o:SVhH", 
    1191                       (CTAGS) ? "BxdtTuvw" : "aDi:"); 
    1192  
    1193   while ((opt = getopt_long (argc, argv, optstring, longopts, 0)) != EOF) 
     1199                      "aCf:Il:o:SVhH", 
     1200                      (CTAGS) ? "BxdtTuvw" : "Di:"); 
     1201 
     1202  while ((opt = getopt_long (argc, argv, optstring, longopts, NULL)) != EOF) 
    11941203    switch (opt) 
    11951204      { 
     
    12191228 
    12201229        /* Common options. */ 
     1230      case 'a': append_to_tagfile = TRUE;       break; 
    12211231      case 'C': cplusplus = TRUE;               break; 
    12221232      case 'f':         /* for compatibility with old makefiles */ 
     
    12681278 
    12691279        /* Etags options */ 
    1270       case 'a': append_to_tagfile = TRUE;                       break; 
    12711280      case 'D': constantypedefs = FALSE;                        break; 
    12721281      case 'i': included_files[nincluded_files++] = optarg;     break; 
     
    12861295      } 
    12871296 
     1297  /* No more options.  Store the rest of arguments. */ 
    12881298  for (; optind < argc; optind++) 
    12891299    { 
     
    14141424  if (!CTAGS || cxref_style) 
    14151425    { 
    1416       put_entries (nodehead);   /* write the remainig tags (ETAGS) */ 
     1426      put_entries (nodehead);   /* write the remaining tags (ETAGS) */ 
    14171427      free_tree (nodehead); 
    14181428      nodehead = NULL; 
     
    14661476    pfatal (tagfile); 
    14671477 
    1468   if (update) 
    1469     { 
    1470       char cmd[2*BUFSIZ+10]; 
    1471       sprintf (cmd, "sort -o %.*s %.*s", BUFSIZ, tagfile, BUFSIZ, tagfile); 
    1472       exit (system (cmd)); 
    1473     } 
     1478  if (CTAGS) 
     1479    if (append_to_tagfile || update) 
     1480      { 
     1481        char cmd[2*BUFSIZ+10]; 
     1482        sprintf (cmd, "sort -o %.*s %.*s", BUFSIZ, tagfile, BUFSIZ, tagfile); 
     1483        exit (system (cmd)); 
     1484      } 
    14741485  return EXIT_SUCCESS; 
    14751486} 
     
    40764087           TRUE);                                                       \ 
    40774088      ) 
    4078 #define LOOKING_AT(cp, keyword) /* keyword is a constant string */      \ 
    4079   (strneq ((cp), keyword, sizeof(keyword)-1) /* cp points at keyword */ \ 
    4080    && notinname ((cp)[sizeof(keyword)-1])       /* end of keyword */    \ 
    4081    && ((cp) = skip_spaces((cp)+sizeof(keyword)-1))) /* skip spaces */ 
     4089 
     4090#define LOOKING_AT(cp, kw)  /* kw is the keyword, a literal string */   \ 
     4091  ((assert("" kw), TRUE)   /* syntax error if not a literal string */   \ 
     4092   && strneq ((cp), kw, sizeof(kw)-1)           /* cp points at kw */   \ 
     4093   && notinname ((cp)[sizeof(kw)-1])            /* end of kw */         \ 
     4094   && ((cp) = skip_spaces((cp)+sizeof(kw)-1)))  /* skip spaces */ 
     4095 
     4096/* Similar to LOOKING_AT but does not use notinname, does not skip */ 
     4097#define LOOKING_AT_NOCASE(cp, kw) /* the keyword is a literal string */ \ 
     4098  ((assert("" kw), TRUE)     /* syntax error if not a literal string */ \ 
     4099   && strncaseeq ((cp), kw, sizeof(kw)-1)       /* cp points at kw */   \ 
     4100   && ((cp) += sizeof(kw)-1))                   /* skip spaces */ 
    40824101 
    40834102/* 
     
    49574976  
    49584977/* 
    4959  * Postscript tag function
     4978 * Postscript tag
    49604979 * Just look for lines where the first character is '/' 
    49614980 * Also look at "defineps" for PSWrap 
     
    49885007  
    49895008/* 
     5009 * Forth tags 
     5010 * Ignore anything after \ followed by space or in ( ) 
     5011 * Look for words defined by : 
     5012 * Look for constant, code, create, defer, value, and variable 
     5013 * OBP extensions:  Look for buffer:, field, 
     5014 * Ideas by Eduardo Horvath <eeh@netbsd.org> (2004) 
     5015 */ 
     5016static void 
     5017Forth_words (inf) 
     5018     FILE *inf; 
     5019{ 
     5020  register char *bp; 
     5021 
     5022  LOOP_ON_INPUT_LINES (inf, lb, bp) 
     5023    while ((bp = skip_spaces (bp))[0] != '\0') 
     5024      if (bp[0] == '\\' && iswhite(bp[1])) 
     5025        break;                  /* read next line */ 
     5026      else if (bp[0] == '(' && iswhite(bp[1])) 
     5027        do                      /* skip to ) or eol */ 
     5028          bp++; 
     5029        while (*bp != ')' && *bp != '\0'); 
     5030      else if ((bp[0] == ':' && iswhite(bp[1]) && bp++) 
     5031               || LOOKING_AT_NOCASE (bp, "constant") 
     5032               || LOOKING_AT_NOCASE (bp, "code") 
     5033               || LOOKING_AT_NOCASE (bp, "create") 
     5034               || LOOKING_AT_NOCASE (bp, "defer") 
     5035               || LOOKING_AT_NOCASE (bp, "value") 
     5036               || LOOKING_AT_NOCASE (bp, "variable") 
     5037               || LOOKING_AT_NOCASE (bp, "buffer:") 
     5038               || LOOKING_AT_NOCASE (bp, "field")) 
     5039        get_tag (skip_spaces (bp), NULL); /* Yay!  A definition! */ 
     5040      else 
     5041        bp = skip_non_spaces (bp); 
     5042} 
     5043 
     5044  
     5045/* 
    49905046 * Scheme tag functions 
    49915047 * look for (def... xyzzy 
     
    49955051 * Original code by Ken Haase (1985?) 
    49965052 */ 
    4997  
    49985053static void 
    49995054Scheme_functions (inf) 
     
    52145269 
    52155270  
    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  
    52215271/* 
    52225272 * HTML support. 
     
    54355485       || (s[pos] == ':' && s[pos + 1] == '-' && (pos += 2))) 
    54365486      && (last == NULL          /* save only the first clause */ 
    5437           || len != strlen (last) 
     5487          || len != (int)strlen (last) 
    54385488          || !strneq (s, last, len))) 
    54395489        { 
     
    65036553} 
    65046554 
    6505 /* Skip spaces, return new pointer. */ 
     6555/* Skip spaces (end of string is not space), return new pointer. */ 
    65066556static char * 
    65076557skip_spaces (cp) 
     
    65136563} 
    65146564 
    6515 /* Skip non spaces, return new pointer. */ 
     6565/* Skip non spaces, except end of string, return new pointer. */ 
    65166566static char * 
    65176567skip_non_spaces (cp)