#define SEEK_END 2
#endif
-/* Conditionalize function prototypes. */
-
-/* Value is non-zero if strings X and Y compare equal. */
-
-#define streq(X, Y) (*(X) == *(Y) && strcmp ((X) + 1, (Y) + 1) == 0)
-
#include <min-max.h>
/* Files are read in chunks of this number of bytes. */
-#define READ_CHUNK_SIZE (100 * 1024)
+enum { READ_CHUNK_SIZE = 100 * 1024 };
-#if defined (__MSDOS__)
-#define FILENAME_EQ(X,Y) (strcasecmp (X,Y) == 0)
-#else
-#if defined (WINDOWSNT)
-#define FILENAME_EQ(X,Y) (stricmp (X,Y) == 0)
+/* Value is true if strings X and Y compare equal. */
+
+static bool
+streq (char const *x, char const *y)
+{
+ return strcmp (x, y) == 0;
+}
+
+static bool
+filename_eq (char const *x, char const *y)
+{
+#ifdef __MSDOS__
+ return strcasecmp (x, y) == 0;
+#elif defined WINDOWSNT
+ return stricmp (x, y) == 0;
#else
-#define FILENAME_EQ(X,Y) (streq (X,Y))
-#endif
+ return streq (x, y);
#endif
+}
+
/* The default output file name. */
#define DEFAULT_OUTFILE "BROWSE"
#define F_EXTERNC 256 /* Is declared extern "C". */
#define F_DEFINE 512 /* Is a #define. */
-/* Two macros to set and test a bit in an int. */
+/* Set and test a bit in an int. */
-#define SET_FLAG(F, FLAG) ((F) |= (FLAG))
-#define HAS_FLAG(F, FLAG) (((F) & (FLAG)) != 0)
+static void
+set_flag (int *f, int flag)
+{
+ *f |= flag;
+}
+
+static bool
+has_flag (int f, int flag)
+{
+ return (f & flag) != 0;
+}
/* Structure describing a class member. */
m = add_member (cls, name, var, sc, hash);
/* Have we seen a new filename? If so record that. */
- if (!cls->filename || !FILENAME_EQ (cls->filename, filename))
+ if (!cls->filename || !filename_eq (cls->filename, filename))
m->filename = filename;
m->regexp = regexp;
if (!cls->sfilename)
cls->sfilename = filename;
- if (!FILENAME_EQ (cls->sfilename, filename))
+ if (!filename_eq (cls->sfilename, filename))
m->def_filename = filename;
m->def_regexp = regexp;
if (!found)
{
if (!global_symbols->filename
- || !FILENAME_EQ (global_symbols->filename, filename))
+ || !filename_eq (global_symbols->filename, filename))
m->filename = filename;
m->regexp = regexp;
for (p = r->subs; p; p = p->next)
{
for (m = r->fns; m; m = m->next)
- if (HAS_FLAG (m->flags, F_VIRTUAL))
+ if (has_flag (m->flags, F_VIRTUAL))
{
for (m2 = p->sym->fns; m2; m2 = m2->next)
if (m->param_hash == m2->param_hash && streq (m->name, m2->name))
- SET_FLAG (m2->flags, F_VIRTUAL);
+ set_flag (&m2->flags, F_VIRTUAL);
}
mark_virtual (p->sym);
strcpy (scope_buffer + scope_buffer_len, p->name);
scope_buffer_len += len;
- if (HAS_FLAG (p->flags, F_TEMPLATE))
+ if (has_flag (p->flags, F_TEMPLATE))
{
ensure_scope_buffer_room (3);
strcpy (scope_buffer + scope_buffer_len, "<>");
{
/* We can overload the same function on `const' */
hash = (hash << 1) ^ CONST;
- SET_FLAG (*flags, F_CONST);
+ set_flag (flags, F_CONST);
MATCH ();
}
{
MATCH ();
SKIP_MATCHING_IF ('(');
- SET_FLAG (*flags, F_THROW);
+ set_flag (flags, F_THROW);
}
if (LOOKING_AT ('='))
if (LOOKING_AT (CINT) && yyival == 0)
{
MATCH ();
- SET_FLAG (*flags, F_PURE);
+ set_flag (flags, F_PURE);
}
}
}
/* A function or class may follow. */
case TEMPLATE:
MATCH ();
- SET_FLAG (flags, F_TEMPLATE);
+ set_flag (&flags, F_TEMPLATE);
/* Skip over template argument list */
SKIP_MATCHING_IF ('<');
break;
case EXPLICIT:
- SET_FLAG (flags, F_EXPLICIT);
+ set_flag (&flags, F_EXPLICIT);
goto typeseen;
case MUTABLE:
- SET_FLAG (flags, F_MUTABLE);
+ set_flag (&flags, F_MUTABLE);
goto typeseen;
case T_INLINE:
- SET_FLAG (flags, F_INLINE);
+ set_flag (&flags, F_INLINE);
goto typeseen;
case VIRTUAL:
- SET_FLAG (flags, F_VIRTUAL);
+ set_flag (&flags, F_VIRTUAL);
goto typeseen;
case '[':
if (LOOKING_AT ('<'))
{
skip_matching ();
- SET_FLAG (last_class->flags, F_TEMPLATE);
+ set_flag (&last_class->flags, F_TEMPLATE);
}
if (!LOOKING_AT (DCOLON))
break;
case T_INLINE:
- SET_FLAG (flags, F_INLINE);
+ set_flag (&flags, F_INLINE);
MATCH ();
break;
MATCH_IF ('}');
}
else
- SET_FLAG (flags, F_EXTERNC);
+ set_flag (&flags, F_EXTERNC);
}
break;
case TEMPLATE:
MATCH ();
SKIP_MATCHING_IF ('<');
- SET_FLAG (flags, F_TEMPLATE);
+ set_flag (&flags, F_TEMPLATE);
break;
case CLASS: case STRUCT: case UNION:
# define CTAGS false
#endif
-#define streq(s,t) (assert ((s)!=NULL || (t)!=NULL), !strcmp (s, t))
-#define strcaseeq(s,t) (assert ((s)!=NULL && (t)!=NULL), !c_strcasecmp (s, t))
-#define strneq(s,t,n) (assert ((s)!=NULL || (t)!=NULL), !strncmp (s, t, n))
-#define strncaseeq(s,t,n) (assert ((s)!=NULL && (t)!=NULL), !c_strncasecmp (s, t, n))
+static bool
+streq (char const *s, char const *t)
+{
+ return strcmp (s, t) == 0;
+}
+
+static bool
+strcaseeq (char const *s, char const *t)
+{
+ return c_strcasecmp (s, t) == 0;
+}
+
+static bool
+strneq (char const *s, char const *t, size_t n)
+{
+ return strncmp (s, t, n) == 0;
+}
+
+static bool
+strncaseeq (char const *s, char const *t, size_t n)
+{
+ return c_strncasecmp (s, t, n) == 0;
+}
/* C is not in a name. */
static bool