Show
Ignore:
Timestamp:
08/10/06 11:19:54 (2 years ago)
Author:
miyoshi
Message:

Sync up with Emacs CVS HEAD.

Files:

Legend:

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

    r4111 r4140  
    4242 */ 
    4343 
    44 char pot_etags_version[] = "@(#) pot revision number is 17.18"; 
     44char pot_etags_version[] = "@(#) pot revision number is 17.20"; 
    4545 
    4646#define TRUE    1 
     
    6060     of unexec.  We don't want that here since we don't use unexec. */ 
    6161# undef static 
    62 # define ETAGS_REGEXPS          /* use the regexp features */ 
    63 # define LONG_OPTIONS           /* accept long options */ 
    64 # ifndef PTR                    /* for Xemacs */ 
     62# ifndef PTR                    /* for XEmacs */ 
    6563#   define PTR void * 
    6664# endif 
    67 # ifndef __P                    /* for Xemacs */ 
     65# ifndef __P                    /* for XEmacs */ 
    6866#   define __P(args) args 
    6967# endif 
     
    8381#endif 
    8482 
    85 #ifdef LONG_OPTIONS 
    86 #  undef LONG_OPTIONS 
    87 #  define LONG_OPTIONS TRUE 
    88 #else 
    89 #  define LONG_OPTIONS  FALSE 
    90 #endif 
    91  
    92 /* WIN32_NATIVE is for Xemacs. 
     83/* WIN32_NATIVE is for XEmacs. 
    9384   MSDOS, WINDOWSNT, DOS_NT are for Emacs. */ 
    9485#ifdef WIN32_NATIVE 
     
    168159#endif 
    169160 
    170 #if LONG_OPTIONS 
    171 # include <getopt.h> 
    172 #else 
     161#ifdef NO_LONG_OPTIONS          /* define this if you don't have GNU getopt */ 
     162# define NO_LONG_OPTIONS TRUE 
    173163# define getopt_long(argc,argv,optstr,lopts,lind) getopt (argc, argv, optstr) 
    174164  extern char *optarg; 
    175165  extern int optind, opterr; 
    176 #endif /* LONG_OPTIONS */ 
    177  
    178 #ifdef ETAGS_REGEXPS 
    179 # ifndef HAVE_CONFIG_H          /* this is a standalone compilation */ 
    180 #   ifdef __CYGWIN__            /* compiling on Cygwin */ 
     166#else 
     167# define NO_LONG_OPTIONS FALSE 
     168# include <getopt.h> 
     169#endif /* NO_LONG_OPTIONS */ 
     170 
     171#ifndef HAVE_CONFIG_H           /* this is a standalone compilation */ 
     172# ifdef __CYGWIN__              /* compiling on Cygwin */ 
    181173                             !!! NOTICE !!! 
    182174 the regex.h distributed with Cygwin is not compatible with etags, alas! 
    183175If you want regular expression support, you should delete this notice and 
    184176              arrange to use the GNU regex.h and regex.c. 
    185 #   endif 
    186177# endif 
    187 # include <regex.h> 
    188 #endif /* ETAGS_REGEXPS */ 
     178#endif 
     179#include <regex.h> 
    189180 
    190181/* Define CTAGS to make the program "ctags" compatible with the usual one. 
     
    313304} argument; 
    314305 
    315 #ifdef ETAGS_REGEXPS 
    316306/* Structure defining a regular expression. */ 
    317307typedef struct regexp 
     
    328318  bool multi_line;              /* do a multi-line match on the whole file */ 
    329319} regexp; 
    330 #endif /* ETAGS_REGEXPS */ 
    331320 
    332321 
     
    376365static void get_tag __P((char *, char **)); 
    377366 
    378 #ifdef ETAGS_REGEXPS 
    379367static void analyse_regex __P((char *)); 
    380368static void free_regexps __P((void)); 
    381369static void regex_tag_multiline __P((void)); 
    382 #endif /* ETAGS_REGEXPS */ 
    383370static void error __P((const char *, const char *)); 
    384371static void suggest_asking_for_help __P((void)); 
     
    486473static bool parsing_stdin;      /* --parse-stdin used */ 
    487474 
    488 #ifdef ETAGS_REGEXPS 
    489475static regexp *p_head;          /* list of all regexps */ 
    490476static bool need_filebuf;       /* some regexes are multi-line */ 
    491 #else 
    492 # define need_filebuf FALSE 
    493 #endif /* ETAGS_REGEXPS */ 
    494  
    495 #if LONG_OPTIONS 
     477 
    496478static struct option longopts[] = 
    497479{ 
     
    508490  { "no-members",         no_argument,       &members,           FALSE }, 
    509491  { "output",             required_argument, NULL,               'o'   }, 
    510 #ifdef ETAGS_REGEXPS 
    511492  { "regex",              required_argument, NULL,               'r'   }, 
    512493  { "no-regex",           no_argument,       NULL,               'R'   }, 
    513494  { "ignore-case-regex",  required_argument, NULL,               'c'   }, 
    514 #endif /* ETAGS_REGEXPS */ 
    515495  { "parse-stdin",        required_argument, NULL,               STDIN }, 
    516496  { "version",            no_argument,       NULL,               'V'   }, 
     
    534514  { NULL } 
    535515}; 
    536 #endif /* LONG_OPTIONS */ 
    537516 
    538517static compressor compressors[] = 
     
    682661"In Objective C code, tags include Objective C definitions for classes,\n\ 
    683662class categories, methods and protocols.  Tags for variables and\n\ 
    684 functions in classes are named `CLASS::VARIABLE' and `CLASS::FUNCTION'."; 
     663functions in classes are named `CLASS::VARIABLE' and `CLASS::FUNCTION'.\n\ 
     664(Use --help --lang=c --lang=objc --lang=java for full help.)"; 
    685665 
    686666static char *Pascal_suffixes [] = 
     
    689669"In Pascal code, the tags are the functions and procedures defined\n\ 
    690670in the file."; 
     671/* " // this is for working around an Emacs highlighting bug... */ 
    691672 
    692673static char *Perl_suffixes [] = 
     
    886867\n\ 
    887868These are the options accepted by %s.\n", progname, progname); 
    888   if (LONG_OPTIONS) 
     869  if (NO_LONG_OPTIONS) 
     870    puts ("WARNING: long option names do not work with this executable,\n\ 
     871as it is not linked with GNU getopt."); 
     872  else 
    889873    puts ("You may use unambiguous abbreviations for the long option names."); 
    890   else 
    891     puts ("Long option names do not work with this executable, as it is not\n\ 
    892 linked with GNU getopt."); 
    893874  puts ("  A - as file name means read names from stdin (one per line).\n\ 
    894875Absolute names are stored in the output file as they are.\n\ 
     
    950931        Create tag entries for members of structures in some languages."); 
    951932 
    952 #ifdef ETAGS_REGEXPS 
    953933  puts ("-r REGEXP, --regex=REGEXP or --regex=@regexfile\n\ 
    954934        Make a tag for each line matching a regular expression pattern\n\ 
     
    965945  puts ("-R, --no-regex\n\ 
    966946        Don't create tags from regexps for the following files."); 
    967 #endif /* ETAGS_REGEXPS */ 
    968947  puts ("-I, --ignore-indentation\n\ 
    969948        In C and C++ do not assume that a closing brace in the first\n\ 
     
    11951174  /* When the optstring begins with a '-' getopt_long does not rearrange the 
    11961175     non-options arguments to be at the end, but leaves them alone. */ 
    1197   optstring = "-"; 
    1198 #ifdef ETAGS_REGEXPS 
    1199   optstring = "-r:Rc:"; 
    1200 #endif /* ETAGS_REGEXPS */ 
    1201   if (!LONG_OPTIONS) 
    1202     optstring += 1;             /* remove the initial '-' */ 
    1203   optstring = concat (optstring, 
    1204                       "aCf:Il:o:SVhH", 
     1176  optstring = concat (NO_LONG_OPTIONS ? "" : "-", 
     1177                      "ac:Cf:Il:o:r:RSVhH", 
    12051178                      (CTAGS) ? "BxdtTuvw" : "Di:"); 
    12061179 
     
    13761349          lang = argbuffer[i].lang; 
    13771350          break; 
    1378 #ifdef ETAGS_REGEXPS 
    13791351        case at_regexp: 
    13801352          analyse_regex (argbuffer[i].what); 
    13811353          break; 
    1382 #endif 
    13831354        case at_filename: 
    13841355#ifdef VMS 
     
    14201391    } 
    14211392 
    1422 #ifdef ETAGS_REGEXPS 
    14231393  free_regexps (); 
    1424 #endif /* ETAGS_REGEXPS */ 
    14251394  free (lb.buffer); 
    14261395  free (filebuf.buffer); 
     
    19801949  parser (inf); 
    19811950 
    1982 #ifdef ETAGS_REGEXPS 
    19831951  regex_tag_multiline (); 
    1984 #endif /* ETAGS_REGEXPS */ 
    19851952} 
    19861953 
     
    32403207  bool incomm, inquote, inchar, quotednl, midtoken; 
    32413208  bool yacc_rules;              /* in the rules part of a yacc file */ 
    3242   struct tok savetoken;                /* token saved during preprocessor handling */ 
     3209  struct tok savetoken = {0};  /* token saved during preprocessor handling */ 
    32433210 
    32443211 
     
    51995166      /* Skip to next line if we hit the TeX comment char. */ 
    52005167      if (c == '%') 
    5201         while (c != '\n'
     5168        while (c != '\n' && c != EOF
    52025169          c = getc (inf); 
    52035170      else if (c == TEX_LESC || c == TEX_SESC ) 
     
    57365703 
    57375704  
    5738 #ifdef ETAGS_REGEXPS 
    5739  
    57405705static char *scan_separators __P((char *)); 
    57415706static void add_regex __P((char *, language *)); 
     
    61426107} 
    61436108 
    6144 #endif /* ETAGS_REGEXPS */ 
    6145  
    61466109  
    61476110static bool 
     
    62976260 
    62986261          if (DEBUG) start = 0; /* shut up the compiler */ 
    6299           if (sscanf (lbp->buffer, "#line %d \"%n", &lno, &start) == 1) 
    6300             { 
    6301               char *endp = lbp->buffer + start; 
     6262          if (sscanf (lbp->buffer, "#line %d %n\"", &lno, &start) >= 1 
     6263              && lbp->buffer[start] == '"') 
     6264            { 
     6265              char *endp = lbp->buffer + ++start; 
    63026266 
    63036267              assert (start > 0); 
     
    64066370    } /* if #line directives should be considered */ 
    64076371 
    6408 #ifdef ETAGS_REGEXPS 
    64096372  { 
    64106373    int match; 
     
    64636426        } 
    64646427  } 
    6465 #endif /* ETAGS_REGEXPS */ 
    64666428} 
    64676429 
     
    66246586{ 
    66256587  fprintf (stderr, "\tTry `%s %s' for a complete list of options.\n", 
    6626            progname, LONG_OPTIONS ? "--help" : "-h"); 
     6588           progname, NO_LONG_OPTIONS ? "-h" : "--help"); 
    66276589  exit (EXIT_FAILURE); 
    66286590}