/* ebrowse.c --- parsing files for the ebrowse C++ browser
-Copyright (C) 1992-2013 Free Software Foundation, Inc.
+Copyright (C) 1992-2014 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#include <config.h>
+#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *def_regexp; /* Regular expression matching definition. */
const char *def_filename; /* File name of definition. */
int def_pos; /* Buffer position of definition. */
- char name[1]; /* Member name. */
+ char name[FLEXIBLE_ARRAY_MEMBER]; /* Member name. */
};
/* Structures of this type are used to connect class structures with
struct alias *next; /* Next in list. */
struct sym *namesp; /* Namespace in which defined. */
struct link *aliasee; /* List of aliased namespaces (A::B::C...). */
- char name[1]; /* Alias name. */
+ char name[FLEXIBLE_ARRAY_MEMBER]; /* Alias name. */
};
/* The structure used to describe a class in the symbol table,
const char *filename; /* File in which it can be found. */
const char *sfilename; /* File in which members can be found. */
struct sym *namesp; /* Namespace in which defined. . */
- char name[1]; /* Name of the class. */
+ char name[FLEXIBLE_ARRAY_MEMBER]; /* Name of the class. */
};
/* Experimental: Print info for `--position-info'. We print
xstrdup (char *s)
{
if (s)
- s = strcpy (xmalloc (strlen (s) + 1), s);
+ return strcpy (xmalloc (strlen (s) + 1), s);
return s;
}
puts (name);
}
- sym = (struct sym *) xmalloc (sizeof *sym + strlen (name));
- memset (sym, 0, sizeof *sym);
+ sym = xmalloc (offsetof (struct sym, name) + strlen (name) + 1);
+ memset (sym, 0, offsetof (struct sym, name));
strcpy (sym->name, name);
sym->namesp = scope;
sym->next = class_table[h];
static struct member *
add_member (struct sym *cls, char *name, int var, int sc, unsigned int hash)
{
- struct member *m = (struct member *) xmalloc (sizeof *m + strlen (name));
+ struct member *m = xmalloc (offsetof (struct member, name)
+ + strlen (name) + 1);
struct member **list;
struct member *p;
struct member *prev;
static struct sym *
make_namespace (char *name, struct sym *context)
{
- struct sym *s = (struct sym *) xmalloc (sizeof *s + strlen (name));
- memset (s, 0, sizeof *s);
+ struct sym *s = xmalloc (offsetof (struct sym, name) + strlen (name) + 1);
+ memset (s, 0, offsetof (struct sym, name));
strcpy (s->name, name);
s->next = all_namespaces;
s->namesp = context;
if (streq (new_name, al->name) && (al->namesp == current_namespace))
return;
- al = (struct alias *) xmalloc (sizeof *al + strlen (new_name));
+ al = xmalloc (offsetof (struct alias, name) + strlen (new_name) + 1);
strcpy (al->name, new_name);
al->next = namespace_alias_table[h];
al->namesp = current_namespace;
/* Write string S to the output file FP in a Lisp-readable form.
If S is null, write out `()'. */
-static inline void
+static void
putstr (const char *s, FILE *fp)
{
if (!s)
/* Display usage information and exit program. */
-#define USAGE "\
+static char const *const usage_message[] =
+ {
+ "\
Usage: ebrowse [options] {files}\n\
\n\
-a, --append append output to existing file\n\
-I, --search-path=LIST set search path for input files\n\
-m, --min-regexp-length=N set minimum regexp length to N\n\
-M, --max-regexp-length=N set maximum regexp length to N\n\
+",
+ "\
-n, --no-nested-classes exclude nested classes\n\
-o, --output-file=FILE set output file name to FILE\n\
-p, --position-info print info about position in file\n\
-x, --no-regexps don't record regular expressions\n\
--help display this help\n\
--version display version info\n\
+\n\
"
+ };
static _Noreturn void
usage (int error)
{
- puts (USAGE);
+ int i;
+ for (i = 0; i < sizeof usage_message / sizeof *usage_message; i++)
+ fputs (usage_message[i], stdout);
exit (error ? EXIT_FAILURE : EXIT_SUCCESS);
}