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

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

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

revision 1.28 by gerd, Fri Nov 16 10:48:38 2001 UTC revision 1.29 by pj, Wed Dec 19 06:03:40 2001 UTC
# Line 6  Line 6 
6    
7     Author: Gerd Moellmann <gerd@gnu.org>     Author: Gerd Moellmann <gerd@gnu.org>
8     Maintainer: FSF     Maintainer: FSF
9      
10     This file is part of GNU Emacs.     This file is part of GNU Emacs.
11    
12     GNU Emacs is free software; you can redistribute it and/or modify     GNU Emacs is free software; you can redistribute it and/or modify
# Line 28  Line 28 
28  #endif  #endif
29    
30  #include <stdio.h>  #include <stdio.h>
31    
32    #ifdef HAVE_STDLIB_H
33  #include <stdlib.h>  #include <stdlib.h>
34    #endif
35    
36    #ifdef HAVE_STRING_H
37  #include <string.h>  #include <string.h>
38    #endif
39    
40  #include <ctype.h>  #include <ctype.h>
41  #include <assert.h>  #include <assert.h>
42  #include "getopt.h"  #include "getopt.h"
# Line 400  int inbuffer_size; Line 407  int inbuffer_size;
407    
408  #define BUFFER_POS() (in - inbuffer)  #define BUFFER_POS() (in - inbuffer)
409    
410  /* If current lookahead is CSTRING, the following points to the  /* If current lookahead is CSTRING, the following points to the
411     first character in the string constant.  Used for recognizing     first character in the string constant.  Used for recognizing
412     extern "C".  */     extern "C".  */
413    
# Line 686  add_link (super, sub) Line 693  add_link (super, sub)
693      {      {
694        lnk = (struct link *) xmalloc (sizeof *lnk);        lnk = (struct link *) xmalloc (sizeof *lnk);
695        lnk2 = (struct link *) xmalloc (sizeof *lnk2);        lnk2 = (struct link *) xmalloc (sizeof *lnk2);
696      
697        lnk->sym = sub;        lnk->sym = sub;
698        lnk->next = p;        lnk->next = p;
699    
# Line 728  find_member (cls, name, var, sc, hash) Line 735  find_member (cls, name, var, sc, hash)
735      case SC_FRIEND:      case SC_FRIEND:
736        list = &cls->friends;        list = &cls->friends;
737        break;        break;
738          
739      case SC_TYPE:      case SC_TYPE:
740        list = &cls->types;        list = &cls->types;
741        break;        break;
742          
743      case SC_STATIC:      case SC_STATIC:
744        list = var ? &cls->static_vars : &cls->static_fns;        list = var ? &cls->static_vars : &cls->static_fns;
745        break;        break;
746          
747      default:      default:
748        list = var ? &cls->vars : &cls->fns;        list = var ? &cls->vars : &cls->fns;
749        break;        break;
# Line 928  add_global_defn (name, regexp, pos, hash Line 935  add_global_defn (name, regexp, pos, hash
935     a bit set giving additional information about the member (see the     a bit set giving additional information about the member (see the
936     F_* defines).  */     F_* defines).  */
937    
938  void  void
939  add_global_decl (name, regexp, pos, hash, var, sc, flags)  add_global_decl (name, regexp, pos, hash, var, sc, flags)
940       char *name, *regexp;       char *name, *regexp;
941       int pos;       int pos;
# Line 1008  add_member (cls, name, var, sc, hash) Line 1015  add_member (cls, name, var, sc, hash)
1015      case SC_FRIEND:      case SC_FRIEND:
1016        list = &cls->friends;        list = &cls->friends;
1017        break;        break;
1018          
1019      case SC_TYPE:      case SC_TYPE:
1020        list = &cls->types;        list = &cls->types;
1021        break;        break;
1022          
1023      case SC_STATIC:      case SC_STATIC:
1024        list = var ? &cls->static_vars : &cls->static_fns;        list = var ? &cls->static_vars : &cls->static_fns;
1025        break;        break;
1026          
1027      default:      default:
1028        list = var ? &cls->vars : &cls->fns;        list = var ? &cls->vars : &cls->fns;
1029        break;        break;
# Line 1112  check_namespace (name, context) Line 1119  check_namespace (name, context)
1119       struct sym *context;       struct sym *context;
1120  {  {
1121    struct sym *p = NULL;    struct sym *p = NULL;
1122      
1123    for (p = all_namespaces; p; p = p->next)    for (p = all_namespaces; p; p = p->next)
1124      {      {
1125        if (streq (p->name, name) && (p->namesp == context))        if (streq (p->name, name) && (p->namesp == context))
# Line 1137  find_namespace (name, context) Line 1144  find_namespace (name, context)
1144    
1145    return p;    return p;
1146  }  }
1147      
1148    
1149  /* Find namespace alias with name NAME. If not found return NULL. */  /* Find namespace alias with name NAME. If not found return NULL. */
1150    
# Line 1210  enter_namespace (name) Line 1217  enter_namespace (name)
1217                                      size * sizeof *namespace_stack);                                      size * sizeof *namespace_stack);
1218        namespace_stack_size = size;        namespace_stack_size = size;
1219      }      }
1220      
1221    namespace_stack[namespace_sp++] = current_namespace;    namespace_stack[namespace_sp++] = current_namespace;
1222    current_namespace = p;    current_namespace = p;
1223  }  }
# Line 1282  sym_scope_1 (p) Line 1289  sym_scope_1 (p)
1289       struct sym *p;       struct sym *p;
1290  {  {
1291    int len;    int len;
1292      
1293    if (p->namesp)    if (p->namesp)
1294      sym_scope_1 (p->namesp);      sym_scope_1 (p->namesp);
1295    
# Line 1297  sym_scope_1 (p) Line 1304  sym_scope_1 (p)
1304    ensure_scope_buffer_room (len + 1);    ensure_scope_buffer_room (len + 1);
1305    strcat (scope_buffer, p->name);    strcat (scope_buffer, p->name);
1306    scope_buffer_len += len;    scope_buffer_len += len;
1307      
1308    if (HAS_FLAG (p->flags, F_TEMPLATE))    if (HAS_FLAG (p->flags, F_TEMPLATE))
1309      {      {
1310        ensure_scope_buffer_room (3);        ensure_scope_buffer_room (3);
1311        strcat (scope_buffer, "<>");        strcat (scope_buffer, "<>");
1312        scope_buffer_len += 2;        scope_buffer_len += 2;
1313      }      }
1314      
1315    return scope_buffer;    return scope_buffer;
1316  }  }
1317    
# Line 1321  sym_scope (p) Line 1328  sym_scope (p)
1328        scope_buffer_size = 1024;        scope_buffer_size = 1024;
1329        scope_buffer = (char *) xmalloc (scope_buffer_size);        scope_buffer = (char *) xmalloc (scope_buffer_size);
1330      }      }
1331      
1332    *scope_buffer = '\0';    *scope_buffer = '\0';
1333    scope_buffer_len = 0;    scope_buffer_len = 0;
1334      
1335    if (p->namesp)    if (p->namesp)
1336      sym_scope_1 (p->namesp);      sym_scope_1 (p->namesp);
1337    
# Line 1377  dump_sym (fp, root) Line 1384  dump_sym (fp, root)
1384  {  {
1385    fputs (CLASS_STRUCT, fp);    fputs (CLASS_STRUCT, fp);
1386    PUTSTR (root->name, fp);    PUTSTR (root->name, fp);
1387      
1388    /* Print scope, if any.  */    /* Print scope, if any.  */
1389    if (root->namesp)    if (root->namesp)
1390      PUTSTR (sym_scope (root), fp);      PUTSTR (sym_scope (root), fp);
1391    else    else
1392      PUTSTR (NULL, fp);      PUTSTR (NULL, fp);
1393      
1394    /* Print flags.  */    /* Print flags.  */
1395    fprintf (fp, "%u", root->flags);    fprintf (fp, "%u", root->flags);
1396    PUTSTR (root->filename, fp);    PUTSTR (root->filename, fp);
# Line 1563  process_pp_line () Line 1570  process_pp_line ()
1570            add_define (yytext, regexp, pos);            add_define (yytext, regexp, pos);
1571          }          }
1572      }      }
1573      
1574    while (c && (c != '\n' || in_comment || in_string))    while (c && (c != '\n' || in_comment || in_string))
1575      {      {
1576        if (c == '\\')        if (c == '\\')
# Line 1580  process_pp_line () Line 1587  process_pp_line ()
1587          }          }
1588        else if (c == '"')        else if (c == '"')
1589          in_string = !in_string;          in_string = !in_string;
1590          
1591        if (c == '\n')        if (c == '\n')
1592          INCREMENT_LINENO;          INCREMENT_LINENO;
1593    
# Line 2184  re_init_scanner () Line 2191  re_init_scanner ()
2191  {  {
2192    in = inbuffer;    in = inbuffer;
2193    yyline = 1;    yyline = 1;
2194      
2195    if (yytext == NULL)    if (yytext == NULL)
2196      {      {
2197        int size = 256;        int size = 256;
# Line 2386  skip_matching () Line 2393  skip_matching ()
2393      case '{':      case '{':
2394        close = '}';        close = '}';
2395        break;        break;
2396          
2397      case '(':      case '(':
2398        close = ')';        close = ')';
2399        break;        break;
2400          
2401      case '<':      case '<':
2402        close = '>';        close = '>';
2403        break;        break;
2404          
2405      case '[':      case '[':
2406        close = ']';        close = ']';
2407        break;        break;
2408          
2409      default:      default:
2410        abort ();        abort ();
2411      }      }
# Line 2505  parm_list (flags) Line 2512  parm_list (flags)
2512              {              {
2513                char *last_id;                char *last_id;
2514                unsigned ident_type_hash = 0;                unsigned ident_type_hash = 0;
2515                  
2516                parse_qualified_param_ident_or_type (&last_id);                parse_qualified_param_ident_or_type (&last_id);
2517                if (last_id)                if (last_id)
2518                  {                  {
# Line 2533  parm_list (flags) Line 2540  parm_list (flags)
2540          case DOUBLE:    case ENUM:      case FLOAT:     case INT:          case DOUBLE:    case ENUM:      case FLOAT:     case INT:
2541          case LONG:      case SHORT:     case SIGNED:    case STRUCT:          case LONG:      case SHORT:     case SIGNED:    case STRUCT:
2542          case UNION:     case UNSIGNED:  case VOLATILE:  case WCHAR:          case UNION:     case UNSIGNED:  case VOLATILE:  case WCHAR:
2543          case ELLIPSIS:            case ELLIPSIS:
2544            type_seen = 1;            type_seen = 1;
2545            hash = (hash << 1) ^ LA1;            hash = (hash << 1) ^ LA1;
2546            MATCH ();            MATCH ();
# Line 2553  parm_list (flags) Line 2560  parm_list (flags)
2560    if (LOOKING_AT (')'))    if (LOOKING_AT (')'))
2561      {      {
2562        MATCH ();        MATCH ();
2563          
2564        if (LOOKING_AT (CONST))        if (LOOKING_AT (CONST))
2565          {          {
2566            /* We can overload the same function on `const' */            /* We can overload the same function on `const' */
# Line 2638  member (cls, vis) Line 2645  member (cls, vis)
2645          case EXPLICIT:          case EXPLICIT:
2646            SET_FLAG (flags, F_EXPLICIT);            SET_FLAG (flags, F_EXPLICIT);
2647            goto typeseen;            goto typeseen;
2648              
2649          case MUTABLE:          case MUTABLE:
2650            SET_FLAG (flags, F_MUTABLE);            SET_FLAG (flags, F_MUTABLE);
2651            goto typeseen;            goto typeseen;
# Line 2773  member (cls, vis) Line 2780  member (cls, vis)
2780          {          {
2781            regexp = matching_regexp ();            regexp = matching_regexp ();
2782            pos = BUFFER_POS ();            pos = BUFFER_POS ();
2783              
2784            if (cls != NULL)            if (cls != NULL)
2785              {              {
2786                if (type_seen || !paren_seen)                if (type_seen || !paren_seen)
# Line 2782  member (cls, vis) Line 2789  member (cls, vis)
2789                  add_member_decl (cls, id, regexp, pos, hash, 0, sc, vis, 0);                  add_member_decl (cls, id, regexp, pos, hash, 0, sc, vis, 0);
2790              }              }
2791          }          }
2792          
2793        MATCH ();        MATCH ();
2794        print_info ();        print_info ();
2795      }      }
# Line 2879  struct sym * Line 2886  struct sym *
2886  parse_classname ()  parse_classname ()
2887  {  {
2888    struct sym *last_class = NULL;    struct sym *last_class = NULL;
2889      
2890    while (LOOKING_AT (IDENT))    while (LOOKING_AT (IDENT))
2891      {      {
2892        last_class = add_sym (yytext, last_class);        last_class = add_sym (yytext, last_class);
# Line 2890  parse_classname () Line 2897  parse_classname ()
2897            skip_matching ();            skip_matching ();
2898            SET_FLAG (last_class->flags, F_TEMPLATE);            SET_FLAG (last_class->flags, F_TEMPLATE);
2899          }          }
2900          
2901        if (!LOOKING_AT (DCOLON))        if (!LOOKING_AT (DCOLON))
2902          break;          break;
2903          
2904        MATCH ();        MATCH ();
2905      }      }
2906    
# Line 2913  operator_name (sc) Line 2920  operator_name (sc)
2920    static char *id = NULL;    static char *id = NULL;
2921    char *s;    char *s;
2922    int len;    int len;
2923      
2924    MATCH ();    MATCH ();
2925    
2926    if (LOOKING_AT2 (NEW, DELETE))    if (LOOKING_AT2 (NEW, DELETE))
# Line 2924  operator_name (sc) Line 2931  operator_name (sc)
2931    
2932        s = token_string (LA1);        s = token_string (LA1);
2933        MATCH ();        MATCH ();
2934          
2935        len = strlen (s) + 10;        len = strlen (s) + 10;
2936        if (len > id_size)        if (len > id_size)
2937          {          {
# Line 2934  operator_name (sc) Line 2941  operator_name (sc)
2941          }          }
2942        strcpy (id, s);        strcpy (id, s);
2943    
2944        /* Vector new or delete? */        /* Vector new or delete?  */
2945        if (LOOKING_AT ('['))        if (LOOKING_AT ('['))
2946          {          {
2947            strcat (id, "[");            strcat (id, "[");
2948            MATCH ();            MATCH ();
2949              
2950            if (LOOKING_AT (']'))            if (LOOKING_AT (']'))
2951              {              {
2952                strcat (id, "]");                strcat (id, "]");
# Line 3004  parse_qualified_ident_or_type (last_id) Line 3011  parse_qualified_ident_or_type (last_id)
3011    char *id = NULL;    char *id = NULL;
3012    size_t id_size = 0;    size_t id_size = 0;
3013    int enter = 0;    int enter = 0;
3014      
3015    while (LOOKING_AT (IDENT))    while (LOOKING_AT (IDENT))
3016      {      {
3017        int len = strlen (yytext) + 1;        int len = strlen (yytext) + 1;
# Line 3233  declaration (flags) Line 3240  declaration (flags)
3240            sc = SC_TYPE;            sc = SC_TYPE;
3241            MATCH ();            MATCH ();
3242            break;            break;
3243              
3244          case STATIC:          case STATIC:
3245            sc = SC_STATIC;            sc = SC_STATIC;
3246            MATCH ();            MATCH ();
# Line 3361  declaration (flags) Line 3368  declaration (flags)
3368            else            else
3369              add_global_defn (id, regexp, pos, 0, 1, sc, flags);              add_global_defn (id, regexp, pos, 0, 1, sc, flags);
3370          }          }
3371            
3372        MATCH ();        MATCH ();
3373        print_info ();        print_info ();
3374      }      }
# Line 3399  globals (start_flags) Line 3406  globals (start_flags)
3406    for (;;)    for (;;)
3407      {      {
3408        char *prev_in = in;        char *prev_in = in;
3409          
3410        switch (LA1)        switch (LA1)
3411          {          {
3412          case NAMESPACE:          case NAMESPACE:
# Line 3410  globals (start_flags) Line 3417  globals (start_flags)
3417                {                {
3418                  char *namespace_name = xstrdup (yytext);                  char *namespace_name = xstrdup (yytext);
3419                  MATCH ();                  MATCH ();
3420                    
3421                  if (LOOKING_AT ('='))                  if (LOOKING_AT ('='))
3422                    {                    {
3423                      struct link *qna = match_qualified_namespace_alias ();                      struct link *qna = match_qualified_namespace_alias ();
3424                      if (qna)                      if (qna)
3425                        register_namespace_alias (namespace_name, qna);                        register_namespace_alias (namespace_name, qna);
3426                          
3427                      if (skip_to (';') == ';')                      if (skip_to (';') == ';')
3428                        MATCH ();                        MATCH ();
3429                    }                    }
# Line 3441  globals (start_flags) Line 3448  globals (start_flags)
3448              {              {
3449                /* This is `extern "C"'.  */                /* This is `extern "C"'.  */
3450                MATCH ();                MATCH ();
3451                  
3452                if (LOOKING_AT ('{'))                if (LOOKING_AT ('{'))
3453                  {                  {
3454                    MATCH ();                    MATCH ();
# Line 3452  globals (start_flags) Line 3459  globals (start_flags)
3459                  SET_FLAG (flags, F_EXTERNC);                  SET_FLAG (flags, F_EXTERNC);
3460              }              }
3461            break;            break;
3462              
3463          case TEMPLATE:          case TEMPLATE:
3464            MATCH ();            MATCH ();
3465            SKIP_MATCHING_IF ('<');            SKIP_MATCHING_IF ('<');
# Line 3492  globals (start_flags) Line 3499  globals (start_flags)
3499    
3500          case '}':          case '}':
3501            return 0;            return 0;
3502              
3503          default:          default:
3504            declaration (flags);            declaration (flags);
3505            flags = start_flags;            flags = start_flags;
# Line 3531  add_search_path (path_list) Line 3538  add_search_path (path_list)
3538      {      {
3539        char *start = path_list;        char *start = path_list;
3540        struct search_path *p;        struct search_path *p;
3541          
3542        while (*path_list && *path_list != PATH_LIST_SEPARATOR)        while (*path_list && *path_list != PATH_LIST_SEPARATOR)
3543          ++path_list;          ++path_list;
3544          
3545        p = (struct search_path *) xmalloc (sizeof *p);        p = (struct search_path *) xmalloc (sizeof *p);
3546        p->path = (char *) xmalloc (path_list - start + 1);        p->path = (char *) xmalloc (path_list - start + 1);
3547        memcpy (p->path, start, path_list - start);        memcpy (p->path, start, path_list - start);
# Line 3568  open_file (file) Line 3575  open_file (file)
3575    static int buffer_size;    static int buffer_size;
3576    struct search_path *path;    struct search_path *path;
3577    int flen = strlen (file) + 1; /* +1 for the slash */    int flen = strlen (file) + 1; /* +1 for the slash */
3578      
3579    filename = xstrdup (file);    filename = xstrdup (file);
3580    
3581    for (path = search_path; path && fp == NULL; path = path->next)    for (path = search_path; path && fp == NULL; path = path->next)
# Line 3580  open_file (file) Line 3587  open_file (file)
3587            buffer_size = max (len + 1, 2 * buffer_size);            buffer_size = max (len + 1, 2 * buffer_size);
3588            buffer = (char *) xrealloc (buffer, buffer_size);            buffer = (char *) xrealloc (buffer, buffer_size);
3589          }          }
3590            
3591        strcpy (buffer, path->path);        strcpy (buffer, path->path);
3592        strcat (buffer, "/");        strcat (buffer, "/");
3593        strcat (buffer, file);        strcat (buffer, file);
3594        fp = fopen (buffer, "r");        fp = fopen (buffer, "r");
3595      }      }
3596      
3597    /* Try the original file name.  */    /* Try the original file name.  */
3598    if (fp == NULL)    if (fp == NULL)
3599       fp = fopen (file, "r");       fp = fopen (file, "r");
3600    
3601    if (fp == NULL)    if (fp == NULL)
3602      yyerror ("cannot open", NULL);      yyerror ("cannot open", NULL);
3603      
3604    return fp;    return fp;
3605  }  }
3606    
# Line 3653  process_file (file) Line 3660  process_file (file)
3660       char *file;       char *file;
3661  {  {
3662    FILE *fp;    FILE *fp;
3663      
3664    fp = open_file (file);    fp = open_file (file);
3665    if (fp)    if (fp)
3666      {            {
3667        int nread, nbytes;        int nread, nbytes;
3668    
3669        /* Give a progress indication if needed.  */        /* Give a progress indication if needed.  */
# Line 3679  process_file (file) Line 3686  process_file (file)
3686                inbuffer_size = nread + READ_CHUNK_SIZE + 1;                inbuffer_size = nread + READ_CHUNK_SIZE + 1;
3687                inbuffer = (char *) xrealloc (inbuffer, inbuffer_size);                inbuffer = (char *) xrealloc (inbuffer, inbuffer_size);
3688              }              }
3689              
3690            nbytes = fread (inbuffer + nread, 1, READ_CHUNK_SIZE, fp);            nbytes = fread (inbuffer + nread, 1, READ_CHUNK_SIZE, fp);
3691            if (nbytes <= 0)            if (nbytes <= 0)
3692              break;              break;
# Line 3722  read_line (fp) Line 3729  read_line (fp)
3729    
3730        buffer[i++] = c;        buffer[i++] = c;
3731      }      }
3732      
3733    if (c == EOF && i == 0)    if (c == EOF && i == 0)
3734      return NULL;      return NULL;
3735      
3736    if (i == buffer_size)    if (i == buffer_size)
3737      {      {
3738        buffer_size = max (100, buffer_size * 2);        buffer_size = max (100, buffer_size * 2);
# Line 3765  main (argc, argv) Line 3772  main (argc, argv)
3772          case 'p':          case 'p':
3773            info_position = atoi (optarg);            info_position = atoi (optarg);
3774            break;            break;
3775              
3776          case 'n':          case 'n':
3777            f_nested_classes = 0;            f_nested_classes = 0;
3778            break;            break;
# Line 3773  main (argc, argv) Line 3780  main (argc, argv)
3780          case 'x':          case 'x':
3781            f_regexps = 0;            f_regexps = 0;
3782            break;            break;
3783            
3784            /* Add the name of a file containing more input files.  */            /* Add the name of a file containing more input files.  */
3785          case 'f':          case 'f':
3786            if (n_input_files == input_filenames_size)            if (n_input_files == input_filenames_size)
# Line 3870  main (argc, argv) Line 3877  main (argc, argv)
3877              yyerror ("error getting size of file `%s'", out_filename);              yyerror ("error getting size of file `%s'", out_filename);
3878            else if (rc == 0)            else if (rc == 0)
3879              yyerror ("file `%s' is empty", out_filename);              yyerror ("file `%s' is empty", out_filename);
3880              
3881            fclose (fp);            fclose (fp);
3882          }          }
3883          
3884        yyout = fopen (out_filename, f_append ? "a" : "w");        yyout = fopen (out_filename, f_append ? "a" : "w");
3885        if (yyout == NULL)        if (yyout == NULL)
3886          {          {
# Line 3903  main (argc, argv) Line 3910  main (argc, argv)
3910        for (i = 0; i < n_input_files; ++i)        for (i = 0; i < n_input_files; ++i)
3911          {          {
3912            FILE *fp = fopen (input_filenames[i], "r");            FILE *fp = fopen (input_filenames[i], "r");
3913              
3914            if (fp == NULL)            if (fp == NULL)
3915              yyerror ("cannot open input file `%s'", input_filenames[i]);              yyerror ("cannot open input file `%s'", input_filenames[i]);
3916            else            else

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.29

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