MCPcopy Index your code
hub / github.com/NetHack/NetHack / debugcore

Function debugcore

src/files.c:3125–3166  ·  view source on GitHub ↗

used by debugpline() to decide whether to issue a message * from a particular source file; caller passes __FILE__ and we check * whether it is in the source file list supplied by SYSCF's DEBUGFILES * * pass FALSE to override wildcard matching; useful for files * like dungeon.c and questpgr.c, which generate a ridiculous amount of * output if DEBUG is defined and effectively block the use of

Source from the content-addressed store, hash-verified

3123 * like dungeon.c and questpgr.c, which generate a ridiculous amount of
3124 * output if DEBUG is defined and effectively block the use of a wildcard */
3125boolean
3126debugcore(const char *filename, boolean wildcards)
3127{
3128 const char *debugfiles, *p;
3129
3130 /* debugpline() messages might disclose information that the player
3131 doesn't normally get to see, so only display them in wizard mode */
3132 if (!wizard)
3133 return FALSE;
3134
3135 if (!filename || !*filename)
3136 return FALSE; /* sanity precaution */
3137
3138 debugfiles = sysopt.debugfiles;
3139 /* usual case: sysopt.debugfiles will be empty */
3140 if (!debugfiles || !*debugfiles)
3141 return FALSE;
3142
3143 /* strip filename's path if present */
3144 filename = nh_basename(filename, TRUE);
3145
3146 /*
3147 * Wildcard match will only work if there's a single pattern (which
3148 * might be a single file name without any wildcarding) rather than
3149 * a space-separated list.
3150 * [to NOT do: We could step through the space-separated list and
3151 * attempt a wildcard match against each element, but that would be
3152 * overkill for the intended usage.]
3153 */
3154 if (wildcards && pmatch(debugfiles, filename))
3155 return TRUE;
3156
3157 /* check whether filename is an element of the list */
3158 if ((p = strstr(debugfiles, filename)) != 0) {
3159 int l = (int) strlen(filename);
3160
3161 if ((p == debugfiles || p[-1] == ' ' || p[-1] == '/')
3162 && (p[l] == ' ' || p[l] == '\0'))
3163 return TRUE;
3164 }
3165 return FALSE;
3166}
3167
3168#endif /*DEBUG*/
3169

Callers

nothing calls this directly

Calls 2

nh_basenameFunction · 0.85
pmatchFunction · 0.85

Tested by

no test coverage detected