| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
#include "../../src/trace.h" |
| 35 |
#include "../../src/commands.h" |
| 36 |
#include "../../src/debug.h" |
| 37 |
#include "../../src/main.h" |
| 38 |
#include "../cmd.h" |
| 39 |
#include "../fns.h" |
| 40 |
#include "../msg.h" |
| 41 |
#include "../subcmd.h" |
| 42 |
|
| 43 |
#ifdef HAVE_LIBREADLINE |
| 44 |
#include <stdio.h> |
| 45 |
#include <stdlib.h> |
| 46 |
|
| 47 |
#undef HAVE_READLINE_READLINE_H |
| 48 |
#include <readline/readline.h> |
| 49 |
|
| 50 |
|
| 51 |
#ifndef whitespace |
| 52 |
#define whitespace(c) (((c) == ' ') || ((c) == '\t')) |
| 53 |
#endif |
| 54 |
#endif |
| 55 |
|
| 56 |
subcommand_var_info_t set_subcommands[] = { |
| 57 |
{ "basename", |
| 58 |
"Set if we are to show short or long filenames", |
| 59 |
" {on|off|toggle} \n\nSet if we are to show short or long filenames.", |
| 60 |
&basename_filenames, true, 1}, |
| 61 |
{ "debug", |
| 62 |
"Set GNU Make debug mask (set via --debug or -d)", |
| 63 |
" VALUE \n\nSet GNU Make debug mask (set via --debug or -d).", |
| 64 |
&db_level, false, 3}, |
| 65 |
{ "ignore-errors", |
| 66 |
"Set value of GNU Make --ignore-errors (or -i) flag", |
| 67 |
" {on|off|toggle} \n\nSet value of GNU Make --ignore-errors (or -i) flag.", |
| 68 |
&ignore_errors_flag, true, 3}, |
| 69 |
{ "keep-going", |
| 70 |
"Set value of GNU Make --keep-going (or -k) flag", |
| 71 |
" {on|off|toggle}\n\nSet value of GNU Make --keep-going (or -k) flag.", |
| 72 |
&keep_going_flag, true, 1}, |
| 73 |
{ "silent", |
| 74 |
"Set value of GNU Make --silent (or -s) flags.", |
| 75 |
" {on|off|toggle} \n\nSet value of GNU Make --silent (or -s) flags.", |
| 76 |
&silent_flag, true, 1}, |
| 77 |
#ifdef FIXED |
| 78 |
{ "trace", |
| 79 |
"Set value of shell_tracing.", |
| 80 |
NULL, |
| 81 |
&no_shell_trace, false, 3}, |
| 82 |
#endif |
| 83 |
{ "variable", |
| 84 |
"Change a debugger setting", |
| 85 |
" OPTION is one of: basename, debug, ignore-errors, keep-going, or silent\n\n" |
| 86 |
"\n" |
| 87 |
"See also 'setq' and 'setqx' for setting a GNU Make variable.", |
| 88 |
NULL, |
| 89 |
false, 0}, |
| 90 |
{ NULL, NULL, NULL, NULL, false, 0} |
| 91 |
}; |
| 92 |
|
| 93 |
static bool |
| 94 |
dbg_cmd_set_bool(const char *psz_varname, const char *psz_flag_name, |
| 95 |
const char *psz_flag_value, |
| 96 |
unsigned int min, int *p_bool_flag) |
| 97 |
{ |
| 98 |
if (is_abbrev_of (psz_varname, psz_flag_name, min)) { |
| 99 |
if (!psz_flag_value || 0==strlen(psz_flag_value)) |
| 100 |
on_off_toggle(psz_flag_value, p_bool_flag); |
| 101 |
else |
| 102 |
on_off_toggle(psz_flag_value, p_bool_flag); |
| 103 |
dbg_cmd_show((char *) psz_flag_name); |
| 104 |
return true; |
| 105 |
} |
| 106 |
return false; |
| 107 |
} |
| 108 |
|
| 109 |
|
| 110 |
extern debug_return_t |
| 111 |
dbg_cmd_set(char *psz_args) |
| 112 |
{ |
| 113 |
if (!psz_args || 0==strlen(psz_args)) { |
| 114 |
unsigned int i; |
| 115 |
for (i = 0; set_subcommands[i].name; i++) { |
| 116 |
dbg_help_subcmd_entry("set", "%-10s -- %s", |
| 117 |
&(set_subcommands[i]), false); |
| 118 |
} |
| 119 |
return debug_readloop; |
| 120 |
} else { |
| 121 |
char *psz_varname = get_word(&psz_args); |
| 122 |
subcommand_var_info_t *p_subcmd_info; |
| 123 |
|
| 124 |
while (*psz_args && whitespace (*psz_args)) |
| 125 |
*psz_args +=1; |
| 126 |
|
| 127 |
|
| 128 |
if (is_abbrev_of (psz_varname, "debug", 3)) { |
| 129 |
int dbg_mask; |
| 130 |
if (get_int(psz_args, &dbg_mask, true)) { |
| 131 |
db_level = dbg_mask; |
| 132 |
} |
| 133 |
dbg_cmd_show(psz_varname); |
| 134 |
return debug_readloop; |
| 135 |
} else if (is_abbrev_of (psz_varname, "variable", 3)) { |
| 136 |
|
| 137 |
return dbg_cmd_set_var(psz_args, 1); |
| 138 |
#if FIXME_SET_ARGS |
| 139 |
} else if (is_abbrev_of (psz_varname, "args", 3)) { |
| 140 |
... |
| 141 |
#endif |
| 142 |
} else |
| 143 |
for (p_subcmd_info = set_subcommands; p_subcmd_info && p_subcmd_info->name; |
| 144 |
p_subcmd_info++) { |
| 145 |
if (dbg_cmd_set_bool(psz_varname, p_subcmd_info->name, |
| 146 |
psz_args, p_subcmd_info->min_abbrev, |
| 147 |
p_subcmd_info->var)) |
| 148 |
return debug_readloop; |
| 149 |
} |
| 150 |
dbg_errmsg("Unknown set option %s\nSee 'help set' for options. Or did you mean setq?\n", |
| 151 |
psz_varname); |
| 152 |
return debug_cmd_error; |
| 153 |
} |
| 154 |
} |
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|