mirror of
https://github.com/tmux/tmux.git
synced 2026-10-13 06:04:34 +00:00
Not so much const.
This commit is contained in:
@@ -373,6 +373,7 @@ cmd_invoke_get(struct cmd_parse_tree *tree, struct cmdq_state *state, int argc,
|
|||||||
is = xcalloc(1, sizeof *is);
|
is = xcalloc(1, sizeof *is);
|
||||||
is->references = 1;
|
is->references = 1;
|
||||||
is->tree = cmd_parse_add_ref(tree);
|
is->tree = cmd_parse_add_ref(tree);
|
||||||
|
cmd_parse_log(tree);
|
||||||
|
|
||||||
is->argc = argc;
|
is->argc = argc;
|
||||||
if (argc != 0) {
|
if (argc != 0) {
|
||||||
@@ -444,6 +445,7 @@ cmd_invoke_fire(struct cmdq_item *item, struct cmd_invoke_state *is)
|
|||||||
node = cmd_invoke_next(is);
|
node = cmd_invoke_next(is);
|
||||||
if (node == NULL)
|
if (node == NULL)
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
cmd_parse_log_node(node);
|
||||||
|
|
||||||
switch (cmd_parse_node_type(node)) {
|
switch (cmd_parse_node_type(node)) {
|
||||||
case CMD_PARSE_ROOT:
|
case CMD_PARSE_ROOT:
|
||||||
|
|||||||
58
cmd-parse.y
58
cmd-parse.y
@@ -699,7 +699,7 @@ cmd_parse_root(struct cmd_parse_tree *tree)
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum cmd_parse_node_type
|
enum cmd_parse_node_type
|
||||||
cmd_parse_node_type(const struct cmd_parse_node *node)
|
cmd_parse_node_type(struct cmd_parse_node *node)
|
||||||
{
|
{
|
||||||
return (node->type);
|
return (node->type);
|
||||||
}
|
}
|
||||||
@@ -739,19 +739,19 @@ cmd_parse_node_type_string(enum cmd_parse_node_type type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
cmd_parse_node_value(const struct cmd_parse_node *node)
|
cmd_parse_node_value(struct cmd_parse_node *node)
|
||||||
{
|
{
|
||||||
return (node->value);
|
return (node->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
u_int
|
u_int
|
||||||
cmd_parse_node_line(const struct cmd_parse_node *node)
|
cmd_parse_node_line(struct cmd_parse_node *node)
|
||||||
{
|
{
|
||||||
return (node->line);
|
return (node->line);
|
||||||
}
|
}
|
||||||
|
|
||||||
u_int
|
u_int
|
||||||
cmd_parse_node_end_line(const struct cmd_parse_node *node)
|
cmd_parse_node_end_line(struct cmd_parse_node *node)
|
||||||
{
|
{
|
||||||
return (node->end_line);
|
return (node->end_line);
|
||||||
}
|
}
|
||||||
@@ -831,29 +831,34 @@ cmd_parse_escape(const char *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cmd_parse_log_node(struct cmd_parse_node *node, u_int depth)
|
cmd_parse_log_one_node(struct cmd_parse_node *node, u_int depth)
|
||||||
{
|
{
|
||||||
struct cmd_parse_node *child;
|
struct cmd_parse_node *child;
|
||||||
char *esc;
|
const char *type = cmd_parse_node_type_string(node->type);
|
||||||
|
char *escaped;
|
||||||
|
|
||||||
if (node->value != NULL) {
|
if (node->value == NULL)
|
||||||
esc = cmd_parse_escape(node->value);
|
log_debug("%*s%s", depth * 2, "", type);
|
||||||
log_debug("%*s%s value=\"%s\"", depth * 2, "",
|
else {
|
||||||
cmd_parse_node_type_string(node->type), esc);
|
escaped = cmd_parse_escape(node->value);
|
||||||
free(esc);
|
log_debug("%*s%s value=\"%s\"", depth * 2, "", type, escaped);
|
||||||
} else {
|
free(escaped);
|
||||||
log_debug("%*s%s", depth * 2, "",
|
|
||||||
cmd_parse_node_type_string(node->type));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TAILQ_FOREACH(child, &node->children, entry)
|
TAILQ_FOREACH(child, &node->children, entry)
|
||||||
cmd_parse_log_node(child, depth + 1);
|
cmd_parse_log_one_node(child, depth + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_parse_log(const struct cmd_parse_tree *tree)
|
cmd_parse_log_node(struct cmd_parse_node *node)
|
||||||
{
|
{
|
||||||
cmd_parse_log_node(tree->root, 0);
|
cmd_parse_log_one_node(node, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_parse_log(struct cmd_parse_tree *tree)
|
||||||
|
{
|
||||||
|
cmd_parse_log_node(tree->root);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Does this literal text need quoting to reparse as itself? */
|
/* Does this literal text need quoting to reparse as itself? */
|
||||||
@@ -1123,7 +1128,7 @@ cmd_parse_print_sequence(char **buf, struct cmd_parse_node *seq, u_int depth)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
cmd_parse_print(const struct cmd_parse_tree *tree)
|
cmd_parse_print(struct cmd_parse_tree *tree)
|
||||||
{
|
{
|
||||||
struct cmd_parse_node *root = tree->root, *child;
|
struct cmd_parse_node *root = tree->root, *child;
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
@@ -1503,10 +1508,8 @@ yylex_token(int ch)
|
|||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
/* EOF or \n are always the end of the token. */
|
/* EOF or \n are always the end of the token. */
|
||||||
if (ch == EOF) {
|
if (ch == EOF)
|
||||||
log_debug("%s: end at EOF", __func__);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
if (state == NONE && ch == '\r') {
|
if (state == NONE && ch == '\r') {
|
||||||
ch = yylex_getc();
|
ch = yylex_getc();
|
||||||
if (ch != '\n') {
|
if (ch != '\n') {
|
||||||
@@ -1515,22 +1518,16 @@ yylex_token(int ch)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ch == '\n') {
|
if (ch == '\n') {
|
||||||
if (state == NONE) {
|
if (state == NONE)
|
||||||
log_debug("%s: end at EOL", __func__);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
pi->line++;
|
pi->line++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Whitespace or ; or } ends a token unless inside quotes. */
|
/* Whitespace or ; or } ends a token unless inside quotes. */
|
||||||
if (state == NONE && (ch == ' ' || ch == '\t')) {
|
if (state == NONE && (ch == ' ' || ch == '\t'))
|
||||||
log_debug("%s: end at WS", __func__);
|
|
||||||
break;
|
break;
|
||||||
}
|
if (state == NONE && (ch == ';' || ch == '}'))
|
||||||
if (state == NONE && (ch == ';' || ch == '}')) {
|
|
||||||
log_debug("%s: end at %c", __func__, ch);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Spaces and comments inside quotes after \n are removed but
|
* Spaces and comments inside quotes after \n are removed but
|
||||||
@@ -1671,7 +1668,6 @@ yylex_format(void)
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
log_debug("%s: %s", __func__, buf);
|
|
||||||
return (buf);
|
return (buf);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
|||||||
@@ -80,13 +80,14 @@ struct cmd_parse_tree *cmd_parse_from_string(const char *,
|
|||||||
struct cmd_parse_tree *cmd_parse_add_ref(struct cmd_parse_tree *);
|
struct cmd_parse_tree *cmd_parse_add_ref(struct cmd_parse_tree *);
|
||||||
void cmd_parse_free(struct cmd_parse_tree *);
|
void cmd_parse_free(struct cmd_parse_tree *);
|
||||||
struct cmd_parse_node *cmd_parse_root(struct cmd_parse_tree *);
|
struct cmd_parse_node *cmd_parse_root(struct cmd_parse_tree *);
|
||||||
char *cmd_parse_print(const struct cmd_parse_tree *);
|
char *cmd_parse_print(struct cmd_parse_tree *);
|
||||||
void cmd_parse_log(const struct cmd_parse_tree *);
|
void cmd_parse_log(struct cmd_parse_tree *);
|
||||||
enum cmd_parse_node_type cmd_parse_node_type(const struct cmd_parse_node *);
|
void cmd_parse_log_node(struct cmd_parse_node *);
|
||||||
|
enum cmd_parse_node_type cmd_parse_node_type(struct cmd_parse_node *);
|
||||||
const char *cmd_parse_node_type_string(enum cmd_parse_node_type);
|
const char *cmd_parse_node_type_string(enum cmd_parse_node_type);
|
||||||
const char *cmd_parse_node_value(const struct cmd_parse_node *);
|
const char *cmd_parse_node_value(struct cmd_parse_node *);
|
||||||
u_int cmd_parse_node_line(const struct cmd_parse_node *);
|
u_int cmd_parse_node_line(struct cmd_parse_node *);
|
||||||
u_int cmd_parse_node_end_line(const struct cmd_parse_node *);
|
u_int cmd_parse_node_end_line(struct cmd_parse_node *);
|
||||||
struct cmd_parse_node *cmd_parse_node_first_child(struct cmd_parse_node *);
|
struct cmd_parse_node *cmd_parse_node_first_child(struct cmd_parse_node *);
|
||||||
struct cmd_parse_node *cmd_parse_node_next(struct cmd_parse_node *);
|
struct cmd_parse_node *cmd_parse_node_next(struct cmd_parse_node *);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user