remake  4.3+dbg-1.5
set.h
Go to the documentation of this file.
1 /* Set a variable definition with all variable references in the value
2  part of psz_string expanded. */
3 /*
4  "Copyright (C) 2011, 2015, 2020 R. Bernstein <rocky@gnu.org>\n" \
5  This file is part of GNU Make (remake variant).
6 
7 GNU Make is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11 
12 GNU Make is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with GNU Make; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21 
22 /* Documentation for help set, and help set xxx. Note the format has
23  been customized to make ddd work. In particular for "basename" it should
24  be
25  set basename -- Set if were are to show shor or long filenames is off.
26  (or "is on").
27 */
28 
29 #include "../subcmd.h"
30 
32  { "basename",
33  "Set if we are to show short or long filenames",
34  " {on|off|toggle} \n\nSet if we are to show short or long filenames.",
35  &basename_filenames, true, 1},
36  { "debug",
37  "Set GNU Make debug mask (set via --debug or -d)",
38  " VALUE \n\nSet GNU Make debug mask (set via --debug or -d).",
39  &db_level, false, 3},
40  { "ignore-errors",
41  "Set value of GNU Make --ignore-errors (or -i) flag",
42  " {on|off|toggle} \n\nSet value of GNU Make --ignore-errors (or -i) flag.",
43  &ignore_errors_flag, true, 3},
44  { "keep-going",
45  "Set value of GNU Make --keep-going (or -k) flag",
46  " {on|off|toggle}\n\nSet value of GNU Make --keep-going (or -k) flag.",
47  &keep_going_flag, true, 1},
48  { "silent",
49  "Set value of GNU Make --silent (or -s) flags.",
50  " {on|off|toggle} \n\nSet value of GNU Make --silent (or -s) flags.",
51  &silent_flag, true, 1},
52 #ifdef FIXED
53  { "trace",
54  "Set value of shell_tracing.",
55  NULL,
56  &no_shell_trace, false, 3},
57 #endif
58  { "variable",
59  "Change a debugger setting",
60  " OPTION is one of: basename, debug, ignore-errors, keep-going, or silent\n\n"
61 "\n"
62 "See also 'setq' and 'setqx' for setting a GNU Make variable.",
63  NULL,
64  false, 0},
65  { NULL, NULL, NULL, NULL, false, 0}
66 };
67 
68 static bool
69 dbg_cmd_set_bool(const char *psz_varname, const char *psz_flag_name,
70  const char *psz_flag_value,
71  unsigned int min, int *p_bool_flag)
72 {
73  if (is_abbrev_of (psz_varname, psz_flag_name, min)) {
74  if (!psz_flag_value || 0==strlen(psz_flag_value))
75  on_off_toggle(psz_flag_value, p_bool_flag);
76  else
77  on_off_toggle(psz_flag_value, p_bool_flag);
78  dbg_cmd_show((char *) psz_flag_name);
79  return true;
80  }
81  return false;
82 }
83 
84 
85 static debug_return_t
86 dbg_cmd_set(char *psz_args)
87 {
88  if (!psz_args || 0==strlen(psz_args)) {
89  unsigned int i;
90  for (i = 0; set_subcommands[i].name; i++) {
91  dbg_help_subcmd_entry("set", "%-10s -- %s",
92  &(set_subcommands[i]), false);
93  }
94  return debug_readloop;
95  } else {
96  char *psz_varname = get_word(&psz_args);
97  subcommand_var_info_t *p_subcmd_info;
98 
99  while (*psz_args && whitespace (*psz_args))
100  *psz_args +=1;
101 
102  /* FIXME, add min to above table and DRY below code. */
103  if (is_abbrev_of (psz_varname, "debug", 3)) {
104  int dbg_mask;
105  if (get_int(psz_args, &dbg_mask, true)) {
106  db_level = dbg_mask;
107  }
108  dbg_cmd_show(psz_varname);
109  return debug_readloop;
110  } else if (is_abbrev_of (psz_varname, "variable", 3)) {
111  /* Treat as set variable */
112  return dbg_cmd_set_var(psz_args, 1);
113 #if FIXME_SET_ARGS
114  } else if (is_abbrev_of (psz_varname, "args", 3)) {
115  ...
116 #endif
117  } else
118  for (p_subcmd_info = set_subcommands; p_subcmd_info && p_subcmd_info->name;
119  p_subcmd_info++) {
120  if (dbg_cmd_set_bool(psz_varname, p_subcmd_info->name,
121  psz_args, p_subcmd_info->min_abbrev,
122  p_subcmd_info->var))
123  return debug_readloop;
124  }
125  dbg_errmsg("Unknown set option %s\nSee 'help set' for options. Or did you mean setq?\n",
126  psz_varname);
127  return debug_cmd_error;
128  }
129 }
130 
131 static void
132 dbg_cmd_set_init(unsigned int c)
133 {
134 
135  short_command[c].func = &dbg_cmd_set;
136  short_command[c].use =
137  _("set OPTION {on|off|toggle}");
138 }
139 
140 /*
141  * Local variables:
142  * eval: (c-set-style "gnu")
143  * indent-tabs-mode: nil
144  * End:
145  */
int ignore_errors_flag
const char * name
Definition: subcmd.h:5
int keep_going_flag
void dbg_errmsg()
subcommand_var_info_t set_subcommands[]
Definition: set.h:31
void on_off_toggle(const char *psz_onoff, int *var)
bool is_abbrev_of(const char *psz_substr, const char *psz_word, unsigned int i_min)
debug_return_t dbg_cmd_show(char *psz_args)
Definition: show.h:81
debug_return_t
Definition: trace.h:32
Definition: subcmd.h:4
#define _(msgid)
Definition: make.h:293
Definition: trace.h:40
int basename_filenames
char * get_word(char **ppsz_str)
int silent_flag
int no_shell_trace
Definition: trace.h:42
int db_level
Definition: debug.h:163
void dbg_help_subcmd_entry(const char *psz_subcmd_name, const char *psz_fmt, subcommand_var_info_t *p_subcmd, bool full_info)
Definition: help.h:25
bool get_int(const char *psz_arg, int *pi_result, bool b_warn)
unsigned int min_abbrev
Definition: subcmd.h:13
int * var
Definition: subcmd.h:8