aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src/ebrowse.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib-src/ebrowse.c')
-rw-r--r--lib-src/ebrowse.c374
1 files changed, 131 insertions, 243 deletions
diff --git a/lib-src/ebrowse.c b/lib-src/ebrowse.c
index b51b4aa6965..1fcbb8662f5 100644
--- a/lib-src/ebrowse.c
+++ b/lib-src/ebrowse.c
@@ -20,20 +20,14 @@ You should have received a copy of the GNU General Public License
20along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 20along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21 21
22 22
23#ifdef HAVE_CONFIG_H
24#include <config.h> 23#include <config.h>
25#endif
26
27#include <stdio.h> 24#include <stdio.h>
28 25
29#ifdef HAVE_STDLIB_H 26#ifdef HAVE_STDLIB_H
30#include <stdlib.h> 27#include <stdlib.h>
31#endif 28#endif
32 29
33#ifdef HAVE_STRING_H
34#include <string.h> 30#include <string.h>
35#endif
36
37#include <ctype.h> 31#include <ctype.h>
38#include <assert.h> 32#include <assert.h>
39#include "getopt.h" 33#include "getopt.h"
@@ -45,12 +39,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
45 39
46/* Conditionalize function prototypes. */ 40/* Conditionalize function prototypes. */
47 41
48#ifdef PROTOTYPES /* From config.h. */
49#define P_(x) x
50#else
51#define P_(x) ()
52#endif
53
54/* Value is non-zero if strings X and Y compare equal. */ 42/* Value is non-zero if strings X and Y compare equal. */
55 43
56#define streq(X, Y) (*(X) == *(Y) && strcmp ((X) + 1, (Y) + 1) == 0) 44#define streq(X, Y) (*(X) == *(Y) && strcmp ((X) + 1, (Y) + 1) == 0)
@@ -261,10 +249,10 @@ struct member
261 int vis; /* Visibility (public, ...). */ 249 int vis; /* Visibility (public, ...). */
262 int flags; /* See F_* above. */ 250 int flags; /* See F_* above. */
263 char *regexp; /* Matching regular expression. */ 251 char *regexp; /* Matching regular expression. */
264 char *filename; /* Don't free this shared string. */ 252 const char *filename; /* Don't free this shared string. */
265 int pos; /* Buffer position of occurrence. */ 253 int pos; /* Buffer position of occurrence. */
266 char *def_regexp; /* Regular expression matching definition. */ 254 char *def_regexp; /* Regular expression matching definition. */
267 char *def_filename; /* File name of definition. */ 255 const char *def_filename; /* File name of definition. */
268 int def_pos; /* Buffer position of definition. */ 256 int def_pos; /* Buffer position of definition. */
269 char name[1]; /* Member name. */ 257 char name[1]; /* Member name. */
270}; 258};
@@ -306,8 +294,8 @@ struct sym
306 struct member *types; /* List of local types. */ 294 struct member *types; /* List of local types. */
307 char *regexp; /* Matching regular expression. */ 295 char *regexp; /* Matching regular expression. */
308 int pos; /* Buffer position. */ 296 int pos; /* Buffer position. */
309 char *filename; /* File in which it can be found. */ 297 const char *filename; /* File in which it can be found. */
310 char *sfilename; /* File in which members can be found. */ 298 const char *sfilename; /* File in which members can be found. */
311 struct sym *namesp; /* Namespace in which defined. . */ 299 struct sym *namesp; /* Namespace in which defined. . */
312 char name[1]; /* Name of the class. */ 300 char name[1]; /* Name of the class. */
313}; 301};
@@ -365,7 +353,7 @@ int yyline;
365 353
366/* The name of the current input file. */ 354/* The name of the current input file. */
367 355
368char *filename; 356const char *filename;
369 357
370/* Three character class vectors, and macros to test membership 358/* Three character class vectors, and macros to test membership
371 of characters. */ 359 of characters. */
@@ -456,7 +444,7 @@ int tk = -1;
456 444
457struct kw 445struct kw
458{ 446{
459 char *name; /* Spelling. */ 447 const char *name; /* Spelling. */
460 int tk; /* Token value. */ 448 int tk; /* Token value. */
461 struct kw *next; /* Next in collision chain. */ 449 struct kw *next; /* Next in collision chain. */
462}; 450};
@@ -479,62 +467,59 @@ struct search_path *search_path_tail;
479 467
480/* Function prototypes. */ 468/* Function prototypes. */
481 469
482int yylex P_ ((void)); 470int yylex (void);
483void yyparse P_ ((void)); 471void yyparse (void);
484void re_init_parser P_ ((void)); 472void re_init_parser (void);
485char *token_string P_ ((int)); 473const char *token_string (int);
486char *matching_regexp P_ ((void)); 474char *matching_regexp (void);
487void init_sym P_ ((void)); 475void init_sym (void);
488struct sym *add_sym P_ ((char *, struct sym *)); 476struct sym *add_sym (const char *, struct sym *);
489void add_link P_ ((struct sym *, struct sym *)); 477void add_link (struct sym *, struct sym *);
490void add_member_defn P_ ((struct sym *, char *, char *, 478void add_member_defn (struct sym *, char *, char *,
491 int, unsigned, int, int, int)); 479 int, unsigned, int, int, int);
492void add_member_decl P_ ((struct sym *, char *, char *, int, 480void add_member_decl (struct sym *, char *, char *, int,
493 unsigned, int, int, int, int)); 481 unsigned, int, int, int, int);
494void dump_roots P_ ((FILE *)); 482void dump_roots (FILE *);
495void *xmalloc P_ ((int)); 483void *xmalloc (int);
496void xfree P_ ((void *)); 484void xfree (void *);
497void add_global_defn P_ ((char *, char *, int, unsigned, int, int, int)); 485void add_global_defn (char *, char *, int, unsigned, int, int, int);
498void add_global_decl P_ ((char *, char *, int, unsigned, int, int, int)); 486void add_global_decl (char *, char *, int, unsigned, int, int, int);
499void add_define P_ ((char *, char *, int)); 487void add_define (char *, char *, int);
500void mark_inherited_virtual P_ ((void)); 488void mark_inherited_virtual (void);
501void leave_namespace P_ ((void)); 489void leave_namespace (void);
502void enter_namespace P_ ((char *)); 490void enter_namespace (char *);
503void register_namespace_alias P_ ((char *, struct link *)); 491void register_namespace_alias (char *, struct link *);
504void insert_keyword P_ ((char *, int)); 492void insert_keyword (const char *, int);
505void re_init_scanner P_ ((void)); 493void re_init_scanner (void);
506void init_scanner P_ ((void)); 494void init_scanner (void);
507void usage P_ ((int)); 495void process_file (char *);
508void version P_ ((void)); 496void add_search_path (char *);
509void process_file P_ ((char *)); 497FILE *open_file (char *);
510void add_search_path P_ ((char *)); 498int process_pp_line (void);
511FILE *open_file P_ ((char *)); 499int dump_members (FILE *, struct member *);
512int process_pp_line P_ ((void)); 500void dump_sym (FILE *, struct sym *);
513int dump_members P_ ((FILE *, struct member *)); 501int dump_tree (FILE *, struct sym *);
514void dump_sym P_ ((FILE *, struct sym *)); 502struct member *find_member (struct sym *, char *, int, int, unsigned);
515int dump_tree P_ ((FILE *, struct sym *)); 503struct member *add_member (struct sym *, char *, int, int, unsigned);
516struct member *find_member P_ ((struct sym *, char *, int, int, unsigned)); 504void mark_virtual (struct sym *);
517struct member *add_member P_ ((struct sym *, char *, int, int, unsigned)); 505struct sym *make_namespace (char *, struct sym *);
518void mark_virtual P_ ((struct sym *)); 506char *sym_scope (struct sym *);
519void mark_virtual P_ ((struct sym *)); 507char *sym_scope_1 (struct sym *);
520struct sym *make_namespace P_ ((char *, struct sym *)); 508int skip_to (int);
521char *sym_scope P_ ((struct sym *)); 509void skip_matching (void);
522char *sym_scope_1 P_ ((struct sym *)); 510void member (struct sym *, int);
523int skip_to P_ ((int)); 511void class_body (struct sym *, int);
524void skip_matching P_ ((void)); 512void class_definition (struct sym *, int, int, int);
525void member P_ ((struct sym *, int)); 513void declaration (int);
526void class_body P_ ((struct sym *, int)); 514unsigned parm_list (int *);
527void class_definition P_ ((struct sym *, int, int, int)); 515char *operator_name (int *);
528void declaration P_ ((int)); 516struct sym *parse_classname (void);
529unsigned parm_list P_ ((int *)); 517struct sym *parse_qualified_ident_or_type (char **);
530char *operator_name P_ ((int *)); 518void parse_qualified_param_ident_or_type (char **);
531struct sym *parse_classname P_ ((void)); 519int globals (int);
532struct sym *parse_qualified_ident_or_type P_ ((char **)); 520void yyerror (const char *, const char *);
533void parse_qualified_param_ident_or_type P_ ((char **)); 521void usage (int) NO_RETURN;
534int globals P_ ((int)); 522void version (void) NO_RETURN;
535void yyerror P_ ((char *, char *));
536void usage P_ ((int)) NO_RETURN;
537void version P_ (()) NO_RETURN;
538 523
539 524
540 525
@@ -546,8 +531,7 @@ void version P_ (()) NO_RETURN;
546 name and line number. */ 531 name and line number. */
547 532
548void 533void
549yyerror (format, s) 534yyerror (const char *format, const char *s)
550 char *format, *s;
551{ 535{
552 fprintf (stderr, "%s:%d: ", filename, yyline); 536 fprintf (stderr, "%s:%d: ", filename, yyline);
553 fprintf (stderr, format, s); 537 fprintf (stderr, format, s);
@@ -559,8 +543,7 @@ yyerror (format, s)
559 available. */ 543 available. */
560 544
561void * 545void *
562xmalloc (nbytes) 546xmalloc (int nbytes)
563 int nbytes;
564{ 547{
565 void *p = malloc (nbytes); 548 void *p = malloc (nbytes);
566 if (p == NULL) 549 if (p == NULL)
@@ -575,9 +558,7 @@ xmalloc (nbytes)
575/* Like realloc but print an error and exit if out of memory. */ 558/* Like realloc but print an error and exit if out of memory. */
576 559
577void * 560void *
578xrealloc (p, sz) 561xrealloc (void *p, int sz)
579 void *p;
580 int sz;
581{ 562{
582 p = realloc (p, sz); 563 p = realloc (p, sz);
583 if (p == NULL) 564 if (p == NULL)
@@ -593,8 +574,7 @@ xrealloc (p, sz)
593 available.. If S is null, return null. */ 574 available.. If S is null, return null. */
594 575
595char * 576char *
596xstrdup (s) 577xstrdup (char *s)
597 char *s;
598{ 578{
599 if (s) 579 if (s)
600 s = strcpy (xmalloc (strlen (s) + 1), s); 580 s = strcpy (xmalloc (strlen (s) + 1), s);
@@ -611,7 +591,7 @@ xstrdup (s)
611 special symbol for globals (`*Globals*'). */ 591 special symbol for globals (`*Globals*'). */
612 592
613void 593void
614init_sym () 594init_sym (void)
615{ 595{
616 global_symbols = add_sym (GLOBALS_NAME, NULL); 596 global_symbols = add_sym (GLOBALS_NAME, NULL);
617} 597}
@@ -625,13 +605,11 @@ init_sym ()
625 create a new symbol and set it to default values. */ 605 create a new symbol and set it to default values. */
626 606
627struct sym * 607struct sym *
628add_sym (name, nested_in_class) 608add_sym (const char *name, struct sym *nested_in_class)
629 char *name;
630 struct sym *nested_in_class;
631{ 609{
632 struct sym *sym; 610 struct sym *sym;
633 unsigned h; 611 unsigned h;
634 char *s; 612 const char *s;
635 struct sym *scope = nested_in_class ? nested_in_class : current_namespace; 613 struct sym *scope = nested_in_class ? nested_in_class : current_namespace;
636 614
637 for (s = name, h = 0; *s; ++s) 615 for (s = name, h = 0; *s; ++s)
@@ -654,7 +632,7 @@ add_sym (name, nested_in_class)
654 } 632 }
655 633
656 sym = (struct sym *) xmalloc (sizeof *sym + strlen (name)); 634 sym = (struct sym *) xmalloc (sizeof *sym + strlen (name));
657 bzero (sym, sizeof *sym); 635 memset (sym, 0, sizeof *sym);
658 strcpy (sym->name, name); 636 strcpy (sym->name, name);
659 sym->namesp = scope; 637 sym->namesp = scope;
660 sym->next = class_table[h]; 638 sym->next = class_table[h];
@@ -668,8 +646,7 @@ add_sym (name, nested_in_class)
668/* Add links between superclass SUPER and subclass SUB. */ 646/* Add links between superclass SUPER and subclass SUB. */
669 647
670void 648void
671add_link (super, sub) 649add_link (struct sym *super, struct sym *sub)
672 struct sym *super, *sub;
673{ 650{
674 struct link *lnk, *lnk2, *p, *prev; 651 struct link *lnk, *lnk2, *p, *prev;
675 652
@@ -709,11 +686,7 @@ add_link (super, sub)
709 found or null if not found. */ 686 found or null if not found. */
710 687
711struct member * 688struct member *
712find_member (cls, name, var, sc, hash) 689find_member (struct sym *cls, char *name, int var, int sc, unsigned int hash)
713 struct sym *cls;
714 char *name;
715 int var, sc;
716 unsigned hash;
717{ 690{
718 struct member **list; 691 struct member **list;
719 struct member *p; 692 struct member *p;
@@ -763,16 +736,7 @@ find_member (cls, name, var, sc, hash)
763 F_* defines). */ 736 F_* defines). */
764 737
765void 738void
766add_member_decl (cls, name, regexp, pos, hash, var, sc, vis, flags) 739add_member_decl (struct sym *cls, char *name, char *regexp, int pos, unsigned int hash, int var, int sc, int vis, int flags)
767 struct sym *cls;
768 char *name;
769 char *regexp;
770 int pos;
771 unsigned hash;
772 int var;
773 int sc;
774 int vis;
775 int flags;
776{ 740{
777 struct member *m; 741 struct member *m;
778 742
@@ -820,15 +784,7 @@ add_member_decl (cls, name, regexp, pos, hash, var, sc, vis, flags)
820 F_* defines). */ 784 F_* defines). */
821 785
822void 786void
823add_member_defn (cls, name, regexp, pos, hash, var, sc, flags) 787add_member_defn (struct sym *cls, char *name, char *regexp, int pos, unsigned int hash, int var, int sc, int flags)
824 struct sym *cls;
825 char *name;
826 char *regexp;
827 int pos;
828 unsigned hash;
829 int var;
830 int sc;
831 int flags;
832{ 788{
833 struct member *m; 789 struct member *m;
834 790
@@ -870,9 +826,7 @@ add_member_defn (cls, name, regexp, pos, hash, var, sc, flags)
870 if it is non-null. POS is the position in the file. */ 826 if it is non-null. POS is the position in the file. */
871 827
872void 828void
873add_define (name, regexp, pos) 829add_define (char *name, char *regexp, int pos)
874 char *name, *regexp;
875 int pos;
876{ 830{
877 add_global_defn (name, regexp, pos, 0, 1, SC_FRIEND, F_DEFINE); 831 add_global_defn (name, regexp, pos, 0, 1, SC_FRIEND, F_DEFINE);
878 add_global_decl (name, regexp, pos, 0, 1, SC_FRIEND, F_DEFINE); 832 add_global_decl (name, regexp, pos, 0, 1, SC_FRIEND, F_DEFINE);
@@ -890,13 +844,7 @@ add_define (name, regexp, pos)
890 F_* defines). */ 844 F_* defines). */
891 845
892void 846void
893add_global_defn (name, regexp, pos, hash, var, sc, flags) 847add_global_defn (char *name, char *regexp, int pos, unsigned int hash, int var, int sc, int flags)
894 char *name, *regexp;
895 int pos;
896 unsigned hash;
897 int var;
898 int sc;
899 int flags;
900{ 848{
901 int i; 849 int i;
902 struct sym *sym; 850 struct sym *sym;
@@ -927,13 +875,7 @@ add_global_defn (name, regexp, pos, hash, var, sc, flags)
927 F_* defines). */ 875 F_* defines). */
928 876
929void 877void
930add_global_decl (name, regexp, pos, hash, var, sc, flags) 878add_global_decl (char *name, char *regexp, int pos, unsigned int hash, int var, int sc, int flags)
931 char *name, *regexp;
932 int pos;
933 unsigned hash;
934 int var;
935 int sc;
936 int flags;
937{ 879{
938 /* Add declaration only if not already declared. Header files must 880 /* Add declaration only if not already declared. Header files must
939 be processed before source files for this to have the right effect. 881 be processed before source files for this to have the right effect.
@@ -972,12 +914,7 @@ add_global_decl (name, regexp, pos, hash, var, sc, flags)
972 Value is a pointer to the member's structure. */ 914 Value is a pointer to the member's structure. */
973 915
974struct member * 916struct member *
975add_member (cls, name, var, sc, hash) 917add_member (struct sym *cls, char *name, int var, int sc, unsigned int hash)
976 struct sym *cls;
977 char *name;
978 int var;
979 int sc;
980 unsigned hash;
981{ 918{
982 struct member *m = (struct member *) xmalloc (sizeof *m + strlen (name)); 919 struct member *m = (struct member *) xmalloc (sizeof *m + strlen (name));
983 struct member **list; 920 struct member **list;
@@ -1048,8 +985,7 @@ add_member (cls, name, var, sc, hash)
1048 in base classes. */ 985 in base classes. */
1049 986
1050void 987void
1051mark_virtual (r) 988mark_virtual (struct sym *r)
1052 struct sym *r;
1053{ 989{
1054 struct link *p; 990 struct link *p;
1055 struct member *m, *m2; 991 struct member *m, *m2;
@@ -1073,7 +1009,7 @@ mark_virtual (r)
1073 are virtual because of a virtual declaration in a base class. */ 1009 are virtual because of a virtual declaration in a base class. */
1074 1010
1075void 1011void
1076mark_inherited_virtual () 1012mark_inherited_virtual (void)
1077{ 1013{
1078 struct sym *r; 1014 struct sym *r;
1079 int i; 1015 int i;
@@ -1088,12 +1024,10 @@ mark_inherited_virtual ()
1088/* Create and return a symbol for a namespace with name NAME. */ 1024/* Create and return a symbol for a namespace with name NAME. */
1089 1025
1090struct sym * 1026struct sym *
1091make_namespace (name, context) 1027make_namespace (char *name, struct sym *context)
1092 char *name;
1093 struct sym *context;
1094{ 1028{
1095 struct sym *s = (struct sym *) xmalloc (sizeof *s + strlen (name)); 1029 struct sym *s = (struct sym *) xmalloc (sizeof *s + strlen (name));
1096 bzero (s, sizeof *s); 1030 memset (s, 0, sizeof *s);
1097 strcpy (s->name, name); 1031 strcpy (s->name, name);
1098 s->next = all_namespaces; 1032 s->next = all_namespaces;
1099 s->namesp = context; 1033 s->namesp = context;
@@ -1105,9 +1039,7 @@ make_namespace (name, context)
1105/* Find the symbol for namespace NAME. If not found, retrun NULL */ 1039/* Find the symbol for namespace NAME. If not found, retrun NULL */
1106 1040
1107struct sym * 1041struct sym *
1108check_namespace (name, context) 1042check_namespace (char *name, struct sym *context)
1109 char *name;
1110 struct sym *context;
1111{ 1043{
1112 struct sym *p = NULL; 1044 struct sym *p = NULL;
1113 1045
@@ -1115,18 +1047,16 @@ check_namespace (name, context)
1115 { 1047 {
1116 if (streq (p->name, name) && (p->namesp == context)) 1048 if (streq (p->name, name) && (p->namesp == context))
1117 break; 1049 break;
1118 } 1050 }
1119 1051
1120 return p; 1052 return p;
1121 } 1053}
1122 1054
1123/* Find the symbol for namespace NAME. If not found, add a new symbol 1055/* Find the symbol for namespace NAME. If not found, add a new symbol
1124 for NAME to all_namespaces. */ 1056 for NAME to all_namespaces. */
1125 1057
1126struct sym * 1058struct sym *
1127find_namespace (name, context) 1059find_namespace (char *name, struct sym *context)
1128 char *name;
1129 struct sym *context;
1130{ 1060{
1131 struct sym *p = check_namespace (name, context); 1061 struct sym *p = check_namespace (name, context);
1132 1062
@@ -1140,8 +1070,7 @@ find_namespace (name, context)
1140/* Find namespace alias with name NAME. If not found return NULL. */ 1070/* Find namespace alias with name NAME. If not found return NULL. */
1141 1071
1142struct link * 1072struct link *
1143check_namespace_alias (name) 1073check_namespace_alias (char *name)
1144 char *name;
1145{ 1074{
1146 struct link *p = NULL; 1075 struct link *p = NULL;
1147 struct alias *al; 1076 struct alias *al;
@@ -1165,9 +1094,7 @@ check_namespace_alias (name)
1165/* Register the name NEW_NAME as an alias for namespace list OLD_NAME. */ 1094/* Register the name NEW_NAME as an alias for namespace list OLD_NAME. */
1166 1095
1167void 1096void
1168register_namespace_alias (new_name, old_name) 1097register_namespace_alias (char *new_name, struct link *old_name)
1169 char *new_name;
1170 struct link *old_name;
1171{ 1098{
1172 unsigned h; 1099 unsigned h;
1173 char *s; 1100 char *s;
@@ -1195,8 +1122,7 @@ register_namespace_alias (new_name, old_name)
1195/* Enter namespace with name NAME. */ 1122/* Enter namespace with name NAME. */
1196 1123
1197void 1124void
1198enter_namespace (name) 1125enter_namespace (char *name)
1199 char *name;
1200{ 1126{
1201 struct sym *p = find_namespace (name, current_namespace); 1127 struct sym *p = find_namespace (name, current_namespace);
1202 1128
@@ -1217,7 +1143,7 @@ enter_namespace (name)
1217/* Leave the current namespace. */ 1143/* Leave the current namespace. */
1218 1144
1219void 1145void
1220leave_namespace () 1146leave_namespace (void)
1221{ 1147{
1222 assert (namespace_sp > 0); 1148 assert (namespace_sp > 0);
1223 current_namespace = namespace_stack[--namespace_sp]; 1149 current_namespace = namespace_stack[--namespace_sp];
@@ -1259,8 +1185,7 @@ int scope_buffer_len;
1259/* Make sure scope_buffer has enough room to add LEN chars to it. */ 1185/* Make sure scope_buffer has enough room to add LEN chars to it. */
1260 1186
1261void 1187void
1262ensure_scope_buffer_room (len) 1188ensure_scope_buffer_room (int len)
1263 int len;
1264{ 1189{
1265 if (scope_buffer_len + len >= scope_buffer_size) 1190 if (scope_buffer_len + len >= scope_buffer_size)
1266 { 1191 {
@@ -1276,8 +1201,7 @@ ensure_scope_buffer_room (len)
1276 scope name constructed. */ 1201 scope name constructed. */
1277 1202
1278char * 1203char *
1279sym_scope_1 (p) 1204sym_scope_1 (struct sym *p)
1280 struct sym *p;
1281{ 1205{
1282 int len; 1206 int len;
1283 1207
@@ -1311,8 +1235,7 @@ sym_scope_1 (p)
1311 as it would appear in a C*+ source file. */ 1235 as it would appear in a C*+ source file. */
1312 1236
1313char * 1237char *
1314sym_scope (p) 1238sym_scope (struct sym *p)
1315 struct sym *p;
1316{ 1239{
1317 if (!scope_buffer) 1240 if (!scope_buffer)
1318 { 1241 {
@@ -1334,9 +1257,7 @@ sym_scope (p)
1334 list. */ 1257 list. */
1335 1258
1336int 1259int
1337dump_members (fp, m) 1260dump_members (FILE *fp, struct member *m)
1338 FILE *fp;
1339 struct member *m;
1340{ 1261{
1341 int n; 1262 int n;
1342 1263
@@ -1369,9 +1290,7 @@ dump_members (fp, m)
1369/* Dump class ROOT to stream FP. */ 1290/* Dump class ROOT to stream FP. */
1370 1291
1371void 1292void
1372dump_sym (fp, root) 1293dump_sym (FILE *fp, struct sym *root)
1373 FILE *fp;
1374 struct sym *root;
1375{ 1294{
1376 fputs (CLASS_STRUCT, fp); 1295 fputs (CLASS_STRUCT, fp);
1377 PUTSTR (root->name, fp); 1296 PUTSTR (root->name, fp);
@@ -1397,9 +1316,7 @@ dump_sym (fp, root)
1397 number of classes written. */ 1316 number of classes written. */
1398 1317
1399int 1318int
1400dump_tree (fp, root) 1319dump_tree (FILE *fp, struct sym *root)
1401 FILE *fp;
1402 struct sym *root;
1403{ 1320{
1404 struct link *lk; 1321 struct link *lk;
1405 unsigned n = 0; 1322 unsigned n = 0;
@@ -1446,8 +1363,7 @@ dump_tree (fp, root)
1446/* Dump the entire class tree to file FP. */ 1363/* Dump the entire class tree to file FP. */
1447 1364
1448void 1365void
1449dump_roots (fp) 1366dump_roots (FILE *fp)
1450 FILE *fp;
1451{ 1367{
1452 int i, n = 0; 1368 int i, n = 0;
1453 struct sym *r; 1369 struct sym *r;
@@ -1521,7 +1437,7 @@ do { \
1521 input buffer not consumed. */ 1437 input buffer not consumed. */
1522 1438
1523int 1439int
1524process_pp_line () 1440process_pp_line (void)
1525{ 1441{
1526 int in_comment = 0, in_string = 0; 1442 int in_comment = 0, in_string = 0;
1527 int c; 1443 int c;
@@ -1592,7 +1508,7 @@ process_pp_line ()
1592/* Value is the next token from the input buffer. */ 1508/* Value is the next token from the input buffer. */
1593 1509
1594int 1510int
1595yylex () 1511yylex (void)
1596{ 1512{
1597 int c; 1513 int c;
1598 char end_char; 1514 char end_char;
@@ -2009,7 +1925,7 @@ static char *matching_regexp_buffer, *matching_regexp_end_buf;
2009 shorter than min_regexp. */ 1925 shorter than min_regexp. */
2010 1926
2011char * 1927char *
2012matching_regexp () 1928matching_regexp (void)
2013{ 1929{
2014 char *p; 1930 char *p;
2015 char *s; 1931 char *s;
@@ -2059,9 +1975,8 @@ matching_regexp ()
2059 1975
2060/* Return a printable representation of token T. */ 1976/* Return a printable representation of token T. */
2061 1977
2062char * 1978const char *
2063token_string (t) 1979token_string (int t)
2064 int t;
2065{ 1980{
2066 static char b[3]; 1981 static char b[3];
2067 1982
@@ -2178,7 +2093,7 @@ token_string (t)
2178/* Reinitialize the scanner for a new input file. */ 2093/* Reinitialize the scanner for a new input file. */
2179 2094
2180void 2095void
2181re_init_scanner () 2096re_init_scanner (void)
2182{ 2097{
2183 in = inbuffer; 2098 in = inbuffer;
2184 yyline = 1; 2099 yyline = 1;
@@ -2196,11 +2111,9 @@ re_init_scanner ()
2196 table. */ 2111 table. */
2197 2112
2198void 2113void
2199insert_keyword (name, tk) 2114insert_keyword (const char *name, int tk)
2200 char *name;
2201 int tk;
2202{ 2115{
2203 char *s; 2116 const char *s;
2204 unsigned h = 0; 2117 unsigned h = 0;
2205 struct kw *k = (struct kw *) xmalloc (sizeof *k); 2118 struct kw *k = (struct kw *) xmalloc (sizeof *k);
2206 2119
@@ -2219,7 +2132,7 @@ insert_keyword (name, tk)
2219 character class vectors and fills the keyword hash table. */ 2132 character class vectors and fills the keyword hash table. */
2220 2133
2221void 2134void
2222init_scanner () 2135init_scanner (void)
2223{ 2136{
2224 int i; 2137 int i;
2225 2138
@@ -2363,8 +2276,7 @@ init_scanner ()
2363 the current lookahead token after skipping. */ 2276 the current lookahead token after skipping. */
2364 2277
2365int 2278int
2366skip_to (token) 2279skip_to (int token)
2367 int token;
2368{ 2280{
2369 while (!LOOKING_AT2 (YYEOF, token)) 2281 while (!LOOKING_AT2 (YYEOF, token))
2370 MATCH (); 2282 MATCH ();
@@ -2375,7 +2287,7 @@ skip_to (token)
2375 angle brackets, curly brackets) matching the current lookahead. */ 2287 angle brackets, curly brackets) matching the current lookahead. */
2376 2288
2377void 2289void
2378skip_matching () 2290skip_matching (void)
2379{ 2291{
2380 int open, close, n; 2292 int open, close, n;
2381 2293
@@ -2418,7 +2330,7 @@ skip_matching ()
2418} 2330}
2419 2331
2420void 2332void
2421skip_initializer () 2333skip_initializer (void)
2422{ 2334{
2423 for (;;) 2335 for (;;)
2424 { 2336 {
@@ -2445,7 +2357,7 @@ skip_initializer ()
2445/* Build qualified namespace alias (A::B::c) and return it. */ 2357/* Build qualified namespace alias (A::B::c) and return it. */
2446 2358
2447struct link * 2359struct link *
2448match_qualified_namespace_alias () 2360match_qualified_namespace_alias (void)
2449{ 2361{
2450 struct link *head = NULL; 2362 struct link *head = NULL;
2451 struct link *cur = NULL; 2363 struct link *cur = NULL;
@@ -2458,7 +2370,7 @@ match_qualified_namespace_alias ()
2458 { 2370 {
2459 case IDENT: 2371 case IDENT:
2460 tmp = (struct link *) xmalloc (sizeof *cur); 2372 tmp = (struct link *) xmalloc (sizeof *cur);
2461 tmp->sym = find_namespace (yytext, cur); 2373 tmp->sym = find_namespace (yytext, cur ? cur->sym : NULL);
2462 tmp->next = NULL; 2374 tmp->next = NULL;
2463 if (head) 2375 if (head)
2464 { 2376 {
@@ -2482,7 +2394,7 @@ match_qualified_namespace_alias ()
2482/* Re-initialize the parser by resetting the lookahead token. */ 2394/* Re-initialize the parser by resetting the lookahead token. */
2483 2395
2484void 2396void
2485re_init_parser () 2397re_init_parser (void)
2486{ 2398{
2487 tk = -1; 2399 tk = -1;
2488} 2400}
@@ -2495,8 +2407,7 @@ re_init_parser ()
2495 distinguish between overloaded functions. */ 2407 distinguish between overloaded functions. */
2496 2408
2497unsigned 2409unsigned
2498parm_list (flags) 2410parm_list (int *flags)
2499 int *flags;
2500{ 2411{
2501 unsigned hash = 0; 2412 unsigned hash = 0;
2502 int type_seen = 0; 2413 int type_seen = 0;
@@ -2609,7 +2520,7 @@ parm_list (flags)
2609/* Print position info to stdout. */ 2520/* Print position info to stdout. */
2610 2521
2611void 2522void
2612print_info () 2523print_info (void)
2613{ 2524{
2614 if (info_position >= 0 && BUFFER_POS () <= info_position) 2525 if (info_position >= 0 && BUFFER_POS () <= info_position)
2615 if (info_cls) 2526 if (info_cls)
@@ -2624,9 +2535,7 @@ print_info ()
2624 public). */ 2535 public). */
2625 2536
2626void 2537void
2627member (cls, vis) 2538member (struct sym *cls, int vis)
2628 struct sym *cls;
2629 int vis;
2630{ 2539{
2631 char *id = NULL; 2540 char *id = NULL;
2632 int sc = SC_MEMBER; 2541 int sc = SC_MEMBER;
@@ -2835,9 +2744,7 @@ member (cls, vis)
2835 union, class). */ 2744 union, class). */
2836 2745
2837void 2746void
2838class_body (cls, tag) 2747class_body (struct sym *cls, int tag)
2839 struct sym *cls;
2840 int tag;
2841{ 2748{
2842 int vis = tag == CLASS ? PRIVATE : PUBLIC; 2749 int vis = tag == CLASS ? PRIVATE : PUBLIC;
2843 int temp; 2750 int temp;
@@ -2898,7 +2805,7 @@ class_body (cls, tag)
2898 symbol for that class. */ 2805 symbol for that class. */
2899 2806
2900struct sym * 2807struct sym *
2901parse_classname () 2808parse_classname (void)
2902{ 2809{
2903 struct sym *last_class = NULL; 2810 struct sym *last_class = NULL;
2904 2811
@@ -2928,12 +2835,11 @@ parse_classname ()
2928 a static buffer holding the constructed operator name string. */ 2835 a static buffer holding the constructed operator name string. */
2929 2836
2930char * 2837char *
2931operator_name (sc) 2838operator_name (int *sc)
2932 int *sc;
2933{ 2839{
2934 static int id_size = 0; 2840 static int id_size = 0;
2935 static char *id = NULL; 2841 static char *id = NULL;
2936 char *s; 2842 const char *s;
2937 int len; 2843 int len;
2938 2844
2939 MATCH (); 2845 MATCH ();
@@ -3019,8 +2925,7 @@ operator_name (sc)
3019 symbol structure for the ident. */ 2925 symbol structure for the ident. */
3020 2926
3021struct sym * 2927struct sym *
3022parse_qualified_ident_or_type (last_id) 2928parse_qualified_ident_or_type (char **last_id)
3023 char **last_id;
3024{ 2929{
3025 struct sym *cls = NULL; 2930 struct sym *cls = NULL;
3026 char *id = NULL; 2931 char *id = NULL;
@@ -3085,8 +2990,7 @@ parse_qualified_ident_or_type (last_id)
3085 symbol structure for the ident. */ 2990 symbol structure for the ident. */
3086 2991
3087void 2992void
3088parse_qualified_param_ident_or_type (last_id) 2993parse_qualified_param_ident_or_type (char **last_id)
3089 char **last_id;
3090{ 2994{
3091 struct sym *cls = NULL; 2995 struct sym *cls = NULL;
3092 static char *id = NULL; 2996 static char *id = NULL;
@@ -3128,11 +3032,7 @@ parse_qualified_param_ident_or_type (last_id)
3128 Current lookahead is the class name. */ 3032 Current lookahead is the class name. */
3129 3033
3130void 3034void
3131class_definition (containing, tag, flags, nested) 3035class_definition (struct sym *containing, int tag, int flags, int nested)
3132 struct sym *containing;
3133 int tag;
3134 int flags;
3135 int nested;
3136{ 3036{
3137 struct sym *current; 3037 struct sym *current;
3138 struct sym *base_class; 3038 struct sym *base_class;
@@ -3229,10 +3129,7 @@ class_definition (containing, tag, flags, nested)
3229 information about the member (see the F_* defines). */ 3129 information about the member (see the F_* defines). */
3230 3130
3231void 3131void
3232add_declarator (cls, id, flags, sc) 3132add_declarator (struct sym **cls, char **id, int flags, int sc)
3233 struct sym **cls;
3234 char **id;
3235 int flags, sc;
3236{ 3133{
3237 if (LOOKING_AT2 (';', ',')) 3134 if (LOOKING_AT2 (';', ','))
3238 { 3135 {
@@ -3275,8 +3172,7 @@ add_declarator (cls, id, flags, sc)
3275/* Parse a declaration. */ 3172/* Parse a declaration. */
3276 3173
3277void 3174void
3278declaration (flags) 3175declaration (int flags)
3279 int flags;
3280{ 3176{
3281 char *id = NULL; 3177 char *id = NULL;
3282 struct sym *cls = NULL; 3178 struct sym *cls = NULL;
@@ -3430,8 +3326,7 @@ declaration (flags)
3430 otherwise. */ 3326 otherwise. */
3431 3327
3432int 3328int
3433globals (start_flags) 3329globals (int start_flags)
3434 int start_flags;
3435{ 3330{
3436 int anonymous; 3331 int anonymous;
3437 int class_tk; 3332 int class_tk;
@@ -3549,7 +3444,7 @@ globals (start_flags)
3549/* Parse the current input file. */ 3444/* Parse the current input file. */
3550 3445
3551void 3446void
3552yyparse () 3447yyparse (void)
3553{ 3448{
3554 while (globals (0) == 0) 3449 while (globals (0) == 0)
3555 MATCH_IF ('}'); 3450 MATCH_IF ('}');
@@ -3565,8 +3460,7 @@ yyparse ()
3565 input files. */ 3460 input files. */
3566 3461
3567void 3462void
3568add_search_path (path_list) 3463add_search_path (char *path_list)
3569 char *path_list;
3570{ 3464{
3571 while (*path_list) 3465 while (*path_list)
3572 { 3466 {
@@ -3601,8 +3495,7 @@ add_search_path (path_list)
3601 unchanged file name. */ 3495 unchanged file name. */
3602 3496
3603FILE * 3497FILE *
3604open_file (file) 3498open_file (char *file)
3605 char *file;
3606{ 3499{
3607 FILE *fp = NULL; 3500 FILE *fp = NULL;
3608 static char *buffer; 3501 static char *buffer;
@@ -3661,8 +3554,7 @@ Usage: ebrowse [options] {files}\n\
3661" 3554"
3662 3555
3663void 3556void
3664usage (error) 3557usage (int error)
3665 int error;
3666{ 3558{
3667 puts (USAGE); 3559 puts (USAGE);
3668 exit (error ? EXIT_FAILURE : EXIT_SUCCESS); 3560 exit (error ? EXIT_FAILURE : EXIT_SUCCESS);
@@ -3677,7 +3569,7 @@ usage (error)
3677#endif 3569#endif
3678 3570
3679void 3571void
3680version () 3572version (void)
3681{ 3573{
3682 /* Makes it easier to update automatically. */ 3574 /* Makes it easier to update automatically. */
3683 char emacs_copyright[] = "Copyright (C) 2010 Free Software Foundation, Inc."; 3575 char emacs_copyright[] = "Copyright (C) 2010 Free Software Foundation, Inc.";
@@ -3693,8 +3585,7 @@ version ()
3693 table. */ 3585 table. */
3694 3586
3695void 3587void
3696process_file (file) 3588process_file (char *file)
3697 char *file;
3698{ 3589{
3699 FILE *fp; 3590 FILE *fp;
3700 3591
@@ -3749,8 +3640,7 @@ process_file (file)
3749 is null when EOF is reached. */ 3640 is null when EOF is reached. */
3750 3641
3751char * 3642char *
3752read_line (fp) 3643read_line (FILE *fp)
3753 FILE *fp;
3754{ 3644{
3755 static char *buffer; 3645 static char *buffer;
3756 static int buffer_size; 3646 static int buffer_size;
@@ -3786,13 +3676,11 @@ read_line (fp)
3786/* Main entry point. */ 3676/* Main entry point. */
3787 3677
3788int 3678int
3789main (argc, argv) 3679main (int argc, char **argv)
3790 int argc;
3791 char **argv;
3792{ 3680{
3793 int i; 3681 int i;
3794 int any_inputfiles = 0; 3682 int any_inputfiles = 0;
3795 static char *out_filename = DEFAULT_OUTFILE; 3683 static const char *out_filename = DEFAULT_OUTFILE;
3796 static char **input_filenames = NULL; 3684 static char **input_filenames = NULL;
3797 static int input_filenames_size = 0; 3685 static int input_filenames_size = 0;
3798 static int n_input_files; 3686 static int n_input_files;