GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: lib/libcurses/trace/trace_tries.c Lines: 0 0 0.0 %
Date: 2017-11-13 Branches: 0 0 0.0 %

Line Branch Exec Source
1
/* $OpenBSD: trace_tries.c,v 1.5 2010/01/12 23:22:07 nicm Exp $ */
2
3
/****************************************************************************
4
 * Copyright (c) 1999-2007,2008 Free Software Foundation, Inc.              *
5
 *                                                                          *
6
 * Permission is hereby granted, free of charge, to any person obtaining a  *
7
 * copy of this software and associated documentation files (the            *
8
 * "Software"), to deal in the Software without restriction, including      *
9
 * without limitation the rights to use, copy, modify, merge, publish,      *
10
 * distribute, distribute with modifications, sublicense, and/or sell       *
11
 * copies of the Software, and to permit persons to whom the Software is    *
12
 * furnished to do so, subject to the following conditions:                 *
13
 *                                                                          *
14
 * The above copyright notice and this permission notice shall be included  *
15
 * in all copies or substantial portions of the Software.                   *
16
 *                                                                          *
17
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
18
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
19
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
20
 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
21
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
22
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
23
 * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
24
 *                                                                          *
25
 * Except as contained in this notice, the name(s) of the above copyright   *
26
 * holders shall not be used in advertising or otherwise to promote the     *
27
 * sale, use or other dealings in this Software without prior written       *
28
 * authorization.                                                           *
29
 ****************************************************************************/
30
31
/****************************************************************************
32
 *  Author: Thomas E. Dickey <dickey@clark.net> 1999                        *
33
 ****************************************************************************/
34
/*
35
 *	trace_tries.c - Tracing/Debugging buffers (keycode tries-trees)
36
 */
37
38
#include <curses.priv.h>
39
40
MODULE_ID("$Id: trace_tries.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
41
42
#ifdef TRACE
43
#define my_buffer _nc_globals.tracetry_buf
44
#define my_length _nc_globals.tracetry_used
45
46
static void
47
recur_tries(TRIES * tree, unsigned level)
48
{
49
    if (level > my_length) {
50
	my_length = (level + 1) * 4;
51
	my_buffer = (unsigned char *) realloc(my_buffer, my_length);
52
    }
53
54
    while (tree != 0) {
55
	if ((my_buffer[level] = tree->ch) == 0)
56
	    my_buffer[level] = 128;
57
	my_buffer[level + 1] = 0;
58
	if (tree->value != 0) {
59
	    _tracef("%5d: %s (%s)", tree->value,
60
		    _nc_visbuf((char *) my_buffer), keyname(tree->value));
61
	}
62
	if (tree->child)
63
	    recur_tries(tree->child, level + 1);
64
	tree = tree->sibling;
65
    }
66
}
67
68
NCURSES_EXPORT(void)
69
_nc_trace_tries(TRIES * tree)
70
{
71
    my_buffer = typeMalloc(unsigned char, my_length = 80);
72
    _tracef("BEGIN tries %p", tree);
73
    recur_tries(tree, 0);
74
    _tracef(". . . tries %p", tree);
75
    free(my_buffer);
76
}
77
78
#else
79
NCURSES_EXPORT(void)
80
_nc_trace_tries(TRIES * tree)
81
{
82
}
83
#endif