2008-04-16 Johannes Schmid <jhs@gnome.org>
[anjuta-git-plugin.git] / tagmanager / debug.c
blob24a1c20d30379c731cfaba9a4168314e550bf44a
1 /*
2 * $Id$
4 * Copyright (c) 1996-2002, Darren Hiebert
6 * This source code is released for free distribution under the terms of the
7 * GNU General Public License.
9 * This module contains debugging functions.
13 * INCLUDE FILES
15 #include "general.h" /* must always come first */
17 #include <ctype.h>
18 #include <stdarg.h>
20 #include "debug.h"
21 #include "options.h"
22 #include "read.h"
25 * FUNCTION DEFINITIONS
28 #ifdef DEBUG
30 extern void lineBreak (void) {} /* provides a line-specified break point */
32 extern void debugPrintf (
33 const enum eDebugLevels level, const char *const format, ... )
35 va_list ap;
37 va_start (ap, format);
38 if (debug (level))
39 vprintf (format, ap);
40 fflush (stdout);
41 va_end (ap);
44 extern void debugPutc (const int level, const int c)
46 if (debug (level) && c != EOF)
48 if (c == STRING_SYMBOL) printf ("\"string\"");
49 else if (c == CHAR_SYMBOL) printf ("'c'");
50 else putchar (c);
52 fflush (stdout);
56 extern void debugParseNest (const boolean increase, const unsigned int level)
58 debugPrintf (DEBUG_PARSE, "<*%snesting:%d*>", increase ? "++" : "--", level);
61 extern void debugCppNest (const boolean begin, const unsigned int level)
63 debugPrintf (DEBUG_CPP, "<*cpp:%s level %d*>", begin ? "begin":"end", level);
66 extern void debugCppIgnore (const boolean ignore)
68 debugPrintf (DEBUG_CPP, "<*cpp:%s ignore*>", ignore ? "begin":"end");
71 extern void clearString (char *const string, const int length)
73 int i;
74 for (i = 0 ; i < length ; ++i)
75 string [i] = '\0';
78 extern void debugEntry (const tagEntryInfo *const tag)
80 const char *const scope = tag->isFileScope ? "{fs}" : "";
82 if (debug (DEBUG_PARSE))
84 printf ("<#%s%s:%s", scope, tag->kindName, tag->name);
86 if (tag->extensionFields.scope [0] != NULL &&
87 tag->extensionFields.scope [1] != NULL)
88 printf (" [%s:%s]", tag->extensionFields.scope [0],
89 tag->extensionFields.scope [1]);
91 if (Option.extensionFields.inheritance &&
92 tag->extensionFields.inheritance != NULL)
93 printf (" [inherits:%s]", tag->extensionFields.inheritance);
95 if (Option.extensionFields.fileScope &&
96 tag->isFileScope && ! isHeaderFile ())
97 printf (" [file:]");
99 if (Option.extensionFields.access &&
100 tag->extensionFields.access != NULL)
101 printf (" [access:%s]", tag->extensionFields.access);
103 if (Option.extensionFields.implementation &&
104 tag->extensionFields.implementation != NULL)
105 printf (" [imp:%s]", tag->extensionFields.implementation);
107 if (Option.extensionFields.typeRef &&
108 tag->extensionFields.typeRef [0] != NULL &&
109 tag->extensionFields.typeRef [1] != NULL)
110 printf (" [%s:%s]", tag->extensionFields.typeRef [0],
111 tag->extensionFields.typeRef [1]);
113 printf ("#>");
114 fflush (stdout);
118 #endif
120 /* vi:set tabstop=4 shiftwidth=4: */